@Test public void readJSONReturnsCorrectSex() { JSONObject json = new JSONObject(); json.put(DATA_NAME, SEX_MALE); PatientData<String> result = this.component.readJSON(json); Assert.assertEquals(SEX_MALE, result.getValue()); json = new JSONObject(); json.put(DATA_NAME, SEX_FEMALE); result = this.component.readJSON(json); Assert.assertEquals(SEX_FEMALE, result.getValue()); json = new JSONObject(); json.put(DATA_NAME, SEX_OTHER); result = this.component.readJSON(json); Assert.assertEquals(SEX_OTHER, result.getValue()); json = new JSONObject(); json.put(DATA_NAME, SEX_UNKNOWN); result = this.component.readJSON(json); Assert.assertEquals(SEX_UNKNOWN, result.getValue()); }
@Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(DATA_NAME)) { return null; } String gender = parseGender(json.getString(DATA_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); }
SexController implements PatientDataController<String> { @Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(DATA_NAME)) { return null; } String gender = parseGender(json.getString(DATA_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); } }
SexController implements PatientDataController<String> { @Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(DATA_NAME)) { return null; } String gender = parseGender(json.getString(DATA_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); }  }
SexController implements PatientDataController<String> { @Override public PatientData<String> readJSON(JSONObject json) { if (!json.has(DATA_NAME)) { return null; } String gender = parseGender(json.getString(DATA_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); }  @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> readJSON(JSONObject json) { if (!json.has(DATA_NAME)) { return null; } String gender = parseGender(json.getString(DATA_NAME)); return new SimpleValuePatientData<>(DATA_NAME, gender); }  @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();  }