@Test public void testFindAllPatientByFirstNameAndLastName() { List<Patient> patients = new ArrayList<Patient>(); Patient patient = mock(Patient.class); Patient patient2 = mock(Patient.class); patients.add(patient); patients.add(patient2); when( patientRepository.findAllByFirstNameLikesAndLastNameLikes( "%john%", "%smith%")).thenReturn(patients); PatientAdminDto patientAdminDto = mock(PatientAdminDto.class); PatientAdminDto patientAdminDto2 = mock(PatientAdminDto.class); when(modelMapper.map(patient, PatientAdminDto.class)).thenReturn( patientAdminDto); when(modelMapper.map(patient2, PatientAdminDto.class)).thenReturn( patientAdminDto2); assertEquals( Arrays.asList(patientAdminDto, patientAdminDto2), sut.findAllPatientByFirstNameAndLastName(new String[] { "john", "smith" })); }
@Override public List<PatientAdminDto> findAllPatientByFirstNameAndLastName( String[] tokens) { List<Patient> patients; if (tokens.length == 1) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%"); } else if (tokens.length >= 2) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%", "%" + tokens[1] + "%"); } else { patients = new ArrayList<Patient>(); } List<PatientAdminDto> PatientAdminDtoList = mapPatientListToPatientAdminDtoList(patients); return PatientAdminDtoList; }
PatientServiceImpl implements PatientService { @Override public List<PatientAdminDto> findAllPatientByFirstNameAndLastName( String[] tokens) { List<Patient> patients; if (tokens.length == 1) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%"); } else if (tokens.length >= 2) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%", "%" + tokens[1] + "%"); } else { patients = new ArrayList<Patient>(); } List<PatientAdminDto> PatientAdminDtoList = mapPatientListToPatientAdminDtoList(patients); return PatientAdminDtoList; } }
PatientServiceImpl implements PatientService { @Override public List<PatientAdminDto> findAllPatientByFirstNameAndLastName( String[] tokens) { List<Patient> patients; if (tokens.length == 1) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%"); } else if (tokens.length >= 2) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%", "%" + tokens[1] + "%"); } else { patients = new ArrayList<Patient>(); } List<PatientAdminDto> PatientAdminDtoList = mapPatientListToPatientAdminDtoList(patients); return PatientAdminDtoList; } 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<PatientAdminDto> findAllPatientByFirstNameAndLastName( String[] tokens) { List<Patient> patients; if (tokens.length == 1) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%"); } else if (tokens.length >= 2) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%", "%" + tokens[1] + "%"); } else { patients = new ArrayList<Patient>(); } List<PatientAdminDto> PatientAdminDtoList = mapPatientListToPatientAdminDtoList(patients); return PatientAdminDtoList; } 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<PatientAdminDto> findAllPatientByFirstNameAndLastName( String[] tokens) { List<Patient> patients; if (tokens.length == 1) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%"); } else if (tokens.length >= 2) { patients = patientRepository .findAllByFirstNameLikesAndLastNameLikes("%" + tokens[0] + "%", "%" + tokens[1] + "%"); } else { patients = new ArrayList<Patient>(); } List<PatientAdminDto> PatientAdminDtoList = mapPatientListToPatientAdminDtoList(patients); return PatientAdminDtoList; } 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; }