InfoWindowConfig implements Config { @Override public JSONObject toJsonObject() throws JSONException { JSONObject config = new JSONObject(); config.put(KEY_VISIBLE_PROPERTIES, visibleProperties); return config; } InfoWindowConfig();  InfoWindowConfig(JSONObject config); JSONArray getVisibleProperties(); void setVisibleProperties(@NonNull JSONArray visibleProperties); void addVisibleProperty(@NonNull String id, @NonNull String label); @Override boolean isValid(); @Override JSONObject toJsonObject(); static final String KEY_VISIBLE_PROPERTIES; static final String KEY_VP_ID; static final String KEY_VP_LABEL; }
@Test public void toJsonObject() throws JSONException, InvalidMapBoxStyleException { int size = 4; JSONArray array1 = new JSONArray(); for (int i = 0; i < size; i++) { JSONObject visProperties = new JSONObject(); visProperties.put(InfoWindowConfig.KEY_VP_LABEL, "label" + String.valueOf(i)); visProperties.put(InfoWindowConfig.KEY_VP_ID, "id" + String.valueOf(i)); array1.put(visProperties); } JSONObject object1 = new JSONObject(); object1.put(InfoWindowConfig.KEY_VISIBLE_PROPERTIES, array1); InfoWindowConfig config1 = new InfoWindowConfig(object1); Assert.assertEquals(config1.toJsonObject().getJSONArray( InfoWindowConfig.KEY_VISIBLE_PROPERTIES).length(), size); for (int i = 0; i < size; i++) { Assert.assertEquals(config1.toJsonObject().getJSONArray( InfoWindowConfig.KEY_VISIBLE_PROPERTIES).getJSONObject(i) .getString(InfoWindowConfig.KEY_VP_ID), "id" + String.valueOf(i)); Assert.assertEquals(config1.toJsonObject().getJSONArray( InfoWindowConfig.KEY_VISIBLE_PROPERTIES).getJSONObject(i) .getString(InfoWindowConfig.KEY_VP_LABEL), "label" + String.valueOf(i)); } Assert.assertNotSame(config1.toJsonObject(), object1); }