类 JsonPathExpectationsHelper
Based on the JsonPath project: requiring version 0.9+, with 1.1+ strongly recommended.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Craig Andrews, Sam Brannen
-
字段概要
字段 -
构造器概要
构造器构造器说明JsonPathExpectationsHelper(String expression, Object... args) Construct a newJsonPathExpectationsHelper. -
方法概要
修饰符和类型方法说明private ObjectassertExistsAndReturn(String content) voidassertValue(String content, Object expectedValue) Evaluate the JSON path expression against the suppliedcontentand assert that the result is equal to the expected value.<T> voidassertValue(String content, org.hamcrest.Matcher<? super T> matcher) Evaluate the JSON path expression against the suppliedcontentand assert the resulting value with the givenMatcher.<T> voidassertValue(String content, org.hamcrest.Matcher<? super T> matcher, Class<T> targetType) An overloaded variant ofassertValue(String, Matcher)that also accepts a target type for the resulting value.voidassertValueIsArray(String content) Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is an array.voidassertValueIsBoolean(String content) Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is aBoolean.voidassertValueIsEmpty(String content) Evaluate the JSON path expression against the suppliedcontentand assert that an empty value exists at the given path.voidassertValueIsMap(String content) Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is aMap.voidassertValueIsNotEmpty(String content) Evaluate the JSON path expression against the suppliedcontentand assert that a non-empty value exists at the given path.voidassertValueIsNumber(String content) Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is aNumber.voidassertValueIsString(String content) Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is aString.voiddoesNotExist(String content) Evaluate the JSON path expression against the suppliedcontentand assert that a non-null value does not exist at the given path.voiddoesNotHaveJsonPath(String content) Evaluate the JSON path expression against the suppliedcontentand assert that a value, includingnullvalues, does not exist at the given path.evaluateJsonPath(String content) Evaluate the JSON path and return the resulting value.evaluateJsonPath(String content, Class<?> targetType) Variant ofevaluateJsonPath(String)with a target type.voidEvaluate the JSON path expression against the suppliedcontentand assert that a non-null value, possibly an empty array or map, exists at the given path.private StringfailureReason(String expectedDescription, Object value) voidhasJsonPath(String content) Evaluate the JSON path expression against the suppliedcontentand assert that a value, possiblynull, exists.private boolean
-
字段详细资料
-
expression
-
jsonPath
private final com.jayway.jsonpath.JsonPath jsonPath
-
-
构造器详细资料
-
JsonPathExpectationsHelper
Construct a newJsonPathExpectationsHelper.- 参数:
expression- theJsonPathexpression; nevernullor emptyargs- arguments to parameterize theJsonPathexpression with, using formatting specifiers defined inString.format(String, Object...)
-
-
方法详细资料
-
assertValue
Evaluate the JSON path expression against the suppliedcontentand assert the resulting value with the givenMatcher.- 参数:
content- the JSON contentmatcher- the matcher with which to assert the result
-
assertValue
public <T> void assertValue(String content, org.hamcrest.Matcher<? super T> matcher, Class<T> targetType) An overloaded variant ofassertValue(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- the expected type of the resulting value
-
assertValue
Evaluate the JSON path expression against the suppliedcontentand assert that the result is equal to the expected value.- 参数:
content- the JSON contentexpectedValue- the expected value
-
assertValueIsString
Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is aString.- 参数:
content- the JSON content
-
assertValueIsBoolean
Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is aBoolean.- 参数:
content- the JSON content
-
assertValueIsNumber
Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is aNumber.- 参数:
content- the JSON content
-
assertValueIsArray
Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is an array.- 参数:
content- the JSON content
-
assertValueIsMap
Evaluate the JSON path expression against the suppliedcontentand assert that the resulting value is aMap.- 参数:
content- the JSON content
-
exists
Evaluate the JSON path expression against the suppliedcontentand assert that a non-null value, possibly an empty array or map, exists at the given path.Note that if the JSON path expression is not definite, this method asserts that the list of values at the given path is not empty.
- 参数:
content- the JSON content
-
doesNotExist
Evaluate the JSON path expression against the suppliedcontentand assert that a non-null value does not exist at the given path.Note that if the JSON path expression is not definite, this method asserts that the list of values at the given path is empty.
- 参数:
content- the JSON content
-
assertValueIsEmpty
Evaluate the JSON path expression against the suppliedcontentand 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 content
-
assertValueIsNotEmpty
Evaluate the JSON path expression against the suppliedcontentand 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
-
hasJsonPath
Evaluate the JSON path expression against the suppliedcontentand 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.
- 参数:
content- the JSON content
-
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.
- 参数:
content- the JSON content
-
failureReason
-
evaluateJsonPath
Evaluate the JSON path and return the resulting value.- 参数:
content- the content to evaluate against- 返回:
- the result of the evaluation
- 抛出:
AssertionError- if the evaluation fails
-
evaluateJsonPath
Variant ofevaluateJsonPath(String)with a target type.This can be useful for matching numbers reliably for example coercing an integer into a double.
- 参数:
content- the content to evaluate against- 返回:
- the result of the evaluation
- 抛出:
AssertionError- if the evaluation fails
-
assertExistsAndReturn
-
pathIsIndefinite
private boolean pathIsIndefinite()
-