org.skyscreamer.jsonassert
Class Customization

java.lang.Object
  extended by org.skyscreamer.jsonassert.Customization

public final class Customization
extends Object

Associates a custom matcher to a specific jsonpath.


Constructor Summary
Customization(String path, ValueMatcher<Object> comparator)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Customization

public Customization(String path,
                     ValueMatcher<Object> comparator)
Method Detail

customization

public static Customization customization(String path,
                                          ValueMatcher<Object> comparator)

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 tested
expected - 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 tested
expected - expected JSON value
result - 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.


Copyright © 2014. All Rights Reserved.