CompositeJSONProvider implements JSONProvider { @Override public JSONObject get() throws JSONException { JSONObject mergedJsonObject = new JSONObject(); for (JSONProvider jsonProvider : jsonProviderList) { JSONObject jsonObject = jsonProvider.get(); mergeInto(mergedJsonObject, jsonObject); } return mergedJsonObject; } CompositeJSONProvider(List<JSONProvider> jsonProviderList);  CompositeJSONProvider(JSONProvider... jsonProviders); @Override JSONObject get();  }
@Test public void testOrder2() throws Exception { JSONObject jsonObject = compositeJSONProvider2.get(); Assert.assertEquals(jsonObject.get("key1"), "value1"); Assert.assertEquals(jsonObject.getJSONObject("key2").get("key3"), "value3"); Assert.assertEquals(jsonObject.get("key3"), "value3"); Assert.assertEquals(jsonObject.getJSONObject("key4").get("key5"), "value5"); Assert.assertEquals(jsonObject.getJSONObject("key4").get("key6"), "value6"); Assert.assertEquals(jsonObject.getJSONObject("key4").get("key7"), "value7a"); }
@Test public void testOrder1() throws Exception { JSONObject jsonObject = compositeJSONProvider1.get(); Assert.assertEquals(jsonObject.get("key1"), "value1"); Assert.assertEquals(jsonObject.get("key2"), "value2"); Assert.assertEquals(jsonObject.get("key3"), "value3"); Assert.assertEquals(jsonObject.getJSONObject("key4").get("key5"), "value5"); Assert.assertEquals(jsonObject.getJSONObject("key4").get("key6"), "value6"); Assert.assertEquals(jsonObject.getJSONObject("key4").get("key7"), "value7b"); }