@Test public void saveReplacesGenesWhenPolicyIsReplace() throws XWikiException { List<Gene> data = new LinkedList<>(); Gene gene = new PhenoTipsGene("GENE1", null, null, null, "Notes1"); Gene gene2 = new PhenoTipsGene("GENE2", null, null, null, null); data.add(gene); data.add(gene2); when(this.patient.<Gene>getData(CONTROLLER_NAME)) .thenReturn(new IndexedPatientData<>(CONTROLLER_NAME, data)); when(this.context.getWiki()).thenReturn(mock(XWiki.class)); BaseObject o1 = mock(BaseObject.class); BaseObject o2 = mock(BaseObject.class); when(this.doc.newXObject(Gene.GENE_CLASS, this.context)).thenReturn(o1, o2); this.component.save(this.patient, PatientWritePolicy.REPLACE); verify(this.doc).removeXObjects(Gene.GENE_CLASS); verify(o1).set(GENE_KEY, "GENE1", this.context); verify(o1).set(COMMENTS_KEY, "Notes1", this.context); verify(o2).set(GENE_KEY, "GENE2", this.context); verify(o2, never()).set(eq(COMMENTS_KEY), anyString(), eq(this.context)); }
@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);  }