Class JSONCompareResult

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

public class JSONCompareResult extends Object
Bean for holding results from JSONCompare.
  • 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

      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 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

      @Deprecated 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
      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 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
      Returns:
      result of comparision
    • fail

      public JSONCompareResult fail(String field, ValueMatcherException exception)
      Identify that the comparison failed
      Parameters:
      field - Which field failed
      exception - 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 field
      expected - expected result
      Returns:
      result of comparison
    • unexpected

      public JSONCompareResult unexpected(String field, Object actual)
      Identify unexpected field
      Parameters:
      field - unexpected field
      actual - actual result
      Returns:
      result of comparison
    • toString

      public String toString()
      Overrides:
      toString in class Object