Class JsonVerifier

java.lang.Object
org.japprove.verifier.Verifier
org.japprove.verifier.JsonVerifier

public class JsonVerifier
extends Verifier
The JsonVerifier provides a method to verify JSON objects within Approval Tests. With its ignore method it is also possible to ignore specific elements of a JSON object.
  • Constructor Summary

    Constructors 
    Constructor Description
    JsonVerifier​(ApprovalTestingEngine approvalTestingEngine)  
  • Method Summary

    Modifier and Type Method Description
    JsonVerifier ignore​(java.lang.String jsonPath)
    Receives a JSONPath that should be ignored on the verification process.
    void verify​(com.fasterxml.jackson.databind.JsonNode data)
    Receives a JsonNode that should be verified within an Approval Test.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • verify

      public void verify​(com.fasterxml.jackson.databind.JsonNode data)
      Receives a JsonNode that should be verified within an Approval Test.

      Within the verification process, a baseline candidate is created in the baseline candidate's directory and compared to a baseline (if exists). In the case the versions are equal, the test passes. If no baseline exists, a VersionNotApprovedError is thrown. If there is a baseline that is not equal to the current version, a VerificationFailedError is thrown.

      Parameters:
      data - The JsonNode that should be verified
    • ignore

      public JsonVerifier ignore​(java.lang.String jsonPath)
      Receives a JSONPath that should be ignored on the verification process.
      Parameters:
      jsonPath - a JSONPath that should be ignored on the verification process
      Returns:
      the JsonVerifier