Introduce WebClient.ResponseSpec.awaitBodilessEntity()
This commit also allows awaitBody<Unit>() to be used. Closes gh-26504
This commit is contained in:
committed by
Sébastien Deleuze
parent
3718c8d0e0
commit
b00c7075a5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,6 +27,7 @@ import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.reactivestreams.Publisher
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
import org.springframework.http.ResponseEntity
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
import java.util.concurrent.CompletableFuture
|
||||
@@ -125,6 +126,26 @@ class WebClientExtensionsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `awaitBody of type Unit`() {
|
||||
val spec = mockk<WebClient.ResponseSpec>()
|
||||
val entity = mockk<ResponseEntity<Void>>()
|
||||
every { spec.toBodilessEntity() } returns Mono.just(entity)
|
||||
runBlocking {
|
||||
assertThat(spec.awaitBody<Unit>()).isEqualTo(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun awaitBodilessEntity() {
|
||||
val spec = mockk<WebClient.ResponseSpec>()
|
||||
val entity = mockk<ResponseEntity<Void>>()
|
||||
every { spec.toBodilessEntity() } returns Mono.just(entity)
|
||||
runBlocking {
|
||||
assertThat(spec.awaitBodilessEntity()).isEqualTo(entity)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#toEntity with reified type parameters`() {
|
||||
responseSpec.toEntity<List<Foo>>()
|
||||
|
||||
Reference in New Issue
Block a user