@Test public void shouldOnEmailAddressNotUpdateAnythingIfErrors() { EmailAddress expectedEmailAddress = new EmailAddress("invalid"); setupUpdateEmailAddress(expectedEmailAddress.getEmailAddress()); when(bindingResult.hasErrors()).thenReturn(true); underTest.updateCommunicationEmailAddress( request, response, false, expectedEmailAddress, bindingResult, modelMap); verifyNoUpdatesDone(); }
@Test public void shouldOnErrorsForUpdateEmailAddressReturnMainFormAgain() { EmailAddress expectedEmailAddress = new EmailAddress("invalid"); setupUpdateEmailAddress(expectedEmailAddress.getEmailAddress()); when(bindingResult.hasErrors()).thenReturn(true); assertMainProfilePageViewName( underTest.updateCommunicationEmailAddress( request, response, false, expectedEmailAddress, bindingResult, modelMap)); }
@Test public void shouldOnErrorsForUpdateEmailAddressReturnPlayerObjectAgain() { EmailAddress expectedEmailAddress = new EmailAddress("dont@@hit.me"); PlayerProfile expectedUserProfile = setupUpdateEmailAddress(expectedEmailAddress.getEmailAddress()); when(bindingResult.hasErrors()).thenReturn(true); underTest.updateCommunicationEmailAddress( request, response, false, expectedEmailAddress, bindingResult, modelMap); assertModelMapContainsPlayerObject(expectedUserProfile); }