@Test public void readJSONObjectWithNoData() { JSONObject json = new JSONObject(); json.put("prenatal_perinatal_history", (Object) null); PatientData<Integer> readData = this.parentalAgeController.readJSON(json); Assert.assertNull(readData); }
@Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json.optJSONObject(getJsonPropertyName()); 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.optInt(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { result.put(property, age); } } } return new DictionaryPatientData<>(getName(), result); }
ParentalAgeController implements PatientDataController<Integer> { @Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json.optJSONObject(getJsonPropertyName()); 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.optInt(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { result.put(property, age); } } } return new DictionaryPatientData<>(getName(), result); } }
ParentalAgeController implements PatientDataController<Integer> { @Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json.optJSONObject(getJsonPropertyName()); 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.optInt(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { result.put(property, age); } } } return new DictionaryPatientData<>(getName(), result); }  }
ParentalAgeController implements PatientDataController<Integer> { @Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json.optJSONObject(getJsonPropertyName()); 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.optInt(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { 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); }
ParentalAgeController implements PatientDataController<Integer> { @Override public PatientData<Integer> readJSON(JSONObject json) { if (json == null || json.length() == 0) { return null; } JSONObject data = json.optJSONObject(getJsonPropertyName()); 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.optInt(property, Integer.MIN_VALUE); if (age != Integer.MIN_VALUE) { 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; }