Package org.skyscreamer.jsonassert
Class Customization
- java.lang.Object
-
- org.skyscreamer.jsonassert.Customization
-
public final class Customization extends Object
Associates a custom matcher to a specific jsonpath.
-
-
Constructor Summary
Constructors Constructor Description Customization(String path, ValueMatcher<Object> comparator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
appliesToPath(String path)
static Customization
customization(String path, ValueMatcher<Object> comparator)
boolean
matches(Object actual, Object expected)
Deprecated.boolean
matches(String prefix, Object actual, Object expected, JSONCompareResult result)
Return true if actual value matches expected value using this Customization's comparator.
-
-
-
Constructor Detail
-
Customization
public Customization(String path, ValueMatcher<Object> comparator)
-
-
Method Detail
-
customization
public static Customization customization(String path, ValueMatcher<Object> comparator)
- Parameters:
path
- the json pathcomparator
- the comparator- Returns:
- a new Customization
-
appliesToPath
public boolean appliesToPath(String path)
-
matches
@Deprecated public boolean matches(Object actual, Object expected)
Deprecated.Return true if actual value matches expected value using this Customization's comparator. Calls to this method should be replaced by calls to matches(String prefix, Object actual, Object expected, JSONCompareResult result).- Parameters:
actual
- JSON value being testedexpected
- expected JSON value- Returns:
- true if actual value matches expected value
-
matches
public boolean matches(String prefix, Object actual, Object expected, JSONCompareResult result) throws ValueMatcherException
Return true if actual value matches expected value using this Customization's comparator. The equal method used for comparison depends on type of comparator.- Parameters:
prefix
- JSON path of the JSON item being tested (only used if comparator is a LocationAwareValueMatcher)actual
- JSON value being testedexpected
- expected JSON valueresult
- JSONCompareResult to which match failure may be passed (only used if comparator is a LocationAwareValueMatcher)- Returns:
- true if expected and actual equal or any difference has already been passed to specified result instance, false otherwise.
- Throws:
ValueMatcherException
- if expected and actual values not equal and ValueMatcher needs to override default comparison failure message that would be generated if this method returned false.
-
-