@Test void testChangePassword() { String username = "MyUsername"; String token = "MyToken"; String password = "MyPassword"; User user = mock(User.class); when(userService.getUser(username)).thenReturn(user); passwordResetServiceImpl.changePassword(username, token, password); verify(passwordResetTokenRepository).validateToken(user, token); verify(user).setPassword(password); verify(userService).update(user); verify(passwordResetTokenRepository).deleteToken(user, token); }
@Transactional @RunAsSystem @Override public void changePassword(String username, String token, String password) { User user = getUser(username); passwordResetTokenService.validateToken(user, token); user.setPassword(password); userService.update(user); passwordResetTokenService.deleteToken(user, token); }
PasswordResetterImpl implements PasswordResetter { @Transactional @RunAsSystem @Override public void changePassword(String username, String token, String password) { User user = getUser(username); passwordResetTokenService.validateToken(user, token); user.setPassword(password); userService.update(user); passwordResetTokenService.deleteToken(user, token); } }
PasswordResetterImpl implements PasswordResetter { @Transactional @RunAsSystem @Override public void changePassword(String username, String token, String password) { User user = getUser(username); passwordResetTokenService.validateToken(user, token); user.setPassword(password); userService.update(user); passwordResetTokenService.deleteToken(user, token); } PasswordResetterImpl(
      PasswordResetTokenRepository passwordResetTokenRepository,
      UserService userService,
      MailSender mailSender,
      AppSettings appSettings); }
PasswordResetterImpl implements PasswordResetter { @Transactional @RunAsSystem @Override public void changePassword(String username, String token, String password) { User user = getUser(username); passwordResetTokenService.validateToken(user, token); user.setPassword(password); userService.update(user); passwordResetTokenService.deleteToken(user, token); } PasswordResetterImpl(
      PasswordResetTokenRepository passwordResetTokenRepository,
      UserService userService,
      MailSender mailSender,
      AppSettings appSettings); @Transactional @RunAsSystem @Override void resetPassword(String emailAddress); @Transactional(readOnly = true) @RunAsSystem @Override void validatePasswordResetToken(String username, String token); @Transactional @RunAsSystem @Override void changePassword(String username, String token, String password); @Transactional @Override void changePasswordAuthenticatedUser(String password); }
PasswordResetterImpl implements PasswordResetter { @Transactional @RunAsSystem @Override public void changePassword(String username, String token, String password) { User user = getUser(username); passwordResetTokenService.validateToken(user, token); user.setPassword(password); userService.update(user); passwordResetTokenService.deleteToken(user, token); } PasswordResetterImpl(
      PasswordResetTokenRepository passwordResetTokenRepository,
      UserService userService,
      MailSender mailSender,
      AppSettings appSettings); @Transactional @RunAsSystem @Override void resetPassword(String emailAddress); @Transactional(readOnly = true) @RunAsSystem @Override void validatePasswordResetToken(String username, String token); @Transactional @RunAsSystem @Override void changePassword(String username, String token, String password); @Transactional @Override void changePasswordAuthenticatedUser(String password);  }