public class ExchangeResult
extends java.lang.Object
WebTestClient
.
Note that a decoded response body is not exposed at this level since the
body may not have been decoded and consumed yet. Sub-types
EntityExchangeResult
and FluxExchangeResult
provide access
to a decoded response entity and a decoded (but not consumed) response body
respectively.
EntityExchangeResult
,
FluxExchangeResult
Modifier and Type | Field and Description |
---|---|
private static java.util.List<MediaType> |
PRINTABLE_MEDIA_TYPES |
private ClientHttpRequest |
request |
private <any> |
requestBody |
private ClientHttpResponse |
response |
private <any> |
responseBody |
private java.time.Duration |
timeout |
private java.lang.String |
uriTemplate |
Constructor and Description |
---|
ExchangeResult(ClientHttpRequest request,
ClientHttpResponse response,
<any> requestBody,
<any> responseBody,
java.time.Duration timeout,
java.lang.String uriTemplate)
Create an instance with an HTTP request and response along with promises
for the serialized request and response body content.
|
ExchangeResult(ExchangeResult other)
Copy constructor to use after body is decoded and/or consumed.
|
Modifier and Type | Method and Description |
---|---|
void |
assertWithDiagnostics(java.lang.Runnable assertion)
Execute the given Runnable, catch any
AssertionError , decorate
with AssertionError containing diagnostic information about the
request and response, and then re-throw. |
private java.lang.String |
formatBody(MediaType contentType,
<any> body) |
private java.lang.String |
formatHeaders(HttpHeaders headers,
java.lang.String delimiter) |
HttpMethod |
getMethod()
Return the method of the request.
|
byte[] |
getRequestBodyContent()
Return the raw request body content written through the request.
|
HttpHeaders |
getRequestHeaders()
Return the request headers sent to the server.
|
byte[] |
getResponseBodyContent()
Return the raw request body content written to the response.
|
MultiValueMap<java.lang.String,ResponseCookie> |
getResponseCookies()
Return response cookies received from the server.
|
HttpHeaders |
getResponseHeaders()
Return the response headers received from the server.
|
HttpStatus |
getStatus()
Return the status of the executed request.
|
private java.lang.String |
getStatusReason() |
java.lang.String |
getUriTemplate()
Return the original URI template used to prepare the request, if any.
|
java.net.URI |
getUrl()
Return the URI of the request.
|
java.lang.String |
toString() |
private static final java.util.List<MediaType> PRINTABLE_MEDIA_TYPES
private final ClientHttpRequest request
private final ClientHttpResponse response
private final <any> requestBody
private final <any> responseBody
private final java.time.Duration timeout
@Nullable private final java.lang.String uriTemplate
ExchangeResult(ClientHttpRequest request, ClientHttpResponse response, <any> requestBody, <any> responseBody, java.time.Duration timeout, @Nullable java.lang.String uriTemplate)
request
- the HTTP requestresponse
- the HTTP responserequestBody
- capture of serialized request body contentresponseBody
- capture of serialized response body contenttimeout
- how long to wait for content to materializeuriTemplate
- the URI template used to set up the request, if anyExchangeResult(ExchangeResult other)
public HttpMethod getMethod()
public java.net.URI getUrl()
@Nullable public java.lang.String getUriTemplate()
public HttpHeaders getRequestHeaders()
@Nullable public byte[] getRequestBodyContent()
Note: If the request content has not been consumed for any reason yet, use of this method will trigger consumption.
java.lang.IllegalStateException
- if the request body is not been fully written.public HttpStatus getStatus()
public HttpHeaders getResponseHeaders()
public MultiValueMap<java.lang.String,ResponseCookie> getResponseCookies()
@Nullable public byte[] getResponseBodyContent()
Note: If the response content has not been consumed yet, use of this method will trigger consumption.
java.lang.IllegalStateException
- if the response is not been fully read.public void assertWithDiagnostics(java.lang.Runnable assertion)
AssertionError
, decorate
with AssertionError
containing diagnostic information about the
request and response, and then re-throw.public java.lang.String toString()
toString
in class java.lang.Object
private java.lang.String getStatusReason()
private java.lang.String formatHeaders(HttpHeaders headers, java.lang.String delimiter)