### Question:
PasswordResetController { @RequestMapping(value = "passwordReset", method = RequestMethod.POST) @ResponseBody public String processForgotPasswordFormView(@RequestParam final String login) { if (StringUtils.isBlank(login)) { return "loginIsBlank"; } return performPasswordReseting(login); }  @RequestMapping(value = "passwordReset", method = RequestMethod.GET) ModelAndView getForgotPasswordFormView(@RequestParam(required = false, defaultValue = FALSE) final Boolean iframe,
            @RequestParam(required = false, defaultValue = FALSE) final Boolean popup, final Locale locale); @RequestMapping(value = "passwordReset", method = RequestMethod.POST) @ResponseBody String processForgotPasswordFormView(@RequestParam final String login);  }### Answer:
@Test public final void shouldReturnSuccess() throws Exception { String result = passwordResetController.processForgotPasswordFormView(EXISTING_USER_NAME); assertEquals("success", result); verify(passwordReminderService, times(1)).generateAndSendNewPassword(EXISTING_USER_NAME); verify(passwordReminderService, never()).generateAndSendNewPassword(not(Mockito.eq(EXISTING_USER_NAME))); }
@Test public final void shouldReturnUserNotFound() throws Exception { String result = passwordResetController.processForgotPasswordFormView("userThatDoesNotExists"); assertEquals("userNotFound", result); verify(passwordReminderService, times(1)).generateAndSendNewPassword(Mockito.anyString()); }
@Test public final void shouldReturnLoginIsBlankWhenLoginIsNull() throws Exception { String result = passwordResetController.processForgotPasswordFormView(null); assertEquals("loginIsBlank", result); verifyZeroInteractions(passwordReminderService); }
@Test public final void shouldReturnLoginIsBlankWhenLoginIsEmpty() throws Exception { String result = passwordResetController.processForgotPasswordFormView(""); assertEquals("loginIsBlank", result); verifyZeroInteractions(passwordReminderService); }
@Test public final void shouldReturnLoginIsBlank() throws Exception { String result = passwordResetController.processForgotPasswordFormView(" "); assertEquals("loginIsBlank", result); verifyZeroInteractions(passwordReminderService); }
@Test public final void shouldReturnErrorWhenUnexpectedErrorOccured() throws Exception { doThrow(new RuntimeException()).when(passwordReminderService).generateAndSendNewPassword(Mockito.anyString()); String result = passwordResetController.processForgotPasswordFormView(EXISTING_USER_NAME); assertEquals("error", result); }
@Test public final void shouldReturnInvalidMailConfigWhenMailConfigurationErrorOccured() throws Exception { doThrow(new MailConfigurationException("error")).when(passwordReminderService).generateAndSendNewPassword( Mockito.anyString()); String result = passwordResetController.processForgotPasswordFormView(EXISTING_USER_NAME); assertEquals("invalidMailConfig", result); }
@Test public final void shouldReturnInvalidMailAddressWhenMailConfigurationErrorOccured() throws Exception { doThrow(new InvalidMailAddressException("error")).when(passwordReminderService).generateAndSendNewPassword( Mockito.anyString()); String result = passwordResetController.processForgotPasswordFormView(EXISTING_USER_NAME); assertEquals("invalidMailAddress", result); }