@Test public void loadReturnsAllData() throws ComponentLookupException { String datum1 = "datum2"; String datum2 = "datum2"; String datum3 = "datum3"; doReturn(datum1).when(this.data).getStringValue(PROPERTY_1); doReturn(datum2).when(this.data).getStringValue(PROPERTY_2); doReturn(datum3).when(this.data).getStringValue(PROPERTY_3); PatientData<String> result = this.component.load(this.patient); Assert.assertEquals(datum1, result.get(PROPERTY_1)); Assert.assertEquals(datum2, result.get(PROPERTY_2)); Assert.assertEquals(datum3, result.get(PROPERTY_3)); Assert.assertEquals(3, result.size()); }
@Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getStorageXClass()); if (data == null) { return null; } Map<String, String> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { String value = data.getStringValue(propertyName); result.put(propertyName, value); } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getStorageXClass()); if (data == null) { return null; } Map<String, String> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { String value = data.getStringValue(propertyName); result.put(propertyName, value); } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getStorageXClass()); if (data == null) { return null; } Map<String, String> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { String value = data.getStringValue(propertyName); result.put(propertyName, value); } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getStorageXClass()); if (data == null) { return null; } Map<String, String> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { String value = data.getStringValue(propertyName); result.put(propertyName, value); } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override PatientData<String> load(Patient patient); @Override void save(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<String> readJSON(JSONObject json); }
AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getStorageXClass()); if (data == null) { return null; } Map<String, String> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { String value = data.getStringValue(propertyName); result.put(propertyName, value); } return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override PatientData<String> load(Patient patient); @Override void save(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<String> readJSON(JSONObject json);  }