Class JSONMatcher<T>

  • Type Parameters:
    T - the type parameter of the matcher
    All Implemented Interfaces:
    org.hamcrest.Matcher<T>, org.hamcrest.SelfDescribing

    public class JSONMatcher<T>
    extends org.hamcrest.BaseMatcher<T>
    Custom Matcher to assert that the serialization of an object matches the one stored in file.
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONMatcher​(java.lang.String pathToExpected)
      Will return true if the JSON serialization of the actual is equal to the trimmed serialization of the JSON contained in the provided path
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void describeTo​(org.hamcrest.Description description)  
      boolean matches​(java.lang.Object actual)  
      • Methods inherited from class org.hamcrest.BaseMatcher

        _dont_implement_Matcher___instead_extend_BaseMatcher_, describeMismatch, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • JSONMatcher

        public JSONMatcher​(java.lang.String pathToExpected)
                    throws java.io.IOException
        Will return true if the JSON serialization of the actual is equal to the trimmed serialization of the JSON contained in the provided path
        Parameters:
        pathToExpected - path in the classpath to the file containing the expected JSON string, it can contain a beautified JSON
        Throws:
        java.io.IOException
    • Method Detail

      • matches

        public boolean matches​(java.lang.Object actual)
      • describeTo

        public void describeTo​(org.hamcrest.Description description)