@Test public void writeJSONAddsVersionInformationWhenSelectedFieldsIsNull() throws ComponentLookupException { Map<String, String> map = new LinkedHashMap<>(); map.put("first_version", "1.0"); map.put("second_version", "2.0"); PatientData<String> patientData = new DictionaryPatientData<>(DATA_NAME, map); doReturn(patientData).when(this.patient).getData(DATA_NAME); JSONObject json = new JSONObject(); this.mocker.getComponentUnderTest().writeJSON(this.patient, json, null); Assert.assertTrue(json.get("meta") instanceof JSONObject); JSONObject container = json.getJSONObject("meta"); Assert.assertEquals("1.0", container.get("first_version")); Assert.assertEquals("2.0", container.get("second_version")); }
@Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames == null || selectedFieldNames.contains(getEnablingFieldName())) { super.writeJSON(patient, json, null); } }
VersionsController extends AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames == null || selectedFieldNames.contains(getEnablingFieldName())) { super.writeJSON(patient, json, null); } } }
VersionsController extends AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames == null || selectedFieldNames.contains(getEnablingFieldName())) { super.writeJSON(patient, json, null); } }  }
VersionsController extends AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames == null || selectedFieldNames.contains(getEnablingFieldName())) { super.writeJSON(patient, json, null); } }  @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override String getName(); static String getEnablingFieldName(); }
VersionsController extends AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames == null || selectedFieldNames.contains(getEnablingFieldName())) { super.writeJSON(patient, json, null); } }  @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override String getName(); static String getEnablingFieldName();  }