@Test public void saveAddsAllDatesWhenPolicyIsUpdate() { Map<String, PhenoTipsDate> datesMap = new LinkedHashMap<>(); PhenoTipsDate birthDate = new PhenoTipsDate("1990s-11-12"); PhenoTipsDate deathDate = new PhenoTipsDate(new Date(999999999)); PhenoTipsDate examDate = new PhenoTipsDate(new JSONObject("{'year': 1990, 'range': {'years': 10}}")); datesMap.put(DatesController.PATIENT_DATEOFBIRTH_FIELDNAME, birthDate); datesMap.put(DatesController.PATIENT_DATEOFDEATH_FIELDNAME, deathDate); datesMap.put(DatesController.PATIENT_EXAMDATE_FIELDNAME, examDate); PatientData<PhenoTipsDate> datesData = new DictionaryPatientData<>(DATA_NAME, datesMap); doReturn(datesData).when(this.patient).getData(DATA_NAME); this.component.save(this.patient); String deathAsEnteredField = DatesController.CORRESPONDING_ASENTERED_FIELDNAMES.get(DatesController.PATIENT_DATEOFDEATH_FIELDNAME); verify(this.data).setStringValue(deathAsEnteredField, deathDate.toString()); verify(this.data).setDateValue(DatesController.PATIENT_DATEOFDEATH_FIELDNAME, deathDate.toEarliestPossibleISODate()); String birthAsEnteredField = DatesController.CORRESPONDING_ASENTERED_FIELDNAMES.get(DatesController.PATIENT_DATEOFBIRTH_FIELDNAME); verify(this.data).setStringValue(birthAsEnteredField, birthDate.toString()); verify(this.data).setDateValue(DatesController.PATIENT_DATEOFBIRTH_FIELDNAME, birthDate.toEarliestPossibleISODate()); verify(this.data).setDateValue(DatesController.PATIENT_EXAMDATE_FIELDNAME, examDate.toEarliestPossibleISODate()); verifyNoMoreInteractions(this.data); }
@Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); } }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @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 save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @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();  }