@@ -32,26 +32,71 @@ public class JsonExpectationsHelper {
32
32
/**
33
33
* Parse the expected and actual strings as JSON and assert the two
34
34
* are "similar" - i.e. they contain the same attribute-value pairs
35
- * regardless of order and formatting.
35
+ * regardless of formatting with a lenient checking (extensible, and non-strict
36
+ * array ordering).
36
37
*
37
38
* @param expected the expected JSON content
38
39
* @param actual the actual JSON content
39
40
* @since 4.1
41
+ * @see #assertJsonEqual(String, String, boolean)
40
42
*/
41
43
public void assertJsonEqual (String expected , String actual ) throws Exception {
42
- JSONAssert .assertEquals (expected , actual , false );
44
+ assertJsonEqual (expected , actual , false );
45
+ }
46
+
47
+ /**
48
+ * Parse the expected and actual strings as JSON and assert the two
49
+ * are "similar" - i.e. they contain the same attribute-value pairs
50
+ * regardless of formatting.
51
+ *
52
+ * <p>Can compare in two modes, depending on {@code strict} parameter value:
53
+ * <ul>
54
+ * <li>{@code true}: strict checking. Not extensible, and strict array ordering.</li>
55
+ * <li>{@code false}: lenient checking. Extensible, and non-strict array ordering.</li>
56
+ * </ul>
57
+ *
58
+ * @param expected the expected JSON content
59
+ * @param actual the actual JSON content
60
+ * @param strict enables strict checking
61
+ * @since 4.2
62
+ */
63
+ public void assertJsonEqual (String expected , String actual , boolean strict ) throws Exception {
64
+ JSONAssert .assertEquals (expected , actual , strict );
43
65
}
44
66
45
67
/**
46
68
* Parse the expected and actual strings as JSON and assert the two
47
69
* are "not similar" - i.e. they contain different attribute-value pairs
48
- * regardless of order and formatting.
70
+ * regardless of formatting with a lenient checking (extensible, and non-strict
71
+ * array ordering).
49
72
*
50
73
* @param expected the expected JSON content
51
74
* @param actual the actual JSON content
52
75
* @since 4.1
76
+ * @see #assertJsonNotEqual(String, String, boolean)
53
77
*/
54
78
public void assertJsonNotEqual (String expected , String actual ) throws Exception {
55
- JSONAssert . assertNotEquals (expected , actual , false );
79
+ assertJsonNotEqual (expected , actual , false );
56
80
}
81
+
82
+ /**
83
+ * Parse the expected and actual strings as JSON and assert the two
84
+ * are "not similar" - i.e. they contain different attribute-value pairs
85
+ * regardless of formatting.
86
+ *
87
+ * <p>Can compare in two modes, depending on {@code strict} parameter value:
88
+ * <ul>
89
+ * <li>{@code true}: strict checking. Not extensible, and strict array ordering.</li>
90
+ * <li>{@code false}: lenient checking. Extensible, and non-strict array ordering.</li>
91
+ * </ul>
92
+ *
93
+ * @param expected the expected JSON content
94
+ * @param actual the actual JSON content
95
+ * @param strict enables strict checking
96
+ * @since 4.2
97
+ */
98
+ public void assertJsonNotEqual (String expected , String actual , boolean strict ) throws Exception {
99
+ JSONAssert .assertNotEquals (expected , actual , strict );
100
+ }
101
+
57
102
}
0 commit comments