@Test public void readJSONWithEmptyFilesReturnsEmptyData() throws ComponentLookupException { JSONObject input = new JSONObject(); input.put(DATA_NAME, new JSONArray()); PatientData<Attachment> result = this.mocker.getComponentUnderTest().readJSON(input); Assert.assertNotNull(result); Assert.assertTrue(result.isIndexed()); Assert.assertEquals(0, result.size()); }
@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 files = json.getJSONArray(DATA_NAME); for (Object file : files) { Attachment next = this.adapter.fromJSON((JSONObject) file); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); }
AdditionalDocumentsController 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 files = json.getJSONArray(DATA_NAME); for (Object file : files) { Attachment next = this.adapter.fromJSON((JSONObject) file); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); } }
AdditionalDocumentsController 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 files = json.getJSONArray(DATA_NAME); for (Object file : files) { Attachment next = this.adapter.fromJSON((JSONObject) file); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); }  }
AdditionalDocumentsController 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 files = json.getJSONArray(DATA_NAME); for (Object file : files) { Attachment next = this.adapter.fromJSON((JSONObject) file); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); }  @Override PatientData<Attachment> load(Patient patient); @Override void save(@Nonnull final 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(); }
AdditionalDocumentsController 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 files = json.getJSONArray(DATA_NAME); for (Object file : files) { Attachment next = this.adapter.fromJSON((JSONObject) file); if (next != null) { result.add(next); } } return new IndexedPatientData<>(getName(), result); }  @Override PatientData<Attachment> load(Patient patient); @Override void save(@Nonnull final 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(); static final EntityReference CLASS_REFERENCE; }