Package org.skyscreamer.jsonassert
Class JSONCompareResult
java.lang.Object
org.skyscreamer.jsonassert.JSONCompareResult
Bean for holding results from JSONCompare.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidIdentify that the comparison failedfail(String field, ValueMatcherException exception) Identify that the comparison failedbooleanfailed()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 messagebooleanCheck if comparison failed on any particular fieldsbooleanCheck if comparison failed with missing on any particular fieldsbooleanCheck if comparison failed with unexpected on any particular fieldsIdentify the missing fieldbooleanpassed()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,JSONArrayor otherObjectinstance, ornullif the comparison did not fail on a particular field
-
getExpected
Deprecated.Superseded bygetFieldFailures()Expected field value- Returns:
- a
JSONObject,JSONArrayor otherObjectinstance, ornullif 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
Stringinstance, ornullif 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()