@Test public void saveWithMergePolicyMergesDataForSpecifiedCodeFieldProperties() { final BaseProperty pi1 = mock(BaseProperty.class); final BaseProperty pi2 = mock(BaseProperty.class); when(this.data.getField(PROPERTY_1)).thenReturn(pi1); when(this.data.getField(PROPERTY_2)).thenReturn(pi2); when(pi1.getValue()).thenReturn(Arrays.asList(ID_3, ID_4)); when(pi2.getValue()).thenReturn(Collections.singletonList(ID_5)); final Map<String, List<VocabularyProperty>> dataMap = new LinkedHashMap<>(); dataMap.put(PROPERTY_1, Collections.emptyList()); dataMap.put(PROPERTY_2, Arrays.asList(this.vocabProperty1, this.vocabProperty2)); doReturn(new DictionaryPatientData<>(CODE_FIELDS_DATA_NAME, dataMap)).when(this.patient) .getData(CODE_FIELDS_DATA_NAME); this.codeFieldImplComponent.save(this.patient, PatientWritePolicy.MERGE); verify(this.doc, times(1)).getXObject(Patient.CLASS_REFERENCE, true, this.xcontext); verify(this.doc, times(1)).getXObject(Patient.CLASS_REFERENCE); verifyNoMoreInteractions(this.doc); verify(this.data, times(1)).set(PROPERTY_1, Arrays.asList(ID_3, ID_4), this.xcontext); verify(this.data, times(1)).set(PROPERTY_2, Arrays.asList(ID_5, ID_1, ID_2), this.xcontext); verify(this.data, times(2)).getField(anyString()); verifyNoMoreInteractions(this.data); }
@Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }
AbstractComplexController implements PatientDataController<T> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); } }
AbstractComplexController implements PatientDataController<T> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  }
AbstractComplexController implements PatientDataController<T> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override @SuppressWarnings("unchecked") PatientData<T> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override void writeJSON(Patient patient, JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override PatientData<T> readJSON(JSONObject json); }
AbstractComplexController implements PatientDataController<T> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override @SuppressWarnings("unchecked") PatientData<T> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override void writeJSON(Patient patient, JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override PatientData<T> readJSON(JSONObject json);  }