|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.skyscreamer.jsonassert.comparator.AbstractComparator
org.skyscreamer.jsonassert.comparator.DefaultComparator
org.skyscreamer.jsonassert.comparator.ArraySizeComparator
public class ArraySizeComparator
A JSONAssert array size comparator.
Some typical usage idioms are listed below.
Assuming JSON to be verified is held in String variable ARRAY_OF_JSONOBJECTS and contains:
{a:[7, 8, 9]}
then:
To verify that array 'a' contains 3 elements:
JSONAssert.assertEquals("{a:[3]}", ARRAY_OF_JSONOBJECTS, new ArraySizeComparator(JSONCompareMode.LENIENT));
To verify that array 'a' contains between 2 and 6 elements:
JSONAssert.assertEquals("{a:[2,6]}", ARRAY_OF_JSONOBJECTS, new ArraySizeComparator(JSONCompareMode.LENIENT));
| Constructor Summary | |
|---|---|
ArraySizeComparator(JSONCompareMode mode)
Create new ArraySizeComparator. |
|
| Method Summary | |
|---|---|
void |
compareJSONArray(String prefix,
org.json.JSONArray expected,
org.json.JSONArray actual,
JSONCompareResult result)
Expected array should consist of either 1 or 2 integer values that define maximum and minimum valid lengths of the actual array. |
| Methods inherited from class org.skyscreamer.jsonassert.comparator.DefaultComparator |
|---|
compareJSON, compareValues |
| Methods inherited from class org.skyscreamer.jsonassert.comparator.AbstractComparator |
|---|
checkJsonObjectKeysActualInExpected, checkJsonObjectKeysExpectedInActual, compareJSON, compareJSON, compareJSONArrayOfJsonObjects, compareJSONArrayOfSimpleValues, compareJSONArrayWithStrictOrder, recursivelyCompareJSONArray |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArraySizeComparator(JSONCompareMode mode)
mode - comparison mode, has no impact on ArraySizeComparator but is
used by instance of superclass DefaultComparator to control
comparison of JSON items other than arrays.| Method Detail |
|---|
public void compareJSONArray(String prefix,
org.json.JSONArray expected,
org.json.JSONArray actual,
JSONCompareResult result)
throws org.json.JSONException
compareJSONArray in interface JSONComparatorcompareJSONArray in class DefaultComparatororg.json.JSONException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||