Assert.assertTrue(passwordTokenManager.isRecoveryTokenValid(user, token));
}
@Test
public void testConsumeRecoveryToken() throws Exception {
final User user = userManager.getUserByUsername("user");
final Integer version = user.getVersion();
final String token = passwordTokenManager.generateRecoveryToken(user);
Assert.assertNotNull(token);
Assert.assertTrue(passwordTokenManager.isRecoveryTokenValid(user, token));
// start SMTP Server
final Wiser wiser = new Wiser();
wiser.setPort(smtpPort);
wiser.start();
userManager.updatePassword(user.getUsername(), null, token, "user", "");
wiser.stop();
assertTrue(wiser.getMessages().size() == 1);
Assert.assertTrue(user.getVersion() > version);
Assert.assertFalse(passwordTokenManager.isRecoveryTokenValid(user, token));
}