Interface WebTestClient.BodyContentSpec
- Enclosing interface:
- WebTestClient
-
Method Summary
Modifier and TypeMethodDescriptionconsumeWith
(Consumer<EntityExchangeResult<byte[]>> consumer) Assert the response body content with the givenConsumer
.isEmpty()
Assert the response body is empty and return the exchange result.default WebTestClient.BodyContentSpec
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).Deprecated.json
(String expectedJson, JsonComparator comparator) Parse the expected and actual response content as JSON and perform a comparison using the givenJsonComparator
.json
(String expectedJson, JsonCompareMode compareMode) Parse the expected and actual response content as JSON and perform a comparison using the given mode.Access to response body assertions using a JsonPath expression to inspect a specific subset of the body.Deprecated, for removal: This API element is subject to removal in a future version.in favor of callingString.formatted(Object...)
upfrontEntityExchangeResult<byte[]>
Exit the chained API and return anExchangeResult
with the raw response content.Parse expected and actual response content as XML and assert that the two are "similar", i.e.default XpathAssertions
Access to response body assertions using an XPath expression to inspect a specific subset of the body.Access to response body assertions with specific namespaces using an XPath expression to inspect a specific subset of the body.
-
Method Details
-
isEmpty
EntityExchangeResult<Void> isEmpty()Assert the response body is empty and return the exchange result. -
json
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).Use of this method requires the JSONassert library to be on the classpath.
- Parameters:
expectedJson
- the expected JSON content- See Also:
-
json
Deprecated.in favor ofjson(String, JsonCompareMode)
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.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.
- Parameters:
expectedJson
- the expected JSON contentstrict
- enables strict checking iftrue
- Since:
- 5.3.16
- See Also:
-
json
Parse the expected and actual response content as JSON and perform a comparison using the given mode. If the comparison failed, throws anAssertionError
with the message of theJsonComparison
.Use of this method requires the JSONassert library to be on the classpath.
- Parameters:
expectedJson
- the expected JSON contentcompareMode
- the compare mode- Since:
- 6.2
- See Also:
-
json
Parse the expected and actual response content as JSON and perform a comparison using the givenJsonComparator
. If the comparison failed, throws anAssertionError
with the message of theJsonComparison
.- Parameters:
expectedJson
- the expected JSON contentcomparator
- the comparator to use- Since:
- 6.2
-
xml
Parse expected and actual response content as XML and assert that the two are "similar", i.e. they contain the same elements and attributes regardless of order.Use of this method requires the XMLUnit library on the classpath.
- Parameters:
expectedXml
- the expected XML content.- Since:
- 5.1
- See Also:
-
jsonPath
Access to response body assertions using a JsonPath expression to inspect a specific subset of the body.- Parameters:
expression
- the JsonPath expression- Since:
- 6.2
-
jsonPath
@Deprecated(since="6.2", forRemoval=true) JsonPathAssertions jsonPath(String expression, Object... args) Deprecated, for removal: This API element is subject to removal in a future version.in favor of callingString.formatted(Object...)
upfrontAccess to response body assertions using a JsonPath expression to inspect a specific subset of the body.The JSON path expression can be a parameterized string using formatting specifiers as defined in
String.format(java.lang.String, java.lang.Object...)
.- Parameters:
expression
- the JsonPath expressionargs
- arguments to parameterize the expression
-
xpath
Access to response body assertions using an XPath expression to inspect a specific subset of the body.The XPath expression can be a parameterized string using formatting specifiers as defined in
String.format(java.lang.String, java.lang.Object...)
.- Parameters:
expression
- the XPath expressionargs
- arguments to parameterize the expression- Since:
- 5.1
- See Also:
-
xpath
Access to response body assertions with specific namespaces using an XPath expression to inspect a specific subset of the body.The XPath expression can be a parameterized string using formatting specifiers as defined in
String.format(java.lang.String, java.lang.Object...)
.- Parameters:
expression
- the XPath expressionnamespaces
- the namespaces to useargs
- arguments to parameterize the expression- Since:
- 5.1
-
consumeWith
Assert the response body content with the givenConsumer
.- Parameters:
consumer
- the consumer for the response body; the inputbyte[]
may benull
if there was no response body.
-
returnResult
EntityExchangeResult<byte[]> returnResult()Exit the chained API and return anExchangeResult
with the raw response content.
-
json(String, JsonCompareMode)