This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
data: | |
mongodb: | |
host: localhost | |
port: 27017 | |
username: root | |
password: example | |
authentication-database: admin | |
database: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
class LoanDetailServiceImpl(private val loanDetailRepo: LoanDetailRepo) : LoanDetailService { | |
override fun save(loanDetail: LoanDetail): Mono<LoanDetail> { | |
return loanDetailRepo.save(loanDetail) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Repository | |
interface LoanDetailRepo : ReactiveCrudRepository<LoanDetail, String> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringRunner::class) | |
@SpringBootTest | |
class LoanDetailServiceImplTest { | |
@Autowired | |
private lateinit var loanDetailService: LoanDetailService | |
@Test | |
fun `save load detail service`() { | |
StepVerifier.create(loanDetailService.save(LoanDetail(_id = "1", loanAmount = BigDecimal.valueOf(100000L), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
class MongoContainerInitializer : ApplicationContextInitializer<ConfigurableApplicationContext> { | |
val image:String = "mongo:4.2.0-rc2-bionic" | |
override fun initialize(configurableApplicationContext: ConfigurableApplicationContext) { | |
val mongoContainer = MongoContainer(image) | |
mongoContainer.start() | |
val connectURl = "spring.data.mongodb.uri="+ "mongodb://${mongoContainer.getContainerIpAddress()}:${mongoContainer.getMappedPort(27017)}/test" | |
println(">>>>>>>>>>>>>>>>Connection url: $connectURl") | |
TestPropertyValues.of( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
class MongoContainerInitializer : ApplicationContextInitializer<ConfigurableApplicationContext> { | |
val image:String = "mongo:4.2.0-rc2-bionic" | |
override fun initialize(configurableApplicationContext: ConfigurableApplicationContext) { | |
val mongoContainer = MongoContainer(image) | |
mongoContainer.start() | |
val connectURl = "spring.data.mongodb.uri="+ "mongodb://${mongoContainer.getContainerIpAddress()}:${mongoContainer.getMappedPort(27017)}/test" | |
println(">>>>>>>>>>>>>>>>Connection url: $connectURl") | |
TestPropertyValues.of( | |
"spring.data.mongodb.uri="+ "mongodb://${mongoContainer.getContainerIpAddress()}:${mongoContainer.getMappedPort(27017)}/test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
class MongoContainer : DockerComposeContainer<MongoContainer>(File("src/test/resources/docker-compose-test.yml")) { | |
@PostConstruct | |
fun init() { | |
this.start() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.testcontainers</groupId> | |
<artifactId>testcontainers</artifactId> | |
<version>1.12.4</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Document | |
data class LoanDetail(var _id: String, | |
var loanAmount: BigDecimal, | |
var loanCommencedDate: LocalDate, | |
var interestRate: Float, | |
var numberOfEmi: Int, | |
var emiAmount: BigDecimal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/api/v1/loan") | |
class LoanDetailController () { | |
@GetMapping("/detail", produces = [MediaType.TEXT_EVENT_STREAM_VALUE]) | |
fun getdata():Mono<LoanDetail> { | |
return Mono.justOrEmpty( | |
LoanDetail(_id = "dummy", | |
loanAmount = BigDecimal.valueOf(100_000L), | |
emiAmount = BigDecimal.valueOf(1000L), |