Interface RestTestClient.BodyContentSpec
- Enclosing interface:
- RestTestClient
public static interface RestTestClient.BodyContentSpec
Spec for expectations on the response body content.
- Since:
- 7.0
- Author:
- Rob Worsnop, Rossen Stoyanchev
- 
Method SummaryModifier 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 RestTestClient.BodyContentSpecParse 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).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.EntityExchangeResult<byte[]> Exit the chained API and return anExchangeResultwith the raw response content.Parse expected and actual response content as XML and assert that the two are "similar", i.e.default XpathAssertionsAccess 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- 
isEmptyEntityExchangeResult<Void> isEmpty()Assert the response body is empty and return the exchange result.
- 
jsonParse 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:
 
- 
jsonParse the expected and actual response content as JSON and perform a comparison using the given mode. If the comparison failed, throws anAssertionErrorwith the message of theJsonComparison.Use of this method requires the JSONassert library to be on the classpath. - Parameters:
- expectedJson- the expected JSON content
- compareMode- the compare mode
- See Also:
 
- 
jsonParse the expected and actual response content as JSON and perform a comparison using the givenJsonComparator. If the comparison failed, throws anAssertionErrorwith the message of theJsonComparison.- Parameters:
- expectedJson- the expected JSON content
- comparator- the comparator to use
 
- 
xmlParse 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.
- See Also:
 
- 
jsonPathAccess to response body assertions using a JsonPath expression to inspect a specific subset of the body.- Parameters:
- expression- the JsonPath expression
 
- 
xpathAccess 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(String, Object...).- Parameters:
- expression- the XPath expression
- args- arguments to parameterize the expression
- See Also:
 
- 
xpathAccess 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(String, Object...).- Parameters:
- expression- the XPath expression
- namespaces- the namespaces to use
- args- arguments to parameterize the expression
 
- 
consumeWithAssert the response body content with the givenConsumer.- Parameters:
- consumer- the consumer for the response body; the input- byte[]may be- nullif there was no response body.
 
- 
returnResultEntityExchangeResult<byte[]> returnResult()Exit the chained API and return anExchangeResultwith the raw response content.
 
-