@Test public void readJSONSkipsReportsWithNoContent() throws ComponentLookupException { JSONArray a = new JSONArray(); a.put(this.json1shallow); a.put(this.json2full); JSONObject json = new JSONObject(); json.put(DATA_NAME, a); PatientData<Attachment> result = this.mocker.getComponentUnderTest().readJSON(json); Assert.assertEquals(1, result.size()); Assert.assertEquals(this.a2, result.get(0)); }
@Override public PatientData<Attachment> readJSON(JSONObject json) { if (!json.has(DATA_NAME) || json.optJSONArray(DATA_NAME) == null) { return null; } List<Attachment> result = new ArrayList<>(); JSONArray reports = json.getJSONArray(DATA_NAME); for (Object report : reports) { Attachment next = this.adapter.fromJSON((JSONObject) report); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); }
MedicalReportsController implements PatientDataController<Attachment> { @Override public PatientData<Attachment> readJSON(JSONObject json) { if (!json.has(DATA_NAME) || json.optJSONArray(DATA_NAME) == null) { return null; } List<Attachment> result = new ArrayList<>(); JSONArray reports = json.getJSONArray(DATA_NAME); for (Object report : reports) { Attachment next = this.adapter.fromJSON((JSONObject) report); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); } }
MedicalReportsController implements PatientDataController<Attachment> { @Override public PatientData<Attachment> readJSON(JSONObject json) { if (!json.has(DATA_NAME) || json.optJSONArray(DATA_NAME) == null) { return null; } List<Attachment> result = new ArrayList<>(); JSONArray reports = json.getJSONArray(DATA_NAME); for (Object report : reports) { Attachment next = this.adapter.fromJSON((JSONObject) report); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); }  }
MedicalReportsController implements PatientDataController<Attachment> { @Override public PatientData<Attachment> readJSON(JSONObject json) { if (!json.has(DATA_NAME) || json.optJSONArray(DATA_NAME) == null) { return null; } List<Attachment> result = new ArrayList<>(); JSONArray reports = json.getJSONArray(DATA_NAME); for (Object report : reports) { Attachment next = this.adapter.fromJSON((JSONObject) report); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); }  @Override PatientData<Attachment> 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<Attachment> readJSON(JSONObject json); @Override String getName(); }
MedicalReportsController implements PatientDataController<Attachment> { @Override public PatientData<Attachment> readJSON(JSONObject json) { if (!json.has(DATA_NAME) || json.optJSONArray(DATA_NAME) == null) { return null; } List<Attachment> result = new ArrayList<>(); JSONArray reports = json.getJSONArray(DATA_NAME); for (Object report : reports) { Attachment next = this.adapter.fromJSON((JSONObject) report); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); }  @Override PatientData<Attachment> 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<Attachment> readJSON(JSONObject json); @Override String getName();  }