Class Customization


  • public final class Customization
    extends Object
    Associates a custom matcher to a specific jsonpath.
    • Method Detail

      • customization

        public static Customization customization​(String path,
                                                  ValueMatcher<Object> comparator)
        Creates a new Customization instance for path and comparator.
        Parameters:
        path - the json path
        comparator - 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 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.