Class JsonExpectationsHelper

    • Method Detail

      • assertJsonEqual

        public void assertJsonEqual​(String expected,
                                    String actual)
                             throws Exception
        Parse the expected and actual strings as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting with a lenient checking (extensible, and non-strict array ordering).
        Parameters:
        expected - the expected JSON content
        actual - the actual JSON content
        Throws:
        Exception
        Since:
        4.1
        See Also:
        assertJsonEqual(String, String, boolean)
      • assertJsonEqual

        public void assertJsonEqual​(String expected,
                                    String actual,
                                    boolean strict)
                             throws Exception
        Parse the expected and actual strings as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting.

        Can compare in two modes, depending on strict parameter value:

        • true: strict checking. Not extensible, and strict array ordering.
        • false: lenient checking. Extensible, and non-strict array ordering.
        Parameters:
        expected - the expected JSON content
        actual - the actual JSON content
        strict - enables strict checking
        Throws:
        Exception
        Since:
        4.2
      • assertJsonNotEqual

        public void assertJsonNotEqual​(String expected,
                                       String actual)
                                throws Exception
        Parse the expected and actual strings as JSON and assert the two are "not similar" - i.e. they contain different attribute-value pairs regardless of formatting with a lenient checking (extensible, and non-strict array ordering).
        Parameters:
        expected - the expected JSON content
        actual - the actual JSON content
        Throws:
        Exception
        Since:
        4.1
        See Also:
        assertJsonNotEqual(String, String, boolean)
      • assertJsonNotEqual

        public void assertJsonNotEqual​(String expected,
                                       String actual,
                                       boolean strict)
                                throws Exception
        Parse the expected and actual strings as JSON and assert the two are "not similar" - i.e. they contain different attribute-value pairs regardless of formatting.

        Can compare in two modes, depending on strict parameter value:

        • true: strict checking. Not extensible, and strict array ordering.
        • false: lenient checking. Extensible, and non-strict array ordering.
        Parameters:
        expected - the expected JSON content
        actual - the actual JSON content
        strict - enables strict checking
        Throws:
        Exception
        Since:
        4.2