@Test public void writeJSONReturnsWhenGetDataReturnsNull() { doReturn(null).when(this.patient).getData(DATA_NAME); JSONObject json = new JSONObject(); this.component.writeJSON(this.patient, json); Assert.assertFalse(json.has(DATA_NAME)); }
@Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames != null && !selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { return; } PatientData<String> data = patient.getData(getName()); if (data == null) { if (selectedFieldNames != null && selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { json.put(getName(), VALUE_AFFECTED); } return; } json.put(JSON_FIELDNAME, data.getValue()); }
ClinicalStatusController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames != null && !selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { return; } PatientData<String> data = patient.getData(getName()); if (data == null) { if (selectedFieldNames != null && selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { json.put(getName(), VALUE_AFFECTED); } return; } json.put(JSON_FIELDNAME, data.getValue()); } }
ClinicalStatusController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames != null && !selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { return; } PatientData<String> data = patient.getData(getName()); if (data == null) { if (selectedFieldNames != null && selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { json.put(getName(), VALUE_AFFECTED); } return; } json.put(JSON_FIELDNAME, data.getValue()); }  }
ClinicalStatusController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames != null && !selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { return; } PatientData<String> data = patient.getData(getName()); if (data == null) { if (selectedFieldNames != null && selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { json.put(getName(), VALUE_AFFECTED); } return; } json.put(JSON_FIELDNAME, data.getValue()); }  @Override String getName(); @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override void writeJSON(Patient patient, JSONObject json); @SuppressWarnings("unchecked") @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override PatientData<String> readJSON(JSONObject json); }
ClinicalStatusController implements PatientDataController<String> { @Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames != null && !selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { return; } PatientData<String> data = patient.getData(getName()); if (data == null) { if (selectedFieldNames != null && selectedFieldNames.contains(CONTROLLING_FIELDNAME)) { json.put(getName(), VALUE_AFFECTED); } return; } json.put(JSON_FIELDNAME, data.getValue()); }  @Override String getName(); @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override void writeJSON(Patient patient, JSONObject json); @SuppressWarnings("unchecked") @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override PatientData<String> readJSON(JSONObject json);  }