public static interface WebTestClient.BodyContentSpec
| Modifier and Type | Method and Description |
|---|---|
WebTestClient.BodyContentSpec |
consumeWith(Consumer<EntityExchangeResult<byte[]>> consumer)
Assert the response body content with the given
Consumer. |
EntityExchangeResult<Void> |
isEmpty()
Assert the response body is empty and return the exchange result.
|
default WebTestClient.BodyContentSpec |
json(String expectedJson)
Parse the expected and actual response content as JSON and perform a
comparison verifying that they contain the same attribute-value pairs
regardless of formatting with lenient checking (extensible
and non-strict array ordering).
|
WebTestClient.BodyContentSpec |
json(String expectedJson,
boolean strict)
Parse the expected and actual response content as JSON and perform a
comparison verifying that they contain the same attribute-value pairs
regardless of formatting.
|
JsonPathAssertions |
jsonPath(String expression,
Object... args)
Access to response body assertions using a
JsonPath expression
to inspect a specific subset of the body.
|
EntityExchangeResult<byte[]> |
returnResult()
Exit the chained API and return an
ExchangeResult with the
raw response content. |
WebTestClient.BodyContentSpec |
xml(String expectedXml)
Parse expected and actual response content as XML and assert that
the two are "similar", i.e.
|
XpathAssertions |
xpath(String expression,
Map<String,String> namespaces,
Object... args)
Access to response body assertions with specific namespaces using an
XPath expression to inspect a specific subset of the body.
|
default XpathAssertions |
xpath(String expression,
Object... args)
Access to response body assertions using an XPath expression to
inspect a specific subset of the body.
|
EntityExchangeResult<Void> isEmpty()
default WebTestClient.BodyContentSpec json(String expectedJson)
Use of this method requires the JSONassert library to be on the classpath.
expectedJson - the expected JSON contentjson(String, boolean)WebTestClient.BodyContentSpec json(String expectedJson, boolean strict)
Can compare in two modes, depending on the strict parameter value:
true: strict checking. Not extensible and strict array ordering.false: lenient checking. Extensible and non-strict array ordering.Use of this method requires the JSONassert library to be on the classpath.
expectedJson - the expected JSON contentstrict - enables strict checking if truejson(String)WebTestClient.BodyContentSpec xml(String expectedXml)
Use of this method requires the XMLUnit library on the classpath.
expectedXml - the expected JSON content.XmlExpectationsHelper.assertXmlEqual(String, String)JsonPathAssertions jsonPath(String expression, Object... args)
The JSON path expression can be a parameterized string using
formatting specifiers as defined in String.format(java.lang.String, java.lang.Object...).
expression - the JsonPath expressionargs - arguments to parameterize the expressiondefault XpathAssertions xpath(String expression, Object... args)
The XPath expression can be a parameterized string using
formatting specifiers as defined in String.format(java.lang.String, java.lang.Object...).
expression - the XPath expressionargs - arguments to parameterize the expressionxpath(String, Map, Object...)XpathAssertions xpath(String expression, @Nullable Map<String,String> namespaces, Object... args)
The XPath expression can be a parameterized string using
formatting specifiers as defined in String.format(java.lang.String, java.lang.Object...).
expression - the XPath expressionnamespaces - the namespaces to useargs - arguments to parameterize the expressionWebTestClient.BodyContentSpec consumeWith(Consumer<EntityExchangeResult<byte[]>> consumer)
Consumer.consumer - the consumer for the response body; the input
byte[] may be null if there was no response body.EntityExchangeResult<byte[]> returnResult()
ExchangeResult with the
raw response content.