Package org.skyscreamer.jsonassert
Class JSONCompareResult
- java.lang.Object
-
- org.skyscreamer.jsonassert.JSONCompareResult
-
public class JSONCompareResult extends Object
Bean for holding results from JSONCompare.
-
-
Constructor Summary
Constructors Constructor Description JSONCompareResult()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
fail(String message)
JSONCompareResult
fail(String field, Object expected, Object actual)
Identify that the comparison failedJSONCompareResult
fail(String field, ValueMatcherException exception)
Identify that the comparison failedboolean
failed()
Did the comparison fail?Object
getActual()
Deprecated.Superseded bygetFieldFailures()
Object
getExpected()
Deprecated.Superseded bygetFieldFailures()
String
getField()
Deprecated.Superseded bygetFieldFailures()
List<FieldComparisonFailure>
getFieldFailures()
Get the list of failures on field comparisonsList<FieldComparisonFailure>
getFieldMissing()
Get the list of missed on field comparisonsList<FieldComparisonFailure>
getFieldUnexpected()
Get the list of failures on field comparisonsString
getMessage()
Result messageboolean
isFailureOnField()
Check if comparison failed on any particular fieldsboolean
isMissingOnField()
Check if comparison failed with missing on any particular fieldsboolean
isUnexpectedOnField()
Check if comparison failed with unexpected on any particular fieldsJSONCompareResult
missing(String field, Object expected)
Identify the missing fieldboolean
passed()
Did the comparison pass?String
toString()
JSONCompareResult
unexpected(String field, Object actual)
Identify unexpected field
-
-
-
Method Detail
-
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
public String getMessage()
Result message- Returns:
- String explaining why if the comparison failed
-
getFieldFailures
public List<FieldComparisonFailure> getFieldFailures()
Get the list of failures on field comparisons- Returns:
- list of comparsion failures
-
getFieldMissing
public List<FieldComparisonFailure> getFieldMissing()
Get the list of missed on field comparisons- Returns:
- list of comparsion failures
-
getFieldUnexpected
public List<FieldComparisonFailure> getFieldUnexpected()
Get the list of failures on field comparisons- Returns:
- list of comparsion failures
-
getActual
@Deprecated public Object 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 public Object 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 public String 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
public void fail(String message)
-
fail
public JSONCompareResult fail(String field, Object expected, Object actual)
Identify that the comparison failed- Parameters:
field
- Which field failedexpected
- Expected resultactual
- Actual result- Returns:
- result of comparision
-
fail
public JSONCompareResult fail(String field, ValueMatcherException exception)
Identify that the comparison failed- Parameters:
field
- Which field failedexception
- exception containing details of match failure- Returns:
- result of comparision
-
missing
public JSONCompareResult missing(String field, Object expected)
Identify the missing field- Parameters:
field
- missing fieldexpected
- expected result- Returns:
- result of comparison
-
unexpected
public JSONCompareResult unexpected(String field, Object actual)
Identify unexpected field- Parameters:
field
- unexpected fieldactual
- actual result- Returns:
- result of comparison
-
-