@Test public void writeJSONWithSelectedFieldsAddsSelectedValues() throws ComponentLookupException { Map<String, String> map = new LinkedHashMap<>(); map.put(PROPERTY_1, "datum1"); map.put(PROPERTY_2, "datum2"); map.put(PROPERTY_3, "datum3"); PatientData<String> patientData = new DictionaryPatientData<>(DATA_NAME, map); doReturn(patientData).when(this.patient).getData(DATA_NAME); JSONObject json = new JSONObject(); Collection<String> selectedFields = new LinkedList<>(); selectedFields.add(PROPERTY_1); selectedFields.add(PROPERTY_3); this.component.writeJSON(this.patient, json, selectedFields); Assert.assertNotNull(json.get(DATA_NAME)); Assert.assertTrue(json.get(DATA_NAME) instanceof JSONObject); JSONObject container = json.getJSONObject(DATA_NAME); Assert.assertEquals("datum1", container.get(PROPERTY_1)); Assert.assertEquals("datum3", container.get(PROPERTY_3)); Assert.assertFalse(container.has(PROPERTY_2)); }
@Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); }
AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); } }
AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); }  }
AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); }  @Override PatientData<String> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<String> readJSON(JSONObject json); }
AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); }  @Override PatientData<String> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<String> readJSON(JSONObject json);  }