Package org.skyscreamer.jsonassert
Class JSONCompareResult
- java.lang.Object
-
- org.skyscreamer.jsonassert.JSONCompareResult
-
public class JSONCompareResult extends java.lang.ObjectBean 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 voidfail(java.lang.String message)JSONCompareResultfail(java.lang.String field, java.lang.Object expected, java.lang.Object actual)Identify that the comparison failedJSONCompareResultfail(java.lang.String field, ValueMatcherException exception)Identify that the comparison failedbooleanfailed()Did the comparison fail?java.lang.ObjectgetActual()Deprecated.Superseded bygetFieldFailures()java.lang.ObjectgetExpected()Deprecated.Superseded bygetFieldFailures()java.lang.StringgetField()Deprecated.Superseded bygetFieldFailures()java.util.List<FieldComparisonFailure>getFieldFailures()Get the list of failures on field comparisonsjava.util.List<FieldComparisonFailure>getFieldMissing()Get the list of missed on field comparisonsjava.util.List<FieldComparisonFailure>getFieldUnexpected()Get the list of failures on field comparisonsjava.lang.StringgetMessage()Result messagebooleanisFailureOnField()Check if comparison failed on any particular fieldsbooleanisMissingOnField()Check if comparison failed with missing on any particular fieldsbooleanisUnexpectedOnField()Check if comparison failed with unexpected on any particular fieldsJSONCompareResultmissing(java.lang.String field, java.lang.Object expected)Identify the missing fieldbooleanpassed()Did the comparison pass?java.lang.StringtoString()JSONCompareResultunexpected(java.lang.String field, java.lang.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 java.lang.String getMessage()
Result message- Returns:
- String explaining why if the comparison failed
-
getFieldFailures
public java.util.List<FieldComparisonFailure> getFieldFailures()
Get the list of failures on field comparisons- Returns:
- list of comparsion failures
-
getFieldMissing
public java.util.List<FieldComparisonFailure> getFieldMissing()
Get the list of missed on field comparisons- Returns:
- list of comparsion failures
-
getFieldUnexpected
public java.util.List<FieldComparisonFailure> getFieldUnexpected()
Get the list of failures on field comparisons- Returns:
- list of comparsion failures
-
getActual
@Deprecated public java.lang.Object getActual()
Deprecated.Superseded bygetFieldFailures()Actual field value- Returns:
- a
JSONObject,JSONArrayor otherObjectinstance, ornullif the comparison did not fail on a particular field
-
getExpected
@Deprecated public java.lang.Object 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 public java.lang.String 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
public void fail(java.lang.String message)
-
fail
public JSONCompareResult fail(java.lang.String field, java.lang.Object expected, java.lang.Object actual)
Identify that the comparison failed- Parameters:
field- Which field failedexpected- Expected resultactual- Actual result- Returns:
- result of comparision
-
fail
public JSONCompareResult fail(java.lang.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(java.lang.String field, java.lang.Object expected)
Identify the missing field- Parameters:
field- missing fieldexpected- expected result- Returns:
- result of comparison
-
unexpected
public JSONCompareResult unexpected(java.lang.String field, java.lang.Object actual)
Identify unexpected field- Parameters:
field- unexpected fieldactual- actual result- Returns:
- result of comparison
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-