### Question:
UserManager implements Serializable { public ResultCode confirmManualRegistration(String email, String registrationControlCode, String password) { User user = databaseModel.getUserByEmail(email); ResultCode checkResult = checkRegistrationConfirmationPreconditions(user, registrationControlCode); if (checkResult != ResultCode.OK) { return checkResult; } boolean ok = databaseModel.confirmUserRegistration(email); if (!ok) { LOGGER.error("DB error: Failed to confirm registration for email {}.", email); return ResultCode.DATABASE_ERROR; } UserPassword userPassword = createUserPassword(password); ok = databaseModel.setUserPassword(user.getId(), userPassword); if (!ok) { LOGGER.error("DB error: Failed to set password for user with id={}.", user.getId()); return ResultCode.DATABASE_ERROR; } return ResultCode.OK; } 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 testConfirmManualRegistration() throws Exception { Mockito.when(databaseModel.getUserByEmail("john@example.com")).thenReturn(userWithUnfinishedRegistration); Mockito.when(databaseModel.confirmUserRegistration("john@example.com")).thenReturn(true); Mockito.when(databaseModel.setUserPassword(Mockito.eq(2), Mockito.any(UserPassword.class))).thenReturn(true); ResultCode result = userManager.confirmManualRegistration("john@example.com", userWithUnfinishedRegistration.getRegistrationControlCode(), "password"); Assert.assertEquals(ResultCode.OK, result); Mockito.verify(databaseModel).confirmUserRegistration("john@example.com"); ArgumentCaptor<UserPassword> passwordCaptor = ArgumentCaptor.forClass(UserPassword.class); Mockito.verify(databaseModel).setUserPassword(Mockito.eq(2), passwordCaptor.capture()); UserPassword newPassword = passwordCaptor.getValue(); assertPasswordData("password", newPassword); }