@Test public void loadCatchesUnforeseenExceptions() throws Exception { Exception testException = new RuntimeException("Test Exception"); doThrow(testException).when(this.doc).getXObject(Patient.CLASS_REFERENCE); PatientData<String> result = this.component.load(this.patient); verify(this.mocker.getMockedLogger()).error(eq(PatientDataController.ERROR_MESSAGE_LOAD_FAILED), anyString()); Assert.assertNull(result); }
@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);  }