Skip to content

Instantly share code, notes, and snippets.

@adgadev
Created August 26, 2022 21:20
@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