@Test public void createAlternativesPerformsCorrectly() throws ComponentLookupException, URISyntaxException { List<String> idList = new ArrayList<>(); idList.add(this.patientReference1.getName()); idList.add(this.patientReference2.getName()); when(this.access.hasAccess(this.user, Right.VIEW, this.patientReference2)).thenReturn(true); Alternatives alternatives = this.mocker.getComponentUnderTest().createAlternatives(idList, this.uriInfo); assertEquals(2, alternatives.getPatients().size()); assertEquals(this.patientReference1.getName(), alternatives.getPatients().get(0).getId()); assertEquals(this.patientReference2.getName(), alternatives.getPatients().get(1).getId()); }
@Override public Alternatives createAlternatives(List<String> alternativeIdentifiers, UriInfo uriInfo) { Alternatives result = new Alternatives(); User currentUser = this.users.getCurrentUser(); result.withLinks(this.autolinker.get().forResource(getClass(), uriInfo).build()); for (String id : alternativeIdentifiers) { DocumentReference reference = this.stringResolver.resolve(id, Patient.DEFAULT_DATA_SPACE); if (!this.access.hasAccess(currentUser, Right.VIEW, reference)) { continue; } result.getPatients().add(createAlternative(reference.getName(), uriInfo)); } return result; }
DefaultDomainObjectFactory implements DomainObjectFactory { @Override public Alternatives createAlternatives(List<String> alternativeIdentifiers, UriInfo uriInfo) { Alternatives result = new Alternatives(); User currentUser = this.users.getCurrentUser(); result.withLinks(this.autolinker.get().forResource(getClass(), uriInfo).build()); for (String id : alternativeIdentifiers) { DocumentReference reference = this.stringResolver.resolve(id, Patient.DEFAULT_DATA_SPACE); if (!this.access.hasAccess(currentUser, Right.VIEW, reference)) { continue; } result.getPatients().add(createAlternative(reference.getName(), uriInfo)); } return result; } }
DefaultDomainObjectFactory implements DomainObjectFactory { @Override public Alternatives createAlternatives(List<String> alternativeIdentifiers, UriInfo uriInfo) { Alternatives result = new Alternatives(); User currentUser = this.users.getCurrentUser(); result.withLinks(this.autolinker.get().forResource(getClass(), uriInfo).build()); for (String id : alternativeIdentifiers) { DocumentReference reference = this.stringResolver.resolve(id, Patient.DEFAULT_DATA_SPACE); if (!this.access.hasAccess(currentUser, Right.VIEW, reference)) { continue; } result.getPatients().add(createAlternative(reference.getName(), uriInfo)); } return result; }  }
DefaultDomainObjectFactory implements DomainObjectFactory { @Override public Alternatives createAlternatives(List<String> alternativeIdentifiers, UriInfo uriInfo) { Alternatives result = new Alternatives(); User currentUser = this.users.getCurrentUser(); result.withLinks(this.autolinker.get().forResource(getClass(), uriInfo).build()); for (String id : alternativeIdentifiers) { DocumentReference reference = this.stringResolver.resolve(id, Patient.DEFAULT_DATA_SPACE); if (!this.access.hasAccess(currentUser, Right.VIEW, reference)) { continue; } result.getPatients().add(createAlternative(reference.getName(), uriInfo)); } return result; }  @Override PatientSummary createPatientSummary(Patient patient, UriInfo uriInfo); @Override PatientSummary createPatientSummary(Object[] summaryData, UriInfo uriInfo); @Override Alternatives createAlternatives(List<String> alternativeIdentifiers, UriInfo uriInfo); @Override Alternative createAlternative(String id, UriInfo uriInfo); }
DefaultDomainObjectFactory implements DomainObjectFactory { @Override public Alternatives createAlternatives(List<String> alternativeIdentifiers, UriInfo uriInfo) { Alternatives result = new Alternatives(); User currentUser = this.users.getCurrentUser(); result.withLinks(this.autolinker.get().forResource(getClass(), uriInfo).build()); for (String id : alternativeIdentifiers) { DocumentReference reference = this.stringResolver.resolve(id, Patient.DEFAULT_DATA_SPACE); if (!this.access.hasAccess(currentUser, Right.VIEW, reference)) { continue; } result.getPatients().add(createAlternative(reference.getName(), uriInfo)); } return result; }  @Override PatientSummary createPatientSummary(Patient patient, UriInfo uriInfo); @Override PatientSummary createPatientSummary(Object[] summaryData, UriInfo uriInfo); @Override Alternatives createAlternatives(List<String> alternativeIdentifiers, UriInfo uriInfo); @Override Alternative createAlternative(String id, UriInfo uriInfo);  }