nerses
02/08/2018, 1:40 PMfun populate(hotels: List<Hotel>) {
val context = newFixedThreadPoolContext(threadpoolCoreSize, "thread-geo")
context.use { c ->
val jobs = hotels.map { hotel ->
launch(c) {
repo.suspendableFun()
}
}
runBlocking(c) {
jobs.forEach({ it.join() })
}
}
}
and
@Test(expectedExceptions = [RuntimeException::class])
fun `populate should throw exceptionIn`() = runBlocking {
//and
given(repo.suspendableFun()).willThrow(RuntimeException(""))
//when
victim.populate(hotelList())
//then
//The exception is thrown
}
Ilmir Usmanov [JB]
02/08/2018, 1:47 PMsuspendFun
with suspendableFun
.nerses
02/08/2018, 1:48 PMnerses
02/08/2018, 1:48 PMIlmir Usmanov [JB]
02/08/2018, 2:30 PMIlmir Usmanov [JB]
02/08/2018, 2:35 PMnerses
02/08/2018, 2:56 PMnerses
02/08/2018, 2:56 PMIlmir Usmanov [JB]
02/08/2018, 3:24 PMnerses
02/08/2018, 3:48 PM