@Test public void getPatientsWithEmptyEidAndId() { doReturn(Collections.emptyList()).when(this.request).getProperties(EID_LABEL); doReturn(Collections.emptyList()).when(this.request).getProperties(ID_LABEL); final Response response = this.component.fetchPatients(); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertEquals("[]", response.getEntity()); }
@Override public Response fetchPatients() { final Request request = this.container.getRequest(); final List<Object> eids = request.getProperties("eid"); final List<Object> ids = request.getProperties("id"); this.slf4Jlogger.debug("Retrieving patient records with external IDs [{}] and internal IDs [{}]", eids, ids); final ImmutableSet.Builder<PrimaryEntity> patientsBuilder = ImmutableSet.builder(); try { addEids(patientsBuilder, eids); addIds(patientsBuilder, ids); final String json = this.objectMapper.writeValueAsString(patientsBuilder.build()); return Response.ok(json, MediaType.APPLICATION_JSON_TYPE).build(); } catch (final JsonProcessingException ex) { this.slf4Jlogger.error("Failed to serialize patients [{}] to JSON: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (final QueryException ex) { this.slf4Jlogger.error("Failed to retrieve patients with external ids [{}]: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }
DefaultPatientsFetchResourceImpl extends XWikiResource implements PatientsFetchResource { @Override public Response fetchPatients() { final Request request = this.container.getRequest(); final List<Object> eids = request.getProperties("eid"); final List<Object> ids = request.getProperties("id"); this.slf4Jlogger.debug("Retrieving patient records with external IDs [{}] and internal IDs [{}]", eids, ids); final ImmutableSet.Builder<PrimaryEntity> patientsBuilder = ImmutableSet.builder(); try { addEids(patientsBuilder, eids); addIds(patientsBuilder, ids); final String json = this.objectMapper.writeValueAsString(patientsBuilder.build()); return Response.ok(json, MediaType.APPLICATION_JSON_TYPE).build(); } catch (final JsonProcessingException ex) { this.slf4Jlogger.error("Failed to serialize patients [{}] to JSON: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (final QueryException ex) { this.slf4Jlogger.error("Failed to retrieve patients with external ids [{}]: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } }
DefaultPatientsFetchResourceImpl extends XWikiResource implements PatientsFetchResource { @Override public Response fetchPatients() { final Request request = this.container.getRequest(); final List<Object> eids = request.getProperties("eid"); final List<Object> ids = request.getProperties("id"); this.slf4Jlogger.debug("Retrieving patient records with external IDs [{}] and internal IDs [{}]", eids, ids); final ImmutableSet.Builder<PrimaryEntity> patientsBuilder = ImmutableSet.builder(); try { addEids(patientsBuilder, eids); addIds(patientsBuilder, ids); final String json = this.objectMapper.writeValueAsString(patientsBuilder.build()); return Response.ok(json, MediaType.APPLICATION_JSON_TYPE).build(); } catch (final JsonProcessingException ex) { this.slf4Jlogger.error("Failed to serialize patients [{}] to JSON: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (final QueryException ex) { this.slf4Jlogger.error("Failed to retrieve patients with external ids [{}]: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }  }
DefaultPatientsFetchResourceImpl extends XWikiResource implements PatientsFetchResource { @Override public Response fetchPatients() { final Request request = this.container.getRequest(); final List<Object> eids = request.getProperties("eid"); final List<Object> ids = request.getProperties("id"); this.slf4Jlogger.debug("Retrieving patient records with external IDs [{}] and internal IDs [{}]", eids, ids); final ImmutableSet.Builder<PrimaryEntity> patientsBuilder = ImmutableSet.builder(); try { addEids(patientsBuilder, eids); addIds(patientsBuilder, ids); final String json = this.objectMapper.writeValueAsString(patientsBuilder.build()); return Response.ok(json, MediaType.APPLICATION_JSON_TYPE).build(); } catch (final JsonProcessingException ex) { this.slf4Jlogger.error("Failed to serialize patients [{}] to JSON: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (final QueryException ex) { this.slf4Jlogger.error("Failed to retrieve patients with external ids [{}]: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }  @Override Response fetchPatients(); }
DefaultPatientsFetchResourceImpl extends XWikiResource implements PatientsFetchResource { @Override public Response fetchPatients() { final Request request = this.container.getRequest(); final List<Object> eids = request.getProperties("eid"); final List<Object> ids = request.getProperties("id"); this.slf4Jlogger.debug("Retrieving patient records with external IDs [{}] and internal IDs [{}]", eids, ids); final ImmutableSet.Builder<PrimaryEntity> patientsBuilder = ImmutableSet.builder(); try { addEids(patientsBuilder, eids); addIds(patientsBuilder, ids); final String json = this.objectMapper.writeValueAsString(patientsBuilder.build()); return Response.ok(json, MediaType.APPLICATION_JSON_TYPE).build(); } catch (final JsonProcessingException ex) { this.slf4Jlogger.error("Failed to serialize patients [{}] to JSON: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (final QueryException ex) { this.slf4Jlogger.error("Failed to retrieve patients with external ids [{}]: {}", eids, ex.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }  @Override Response fetchPatients();  }