Package org.springframework.test.web.reactive.server

# Class ExchangeResult

java.lang.Object
org.springframework.test.web.reactive.server.ExchangeResult

Direct Known Subclasses:
  `EntityExchangeResult`, `FluxExchangeResult`

public class ExchangeResult extends Object
Container for request and response details for exchanges performed through `WebTestClient`.

Note that a decoded response body is not exposed at this level since the body may not have been decoded and consumed yet. Subtypes `EntityExchangeResult` and `FluxExchangeResult` provide access to a decoded response entity and a decoded (but not consumed) response body respectively.

Since:
  5.0
Author:
  Rossen Stoyanchev, Sam Brannen
See Also:
  - `EntityExchangeResult`
  - `FluxExchangeResult`

## Method Summary

Modifier and Type
Method
Description
`void`
`assertWithDiagnostics(Runnable assertion)`
Execute the given Runnable, catch any `AssertionError`, log details about the request and response at ERROR level under the class log category, and after that re-throw the error.
`org.springframework.http.HttpMethod`
`getMethod()`
Return the method of the request.
`Object`
`getMockServerResult()`
Return the result from the mock server exchange, if applicable, for further assertions on the state of the server response.
`int`
`getRawStatusCode()`
Deprecated, for removal: This API element is subject to removal in a future version.
in favor of `getStatus()`, for removal in 7.0
`byte[]`
`getRequestBodyContent()`
Return the raw request body content written through the request.
`org.springframework.http.HttpHeaders`
`getRequestHeaders()`
Return the request headers sent to the server.
`byte[]`
`getResponseBodyContent()`
Return the raw request body content written to the response.
`org.springframework.util.MultiValueMap<String,org.springframework.http.ResponseCookie>`
`getResponseCookies()`
Return response cookies received from the server.
`org.springframework.http.HttpHeaders`
`getResponseHeaders()`
Return the response headers received from the server.
`org.springframework.http.HttpStatusCode`
`getStatus()`
Return the HTTP status code as an `HttpStatusCode` value.
`String`
`getUriTemplate()`
Return the original URI template used to prepare the request, if any.
`URI`
`getUrl()`
Return the URI of the request.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Method Details

### getMethod

public org.springframework.http.HttpMethod getMethod()
Return the method of the request.

### getUrl

public URI getUrl()
Return the URI of the request.

### getUriTemplate

@Nullable public String getUriTemplate()
Return the original URI template used to prepare the request, if any.

### getRequestHeaders

public org.springframework.http.HttpHeaders getRequestHeaders()
Return the request headers sent to the server.

### getRequestBodyContent

@Nullable public byte[] getRequestBodyContent()
Return the raw request body content written through the request.

Note: If the request content has not been consumed for any reason yet, use of this method will trigger consumption.

Throws:
  `IllegalStateException` - if the request body has not been fully written.

### getStatus

public org.springframework.http.HttpStatusCode getStatus()
Return the HTTP status code as an `HttpStatusCode` value.

### getRawStatusCode

@Deprecated(since="6.0", forRemoval=true) public int getRawStatusCode()
Deprecated, for removal: This API element is subject to removal in a future version.
in favor of `getStatus()`, for removal in 7.0
Return the HTTP status code as an integer.

Since:
  5.1.10

### getResponseHeaders

public org.springframework.http.HttpHeaders getResponseHeaders()
Return the response headers received from the server.

### getResponseCookies

public org.springframework.util.MultiValueMap<String,org.springframework.http.ResponseCookie> getResponseCookies()
Return response cookies received from the server.

### getResponseBodyContent

@Nullable public byte[] getResponseBodyContent()
Return the raw request body content written to the response.

Note: If the response content has not been consumed yet, use of this method will trigger consumption.

Throws:
  `IllegalStateException` - if the response has not been fully read.

### getMockServerResult

@Nullable public Object getMockServerResult()
Return the result from the mock server exchange, if applicable, for further assertions on the state of the server response.

Since:
  5.3
See Also:
  - `MockMvcWebTestClient.resultActionsFor(ExchangeResult)`

### assertWithDiagnostics

public void assertWithDiagnostics(Runnable assertion)
Execute the given Runnable, catch any `AssertionError`, log details about the request and response at ERROR level under the class log category, and after that re-throw the error.

### toString

public String toString()

Overrides:
  `toString` in class `Object`