@Test public void loadReturnsSexUnknown() { doReturn(SEX_UNKNOWN).when(this.data).getStringValue(INTERNAL_PROPERTY_NAME); PatientData<String> result = this.component.load(this.patient); Assert.assertEquals(SEX_UNKNOWN, result.getValue()); doReturn("!!!!!").when(this.data).getStringValue(INTERNAL_PROPERTY_NAME); result = this.component.load(this.patient); Assert.assertEquals(SEX_UNKNOWN, result.getValue()); doReturn(null).when(this.data).getStringValue(INTERNAL_PROPERTY_NAME); result = this.component.load(this.patient); Assert.assertEquals(SEX_UNKNOWN, result.getValue()); }
@Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String gender = parseGender(data.getStringValue(INTERNAL_PROPERTY_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
SexController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String gender = parseGender(data.getStringValue(INTERNAL_PROPERTY_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
SexController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String gender = parseGender(data.getStringValue(INTERNAL_PROPERTY_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
SexController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String gender = parseGender(data.getStringValue(INTERNAL_PROPERTY_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); } 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); @Override String getName(); }
SexController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } String gender = parseGender(data.getStringValue(INTERNAL_PROPERTY_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); } 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); @Override String getName();  }