@Test public void loadCatchesExceptionFromDocumentAccess() throws Exception { final NullPointerException exception = new NullPointerException(); when(this.patient.getXDocument()).thenThrow(exception); final PatientData<Pair<String, String>> result = this.component.load(this.patient); Assert.assertNull(result); verify(this.mocker.getMockedLogger()).error("Could not find requested document or some unforeseen " + "error has occurred during controller loading ", exception.getMessage()); }
@Override public PatientData<Pair<String, String>> load(final Patient patient) { try { final XWikiDocument doc = patient.getXDocument(); final List<BaseObject> eidXWikiObjects = doc.getXObjects(IDENTIFIER_CLASS_REFERENCE); if (CollectionUtils.isEmpty(eidXWikiObjects)) { return null; } final List<Pair<String, String>> allIdentifiers = toIdentifiers(eidXWikiObjects); return allIdentifiers.isEmpty() ? null : new IndexedPatientData<>(CONTROLLER_NAME, allIdentifiers); } catch (Exception e) { this.logger.error("Could not find requested document or some unforeseen " + "error has occurred during controller loading ", e.getMessage()); } return null; }
LabeledExternalIdentifiersController implements PatientDataController<Pair<String, String>> { @Override public PatientData<Pair<String, String>> load(final Patient patient) { try { final XWikiDocument doc = patient.getXDocument(); final List<BaseObject> eidXWikiObjects = doc.getXObjects(IDENTIFIER_CLASS_REFERENCE); if (CollectionUtils.isEmpty(eidXWikiObjects)) { return null; } final List<Pair<String, String>> allIdentifiers = toIdentifiers(eidXWikiObjects); return allIdentifiers.isEmpty() ? null : new IndexedPatientData<>(CONTROLLER_NAME, allIdentifiers); } catch (Exception e) { this.logger.error("Could not find requested document or some unforeseen " + "error has occurred during controller loading ", e.getMessage()); } return null; } }
LabeledExternalIdentifiersController implements PatientDataController<Pair<String, String>> { @Override public PatientData<Pair<String, String>> load(final Patient patient) { try { final XWikiDocument doc = patient.getXDocument(); final List<BaseObject> eidXWikiObjects = doc.getXObjects(IDENTIFIER_CLASS_REFERENCE); if (CollectionUtils.isEmpty(eidXWikiObjects)) { return null; } final List<Pair<String, String>> allIdentifiers = toIdentifiers(eidXWikiObjects); return allIdentifiers.isEmpty() ? null : new IndexedPatientData<>(CONTROLLER_NAME, allIdentifiers); } catch (Exception e) { this.logger.error("Could not find requested document or some unforeseen " + "error has occurred during controller loading ", e.getMessage()); } return null; }  }
LabeledExternalIdentifiersController implements PatientDataController<Pair<String, String>> { @Override public PatientData<Pair<String, String>> load(final Patient patient) { try { final XWikiDocument doc = patient.getXDocument(); final List<BaseObject> eidXWikiObjects = doc.getXObjects(IDENTIFIER_CLASS_REFERENCE); if (CollectionUtils.isEmpty(eidXWikiObjects)) { return null; } final List<Pair<String, String>> allIdentifiers = toIdentifiers(eidXWikiObjects); return allIdentifiers.isEmpty() ? null : new IndexedPatientData<>(CONTROLLER_NAME, allIdentifiers); } catch (Exception e) { this.logger.error("Could not find requested document or some unforeseen " + "error has occurred during controller loading ", e.getMessage()); } return null; }  @Override String getName(); @Override PatientData<Pair<String, String>> load(final Patient patient); @Override void writeJSON(@Nonnull final Patient patient, @Nonnull final JSONObject json,
        @Nullable final Collection<String> selectedFieldNames); @Override void writeJSON(@Nonnull final Patient patient, @Nonnull final JSONObject json); @Override PatientData<Pair<String, String>> readJSON(@Nullable final JSONObject json); @Override void save(@Nonnull final Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); }
LabeledExternalIdentifiersController implements PatientDataController<Pair<String, String>> { @Override public PatientData<Pair<String, String>> load(final Patient patient) { try { final XWikiDocument doc = patient.getXDocument(); final List<BaseObject> eidXWikiObjects = doc.getXObjects(IDENTIFIER_CLASS_REFERENCE); if (CollectionUtils.isEmpty(eidXWikiObjects)) { return null; } final List<Pair<String, String>> allIdentifiers = toIdentifiers(eidXWikiObjects); return allIdentifiers.isEmpty() ? null : new IndexedPatientData<>(CONTROLLER_NAME, allIdentifiers); } catch (Exception e) { this.logger.error("Could not find requested document or some unforeseen " + "error has occurred during controller loading ", e.getMessage()); } return null; }  @Override String getName(); @Override PatientData<Pair<String, String>> load(final Patient patient); @Override void writeJSON(@Nonnull final Patient patient, @Nonnull final JSONObject json,
        @Nullable final Collection<String> selectedFieldNames); @Override void writeJSON(@Nonnull final Patient patient, @Nonnull final JSONObject json); @Override PatientData<Pair<String, String>> readJSON(@Nullable final JSONObject json); @Override void save(@Nonnull final Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy);  }