CollectionPresenter implements CollectionView.Presenter { protected void populateMap(JSONValue jsonValue) { final JSONObject jsValueObject = jsonValue.isObject(); jsValueObject.keySet().forEach(key -> { Map<String, String> keyPropertiesValues = new HashMap<>(); Map<String, String> valuePropertiesValues = new HashMap<>(); final JSONObject jsonObjectKey = getJSONObject(key); if (jsonObjectKey == null) { keyPropertiesValues.put(VALUE, key); } else { jsonObjectKey.keySet().forEach(propertyName -> keyPropertiesValues.put(propertyName, jsonObjectKey.get(propertyName).isString().stringValue())); } JSONObject jsonObjectValue = jsValueObject.get(key).isObject(); if (jsonObjectValue != null) { jsonObjectValue.keySet().forEach(propertyName -> valuePropertiesValues.put(propertyName, jsonObjectValue.get(propertyName).isString().stringValue())); } else { valuePropertiesValues.put(VALUE, jsValueObject.get(key).toString()); } addMapItem(keyPropertiesValues, valuePropertiesValues); }); }  @Override void initListStructure(String key, Map<String, String> simplePropertiesMap, Map<String, Map<String, String>> expandablePropertiesMap, CollectionView collectionView); @Override void initMapStructure(String key, Map<String, String> keyPropertyMap, Map<String, String> valuePropertyMap, CollectionView collectionView); @Override void setValue(String jsonString); @Override void showEditingBox(); @Override void onToggleRowExpansion(boolean isShown); @Override void updateRowExpansionStatus(boolean isShown); @Override void addListItem(Map<String, String> simplePropertiesValues, Map<String, Map<String, String>> expandablePropertiesValues); @Override void addMapItem(Map<String, String> keyPropertiesValues, Map<String, String> valuePropertiesValues); @Override void save(); @Override void remove(); @Override void toggleEditingStatus(boolean editingStatus);  }
@Test public void populateMap() { collectionEditorPresenterSpy.populateMap(jsonValueMock); verify(collectionEditorPresenterSpy, times(JSON_ARRAY_SIZE)).addMapItem(anyMap(), anyMap()); }