@Test public void saveKeepsRecordsFieldAsIsWhenEmptyDataPresentAndPolicyIsMerge() throws ComponentLookupException, XWikiException, IOException { when(this.patient.getData(CONTROLLER_NAME)) .thenReturn(new IndexedPatientData<>(CONTROLLER_NAME, Collections.emptyList())); when(this.doc.getXObjects(AdditionalDocumentsController.CLASS_REFERENCE)) .thenReturn(Collections.singletonList(this.file1)); this.mocker.getComponentUnderTest().save(this.patient, PatientWritePolicy.MERGE); verify(this.doc).removeXObjects(AdditionalDocumentsController.CLASS_REFERENCE); verify(this.doc, times(1)).newXObject(any(EntityReference.class), any(XWikiContext.class)); verify(this.doc, times(2)).getAttachment(anyString()); verify(this.doc, times(2)).getAttachment("a1.pdf"); verify(this.doc, never()).addAttachment(any(XWikiAttachment.class)); verify(this.xattachment1, times(1)).setContent(any(InputStream.class)); }
@Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); }
AdditionalDocumentsController implements PatientDataController<Attachment> { @Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); } }
AdditionalDocumentsController implements PatientDataController<Attachment> { @Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  }
AdditionalDocumentsController implements PatientDataController<Attachment> { @Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override PatientData<Attachment> load(Patient patient); @Override void save(@Nonnull final 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<Attachment> readJSON(JSONObject json); @Override String getName(); }
AdditionalDocumentsController implements PatientDataController<Attachment> { @Override public void save(@Nonnull final Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override PatientData<Attachment> load(Patient patient); @Override void save(@Nonnull final 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<Attachment> readJSON(JSONObject json); @Override String getName(); static final EntityReference CLASS_REFERENCE; }