Class JsonElementValidatorItem<T>
java.lang.Object
org.citrusframework.validation.json.JsonElementValidatorItem<T>
- Type Parameters:
T- the type of the actual and expected json
Wraps all needed data to validate an actual json with an expected json-template.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJsonElementValidatorItem(int index, T actual, T expected) For array-items.JsonElementValidatorItem(String name, T actual, T expected) For object-items. -
Method Summary
Modifier and TypeMethodDescription<O> JsonElementValidatorItem<O>ensureType(Class<O> type) The json path as string from the root to this item, i.e.getName()The identifier of a json element null on rootnamefor an entry in a json mapindexin square brackets for an item in a json array, i.e.getRoot()booleanisPathIgnoredBy(String jsonPathExpression) static booleanisPathIgnoredBy(String jsonPathExpression, String currentPath, Object json) parent(JsonElementValidatorItem<?> parent) Set the parent of this json-element.static JsonElementValidatorItem<Object>Parses and wraps the given json's.
-
Field Details
-
actual
-
expected
-
-
Constructor Details
-
JsonElementValidatorItem
For array-items.- Parameters:
index- of the item in theparent-element
-
JsonElementValidatorItem
For object-items.- Parameters:
name- /key of the json value in theparent-element
-
-
Method Details
-
parseJson
public static JsonElementValidatorItem<Object> parseJson(int permissiveMode, String actualJson, String expectedJson) Parses and wraps the given json's.- Parameters:
permissiveMode- seeJSONParser#MODE_*orJSONParser.DEFAULT_PERMISSIVE_MODEactualJson- as stringexpectedJson- as string- Returns:
- the two json's wrapped in a
JsonElementValidatorItem<Object>
-
actualAsStringOrNull
- Returns:
actualas string or null
-
expectedAsStringOrNull
- Returns:
expectedas string or null
-
ensureType
- Parameters:
type- to cast the values to- Returns:
- {@link this} as
JsonElementValidatorItem<O> - Throws:
org.citrusframework.exceptions.ValidationException- if eitherexpectedorexpectedis not of the giventype
-
parent
Set the parent of this json-element. -
getJsonPath
The json path as string from the root to this item, i.e. $['books'][1]['name'] -
getName
The identifier of a json element- null on root
namefor an entry in a json mapindexin square brackets for an item in a json array, i.e."[2]"
-
getRoot
-
isPathIgnoredBy
-
isPathIgnoredBy
-
child
-