org.skyscreamer.jsonassert
Class JSONCompareResult

java.lang.Object
  extended by org.skyscreamer.jsonassert.JSONCompareResult

public class JSONCompareResult
extends Object

Bean for holding results from JSONCompare.


Constructor Summary
JSONCompareResult()
          Default constructor.
 
Method Summary
 void fail(String message)
           
 JSONCompareResult fail(String field, Object expected, Object actual)
          Identify that the comparison failed
 boolean failed()
          Did the comparison fail?
 Object getActual()
          Deprecated. Superseded by getFieldFailures()
 Object getExpected()
          Deprecated. Superseded by getFieldFailures()
 String getField()
          Deprecated. Superseded by getFieldFailures()
 List<FieldComparisonFailure> getFieldFailures()
          Get the list of failures on field comparisons
 String getMessage()
          Result message
 boolean isFailureOnField()
          Check if comparison failed on any particular fields
 JSONCompareResult missing(String field, Object expected)
           
 boolean passed()
          Did the comparison pass?
 String toString()
           
 JSONCompareResult unexpected(String field, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSONCompareResult

public JSONCompareResult()
Default constructor.

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


getActual

public Object getActual()
Deprecated. Superseded by getFieldFailures()

Actual field value

Returns:
a JSONObject, JSONArray or other Object instance, or null if the comparison did not fail on a particular field

getExpected

public Object getExpected()
Deprecated. Superseded by getFieldFailures()

Expected field value

Returns:
a JSONObject, JSONArray or other Object instance, or null if the comparison did not fail on a particular field

isFailureOnField

public boolean isFailureOnField()
Check if comparison failed on any particular fields


getField

public String getField()
Deprecated. Superseded by getFieldFailures()

Dot-separated path the the field that failed comparison

Returns:
a String instance, or null 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 failed
expected - Expected result
actual - Actual result

missing

public JSONCompareResult missing(String field,
                                 Object expected)

unexpected

public JSONCompareResult unexpected(String field,
                                    Object value)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.