@Test public void loadCatchesUnforeseenExceptions() throws Exception { NullPointerException testException = new NullPointerException("Test Exception"); when(this.doc.getXObject(Patient.CLASS_REFERENCE)).thenThrow(testException); this.tested.load(this.patient); verify(this.logger).error("Could not find requested document or some unforeseen" + " error has occurred during controller loading: [{}]", "Test Exception"); }
@Override public PatientData<List<VocabularyTerm>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } Map<String, List<VocabularyTerm>> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { PropertyInterface propertyValue = data.get(propertyName); List<VocabularyTerm> holder = new LinkedList<>(); if (propertyValue instanceof StringProperty) { String propertyValueString = ((StringProperty) propertyValue).getValue(); addTerms(propertyValueString, holder); } else if (propertyValue instanceof ListProperty) { for (String item : ((ListProperty) propertyValue).getList()) { addTerms(item, holder); } } result.put(propertyName, holder); } return new DictionaryPatientData<>(DATA_NAME, result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
GlobalQualifiersController implements PatientDataController<List<VocabularyTerm>> { @Override public PatientData<List<VocabularyTerm>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } Map<String, List<VocabularyTerm>> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { PropertyInterface propertyValue = data.get(propertyName); List<VocabularyTerm> holder = new LinkedList<>(); if (propertyValue instanceof StringProperty) { String propertyValueString = ((StringProperty) propertyValue).getValue(); addTerms(propertyValueString, holder); } else if (propertyValue instanceof ListProperty) { for (String item : ((ListProperty) propertyValue).getList()) { addTerms(item, holder); } } result.put(propertyName, holder); } return new DictionaryPatientData<>(DATA_NAME, result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
GlobalQualifiersController implements PatientDataController<List<VocabularyTerm>> { @Override public PatientData<List<VocabularyTerm>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } Map<String, List<VocabularyTerm>> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { PropertyInterface propertyValue = data.get(propertyName); List<VocabularyTerm> holder = new LinkedList<>(); if (propertyValue instanceof StringProperty) { String propertyValueString = ((StringProperty) propertyValue).getValue(); addTerms(propertyValueString, holder); } else if (propertyValue instanceof ListProperty) { for (String item : ((ListProperty) propertyValue).getList()) { addTerms(item, holder); } } result.put(propertyName, holder); } return new DictionaryPatientData<>(DATA_NAME, result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
GlobalQualifiersController implements PatientDataController<List<VocabularyTerm>> { @Override public PatientData<List<VocabularyTerm>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } Map<String, List<VocabularyTerm>> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { PropertyInterface propertyValue = data.get(propertyName); List<VocabularyTerm> holder = new LinkedList<>(); if (propertyValue instanceof StringProperty) { String propertyValueString = ((StringProperty) propertyValue).getValue(); addTerms(propertyValueString, holder); } else if (propertyValue instanceof ListProperty) { for (String item : ((ListProperty) propertyValue).getList()) { addTerms(item, holder); } } result.put(propertyName, holder); } return new DictionaryPatientData<>(DATA_NAME, result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override PatientData<List<VocabularyTerm>> 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<List<VocabularyTerm>> readJSON(JSONObject json); @Override String getName(); }
GlobalQualifiersController implements PatientDataController<List<VocabularyTerm>> { @Override public PatientData<List<VocabularyTerm>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } Map<String, List<VocabularyTerm>> result = new LinkedHashMap<>(); for (String propertyName : getProperties()) { PropertyInterface propertyValue = data.get(propertyName); List<VocabularyTerm> holder = new LinkedList<>(); if (propertyValue instanceof StringProperty) { String propertyValueString = ((StringProperty) propertyValue).getValue(); addTerms(propertyValueString, holder); } else if (propertyValue instanceof ListProperty) { for (String item : ((ListProperty) propertyValue).getList()) { addTerms(item, holder); } } result.put(propertyName, holder); } return new DictionaryPatientData<>(DATA_NAME, result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override PatientData<List<VocabularyTerm>> 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<List<VocabularyTerm>> readJSON(JSONObject json); @Override String getName();  }