### Question:
UserManager implements Serializable { public ResultCode logInWithoutPassword(String userNameOrEmail) { User user; if (EmailUtils.isEmailValid(userNameOrEmail)) { user = databaseModel.getUserByEmail(userNameOrEmail); } else { user = databaseModel.getUserByName(userNameOrEmail); } if (user == null) { return ResultCode.NO_SUCH_USER; } if (!user.isRegistrationConfirmed()) { return ResultCode.REGISTRATION_NOT_CONFIRMED; } sessionModel.setCurrentUser(user); 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 testLogInWithoutPasswordWithEmailNoSuchUser() { Mockito.when(databaseModel.getUserByEmail("john@example.com")).thenReturn(null); ResultCode result = userManager.logInWithoutPassword("john@example.com"); Assert.assertEquals(ResultCode.NO_SUCH_USER, result); }
@Test public void testLogInWithoutPasswordWithEmailRegistrationNotConfirmed() { Mockito.when(databaseModel.getUserByEmail("carl@example.com")).thenReturn(userWithUnfinishedRegistration); ResultCode result = userManager.logInWithoutPassword("carl@example.com"); Assert.assertEquals(ResultCode.REGISTRATION_NOT_CONFIRMED, result); Mockito.verify(sessionModel, Mockito.never()).setCurrentUser(Mockito.notNull(User.class)); }