SampleFacadeEjb implements SampleFacade { @Override public List<SampleDto> getByCaseUuids(List<String> caseUuids) { Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight); return sampleService.getByCaseUuids(caseUuids).stream().map(c -> convertToDto(c, pseudonymizer)).collect(Collectors.toList()); }  @Override List<String> getAllActiveUuids(); @Override List<SampleDto> getAllActiveSamplesAfter(Date date); @Override List<SampleDto> getByUuids(List<String> uuids); @Override List<SampleDto> getByCaseUuids(List<String> caseUuids); @Override boolean exists(String uuid); @Override List<String> getDeletedUuidsSince(Date since); @Override SampleDto getSampleByUuid(String uuid); @Override SampleDto saveSample(SampleDto dto); SampleDto saveSample(SampleDto dto, boolean handleChanges); @Override SampleReferenceDto getReferenceByUuid(String uuid); @Override List<SampleIndexDto> getIndexList(SampleCriteria sampleCriteria, Integer first, Integer max, List<SortProperty> sortProperties); @Override void validate(SampleDto sample); @Override List<SampleExportDto> getExportList(SampleCriteria criteria, int first, int max); @Override List<SampleExportDto> getExportList(CaseCriteria criteria, int first, int max); @Override long count(SampleCriteria sampleCriteria); @Override SampleReferenceDto getReferredFrom(String sampleUuid); @Override void deleteSample(SampleReferenceDto sampleRef); @Override Map<PathogenTestResultType, Long> getNewTestResultCountByResultType(List<Long> caseIds); Sample fromDto(@NotNull SampleDto source); static SampleDto toDto(Sample source); static SampleReferenceDto toReferenceDto(Sample entity); @Override boolean isDeleted(String sampleUuid); Boolean isSampleEditAllowed(String sampleUuid); static final String CONTACT_CASE_REGION; static final String CONTACT_CASE_DISTRICT; static final String DISEASE; static final String DISEASE_DETAILS; static final String REGION; static final String DISTRICT; static final String DISTRICT_NAME; }
@Test public void testGetByCaseUuids() { RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility"); UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_SUPERVISOR); PersonDto person = creator.createPerson(); CaseDataDto caze = creator.createCase(user.toReference(), person.toReference(), rdcf); CaseDataDto caze2 = creator.createCase(user.toReference(), person.toReference(), rdcf); CaseDataDto caze3 = creator.createCase(user.toReference(), person.toReference(), rdcf); SampleDto sample = creator.createSample(caze.toReference(), user.toReference(), rdcf.facility); SampleDto sample2 = creator.createSample(caze.toReference(), user.toReference(), rdcf.facility); SampleDto sample3 = creator.createSample(caze2.toReference(), user.toReference(), rdcf.facility); creator.createSample(caze3.toReference(), user.toReference(), rdcf.facility); List<SampleDto> samples = getSampleFacade().getByCaseUuids(Arrays.asList(caze.getUuid(), caze2.getUuid())); assertThat(samples, hasSize(3)); assertThat(samples, contains(sample, sample2, sample3)); }