@Test public void shouldGiveErrorIfUserDoesNotExist() throws Exception { User user = new User(); String email = "some email"; user.setEmail(email); when(userRepository.getByEmail(email)).thenReturn(null); expectedException.expect(DataException.class); expectedException.expectMessage(USER_EMAIL_INCORRECT); userService.sendForgotPasswordEmail(user, FORGET_PASSWORD_LINK); }
public void sendForgotPasswordEmail(User user, String resetPasswordLink) { user = getValidatedUser(user); userRepository.deletePasswordResetTokenForUser(user.getId()); String subject = messageService.message("forgot.password.email.subject"); SimpleMailMessage emailMessage = createEmailMessage(user, resetPasswordLink, subject); sendEmail(emailMessage); }
UserService { public void sendForgotPasswordEmail(User user, String resetPasswordLink) { user = getValidatedUser(user); userRepository.deletePasswordResetTokenForUser(user.getId()); String subject = messageService.message("forgot.password.email.subject"); SimpleMailMessage emailMessage = createEmailMessage(user, resetPasswordLink, subject); sendEmail(emailMessage); } }
UserService { public void sendForgotPasswordEmail(User user, String resetPasswordLink) { user = getValidatedUser(user); userRepository.deletePasswordResetTokenForUser(user.getId()); String subject = messageService.message("forgot.password.email.subject"); SimpleMailMessage emailMessage = createEmailMessage(user, resetPasswordLink, subject); sendEmail(emailMessage); }  }
UserService { public void sendForgotPasswordEmail(User user, String resetPasswordLink) { user = getValidatedUser(user); userRepository.deletePasswordResetTokenForUser(user.getId()); String subject = messageService.message("forgot.password.email.subject"); SimpleMailMessage emailMessage = createEmailMessage(user, resetPasswordLink, subject); sendEmail(emailMessage); }  static String getCommaSeparatedIds(List<Long> idList); @Transactional void create(User user, String resetPasswordLink); void createUser(User user, String passwordResetLink); @Transactional void update(User user); LinkedHashMap getPreferences(Long userId); void sendForgotPasswordEmail(User user, String resetPasswordLink); List<User> searchUser(String searchParam, Pagination pagination); User getUserWithRolesById(Long id); User getById(Long id); Long getUserIdByPasswordResetToken(String token); @Transactional void updateUserPassword(String token, String password); User getByUserName(String userName); User selectUserByUserNameAndPassword(String userName, String password); void updateUserPassword(Long userId, String password); @Transactional void disable(Long userId, Long modifiedBy); List<User> getUsersWithRightInNodeForProgram(Program program, SupervisoryNode node, String rightName); List<User> getUsersWithRightInHierarchyUsingBaseNode(Long nodeId, Program program, String rightName); List<User> getUsersWithRightOnWarehouse(Long id, String rightName); ArrayList<User> filterForActiveUsers(List<User> userList); Integer getTotalSearchResultCount(String searchParam); @Transactional String updateUserPreferences(Long userId, User user, Long programId, Long facilityId, List<Long> products); List<String> getSupervisoryRights(Long userId); }
UserService { public void sendForgotPasswordEmail(User user, String resetPasswordLink) { user = getValidatedUser(user); userRepository.deletePasswordResetTokenForUser(user.getId()); String subject = messageService.message("forgot.password.email.subject"); SimpleMailMessage emailMessage = createEmailMessage(user, resetPasswordLink, subject); sendEmail(emailMessage); }  static String getCommaSeparatedIds(List<Long> idList); @Transactional void create(User user, String resetPasswordLink); void createUser(User user, String passwordResetLink); @Transactional void update(User user); LinkedHashMap getPreferences(Long userId); void sendForgotPasswordEmail(User user, String resetPasswordLink); List<User> searchUser(String searchParam, Pagination pagination); User getUserWithRolesById(Long id); User getById(Long id); Long getUserIdByPasswordResetToken(String token); @Transactional void updateUserPassword(String token, String password); User getByUserName(String userName); User selectUserByUserNameAndPassword(String userName, String password); void updateUserPassword(Long userId, String password); @Transactional void disable(Long userId, Long modifiedBy); List<User> getUsersWithRightInNodeForProgram(Program program, SupervisoryNode node, String rightName); List<User> getUsersWithRightInHierarchyUsingBaseNode(Long nodeId, Program program, String rightName); List<User> getUsersWithRightOnWarehouse(Long id, String rightName); ArrayList<User> filterForActiveUsers(List<User> userList); Integer getTotalSearchResultCount(String searchParam); @Transactional String updateUserPreferences(Long userId, User user, Long programId, Long facilityId, List<Long> products); List<String> getSupervisoryRights(Long userId);  }