Add awaitBodyOrNull to WebClient.ResponseSpec
Such variant is already provided for ClientResponse but not for WebClient.ResponseSpec. Closes gh-26731
This commit is contained in:
committed by
Sébastien Deleuze
parent
85dbd2a4c3
commit
58e40d1aa2
@@ -136,6 +136,25 @@ class WebClientExtensionsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun awaitBodyOrNull() {
|
||||
val spec = mockk<WebClient.ResponseSpec>()
|
||||
every { spec.bodyToMono<String>() } returns Mono.just("foo")
|
||||
runBlocking {
|
||||
assertThat(spec.awaitBodyOrNull<String>()).isEqualTo("foo")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `awaitBodyOrNull of type Unit`() {
|
||||
val spec = mockk<WebClient.ResponseSpec>()
|
||||
val entity = mockk<ResponseEntity<Void>>()
|
||||
every { spec.toBodilessEntity() } returns Mono.just(entity)
|
||||
runBlocking {
|
||||
assertThat(spec.awaitBodyOrNull<Unit>()).isEqualTo(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun awaitBodilessEntity() {
|
||||
val spec = mockk<WebClient.ResponseSpec>()
|
||||
|
||||
Reference in New Issue
Block a user