Class 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.

Rossen Stoyanchev, Sam Brannen
See Also:
  • Method Details

    • getMethod

      public 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 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.

      IllegalStateException - if the request body has not been fully written.
    • getStatus

      public 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.
      as of 6.0, in favor of getStatus()
      Return the HTTP status code as an integer.
    • getResponseHeaders

      public HttpHeaders getResponseHeaders()
      Return the response headers received from the server.
    • getResponseCookies

      public MultiValueMap<String,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.

      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.
      See Also:
    • 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()
      toString in class Object