@Test public void readJSONIgnoresEmptyParameter() { PatientData<Integer> patientData = this.obstetricHistoryController.readJSON(new JSONObject()); Assert.assertNull(patientData); }
@Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json; for (String path : StringUtils.split(getJsonPropertyName(), '.')) { data = data.optJSONObject(path); if (data == null || data.length() == 0) { return null; } } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { if (data.has(property)) { int age = data.getInt(property); result.put(property, age); } } return new DictionaryPatientData<>(getName(), result); }
ObstetricHistoryController implements PatientDataController<Integer> { @Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json; for (String path : StringUtils.split(getJsonPropertyName(), '.')) { data = data.optJSONObject(path); if (data == null || data.length() == 0) { return null; } } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { if (data.has(property)) { int age = data.getInt(property); result.put(property, age); } } return new DictionaryPatientData<>(getName(), result); } }
ObstetricHistoryController implements PatientDataController<Integer> { @Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json; for (String path : StringUtils.split(getJsonPropertyName(), '.')) { data = data.optJSONObject(path); if (data == null || data.length() == 0) { return null; } } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { if (data.has(property)) { int age = data.getInt(property); result.put(property, age); } } return new DictionaryPatientData<>(getName(), result); }  }
ObstetricHistoryController implements PatientDataController<Integer> { @Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json; for (String path : StringUtils.split(getJsonPropertyName(), '.')) { data = data.optJSONObject(path); if (data == null || data.length() == 0) { return null; } } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { if (data.has(property)) { int age = data.getInt(property); result.put(property, age); } } return new DictionaryPatientData<>(getName(), result); }  @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); }
ObstetricHistoryController implements PatientDataController<Integer> { @Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json; for (String path : StringUtils.split(getJsonPropertyName(), '.')) { data = data.optJSONObject(path); if (data == null || data.length() == 0) { return null; } } Map<String, Integer> result = new LinkedHashMap<>(); for (String property : getProperties()) { if (data.has(property)) { int age = data.getInt(property); result.put(property, age); } } return new DictionaryPatientData<>(getName(), result); }  @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; }