@Test public void saveMergesIdentifiersWhenPolicyIsMerge() throws ComponentLookupException, XWikiException { this.identifiersXWikiObjects.add(this.eidObj2); final List<Pair<String, String>> data = new LinkedList<>(); data.add(Pair.of(OBJ_1_LABEL, OBJ_1_VALUE)); when(this.patient.<Pair<String, String>>getData(CONTROLLER_NAME)) .thenReturn(new IndexedPatientData<>(CONTROLLER_NAME, data)); when(this.doc.newXObject(LabeledExternalIdentifiersController.IDENTIFIER_CLASS_REFERENCE, this.context)) .thenReturn(this.eidObj2, this.eidObj1); this.component.save(this.patient, PatientWritePolicy.MERGE); verify(this.doc, times(1)).getXObjects(LabeledExternalIdentifiersController.IDENTIFIER_CLASS_REFERENCE); verify(this.doc, times(2)).newXObject(LabeledExternalIdentifiersController.IDENTIFIER_CLASS_REFERENCE, this.context); verify(this.doc, times(1)).removeXObjects(LabeledExternalIdentifiersController.IDENTIFIER_CLASS_REFERENCE); verify(this.eidObj1, times(2)).set(anyString(), anyString(), any(XWikiContext.class)); verify(this.eidObj1, times(1)).set(LABEL_KEY, OBJ_1_LABEL, this.context); verify(this.eidObj1, times(1)).set(VALUE_KEY, OBJ_1_VALUE, this.context); verify(this.eidObj2, times(2)).set(anyString(), anyString(), any(XWikiContext.class)); verify(this.eidObj2, times(1)).set(LABEL_KEY, OBJ_2_LABEL, this.context); verify(this.eidObj2, times(1)).set(VALUE_KEY, OBJ_2_VALUE, this.context); Mockito.verifyNoMoreInteractions(this.doc); }
@Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); }
LabeledExternalIdentifiersController implements PatientDataController<Pair<String, String>> { @Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); } }
LabeledExternalIdentifiersController implements PatientDataController<Pair<String, String>> { @Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  }
LabeledExternalIdentifiersController implements PatientDataController<Pair<String, String>> { @Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override String getName(); @Override PatientData<Pair<String, String>> load(final Patient patient); @Override void writeJSON(@Nonnull final Patient patient, @Nonnull final JSONObject json,
        @Nullable final Collection<String> selectedFieldNames); @Override void writeJSON(@Nonnull final Patient patient, @Nonnull final JSONObject json); @Override PatientData<Pair<String, String>> readJSON(@Nullable final JSONObject json); @Override void save(@Nonnull final Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); }
LabeledExternalIdentifiersController implements PatientDataController<Pair<String, String>> { @Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override String getName(); @Override PatientData<Pair<String, String>> load(final Patient patient); @Override void writeJSON(@Nonnull final Patient patient, @Nonnull final JSONObject json,
        @Nullable final Collection<String> selectedFieldNames); @Override void writeJSON(@Nonnull final Patient patient, @Nonnull final JSONObject json); @Override PatientData<Pair<String, String>> readJSON(@Nullable final JSONObject json); @Override void save(@Nonnull final Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy);  }