@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 variantObject = mock(BaseObject.class); when(this.doc.getXObjects(VariantListController.VARIANT_CLASS_REFERENCE)) .thenReturn(Collections.singletonList(variantObject)); final BaseStringProperty variantProperty = mock(BaseStringProperty.class); final BaseStringProperty geneProperty = mock(BaseStringProperty.class); when(variantObject.getFieldList()).thenReturn(Arrays.asList(GENE_KEY, VARIANT_KEY)); when(variantObject.getField(GENE_KEY)).thenReturn(geneProperty); when(variantObject.getField(VARIANT_KEY)).thenReturn(variantProperty); when(variantProperty.getValue()).thenReturn(VARIANT_KEY); when(geneProperty.getValue()).thenReturn(GENE_KEY); final BaseObject xwikiObject = mock(BaseObject.class); when(this.doc.newXObject(VariantListController.VARIANT_CLASS_REFERENCE, this.context)).thenReturn(xwikiObject); this.component.save(this.patient, PatientWritePolicy.MERGE); verify(this.doc, times(1)).removeXObjects(VariantListController.VARIANT_CLASS_REFERENCE); verify(this.doc, times(1)).newXObject(VariantListController.VARIANT_CLASS_REFERENCE, this.context); verify(this.doc, times(1)).getXObjects(VariantListController.VARIANT_CLASS_REFERENCE); verify(xwikiObject, times(1)).set(GENE_KEY, GENE_KEY, this.context); verify(xwikiObject, times(1)).set(VARIANT_KEY, VARIANT_KEY, this.context); verify(xwikiObject, times(1)).setIntValue(START_POSITION_KEY, 0); verify(xwikiObject, times(1)).setIntValue(END_POSITION_KEY, 0); verifyNoMoreInteractions(this.doc); verifyNoMoreInteractions(xwikiObject); }
@Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }
VariantListController extends AbstractComplexController<Map<String, String>> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); } }
VariantListController extends AbstractComplexController<Map<String, String>> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  }
VariantListController extends AbstractComplexController<Map<String, String>> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override String getName(); @Override PatientData<Map<String, String>> load(Patient patient); @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Map<String, String>> readJSON(JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); }
VariantListController extends AbstractComplexController<Map<String, String>> { @Override public void save(Patient patient) { save(patient, PatientWritePolicy.UPDATE); }  @Override String getName(); @Override PatientData<Map<String, String>> load(Patient patient); @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Map<String, String>> readJSON(JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy);  }