### Question:
UserManager implements Serializable { public ResultCode cancelPasswordResetTokens(int userId) { boolean ok = databaseModel.cancelAllPasswordResetTokens(userId); if (ok) { return ResultCode.OK; } else { LOGGER.error("DB error: Failed to cancel password reset tokens for user with id={}.", userId); return ResultCode.DATABASE_ERROR; } } UserManager(); ResultCode cancelPasswordResetTokens(int userId); ResultCode cancelRegistration(int userId, String password); ResultCode changePassword(int userId, String oldPassword, String newPassword); PasswordCheckResult checkPassword(String password, String passwordConfirmation); ResultCode confirmManualRegistration(String email, String registrationControlCode, String password); ResultCode confirmRegistration(String email, String registrationControlCode); ResultCode createPasswordResetToken(String email); User getCurrentUser(); int getRegisteredUserCount(Date since); boolean isPasswordResetTokenValid(String email, String tokenKey); boolean isPasswordValid(int userId, String password); ResultCode logIn(String userNameOrEmail, String password, String usersIp); User loginOrRegisterWithSocialAccount(SocialAccountDetails details, String usersIp); ResultCode logInWithoutPassword(String userNameOrEmail); void logOut(); ResultCode registerUser(String email, String name, String password, boolean registrationConfirmed); ResultCode registerUserManually(String email, String name, int rank); ResultCode resendRegistrationEmail(String address); ResultCode resetPassword(String userEmail, String tokenKey, String newPassword); boolean sendTestingEmail(EmailType emailType, String address);  }### Answer:
@Test public void testCancelPasswordResetTokens() { Mockito.when(databaseModel.cancelAllPasswordResetTokens(1)).thenReturn(true); ResultCode result = userManager.cancelPasswordResetTokens(1); Assert.assertEquals(ResultCode.OK, result); Mockito.verify(databaseModel).cancelAllPasswordResetTokens(1); }
@Test public void testCancelPasswordResetTokensDatabaseError() { Mockito.when(databaseModel.cancelAllPasswordResetTokens(1)).thenReturn(false); ResultCode result = userManager.cancelPasswordResetTokens(1); Assert.assertEquals(ResultCode.DATABASE_ERROR, result); Mockito.verify(databaseModel).cancelAllPasswordResetTokens(1); }