### Question:
UserManager implements Serializable { public boolean sendTestingEmail(EmailType emailType, String address) { switch (emailType) { case REGISTRATION: return emailSender.sendRegistrationEmail(address, "[userName]", 0, "63ab83e73fee9c2113f625fab4ac8c65"); case MANUAL_REGISTRATION: User registrator = new User(0, "[adminName]", "admin@test.com", "", true, null, UserRanks.ADMIN); return emailSender.sendManualRegistrationEmail(address, "[userName]", 0, "63ab83e73fee9c2113f625fab4ac8c65", registrator); case LOST_PASSWORD: return emailSender.sendLostPasswordEmail(address, "63ab83e73fee9c2113f625fab4ac8c65"); default: return false; } } 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 testSendTestingEmail() { Mockito.when(emailSender.sendLostPasswordEmail(Mockito.eq("john@example.com"), Mockito.notNull(String.class))).thenReturn(true); boolean result = userManager.sendTestingEmail(EmailType.LOST_PASSWORD, "john@example.com"); Assert.assertEquals(true, result); Mockito.reset(emailSender); Mockito.when(emailSender.sendRegistrationEmail(Mockito.eq("john@example.com"), Mockito.notNull(String.class), Mockito.anyInt(), Mockito.notNull(String.class))).thenReturn( true); result = userManager.sendTestingEmail(EmailType.REGISTRATION, "john@example.com"); Assert.assertEquals(true, result); }
@Test public void testSendTestingEmailFailedToSendEmail() { Mockito.when(emailSender.sendLostPasswordEmail(Mockito.eq("john@example.com"), Mockito.notNull(String.class))).thenReturn(false); boolean result = userManager.sendTestingEmail(EmailType.LOST_PASSWORD, "john@example.com"); Assert.assertEquals(false, result); Mockito.reset(emailSender); Mockito.when(emailSender.sendRegistrationEmail(Mockito.eq("john@example.com"), Mockito.notNull(String.class), Mockito.anyInt(), Mockito.notNull(String.class))).thenReturn( false); result = userManager.sendTestingEmail(EmailType.REGISTRATION, "john@example.com"); Assert.assertEquals(false, result); }