@Test public void writeJSONWithSelectedFieldsConvertsSolvedStatus() { SolvedData data = new SolvedData("1", null, null); PatientData<SolvedData> patientData = new SimpleValuePatientData<>(DATA_NAME, data); doReturn(patientData).when(this.patient).getData(DATA_NAME); JSONObject json = new JSONObject(); Collection<String> selectedFields = new LinkedList<>(); selectedFields.add(STATUS_KEY); this.component.writeJSON(this.patient, json, selectedFields); Assert.assertEquals(STATUS_SOLVED, json.getJSONObject(DATA_NAME).get("status")); data.setStatus("0"); json = new JSONObject(); patientData = new SimpleValuePatientData<>(DATA_NAME, data); doReturn(patientData).when(this.patient).getData(DATA_NAME); this.component.writeJSON(this.patient, json, selectedFields); Assert.assertEquals(STATUS_UNSOLVED, json.getJSONObject(DATA_NAME).get("status")); json = new JSONObject(); data = new SolvedData(null, null, null); data.setStatus("solved"); patientData = new SimpleValuePatientData<>(DATA_NAME, data); doReturn(patientData).when(this.patient).getData(DATA_NAME); this.component.writeJSON(this.patient, json, selectedFields); Assert.assertFalse(json.has(DATA_NAME)); }
@SuppressWarnings("checkstyle:CyclomaticComplexity") @Override public void writeJSON(Patient patient, JSONObject json) { this.writeJSON(patient, json, null); }
SolvedController implements PatientDataController<SolvedData> { @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override public void writeJSON(Patient patient, JSONObject json) { this.writeJSON(patient, json, null); } }
SolvedController implements PatientDataController<SolvedData> { @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override public void writeJSON(Patient patient, JSONObject json) { this.writeJSON(patient, json, null); }  }
SolvedController implements PatientDataController<SolvedData> { @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override public void writeJSON(Patient patient, JSONObject json) { this.writeJSON(patient, json, null); }  @Override String getName(); @Override PatientData<SolvedData> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<SolvedData> readJSON(JSONObject json); }
SolvedController implements PatientDataController<SolvedData> { @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override public void writeJSON(Patient patient, JSONObject json) { this.writeJSON(patient, json, null); }  @Override String getName(); @Override PatientData<SolvedData> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<SolvedData> readJSON(JSONObject json);  }