private static class DefaultWebTestClient.DefaultResponseSpec extends java.lang.Object implements WebTestClient.ResponseSpec
Modifier and Type | Field and Description |
---|---|
private ExchangeResult |
exchangeResult |
private ClientResponse |
response |
private java.time.Duration |
timeout |
Constructor and Description |
---|
DefaultResponseSpec(WiretapConnector.Info wiretapInfo,
ClientResponse response,
java.lang.String uriTemplate,
java.time.Duration timeout) |
Modifier and Type | Method and Description |
---|---|
WebTestClient.BodyContentSpec |
expectBody()
Consume and decode the response body to
byte[] and then apply
assertions on the raw content (e.g. |
<B> WebTestClient.BodySpec<B,?> |
expectBody(java.lang.Class<B> bodyType)
Consume and decode the response body to a single object of type
<B> and then apply assertions. |
<B> WebTestClient.BodySpec<B,?> |
expectBody(ParameterizedTypeReference<B> bodyType)
Alternative to
WebTestClient.ResponseSpec.expectBody(Class) that accepts information
about a target type with generics. |
<E> WebTestClient.ListBodySpec<E> |
expectBodyList(java.lang.Class<E> elementType)
Consume and decode the response body to
List<E> and then apply
List-specific assertions. |
<E> WebTestClient.ListBodySpec<E> |
expectBodyList(ParameterizedTypeReference<E> elementType)
Alternative to
WebTestClient.ResponseSpec.expectBodyList(Class) that accepts information
about a target type with generics. |
HeaderAssertions |
expectHeader()
Assertions on the headers of the response.
|
StatusAssertions |
expectStatus()
Assertions on the response status.
|
private <E> WebTestClient.ListBodySpec<E> |
getListBodySpec(<any> flux) |
<T> FluxExchangeResult<T> |
returnResult(java.lang.Class<T> elementType)
Exit the chained API and consume the response body externally.
|
<T> FluxExchangeResult<T> |
returnResult(ParameterizedTypeReference<T> elementType)
Alternative to
WebTestClient.ResponseSpec.returnResult(Class) that accepts information
about a target type with generics. |
private final ExchangeResult exchangeResult
private final ClientResponse response
private final java.time.Duration timeout
DefaultResponseSpec(WiretapConnector.Info wiretapInfo, ClientResponse response, @Nullable java.lang.String uriTemplate, java.time.Duration timeout)
public StatusAssertions expectStatus()
WebTestClient.ResponseSpec
expectStatus
in interface WebTestClient.ResponseSpec
public HeaderAssertions expectHeader()
WebTestClient.ResponseSpec
expectHeader
in interface WebTestClient.ResponseSpec
public <B> WebTestClient.BodySpec<B,?> expectBody(java.lang.Class<B> bodyType)
WebTestClient.ResponseSpec
<B>
and then apply assertions.expectBody
in interface WebTestClient.ResponseSpec
bodyType
- the expected body typepublic <B> WebTestClient.BodySpec<B,?> expectBody(ParameterizedTypeReference<B> bodyType)
WebTestClient.ResponseSpec
WebTestClient.ResponseSpec.expectBody(Class)
that accepts information
about a target type with generics.expectBody
in interface WebTestClient.ResponseSpec
public <E> WebTestClient.ListBodySpec<E> expectBodyList(java.lang.Class<E> elementType)
WebTestClient.ResponseSpec
List<E>
and then apply
List-specific assertions.expectBodyList
in interface WebTestClient.ResponseSpec
elementType
- the expected List element typepublic <E> WebTestClient.ListBodySpec<E> expectBodyList(ParameterizedTypeReference<E> elementType)
WebTestClient.ResponseSpec
WebTestClient.ResponseSpec.expectBodyList(Class)
that accepts information
about a target type with generics.expectBodyList
in interface WebTestClient.ResponseSpec
private <E> WebTestClient.ListBodySpec<E> getListBodySpec(<any> flux)
public WebTestClient.BodyContentSpec expectBody()
WebTestClient.ResponseSpec
byte[]
and then apply
assertions on the raw content (e.g. isEmpty, JSONPath, etc.)expectBody
in interface WebTestClient.ResponseSpec
public <T> FluxExchangeResult<T> returnResult(java.lang.Class<T> elementType)
WebTestClient.ResponseSpec
StepVerifier
from "reactor-test" to assert the Flux<T>
stream
of decoded objects.
Note: Do not use this option for cases where there
is no content (e.g. 204, 4xx) or you're not interested in the content.
For such cases you can use expectBody().isEmpty()
or
expectBody(Void.class)
which ensures that resources are
released regardless of whether the response has content or not.
returnResult
in interface WebTestClient.ResponseSpec
public <T> FluxExchangeResult<T> returnResult(ParameterizedTypeReference<T> elementType)
WebTestClient.ResponseSpec
WebTestClient.ResponseSpec.returnResult(Class)
that accepts information
about a target type with generics.returnResult
in interface WebTestClient.ResponseSpec