You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Standardise some failure messages, add unit tests for additional cases
and to verify failure descriptions are correct, improve unit test
coverage, add JavaDoc
* <p>To verify that the 'id' attribute of first element of array 'a' is '1':</p>
30
+
*
31
+
* <code>
32
+
* JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);<br/>
33
+
* Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator, 0));<br/>
34
+
* JSONAssert.assertEquals("{a:[{id:1}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
35
+
* </code>
36
+
*
37
+
* <p>To simplify complexity of expected JSON string, the value <code>"a:[{id:1}]}"</code> may be replaced by <code>"a:{id:1}}"</code></p>
38
+
*
39
+
* <p>To verify that the 'type' attribute of second and third elements of array 'a' is 'row':</p>
40
+
*
41
+
* <code>
42
+
* JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);<br/>
43
+
* Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator, 1, 2));<br/>
44
+
* JSONAssert.assertEquals("{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
45
+
* </code>
46
+
*
47
+
* <p>To verify that the 'type' attribute of every element of array 'a' is 'row':</p>
48
+
*
49
+
* <code>
50
+
* JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);<br/>
51
+
* Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator));<br/>
52
+
* JSONAssert.assertEquals("{a:[{type:row}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
53
+
* </code>
54
+
*
55
+
* <p>To verify that the 'background' attribute of every element of array 'a' alternates between 'white' and 'grey' starting with first element 'background' being 'white':</p>
56
+
*
57
+
* <code>
58
+
* JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);<br/>
59
+
* Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator));<br/>
60
+
* JSONAssert.assertEquals("{a:[{background:white},{background:grey}]}", ARRAY_OF_JSONOBJECTS, new CustomComparator(JSONCompareMode.LENIENT, customization));
61
+
* </code>
62
+
*
63
+
* <p>Assuming JSON to be verified is held in String variable ARRAY_OF_JSONARRAYS and contains:</p>
* <p>To verify that the first three elements of JSON array 'a' are JSON arrays of length 3:</p>
70
+
*
71
+
* <code>
72
+
* JSONComparator comparator = new ArraySizeComparator(JSONCompareMode.STRICT_ORDER);<br/>
73
+
* Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator, 0, 2));<br/>
74
+
* JSONAssert.assertEquals("{a:[[3]]}", ARRAY_OF_JSONARRAYS, new CustomComparator(JSONCompareMode.LENIENT, customization));
75
+
* </code>
76
+
*
77
+
* <p>NOTE: simplified expected JSON strings are not possible in this case as ArraySizeComparator does not support them.</p>
78
+
*
79
+
* <p>To verify that the second elements of JSON array 'a' is a JSON array whose first element has the value 9:</p>
80
+
*
81
+
* <code>
82
+
* Customization innerCustomization = new Customization("a[1]", new ArrayValueMatcher<Object>(comparator, 0));<br/>
83
+
* JSONComparator comparator = new CustomComparator(JSONCompareMode.LENIENT, innerCustomization);<br/>
84
+
* Customization customization = new Customization("a", new ArrayValueMatcher<Object>(comparator, 1));<br/>
85
+
* JSONAssert.assertEquals("{a:[[9]]}", ARRAY_OF_JSONARRAYS, new CustomComparator(JSONCompareMode.LENIENT, customization));
86
+
* </code>
87
+
*
88
+
* <p>To simplify complexity of expected JSON string, the value <code>"{a:[[9]]}"</code> may be replaced by <code>"{a:[9]}"</code> or <code>"{a:9}"</code></p>
20
89
*
21
90
* @author Duncan Mackinder
22
91
*
@@ -44,9 +113,11 @@ public ArrayValueMatcher(JSONComparator comparator) {
0 commit comments