@Test public void loadCatchesInvalidDocument() throws ComponentLookupException { doReturn(null).when(this.patient).getXDocument(); PatientData<Map<String, String>> result = this.mocker.getComponentUnderTest().load(this.patient); verify(this.mocker.getMockedLogger()).error(eq(PatientDataController.ERROR_MESSAGE_LOAD_FAILED), anyString()); Assert.assertNull(result); }
@Override public PatientData<Map<String, String>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> variantXWikiObjects = doc.getXObjects(VARIANT_CLASS_REFERENCE); if (variantXWikiObjects == null || variantXWikiObjects.isEmpty()) { return null; } List<Map<String, String>> allVariants = new LinkedList<>(); for (BaseObject variantObject : variantXWikiObjects) { if (variantObject == null || variantObject.getFieldList().isEmpty()) { continue; } Map<String, String> singleVariant = new LinkedHashMap<>(); for (String property : getProperties()) { String value = getFieldValue(variantObject, property); if (value == null) { continue; } singleVariant.put(property, value); } allVariants.add(singleVariant); } if (allVariants.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allVariants); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
VariantListController extends AbstractComplexController<Map<String, String>> { @Override public PatientData<Map<String, String>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> variantXWikiObjects = doc.getXObjects(VARIANT_CLASS_REFERENCE); if (variantXWikiObjects == null || variantXWikiObjects.isEmpty()) { return null; } List<Map<String, String>> allVariants = new LinkedList<>(); for (BaseObject variantObject : variantXWikiObjects) { if (variantObject == null || variantObject.getFieldList().isEmpty()) { continue; } Map<String, String> singleVariant = new LinkedHashMap<>(); for (String property : getProperties()) { String value = getFieldValue(variantObject, property); if (value == null) { continue; } singleVariant.put(property, value); } allVariants.add(singleVariant); } if (allVariants.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allVariants); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
VariantListController extends AbstractComplexController<Map<String, String>> { @Override public PatientData<Map<String, String>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> variantXWikiObjects = doc.getXObjects(VARIANT_CLASS_REFERENCE); if (variantXWikiObjects == null || variantXWikiObjects.isEmpty()) { return null; } List<Map<String, String>> allVariants = new LinkedList<>(); for (BaseObject variantObject : variantXWikiObjects) { if (variantObject == null || variantObject.getFieldList().isEmpty()) { continue; } Map<String, String> singleVariant = new LinkedHashMap<>(); for (String property : getProperties()) { String value = getFieldValue(variantObject, property); if (value == null) { continue; } singleVariant.put(property, value); } allVariants.add(singleVariant); } if (allVariants.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allVariants); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
VariantListController extends AbstractComplexController<Map<String, String>> { @Override public PatientData<Map<String, String>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> variantXWikiObjects = doc.getXObjects(VARIANT_CLASS_REFERENCE); if (variantXWikiObjects == null || variantXWikiObjects.isEmpty()) { return null; } List<Map<String, String>> allVariants = new LinkedList<>(); for (BaseObject variantObject : variantXWikiObjects) { if (variantObject == null || variantObject.getFieldList().isEmpty()) { continue; } Map<String, String> singleVariant = new LinkedHashMap<>(); for (String property : getProperties()) { String value = getFieldValue(variantObject, property); if (value == null) { continue; } singleVariant.put(property, value); } allVariants.add(singleVariant); } if (allVariants.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allVariants); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override String getName(); @Override PatientData<Map<String, String>> load(Patient patient); @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Map<String, String>> readJSON(JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); }
VariantListController extends AbstractComplexController<Map<String, String>> { @Override public PatientData<Map<String, String>> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); List<BaseObject> variantXWikiObjects = doc.getXObjects(VARIANT_CLASS_REFERENCE); if (variantXWikiObjects == null || variantXWikiObjects.isEmpty()) { return null; } List<Map<String, String>> allVariants = new LinkedList<>(); for (BaseObject variantObject : variantXWikiObjects) { if (variantObject == null || variantObject.getFieldList().isEmpty()) { continue; } Map<String, String> singleVariant = new LinkedHashMap<>(); for (String property : getProperties()) { String value = getFieldValue(variantObject, property); if (value == null) { continue; } singleVariant.put(property, value); } allVariants.add(singleVariant); } if (allVariants.isEmpty()) { return null; } else { return new IndexedPatientData<>(getName(), allVariants); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override String getName(); @Override PatientData<Map<String, String>> load(Patient patient); @SuppressWarnings("checkstyle:CyclomaticComplexity") @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<Map<String, String>> readJSON(JSONObject json); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy);  }