@Test public void saveWithEmptyDataMergesWithStoredDataWhenPolicyIsMerge() throws XWikiException { when(this.patient.getData(CONTROLLER_NAME)) .thenReturn(new IndexedPatientData<>(CONTROLLER_NAME, Collections.emptyList())); when(this.context.getWiki()).thenReturn(mock(XWiki.class)); final BaseObject geneObject = mock(BaseObject.class); when(this.doc.getXObjects(Gene.GENE_CLASS)) .thenReturn(Collections.singletonList(geneObject)); final BaseStringProperty geneProperty = mock(BaseStringProperty.class); final BaseStringProperty statusProperty = mock(BaseStringProperty.class); when(geneObject.getFieldList()).thenReturn(Arrays.asList(GENE_KEY, STATUS_KEY)); when(geneObject.getField(GENE_KEY)).thenReturn(geneProperty); when(geneObject.getField(STATUS_KEY)).thenReturn(statusProperty); when(geneObject.getField(STRATEGY_KEY)).thenReturn(null); when(geneObject.getField(COMMENTS_KEY)).thenReturn(null); when(geneProperty.getValue()).thenReturn(GENE_VALUE); when(statusProperty.getValue()).thenReturn(JSON_OLD_SOLVED_GENE_KEY); final BaseObject xwikiObject = mock(BaseObject.class); when(this.doc.newXObject(Gene.GENE_CLASS, this.context)).thenReturn(xwikiObject); this.component.save(this.patient, PatientWritePolicy.MERGE); verify(this.doc, times(1)).newXObject(Gene.GENE_CLASS, this.context); verify(this.doc, times(1)).removeXObjects(Gene.GENE_CLASS); verify(this.doc, times(1)).getXObjects(Gene.GENE_CLASS); verify(xwikiObject, times(1)).set(GENE_KEY, GENE_VALUE, this.context); verify(xwikiObject, times(1)).set(STATUS_KEY, JSON_OLD_SOLVED_GENE_KEY, this.context); verify(xwikiObject, times(1)).set(eq(STRATEGY_KEY), eq(Collections.emptyList()), eq(this.context)); verify(xwikiObject, never()).set(eq(COMMENTS_KEY), any(), eq(this.context)); verifyNoMoreInteractions(this.doc); verifyNoMoreInteractions(xwikiObject); }
@Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }
GeneListController implements PatientDataController<Gene> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); } }
GeneListController implements PatientDataController<Gene> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  }
GeneListController implements PatientDataController<Gene> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override String getName(); @Override PatientData<Gene> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Gene> readJSON(JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json); }
GeneListController implements PatientDataController<Gene> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override String getName(); @Override PatientData<Gene> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Gene> readJSON(JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json);  }