Skip to content

Instantly share code, notes, and snippets.

@adgadev
Created August 26, 2022 21:20
Show Gist options
  • Save adgadev/61c9ff64ecec82c8260fec96f64564ea to your computer and use it in GitHub Desktop.
Save adgadev/61c9ff64ecec82c8260fec96f64564ea to your computer and use it in GitHub Desktop.
@Testcontainers
@SpringBootTest
@ActiveProfiles("dev")
class DevProfileDemoApplicationTest {
@Container
static MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:4.4.2");
@DynamicPropertySource
static void setProperties(DynamicPropertyRegistry registry) {
registry.add("spring.data.mongodb.uri", mongoDBContainer::getReplicaSetUrl);
}
@Autowired
private HaloService haloService;
@Test
void shouldExecuteOperationOnMongo() {
HaloEntity haloEntity = haloService.addHalo("some name");
assertNotNull(haloService.getHalo(haloEntity.getId()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment