@Test public void loadEmptyPatientTest() { doReturn(null).when(this.doc).getXObject(any(EntityReference.class)); PatientData<Integer> testData = this.parentalAgeController.load(this.patient); Assert.assertNull(testData); verify(this.logger).debug("No parental information for patient [{}]", TEST_PATIENT_ID); }
@Override public PatientData<Integer> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { this.logger.debug("No parental information for patient [{}]", patient.getId()); return null; } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { int age = data.getIntValue(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { result.put(property, age); } } if (!result.isEmpty()) { return new DictionaryPatientData<>(getName(), result); } } catch (Exception ex) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, ex.getMessage()); } return null; }
ParentalAgeController implements PatientDataController<Integer> { @Override public PatientData<Integer> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { this.logger.debug("No parental information for patient [{}]", patient.getId()); return null; } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { int age = data.getIntValue(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { result.put(property, age); } } if (!result.isEmpty()) { return new DictionaryPatientData<>(getName(), result); } } catch (Exception ex) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, ex.getMessage()); } return null; } }
ParentalAgeController implements PatientDataController<Integer> { @Override public PatientData<Integer> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { this.logger.debug("No parental information for patient [{}]", patient.getId()); return null; } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { int age = data.getIntValue(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { result.put(property, age); } } if (!result.isEmpty()) { return new DictionaryPatientData<>(getName(), result); } } catch (Exception ex) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, ex.getMessage()); } return null; }  }
ParentalAgeController implements PatientDataController<Integer> { @Override public PatientData<Integer> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { this.logger.debug("No parental information for patient [{}]", patient.getId()); return null; } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { int age = data.getIntValue(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { result.put(property, age); } } if (!result.isEmpty()) { return new DictionaryPatientData<>(getName(), result); } } catch (Exception ex) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, ex.getMessage()); } return null; }  @Override String getName(); @Override PatientData<Integer> 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<Integer> readJSON(JSONObject json); }
ParentalAgeController implements PatientDataController<Integer> { @Override public PatientData<Integer> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(getXClassReference()); if (data == null) { this.logger.debug("No parental information for patient [{}]", patient.getId()); return null; } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { int age = data.getIntValue(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { result.put(property, age); } } if (!result.isEmpty()) { return new DictionaryPatientData<>(getName(), result); } } catch (Exception ex) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, ex.getMessage()); } return null; }  @Override String getName(); @Override PatientData<Integer> 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<Integer> readJSON(JSONObject json); static final EntityReference CLASS_REFERENCE; }