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 toJSONCompareMode
that 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 boolean
areNotSameDoubles(Object expectedValue, Object actualValue)
protected boolean
areNumbers(Object expectedValue, Object actualValue)
void
compareJSON(String prefix, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareResult result)
Compares twoJSONObject
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.void
compareJSONArray(String prefix, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareResult result)
Compares twoJSONArray
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.void
compareValues(String prefix, Object expectedValue, Object actualValue, JSONCompareResult result)
Compares twoObject
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.-
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(String prefix, org.json.JSONObject expected, org.json.JSONObject actual, JSONCompareResult result) throws org.json.JSONException
Description copied from interface:JSONComparator
Compares twoJSONObject
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.- 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(String prefix, Object expectedValue, Object actualValue, JSONCompareResult result) throws org.json.JSONException
Description copied from interface:JSONComparator
Compares twoObject
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.- 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(String prefix, org.json.JSONArray expected, org.json.JSONArray actual, JSONCompareResult result) throws org.json.JSONException
Description copied from interface:JSONComparator
Compares twoJSONArray
s on the provided path represented byprefix
and updates the result of the comparison in theresult
JSONCompareResult
object.- 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
-
-