@Test public void writeJSONWithSelectedFieldsReturnsWhenGetDataReturnsNull() throws ComponentLookupException { doReturn(null).when(this.patient).getData(DATA_NAME); JSONObject json = new JSONObject(); Collection<String> selectedFields = new LinkedList<>(); this.mocker.getComponentUnderTest().writeJSON(this.patient, json, selectedFields); Assert.assertEquals(0, json.length()); }
@Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { PatientData<String> patientData = patient.<String>getData(getName()); if (patientData != null && patientData.isNamed()) { Iterator<Entry<String, String>> values = patientData.dictionaryIterator(); while (values.hasNext()) { Entry<String, String> datum = values.next(); if (StringUtils.isNotBlank(datum.getValue()) && (selectedFieldNames == null || selectedFieldNames.contains(datum.getKey()))) { json.put(getJSONkey(datum.getKey()), datum.getValue()); } } } }
MetaDataController extends AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { PatientData<String> patientData = patient.<String>getData(getName()); if (patientData != null && patientData.isNamed()) { Iterator<Entry<String, String>> values = patientData.dictionaryIterator(); while (values.hasNext()) { Entry<String, String> datum = values.next(); if (StringUtils.isNotBlank(datum.getValue()) && (selectedFieldNames == null || selectedFieldNames.contains(datum.getKey()))) { json.put(getJSONkey(datum.getKey()), datum.getValue()); } } } } }
MetaDataController extends AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { PatientData<String> patientData = patient.<String>getData(getName()); if (patientData != null && patientData.isNamed()) { Iterator<Entry<String, String>> values = patientData.dictionaryIterator(); while (values.hasNext()) { Entry<String, String> datum = values.next(); if (StringUtils.isNotBlank(datum.getValue()) && (selectedFieldNames == null || selectedFieldNames.contains(datum.getKey()))) { json.put(getJSONkey(datum.getKey()), datum.getValue()); } } } }  }
MetaDataController extends AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { PatientData<String> patientData = patient.<String>getData(getName()); if (patientData != null && patientData.isNamed()) { Iterator<Entry<String, String>> values = patientData.dictionaryIterator(); while (values.hasNext()) { Entry<String, String> datum = values.next(); if (StringUtils.isNotBlank(datum.getValue()) && (selectedFieldNames == null || selectedFieldNames.contains(datum.getKey()))) { json.put(getJSONkey(datum.getKey()), datum.getValue()); } } } }  @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override String getName(); }
MetaDataController extends AbstractSimpleController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { PatientData<String> patientData = patient.<String>getData(getName()); if (patientData != null && patientData.isNamed()) { Iterator<Entry<String, String>> values = patientData.dictionaryIterator(); while (values.hasNext()) { Entry<String, String> datum = values.next(); if (StringUtils.isNotBlank(datum.getValue()) && (selectedFieldNames == null || selectedFieldNames.contains(datum.getKey()))) { json.put(getJSONkey(datum.getKey()), datum.getValue()); } } } }  @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override String getName();  }