@Test public void testFindAddConsentOrganizationalProviderDtoByUsername() { final String username = "TheUsername"; Patient patient = mock(Patient.class); when(patientRepository.findByUsername(username)).thenReturn(patient); OrganizationalProvider provider1 = mock(OrganizationalProvider.class); OrganizationalProvider provider2 = mock(OrganizationalProvider.class); Set<OrganizationalProvider> providerSet = new HashSet(); providerSet.add(provider1); providerSet.add(provider2); when(patient.getOrganizationalProviders()).thenReturn(providerSet); AddConsentOrganizationalProviderDto providerDto1 = mock(AddConsentOrganizationalProviderDto.class); AddConsentOrganizationalProviderDto providerDto2 = mock(AddConsentOrganizationalProviderDto.class); when( modelMapper.map(provider1, AddConsentOrganizationalProviderDto.class)).thenReturn( providerDto1); when( modelMapper.map(provider2, AddConsentOrganizationalProviderDto.class)).thenReturn( providerDto2); List<AddConsentOrganizationalProviderDto> result = sut .findAddConsentOrganizationalProviderDtoByUsername(username); assertEquals(2, result.size()); for (AddConsentOrganizationalProviderDto providerDto : result) { assertTrue(providerDto == providerDto1 || providerDto == providerDto2); } assertTrue(result.get(0) != result.get(1)); }
@Override public List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByUsername( String username) { Patient patient = patientRepository.findByUsername(username); List<AddConsentOrganizationalProviderDto> organizationalProvidersDto = new ArrayList<AddConsentOrganizationalProviderDto>(); Set<OrganizationalProvider> organizationalProviders = patient .getOrganizationalProviders(); Iterator<OrganizationalProvider> organizationalProvidersIterator = organizationalProviders .iterator(); while (organizationalProvidersIterator.hasNext()) { organizationalProvidersDto.add(modelMapper.map( organizationalProvidersIterator.next(), AddConsentOrganizationalProviderDto.class)); } return organizationalProvidersDto; }
PatientServiceImpl implements PatientService { @Override public List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByUsername( String username) { Patient patient = patientRepository.findByUsername(username); List<AddConsentOrganizationalProviderDto> organizationalProvidersDto = new ArrayList<AddConsentOrganizationalProviderDto>(); Set<OrganizationalProvider> organizationalProviders = patient .getOrganizationalProviders(); Iterator<OrganizationalProvider> organizationalProvidersIterator = organizationalProviders .iterator(); while (organizationalProvidersIterator.hasNext()) { organizationalProvidersDto.add(modelMapper.map( organizationalProvidersIterator.next(), AddConsentOrganizationalProviderDto.class)); } return organizationalProvidersDto; } }
PatientServiceImpl implements PatientService { @Override public List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByUsername( String username) { Patient patient = patientRepository.findByUsername(username); List<AddConsentOrganizationalProviderDto> organizationalProvidersDto = new ArrayList<AddConsentOrganizationalProviderDto>(); Set<OrganizationalProvider> organizationalProviders = patient .getOrganizationalProviders(); Iterator<OrganizationalProvider> organizationalProvidersIterator = organizationalProviders .iterator(); while (organizationalProvidersIterator.hasNext()) { organizationalProvidersDto.add(modelMapper.map( organizationalProvidersIterator.next(), AddConsentOrganizationalProviderDto.class)); } return organizationalProvidersDto; } PatientServiceImpl(
			PatientRepository patientRepository,
			PatientLegalRepresentativeAssociationRepository patientLegalRepresentativeAssociationRepository,
			ModelMapper modelMapper,
			UserContext userContext,
			DtoToDomainEntityMapper<PatientProfileDto, Patient> patientProfileDtoToPatientMapper,
			UsersRepository usersRepository, PasswordEncoder passwordEncoder,
			EmailSender emailSender, PixService pixService); }
