类 JsonPathResultMatchers
An instance of this class is typically accessed via
MockMvcResultMatchers.jsonPath(String, Object...).
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Craig Andrews, Sam Brannen, Brian Clozel
-
字段概要
字段 -
构造器概要
构造器限定符构造器说明protectedJsonPathResultMatchers(String expression, Object... args) Protected constructor. -
方法概要
修饰符和类型方法说明Evaluate the JSON path expression against the response content and assert that a non-null value does not exist at the given path.Evaluate the JSON path expression against the suppliedcontentand assert that a value, includingnullvalues, does not exist at the given path.exists()Evaluate the JSON path expression against the response content and assert that a non-null value, possibly an empty array or map, exists at the given path.private StringgetContent(MvcResult result) Evaluate the JSON path expression against the response content and assert that a value, possiblynull, exists.isArray()Evaluate the JSON path expression against the response content and assert that the result is an array.Evaluate the JSON path expression against the response content and assert that the result is aBoolean.isEmpty()Evaluate the JSON path expression against the response content and assert that an empty value exists at the given path.isMap()Evaluate the JSON path expression against the response content and assert that the result is aMap.Evaluate the JSON path expression against the response content and assert that a non-empty value exists at the given path.isNumber()Evaluate the JSON path expression against the response content and assert that the result is aNumber.isString()Evaluate the JSON path expression against the response content and assert that the result is aString.Configures the currentJsonPathResultMatchersinstance to verify that the JSON payload is prepended with the given prefix.Evaluate the JSON path expression against the response content and assert that the result is equal to the supplied value.<T> ResultMatchervalue(org.hamcrest.Matcher<? super T> matcher) Evaluate the JSON path expression against the response content and assert the resulting value with the given HamcrestMatcher.<T> ResultMatcherAn overloaded variant ofvalue(Matcher)that also accepts a target type for the resulting value that the matcher can work reliably against.
-
字段详细资料
-
jsonPathHelper
-
prefix
-
-
构造器详细资料
-
JsonPathResultMatchers
Protected constructor.Use
MockMvcResultMatchers.jsonPath(String, Object...)orMockMvcResultMatchers.jsonPath(String, Matcher).- 参数:
expression- theJsonPathexpression; nevernullor emptyargs- arguments to parameterize theJsonPathexpression with, using formatting specifiers defined inString.format(String, Object...)
-
-
方法详细资料
-
prefix
Configures the currentJsonPathResultMatchersinstance to verify that the JSON payload is prepended with the given prefix.Use this method if the JSON payloads are prefixed to avoid Cross Site Script Inclusion (XSSI) attacks.
- 参数:
prefix- the string prefix prepended to the actual JSON payload
-
value
Evaluate the JSON path expression against the response content and assert the resulting value with the given HamcrestMatcher. -
value
An overloaded variant ofvalue(Matcher)that also accepts a target type for the resulting value that the matcher can work reliably against.This can be useful for matching numbers reliably — for example, to coerce an integer into a double.
- 另请参阅:
-
value
Evaluate the JSON path expression against the response content and assert that the result is equal to the supplied value. -
exists
Evaluate the JSON path expression against the response content and assert that a non-null value, possibly an empty array or map, exists at the given path.If the JSON path expression is not definite, this method asserts that the value at the given path is not empty.
-
doesNotExist
Evaluate the JSON path expression against the response content and assert that a non-null value does not exist at the given path.If the JSON path expression is not definite, this method asserts that the value at the given path is empty.
-
isEmpty
Evaluate the JSON path expression against the response content and assert that an empty value exists at the given path.For the semantics of empty, consult the Javadoc for
ObjectUtils.isEmpty(Object). -
isNotEmpty
Evaluate the JSON path expression against the response content and assert that a non-empty value exists at the given path.For the semantics of empty, consult the Javadoc for
ObjectUtils.isEmpty(Object).- 另请参阅:
-
hasJsonPath
Evaluate the JSON path expression against the response content and assert that a value, possiblynull, exists.If the JSON path expression is not definite, this method asserts that the list of values at the given path is not empty.
- 另请参阅:
-
doesNotHaveJsonPath
Evaluate the JSON path expression against the suppliedcontentand assert that a value, includingnullvalues, does not exist at the given path.If the JSON path expression is not definite, this method asserts that the list of values at the given path is empty.
- 另请参阅:
-
isString
Evaluate the JSON path expression against the response content and assert that the result is aString. -
isBoolean
Evaluate the JSON path expression against the response content and assert that the result is aBoolean. -
isNumber
Evaluate the JSON path expression against the response content and assert that the result is aNumber. -
isArray
Evaluate the JSON path expression against the response content and assert that the result is an array. -
isMap
Evaluate the JSON path expression against the response content and assert that the result is aMap. -
getContent
-