public class JsonPathRequestMatchers extends Object
An instance of this class is typically accessed via
MockRestRequestMatchers.jsonPath(String, Matcher)
or
MockRestRequestMatchers.jsonPath(String, Object...)
.
Modifier | Constructor and Description |
---|---|
protected |
JsonPathRequestMatchers(String expression,
Object... args)
Protected constructor.
|
Modifier and Type | Method and Description |
---|---|
RequestMatcher |
doesNotExist()
Evaluate the JSON path expression against the request content and
assert that a value does not exist at the given path.
|
RequestMatcher |
exists()
Evaluate the JSON path expression against the request content and
assert that a non-null value exists at the given path.
|
RequestMatcher |
isArray()
Evaluate the JSON path expression against the request content and
assert that the result is an array.
|
RequestMatcher |
isBoolean()
Evaluate the JSON path expression against the request content and
assert that the result is a
Boolean . |
RequestMatcher |
isEmpty()
Evaluate the JSON path expression against the request content and
assert that an empty value exists at the given path.
|
RequestMatcher |
isMap()
Evaluate the JSON path expression against the request content and
assert that the result is a
Map . |
RequestMatcher |
isNotEmpty()
Evaluate the JSON path expression against the request content and
assert that a non-empty value exists at the given path.
|
RequestMatcher |
isNumber()
Evaluate the JSON path expression against the request content and
assert that the result is a
Number . |
RequestMatcher |
isString()
Evaluate the JSON path expression against the request content and
assert that the result is a
String . |
<T> RequestMatcher |
value(org.hamcrest.Matcher<T> matcher)
Evaluate the JSON path expression against the request content and
assert the resulting value with the given Hamcrest
Matcher . |
<T> RequestMatcher |
value(org.hamcrest.Matcher<T> matcher,
Class<T> targetType)
An overloaded variant of (@link
value(Matcher) that also
accepts a target type for the resulting value that the matcher can work
reliably against. |
RequestMatcher |
value(Object expectedValue)
Evaluate the JSON path expression against the request content and
assert that the result is equal to the supplied value.
|
protected JsonPathRequestMatchers(String expression, Object... args)
Use MockRestRequestMatchers.jsonPath(String, Matcher)
or
MockRestRequestMatchers.jsonPath(String, Object...)
.
expression
- the JsonPath
expression; never null
or emptyargs
- arguments to parameterize the JsonPath
expression with,
using formatting specifiers defined in String.format(String, Object...)
public <T> RequestMatcher value(org.hamcrest.Matcher<T> matcher)
Matcher
.public <T> RequestMatcher value(org.hamcrest.Matcher<T> matcher, Class<T> targetType)
value(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 coercing an integer into a double.public RequestMatcher value(Object expectedValue)
public RequestMatcher exists()
If the JSON path expression is not definite, this method asserts that the value at the given path is not empty.
public RequestMatcher doesNotExist()
If the JSON path expression is not definite, this method asserts that the value at the given path is empty.
public RequestMatcher isEmpty()
For the semantics of empty, consult the Javadoc for
ObjectUtils.isEmpty(Object)
.
isNotEmpty()
,
exists()
,
doesNotExist()
public RequestMatcher isNotEmpty()
For the semantics of empty, consult the Javadoc for
ObjectUtils.isEmpty(Object)
.
isEmpty()
,
exists()
,
doesNotExist()
public RequestMatcher isString()
String
.public RequestMatcher isBoolean()
Boolean
.public RequestMatcher isNumber()
Number
.public RequestMatcher isArray()
public RequestMatcher isMap()
Map
.