Constructor and Description |
---|
JsonPathExpectationsHelper(String expression,
Object... args)
Construct a new
JsonPathExpectationsHelper . |
Modifier and Type | Method and Description |
---|---|
<T> void |
assertValue(String content,
org.hamcrest.Matcher<T> matcher)
Evaluate the JSON path expression against the supplied
content
and assert the resulting value with the given Matcher . |
<T> void |
assertValue(String content,
org.hamcrest.Matcher<T> matcher,
Class<T> targetType)
An overloaded variant of
assertValue(String, Matcher) that also
accepts a target type for the resulting value. |
void |
assertValue(String content,
Object expectedValue)
Evaluate the JSON path expression against the supplied
content
and assert that the result is equal to the expected value. |
void |
assertValueIsArray(String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is an array. |
void |
assertValueIsBoolean(String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is a Boolean . |
void |
assertValueIsEmpty(String content)
Evaluate the JSON path expression against the supplied
content
and assert that an empty value exists at the given path. |
void |
assertValueIsMap(String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is a Map . |
void |
assertValueIsNotEmpty(String content)
Evaluate the JSON path expression against the supplied
content
and assert that a non-empty value exists at the given path. |
void |
assertValueIsNumber(String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is a Number . |
void |
assertValueIsString(String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is a String . |
void |
doesNotExist(String content)
Evaluate the JSON path expression against the supplied
content
and assert that a value does not exist at the given path. |
void |
exists(String content)
Evaluate the JSON path expression against the supplied
content
and assert that a non-null value exists at the given path. |
public JsonPathExpectationsHelper(String expression, Object... args)
JsonPathExpectationsHelper
.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> void assertValue(String content, org.hamcrest.Matcher<T> matcher)
content
and assert the resulting value with the given Matcher
.content
- the JSON contentmatcher
- the matcher with which to assert the resultpublic <T> void assertValue(String content, org.hamcrest.Matcher<T> matcher, Class<T> targetType)
assertValue(String, Matcher)
that also
accepts a target type for the resulting value. This can be useful for
matching numbers reliably for example coercing an integer into a double.content
- the JSON contentmatcher
- the matcher with which to assert the resulttargetType
- a the expected type of the resulting valuepublic void assertValue(String content, Object expectedValue)
content
and assert that the result is equal to the expected value.content
- the JSON contentexpectedValue
- the expected valuepublic void assertValueIsString(String content)
content
and assert that the resulting value is a String
.content
- the JSON contentpublic void assertValueIsBoolean(String content)
content
and assert that the resulting value is a Boolean
.content
- the JSON contentpublic void assertValueIsNumber(String content)
content
and assert that the resulting value is a Number
.content
- the JSON contentpublic void assertValueIsArray(String content)
content
and assert that the resulting value is an array.content
- the JSON contentpublic void assertValueIsMap(String content)
content
and assert that the resulting value is a Map
.content
- the JSON contentpublic void exists(String content)
content
and assert that a non-null value 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.
content
- the JSON contentpublic void doesNotExist(String content)
content
and assert that a 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.
content
- the JSON contentpublic void assertValueIsEmpty(String content)
content
and assert that an empty value exists at the given path.
For the semantics of empty, consult the Javadoc for
ObjectUtils.isEmpty(Object)
.
content
- the JSON contentpublic void assertValueIsNotEmpty(String content)
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)
.
content
- the JSON content