Derk-Jan Karrenbeld
11/07/2018, 3:39 PMtestMode
with blocking = true, which doesn't alllow us to test asynchronousliness, my refactor where only async requests are cancellable can now "wait" inline:
@Test
fun gsonTestResponseObjectAsync() {
var isAsync = false
val running = reflectedRequest(Method.GET, "user-agent")
.responseObject(gsonDeserializerOf(HttpBinUserAgentModel::class.java)) { _, _, result ->
val (data, error) = result
assertThat("Expected data, actual error $error", data, notNullValue())
assertThat("Expected data to have a user agent", data!!.userAgent, notNullValue())
assertThat("Expected isAsync to be true, actual false", isAsync, equalTo(true))
}
isAsync = true
running.join()
assertThat(running.isDone, equalTo(true))
assertThat(running.isCancelled, equalTo(false))
}