Class DefaultComparator
- java.lang.Object
-
- org.skyscreamer.jsonassert.comparator.AbstractComparator
-
- org.skyscreamer.jsonassert.comparator.DefaultComparator
-
- All Implemented Interfaces:
JSONComparator
- Direct Known Subclasses:
ArraySizeComparator,CustomComparator
public class DefaultComparator extends AbstractComparator
This class is the default json comparator implementation. Comparison is performed according toJSONCompareModethat is passed as constructor's argument.
-
-
Constructor Summary
Constructors Constructor Description DefaultComparator(JSONCompareMode mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanareNotSameDoubles(java.lang.Object expectedValue, java.lang.Object actualValue)protected booleanareNumbers(java.lang.Object expectedValue, java.lang.Object actualValue)voidcompareJSON(java.lang.String prefix, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareResult result)Compares twoJSONObjects on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.voidcompareJSONArray(java.lang.String prefix, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareResult result)Compares twoJSONArrays on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.voidcompareValues(java.lang.String prefix, java.lang.Object expectedValue, java.lang.Object actualValue, JSONCompareResult result)Compares twoObjects on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.-
Methods inherited from class org.skyscreamer.jsonassert.comparator.AbstractComparator
checkJsonObjectKeysActualInExpected, checkJsonObjectKeysExpectedInActual, compareJSON, compareJSON, compareJSONArrayOfJsonObjects, compareJSONArrayOfSimpleValues, compareJSONArrayWithStrictOrder, recursivelyCompareJSONArray
-
-
-
-
Constructor Detail
-
DefaultComparator
public DefaultComparator(JSONCompareMode mode)
-
-
Method Detail
-
compareJSON
public void compareJSON(java.lang.String prefix, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareResult result) throws org.json.JSONExceptionDescription copied from interface:JSONComparatorCompares twoJSONObjects on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.- Parameters:
prefix- the path in the json where the comparison happensexpected- the expected JSON objectactual- the actual JSON objectresult- stores the actual state of the comparison result- Throws:
org.json.JSONException- JSON parsing error
-
compareValues
public void compareValues(java.lang.String prefix, java.lang.Object expectedValue, java.lang.Object actualValue, JSONCompareResult result) throws org.json.JSONExceptionDescription copied from interface:JSONComparatorCompares twoObjects on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.- Parameters:
prefix- the path in the json where the comparison happensexpectedValue- the expected valueactualValue- the actual valueresult- stores the actual state of the comparison result- Throws:
org.json.JSONException- JSON parsing error
-
compareJSONArray
public void compareJSONArray(java.lang.String prefix, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareResult result) throws org.json.JSONExceptionDescription copied from interface:JSONComparatorCompares twoJSONArrays on the provided path represented byprefixand updates the result of the comparison in theresultJSONCompareResultobject.- Parameters:
prefix- the path in the json where the comparison happensexpected- the expected JSON arrayactual- the actual JSON arrayresult- stores the actual state of the comparison result- Throws:
org.json.JSONException- JSON parsing error
-
areNumbers
protected boolean areNumbers(java.lang.Object expectedValue, java.lang.Object actualValue)
-
areNotSameDoubles
protected boolean areNotSameDoubles(java.lang.Object expectedValue, java.lang.Object actualValue)
-
-