@Test public void structUnexpectedItemsInArray() throws JSONException { final JSONObject object1 = (JSONObject) JSONParser.parseJSON("{ \"a\": [ 1 ] }"); final JSONObject object2 = (JSONObject) JSONParser.parseJSON("{ \"a\": [ 1,2 ] }"); final JSONCompareResult results = JSONCompare.compareJSON(object1, object2, new RegularExpressionJSONComparator(JSONCompareMode.STRICT)); Assert.assertTrue(results.failed()); Assert.assertEquals(0, results.getFieldMissing().size()); Assert.assertEquals(1, results.getFieldUnexpected().size()); }
@Test public void structMissingItemsInArray() throws JSONException { final JSONObject object1 = (JSONObject) JSONParser.parseJSON("{ \"a\": [ 1, 2 ] }"); final JSONObject object2 = (JSONObject) JSONParser.parseJSON("{ \"a\": [ 1 ] }"); final JSONCompareResult results = JSONCompare.compareJSON(object1, object2, new RegularExpressionJSONComparator(JSONCompareMode.STRICT)); Assert.assertTrue(results.failed()); Assert.assertEquals(1, results.getFieldMissing().size()); Assert.assertEquals(0, results.getFieldUnexpected().size()); }