PatientServiceImpl implements PatientService { @Override public List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByUsername( String username) { Patient patient = patientRepository.findByUsername(username); List<AddConsentOrganizationalProviderDto> organizationalProvidersDto = new ArrayList<AddConsentOrganizationalProviderDto>(); Set<OrganizationalProvider> organizationalProviders = patient .getOrganizationalProviders(); Iterator<OrganizationalProvider> organizationalProvidersIterator = organizationalProviders .iterator(); while (organizationalProvidersIterator.hasNext()) { organizationalProvidersDto.add(modelMapper.map( organizationalProvidersIterator.next(), AddConsentOrganizationalProviderDto.class)); } return organizationalProvidersDto; } PatientServiceImpl(
			PatientRepository patientRepository,
			PatientLegalRepresentativeAssociationRepository patientLegalRepresentativeAssociationRepository,
			ModelMapper modelMapper,
			UserContext userContext,
			DtoToDomainEntityMapper<PatientProfileDto, Patient> patientProfileDtoToPatientMapper,
			UsersRepository usersRepository, PasswordEncoder passwordEncoder,
			EmailSender emailSender, PixService pixService); @Override long countAllPatients(); @Override PatientProfileDto findPatient(Long id); @Override List<PatientAdminDto> findAllPatientByFirstNameAndLastName(
			String[] tokens); @Override PatientProfileDto findByUsername(String username); @Override Long findIdByUsername(String username); @Override String findUsernameById(long id); @Override String findPatientEmailByUsername(String username); @Override PatientProfileDto findPatientProfileByUsername(String username); @Override PatientConnectionDto findPatientConnectionByUsername(String username); @Override PatientConnectionDto findPatientConnectionByPatient(Patient patient); @Override PatientConnectionDto findPatientConnectionById(long id); @Override List<PatientProfileDto> findPatientEntries(int pageNumber,
			int pageSize); @Override @Transactional PatientProfileDto savePatient(PatientProfileDto patientDto); @Override @Transactional void updatePatient(PatientProfileDto patientDto); @Override @Transactional void updateEid(String username); @Override @Transactional void updateEid(long id); @Override List<AddConsentIndividualProviderDto> findAddConsentIndividualProviderDtoByUsername(
			String username); @Override List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByPatientId(
			long pateintId); @Override List<AddConsentIndividualProviderDto> findAddConsentIndividualProviderDtoByPatientId(
			long pateintId); @Override List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByUsername(
			String username); @Override boolean isLegalRepForCurrentUser(Long legalRepId); @Override List<RecentPatientDto> findRecentPatientDtosById(List<String> ids); }
PatientServiceImpl implements PatientService { @Override public List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByUsername( String username) { Patient patient = patientRepository.findByUsername(username); List<AddConsentOrganizationalProviderDto> organizationalProvidersDto = new ArrayList<AddConsentOrganizationalProviderDto>(); Set<OrganizationalProvider> organizationalProviders = patient .getOrganizationalProviders(); Iterator<OrganizationalProvider> organizationalProvidersIterator = organizationalProviders .iterator(); while (organizationalProvidersIterator.hasNext()) { organizationalProvidersDto.add(modelMapper.map( organizationalProvidersIterator.next(), AddConsentOrganizationalProviderDto.class)); } return organizationalProvidersDto; } PatientServiceImpl(
			PatientRepository patientRepository,
			PatientLegalRepresentativeAssociationRepository patientLegalRepresentativeAssociationRepository,
			ModelMapper modelMapper,
			UserContext userContext,
			DtoToDomainEntityMapper<PatientProfileDto, Patient> patientProfileDtoToPatientMapper,
			UsersRepository usersRepository, PasswordEncoder passwordEncoder,
			EmailSender emailSender, PixService pixService); @Override long countAllPatients(); @Override PatientProfileDto findPatient(Long id); @Override List<PatientAdminDto> findAllPatientByFirstNameAndLastName(
			String[] tokens); @Override PatientProfileDto findByUsername(String username); @Override Long findIdByUsername(String username); @Override String findUsernameById(long id); @Override String findPatientEmailByUsername(String username); @Override PatientProfileDto findPatientProfileByUsername(String username); @Override PatientConnectionDto findPatientConnectionByUsername(String username); @Override PatientConnectionDto findPatientConnectionByPatient(Patient patient); @Override PatientConnectionDto findPatientConnectionById(long id); @Override List<PatientProfileDto> findPatientEntries(int pageNumber,
			int pageSize); @Override @Transactional PatientProfileDto savePatient(PatientProfileDto patientDto); @Override @Transactional void updatePatient(PatientProfileDto patientDto); @Override @Transactional void updateEid(String username); @Override @Transactional void updateEid(long id); @Override List<AddConsentIndividualProviderDto> findAddConsentIndividualProviderDtoByUsername(
			String username); @Override List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByPatientId(
			long pateintId); @Override List<AddConsentIndividualProviderDto> findAddConsentIndividualProviderDtoByPatientId(
			long pateintId); @Override List<AddConsentOrganizationalProviderDto> findAddConsentOrganizationalProviderDtoByUsername(
			String username); @Override boolean isLegalRepForCurrentUser(Long legalRepId); @Override List<RecentPatientDto> findRecentPatientDtosById(List<String> ids); static final Integer LAST_N_DIGITS_OF_SSN; }