@Test public void writeJSONSkipsEmptyFields() { Map<String, PhenoTipsDate> datesMap = new LinkedHashMap<>(); PhenoTipsDate birthDate = new PhenoTipsDate("1990s-11-12"); PhenoTipsDate examDate = new PhenoTipsDate("1980-11"); datesMap.put(DatesController.PATIENT_DATEOFBIRTH_FIELDNAME, birthDate); datesMap.put(DatesController.PATIENT_EXAMDATE_FIELDNAME, examDate); PatientData<PhenoTipsDate> datesData = new DictionaryPatientData<>(DATA_NAME, datesMap); doReturn(datesData).when(this.patient).getData(DATA_NAME); JSONObject json = new JSONObject(); this.component.writeJSON(this.patient, json); Assert.assertEquals(false, json.has(DatesController.PATIENT_DATEOFDEATH_FIELDNAME)); Assert.assertEquals(birthDate.toJSON().toString(), json.getJSONObject(DatesController.PATIENT_DATEOFBIRTH_FIELDNAME).toString()); Assert.assertEquals(examDate.toJSON().toString(), json.getJSONObject(DatesController.PATIENT_EXAMDATE_FIELDNAME).toString()); }
@Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); } }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); }  }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); }  @Override PatientData<PhenoTipsDate> 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<PhenoTipsDate> readJSON(JSONObject json); @Override String getName(); }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public void writeJSON(Patient patient, JSONObject json) { writeJSON(patient, json, null); }  @Override PatientData<PhenoTipsDate> 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<PhenoTipsDate> readJSON(JSONObject json); @Override String getName();  }