@Test public void test_should_validate_search_critieria() { UserSearchCriteria userSearch = mock(UserSearchCriteria.class); List<org.egov.user.domain.model.User> expectedListOfUsers = new ArrayList<org.egov.user.domain.model.User>(); when(userRepository.findAll(userSearch)).thenReturn(expectedListOfUsers); userService.searchUsers(userSearch, true); verify(userSearch).validate(true); }
public List<org.egov.user.domain.model.User> searchUsers(UserSearchCriteria searchCriteria, boolean isInterServiceCall) { searchCriteria.validate(isInterServiceCall); searchCriteria.setTenantId(getStateLevelTenantForCitizen(searchCriteria.getTenantId(), searchCriteria.getType())); List<org.egov.user.domain.model.User> list = userRepository.findAll(searchCriteria); setFileStoreUrlsByFileStoreIds(list); return list; }
UserService { public List<org.egov.user.domain.model.User> searchUsers(UserSearchCriteria searchCriteria, boolean isInterServiceCall) { searchCriteria.validate(isInterServiceCall); searchCriteria.setTenantId(getStateLevelTenantForCitizen(searchCriteria.getTenantId(), searchCriteria.getType())); List<org.egov.user.domain.model.User> list = userRepository.findAll(searchCriteria); setFileStoreUrlsByFileStoreIds(list); return list; } }
UserService { public List<org.egov.user.domain.model.User> searchUsers(UserSearchCriteria searchCriteria, boolean isInterServiceCall) { searchCriteria.validate(isInterServiceCall); searchCriteria.setTenantId(getStateLevelTenantForCitizen(searchCriteria.getTenantId(), searchCriteria.getType())); List<org.egov.user.domain.model.User> list = userRepository.findAll(searchCriteria); setFileStoreUrlsByFileStoreIds(list); return list; } UserService(UserRepository userRepository, OtpRepository otpRepository, FileStoreRepository fileRepository,
                       PasswordEncoder passwordEncoder, TokenStore tokenStore,
                       @Value("${default.password.expiry.in.days}") int defaultPasswordExpiryInDays,
                       @Value("${citizen.login.password.otp.enabled}") boolean isCitizenLoginOtpBased,
                       @Value("${employee.login.password.otp.enabled}") boolean isEmployeeLoginOtpBased); }
UserService { public List<org.egov.user.domain.model.User> searchUsers(UserSearchCriteria searchCriteria, boolean isInterServiceCall) { searchCriteria.validate(isInterServiceCall); searchCriteria.setTenantId(getStateLevelTenantForCitizen(searchCriteria.getTenantId(), searchCriteria.getType())); List<org.egov.user.domain.model.User> list = userRepository.findAll(searchCriteria); setFileStoreUrlsByFileStoreIds(list); return list; } UserService(UserRepository userRepository, OtpRepository otpRepository, FileStoreRepository fileRepository,
                       PasswordEncoder passwordEncoder, TokenStore tokenStore,
                       @Value("${default.password.expiry.in.days}") int defaultPasswordExpiryInDays,
                       @Value("${citizen.login.password.otp.enabled}") boolean isCitizenLoginOtpBased,
                       @Value("${employee.login.password.otp.enabled}") boolean isEmployeeLoginOtpBased); User getUniqueUser(String userName, String tenantId, UserType userType); User getUserByUuid(String uuid); List<org.egov.user.domain.model.User> searchUsers(UserSearchCriteria searchCriteria,
                                                             boolean isInterServiceCall); User createUser(User user); User createCitizen(User user); Object registerWithLogin(User user); Boolean validateOtp(User user); User updateWithoutOtpValidation(final User user); void removeTokensByUser(User user); User partialUpdate(final User user); void updatePasswordForLoggedInUser(LoggedInUserUpdatePasswordRequest updatePasswordRequest); void updatePasswordForNonLoggedInUser(NonLoggedInUserUpdatePasswordRequest request); void resetFailedLoginAttempts(User user); boolean isAccountUnlockAble(User user); void handleFailedLogin(User user, String ipAddress); }
UserService { public List<org.egov.user.domain.model.User> searchUsers(UserSearchCriteria searchCriteria, boolean isInterServiceCall) { searchCriteria.validate(isInterServiceCall); searchCriteria.setTenantId(getStateLevelTenantForCitizen(searchCriteria.getTenantId(), searchCriteria.getType())); List<org.egov.user.domain.model.User> list = userRepository.findAll(searchCriteria); setFileStoreUrlsByFileStoreIds(list); return list; } UserService(UserRepository userRepository, OtpRepository otpRepository, FileStoreRepository fileRepository,
                       PasswordEncoder passwordEncoder, TokenStore tokenStore,
                       @Value("${default.password.expiry.in.days}") int defaultPasswordExpiryInDays,
                       @Value("${citizen.login.password.otp.enabled}") boolean isCitizenLoginOtpBased,
                       @Value("${employee.login.password.otp.enabled}") boolean isEmployeeLoginOtpBased); User getUniqueUser(String userName, String tenantId, UserType userType); User getUserByUuid(String uuid); List<org.egov.user.domain.model.User> searchUsers(UserSearchCriteria searchCriteria,
                                                             boolean isInterServiceCall); User createUser(User user); User createCitizen(User user); Object registerWithLogin(User user); Boolean validateOtp(User user); User updateWithoutOtpValidation(final User user); void removeTokensByUser(User user); User partialUpdate(final User user); void updatePasswordForLoggedInUser(LoggedInUserUpdatePasswordRequest updatePasswordRequest); void updatePasswordForNonLoggedInUser(NonLoggedInUserUpdatePasswordRequest request); void resetFailedLoginAttempts(User user); boolean isAccountUnlockAble(User user); void handleFailedLogin(User user, String ipAddress);  }