Package org.skyscreamer.jsonassert
Class JSONCompareResult
java.lang.Object
org.skyscreamer.jsonassert.JSONCompareResult
Bean for holding results from JSONCompare.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Identify that the comparison failedfail
(String field, ValueMatcherException exception) Identify that the comparison failedboolean
failed()
Did the comparison fail?Deprecated.Deprecated.Superseded bygetFieldFailures()
getField()
Deprecated.Superseded bygetFieldFailures()
Get the list of failures on field comparisonsGet the list of missed on field comparisonsGet the list of failures on field comparisonsResult messageboolean
Check if comparison failed on any particular fieldsboolean
Check if comparison failed with missing on any particular fieldsboolean
Check if comparison failed with unexpected on any particular fieldsIdentify the missing fieldboolean
passed()
Did the comparison pass?toString()
unexpected
(String field, Object actual) Identify unexpected field
-
Constructor Details
-
JSONCompareResult
public JSONCompareResult()Default constructor.
-
-
Method Details
-
passed
public boolean passed()Did the comparison pass?- Returns:
- True if it passed
-
failed
public boolean failed()Did the comparison fail?- Returns:
- True if it failed
-
getMessage
Result message- Returns:
- String explaining why if the comparison failed
-
getFieldFailures
Get the list of failures on field comparisons- Returns:
- list of comparsion failures
-
getFieldMissing
Get the list of missed on field comparisons- Returns:
- list of comparsion failures
-
getFieldUnexpected
Get the list of failures on field comparisons- Returns:
- list of comparsion failures
-
getActual
Deprecated.Superseded bygetFieldFailures()
Actual field value- Returns:
- a
JSONObject
,JSONArray
or otherObject
instance, ornull
if the comparison did not fail on a particular field
-
getExpected
Deprecated.Superseded bygetFieldFailures()
Expected field value- Returns:
- a
JSONObject
,JSONArray
or otherObject
instance, ornull
if the comparison did not fail on a particular field
-
isFailureOnField
public boolean isFailureOnField()Check if comparison failed on any particular fields- Returns:
- true if there are field failures
-
isMissingOnField
public boolean isMissingOnField()Check if comparison failed with missing on any particular fields- Returns:
- true if an expected field is missing
-
isUnexpectedOnField
public boolean isUnexpectedOnField()Check if comparison failed with unexpected on any particular fields- Returns:
- true if an unexpected field is in the result
-
getField
Deprecated.Superseded bygetFieldFailures()
Dot-separated path the the field that failed comparison- Returns:
- a
String
instance, ornull
if the comparison did not fail on a particular field
-
fail
-
fail
Identify that the comparison failed- Parameters:
field
- Which field failedexpected
- Expected resultactual
- Actual result- Returns:
- result of comparision
-
fail
Identify that the comparison failed- Parameters:
field
- Which field failedexception
- exception containing details of match failure- Returns:
- result of comparision
-
missing
Identify the missing field- Parameters:
field
- missing fieldexpected
- expected result- Returns:
- result of comparison
-
unexpected
Identify unexpected field- Parameters:
field
- unexpected fieldactual
- actual result- Returns:
- result of comparison
-
toString
-
getFieldFailures()