public class JsonPathExpectationsHelper
extends java.lang.Object
Based on the JsonPath project: requiring version 0.9+, with 1.1+ strongly recommended.
| Constructor and Description |
|---|
JsonPathExpectationsHelper(java.lang.String expression,
java.lang.Object... args)
Construct a new
JsonPathExpectationsHelper. |
| Modifier and Type | Method and Description |
|---|---|
<T> void |
assertValue(java.lang.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. |
void |
assertValue(java.lang.String content,
java.lang.Object expectedValue)
Evaluate the JSON path expression against the supplied
content
and assert that the result is equal to the expected value. |
void |
assertValueIsArray(java.lang.String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is an array. |
void |
assertValueIsBoolean(java.lang.String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is a Boolean. |
void |
assertValueIsEmpty(java.lang.String content)
Evaluate the JSON path expression against the supplied
content
and assert that an empty value exists at the given path. |
void |
assertValueIsMap(java.lang.String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is a Map. |
void |
assertValueIsNotEmpty(java.lang.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(java.lang.String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is a Number. |
void |
assertValueIsString(java.lang.String content)
Evaluate the JSON path expression against the supplied
content
and assert that the resulting value is a String. |
void |
doesNotExist(java.lang.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(java.lang.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(java.lang.String expression,
java.lang.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(java.lang.String content,
org.hamcrest.Matcher<T> matcher)
throws java.text.ParseException
content
and assert the resulting value with the given Matcher.content - the JSON contentmatcher - the matcher with which to assert the resultjava.text.ParseExceptionpublic void assertValue(java.lang.String content,
java.lang.Object expectedValue)
throws java.text.ParseException
content
and assert that the result is equal to the expected value.content - the JSON contentexpectedValue - the expected valuejava.text.ParseExceptionpublic void assertValueIsString(java.lang.String content)
throws java.text.ParseException
content
and assert that the resulting value is a String.content - the JSON contentjava.text.ParseExceptionpublic void assertValueIsBoolean(java.lang.String content)
throws java.text.ParseException
content
and assert that the resulting value is a Boolean.content - the JSON contentjava.text.ParseExceptionpublic void assertValueIsNumber(java.lang.String content)
throws java.text.ParseException
content
and assert that the resulting value is a Number.content - the JSON contentjava.text.ParseExceptionpublic void assertValueIsArray(java.lang.String content)
throws java.text.ParseException
content
and assert that the resulting value is an array.content - the JSON contentjava.text.ParseExceptionpublic void assertValueIsMap(java.lang.String content)
throws java.text.ParseException
content
and assert that the resulting value is a Map.content - the JSON contentjava.text.ParseExceptionpublic void exists(java.lang.String content)
throws java.text.ParseException
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 contentjava.text.ParseExceptionpublic void doesNotExist(java.lang.String content)
throws java.text.ParseException
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 contentjava.text.ParseExceptionpublic void assertValueIsEmpty(java.lang.String content)
throws java.text.ParseException
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 contentjava.text.ParseExceptionpublic void assertValueIsNotEmpty(java.lang.String content)
throws java.text.ParseException
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 contentjava.text.ParseException