Class CoreJsonAssertion<T,A extends CoreJsonAssertion<T,A>>

java.lang.Object
org.hamcrest.BaseMatcher<T>
uk.org.webcompere.modelassert.json.impl.CoreJsonAssertion<T,A>
Type Parameters:
T - the type of JSON source - e.g. String or File
A - the type of the assertion subclass, into which the fluent methods cast this
All Implemented Interfaces:
org.hamcrest.Matcher<T>, org.hamcrest.SelfDescribing, JsonNodeAssertDsl<A>, ArrayNodeDsl<A>, BooleanNodeDsl<A>, NumberComparisonDsl<A>, NumberNodeDsl<A>, ObjectNodeDsl<A>, Sizeable<A>, TextNodeDsl<A>, IsEqualToDsl<A>, TreeComparisonDsl<A>, Satisfies<A>
Direct Known Subclasses:
AssertJson, HamcrestJsonAssertion

public abstract class CoreJsonAssertion<T,A extends CoreJsonAssertion<T,A>> extends org.hamcrest.BaseMatcher<T> implements JsonNodeAssertDsl<A>, Satisfies<A>
Common implementation of both variants of the json assertion. Is itself a BaseMatcher as the implementation has to work hardest to be compatible with hamcrest
  • Constructor Details

    • CoreJsonAssertion

      protected CoreJsonAssertion(JsonProvider<T> jsonProvider)
  • Method Details

    • satisfies

      public A satisfies(Condition condition)
      Description copied from interface: Satisfies
      Add a condition that the input JSON must satisfy
      Specified by:
      satisfies in interface Satisfies<T>
      Parameters:
      condition - the condition
      Returns:
      this for fluent calling
    • matches

      public boolean matches(Object item)
      Specified by:
      matches in interface org.hamcrest.Matcher<T>
    • describeTo

      public void describeTo(org.hamcrest.Description description)
      Specified by:
      describeTo in interface org.hamcrest.SelfDescribing
    • describeMismatch

      public void describeMismatch(Object item, org.hamcrest.Description description)
      Specified by:
      describeMismatch in interface org.hamcrest.Matcher<T>
      Overrides:
      describeMismatch in class org.hamcrest.BaseMatcher<T>
    • toArgumentMatcher

      public org.mockito.ArgumentMatcher<T> toArgumentMatcher()
      Convert this to a mockito argument matcher in order to test JSON sent through to a method or provide responses based on JSON
      Returns:
      this as an argument matcher