@Test public void loadWorks() throws Exception { when(this.dataHolder.getStringValue(SolvedData.STATUS_PROPERTY_NAME)).thenReturn("1"); when(this.dataHolder.getStringValue(SolvedData.NOTES_PROPERTY_NAME)).thenReturn("n1"); when(this.dataHolder.getListValue(SolvedData.PUBMED_ID_PROPERTY_NAME)).thenReturn(Arrays.asList("123", "abc")); PatientData<SolvedData> result = this.component.load(this.patient); Assert.assertNotNull(result); Assert.assertEquals(1, result.size()); Assert.assertEquals("1", result.getValue().getStatus()); Assert.assertEquals("n1", result.getValue().getNotes()); Assert.assertTrue( CollectionUtils.isEqualCollection(Arrays.asList("123", "abc"), result.getValue().getPubmedIds())); }
@Override public PatientData<SolvedData> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String status = data.getStringValue(SolvedData.STATUS_PROPERTY_NAME); String notes = data.getStringValue(SolvedData.NOTES_PROPERTY_NAME); @SuppressWarnings("unchecked") List<String> patientPubmedIds = data.getListValue(SolvedData.PUBMED_ID_PROPERTY_NAME); SolvedData result = new SolvedData(status, notes, patientPubmedIds); return new SimpleValuePatientData<>(this.getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
SolvedController implements PatientDataController<SolvedData> { @Override public PatientData<SolvedData> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String status = data.getStringValue(SolvedData.STATUS_PROPERTY_NAME); String notes = data.getStringValue(SolvedData.NOTES_PROPERTY_NAME); @SuppressWarnings("unchecked") List<String> patientPubmedIds = data.getListValue(SolvedData.PUBMED_ID_PROPERTY_NAME); SolvedData result = new SolvedData(status, notes, patientPubmedIds); return new SimpleValuePatientData<>(this.getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
SolvedController implements PatientDataController<SolvedData> { @Override public PatientData<SolvedData> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String status = data.getStringValue(SolvedData.STATUS_PROPERTY_NAME); String notes = data.getStringValue(SolvedData.NOTES_PROPERTY_NAME); @SuppressWarnings("unchecked") List<String> patientPubmedIds = data.getListValue(SolvedData.PUBMED_ID_PROPERTY_NAME); SolvedData result = new SolvedData(status, notes, patientPubmedIds); return new SimpleValuePatientData<>(this.getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
SolvedController implements PatientDataController<SolvedData> { @Override public PatientData<SolvedData> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String status = data.getStringValue(SolvedData.STATUS_PROPERTY_NAME); String notes = data.getStringValue(SolvedData.NOTES_PROPERTY_NAME); @SuppressWarnings("unchecked") List<String> patientPubmedIds = data.getListValue(SolvedData.PUBMED_ID_PROPERTY_NAME); SolvedData result = new SolvedData(status, notes, patientPubmedIds); return new SimpleValuePatientData<>(this.getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override String getName(); @Override PatientData<SolvedData> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<SolvedData> readJSON(JSONObject json); }
SolvedController implements PatientDataController<SolvedData> { @Override public PatientData<SolvedData> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String status = data.getStringValue(SolvedData.STATUS_PROPERTY_NAME); String notes = data.getStringValue(SolvedData.NOTES_PROPERTY_NAME); @SuppressWarnings("unchecked") List<String> patientPubmedIds = data.getListValue(SolvedData.PUBMED_ID_PROPERTY_NAME); SolvedData result = new SolvedData(status, notes, patientPubmedIds); return new SimpleValuePatientData<>(this.getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override String getName(); @Override PatientData<SolvedData> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<SolvedData> readJSON(JSONObject json);  }