visakha
04/25/2018, 12:02 AM@Test
fun testFnCall_partyAddrByCleanCd() {
println("\n\n\n\n ---------------- SEE MEE START ----------------------")
val start = System.currentTimeMillis()
val res = ecmDbSvc.callFnGetPartyAddrByExtCleanCd("ECM-123")
assert(res != null)
assertTrue(res.count() == 100)
val fluxOfPartyAddr = Flux.fromIterable(res)
.delayElements(Duration.ofMillis(100))
.parallel(4).runOn(Schedulers.parallel())
.doOnNext { e -> println(e.addrLine1) }
// fluxOfPartyAddr.blockLast() --> Invalid when using parallel
fluxOfPartyAddr.doOnComplete {
val end = System.currentTimeMillis()
println("time talen: " + (end - start) + " milliSeconds")
println("---------------- SEE MEE START COMPLETE ----------------------")
}
fluxOfPartyAddr.subscribe()
// ??? anything here to make the thread wait ???
}Lucas
04/25/2018, 12:20 AMStepVerifier class? https://projectreactor.io/docs/test/release/api/reactor/test/StepVerifier.htmlLucas
04/25/2018, 12:22 AMcallFnGetPartyAddrByExtCleanCd returns listOf(1,2,3) the fluxOfPartyAddr can be tested changing fluxOfPartyAddr.subscribe() to something like:
StepVerifier.create(fluxOfPartyAddr)
.consumeNextWith { assertEquals(1, it) }
.consumeNextWith { assertEquals(2, it) }
.consumeNextWith { assertEquals(3, it) }
.verifyComplete()visakha
04/25/2018, 1:17 AMsdeleuze
04/25/2018, 1:12 PMStepVerifier for that use case, but be ware that you can also use blockLast() operator.