接口 WebTestClient.BodyContentSpec
- 封闭接口:
- WebTestClient
public static interface WebTestClient.BodyContentSpec
Spec for expectations on the response body content.
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 WebTestClient.BodyContentSpec
consumeWith(Consumer<EntityExchangeResult<byte[]>> consumer)
Assert the response body content with the givenConsumer
.EntityExchangeResult<Void>
isEmpty()
Assert the response body is empty and return the exchange result.WebTestClient.BodyContentSpec
json(String expectedJson)
Parse the expected and actual response content as JSON and perform a "lenient" comparison verifying the same attribute-value pairs.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 anExchangeResult
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. they contain the same elements and attributes regardless of order.default XpathAssertions
xpath(String expression, Object... args)
Access to response body assertions using an XPath expression to inspect a specific subset of the body.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.
方法详细资料
isEmpty
EntityExchangeResult<Void> isEmpty()
Assert the response body is empty and return the exchange result.
json
WebTestClient.BodyContentSpec json(String expectedJson)
Parse the expected and actual response content as JSON and perform a "lenient" comparison verifying the same attribute-value pairs.Use of this option requires the JSONassert library on to be on the classpath.
- 参数:
expectedJson
- the expected JSON content.
xml
WebTestClient.BodyContentSpec xml(String expectedXml)
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.
- 参数:
expectedXml
- the expected JSON content.- 从以下版本开始:
- 5.1
- 另请参阅:
XmlExpectationsHelper.assertXmlEqual(String, String)
jsonPath
JsonPathAssertions jsonPath(String expression, Object... args)
Access 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...)
.- 参数:
expression
- the JsonPath expressionargs
- arguments to parameterize the expression
xpath
default XpathAssertions xpath(String expression, Object... args)
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...)
.- 参数:
expression
- the XPath expressionargs
- arguments to parameterize the expression- 从以下版本开始:
- 5.1
- 另请参阅:
xpath(String, Map, Object...)
xpath
XpathAssertions xpath(String expression, @Nullable 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.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 expression- 从以下版本开始:
- 5.1
consumeWith
WebTestClient.BodyContentSpec consumeWith(Consumer<EntityExchangeResult<byte[]>> consumer)
Assert the response body content with the givenConsumer
.- 参数:
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.