@Test public void testMresetPasswordForUserSuccess() { User registratedUser = _userRepository.findByName(userName); String activationKey = registratedUser.getActivationKey(); try { _userService.resetPasswordForUser(2L, activationKey, "newPassword"); } catch (IpatException e) { String errorCode = e.getErrorInfos().get(0).getErrorCode(); fail("reset password should not fail here\nerrorCode:" + errorCode); } registratedUser = _userRepository.findByName(userName); assertNotNull(registratedUser.getPassword()); }
public String resetPasswordForUser(long userId, String key, String password) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setPassword(passwordEncrypter.encryptPassword(password)); userRepository.save(user); return user.getName(); }
UserService { public String resetPasswordForUser(long userId, String key, String password) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setPassword(passwordEncrypter.encryptPassword(password)); userRepository.save(user); return user.getName(); } }
UserService { public String resetPasswordForUser(long userId, String key, String password) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setPassword(passwordEncrypter.encryptPassword(password)); userRepository.save(user); return user.getName(); }  }
UserService { public String resetPasswordForUser(long userId, String key, String password) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setPassword(passwordEncrypter.encryptPassword(password)); userRepository.save(user); return user.getName(); }  User createAnonymous(); UserReportData getUserDetails(String userName, boolean isEditAllowed); void editUser(String userName, String toEdit, String newEntry); String uploadUserImage(String userName, MultipartFile file); void registrateUser(UserRegistrationData userRegistrationData); void activateUser(long userId, String key); void createPasswordResetMail(String userName); String verifiyPasswordResetLink(long userId, String key); String resetPasswordForUser(long userId, String key, String password); User anonymizeUser(String userName); }
UserService { public String resetPasswordForUser(long userId, String key, String password) throws IpatException { User user = getUser(userId); IpatPreconditions.checkArgument(key.equals(user.getActivationKey()), ErrorCodes.INVALID_ACTIVATION_KEY); user.setPassword(passwordEncrypter.encryptPassword(password)); userRepository.save(user); return user.getName(); }  User createAnonymous(); UserReportData getUserDetails(String userName, boolean isEditAllowed); void editUser(String userName, String toEdit, String newEntry); String uploadUserImage(String userName, MultipartFile file); void registrateUser(UserRegistrationData userRegistrationData); void activateUser(long userId, String key); void createPasswordResetMail(String userName); String verifiyPasswordResetLink(long userId, String key); String resetPasswordForUser(long userId, String key, String password); User anonymizeUser(String userName);  }