@Test
 public void shouldOnErrorsForUpdatePasswordReturnMainFormAgain() {
   PlayerProfile userProfile = setUpPlayerProfile();
   PasswordChangeRequest passwordChangeForm = setUpPasswordUpdate();
   when(bindingResult.hasErrors()).thenReturn(true);
   assertMainProfilePageViewName(
       underTest.updatedPassword(
           request, response, false, passwordChangeForm, bindingResult, modelMap));
 }
 @Test
 public void shouldRedirectOnSuccessfulUpdateOfPassword() {
   PlayerProfile userProfile = setUpPlayerProfile();
   PasswordChangeRequest passwordChangeForm = setUpPasswordUpdate();
   when(bindingResult.hasErrors()).thenReturn(false);
   assertRedirectToMainProfilePage(
       underTest.updatedPassword(
           request, response, false, passwordChangeForm, bindingResult, modelMap));
   assertModelMapIsEmptyToAvoidQueryStringOnRedirect(modelMap);
 }
 @Test
 public void shouldOnUpdatePasswordReturnCorrectPartialValue() {
   PlayerProfile userProfile = setUpPlayerProfile();
   PasswordChangeRequest passwordChangeForm = setUpPasswordUpdate();
   when(bindingResult.hasErrors()).thenReturn(false);
   ModelAndView modelAndView =
       underTest.updatedPassword(
           request, response, true, passwordChangeForm, bindingResult, modelMap);
   assertTrue(((RedirectView) modelAndView.getView()).getUrl().endsWith("?partial=true"));
 }
 @Test
 public void shouldOnUpdatePasswordNotUpdateAnythingIfErrors() {
   PlayerProfile userProfile = setUpPlayerProfile();
   PasswordChangeRequest passwordChangeForm = setUpPasswordUpdate();
   passwordChangeForm =
       new PasswordChangeFormTestBuilder(passwordChangeForm).withConfirmNewPassword("bob").build();
   when(bindingResult.hasErrors()).thenReturn(true);
   underTest.updatedPassword(
       request, response, false, passwordChangeForm, bindingResult, modelMap);
   verify(passwordChangeFormValidator).validate(passwordChangeForm, bindingResult);
   verify(playerProfileService, never())
       .updatePlayerInfo(any(BigDecimal.class), any(PlayerProfileSummary.class));
 }
 @Test
 public void shouldOnPasswordUpdateReplacePlayerId() {
   PlayerProfile userProfile = setUpPlayerProfile();
   PasswordChangeRequest passwordChangeForm = setUpPasswordUpdate();
   when(bindingResult.hasErrors()).thenReturn(false);
   underTest.updatedPassword(
       request, response, false, passwordChangeForm, bindingResult, modelMap);
   PasswordChangeRequest expectedPasswordChangeForm =
       new PasswordChangeFormTestBuilder(passwordChangeForm)
           .withPlayerId(userProfile.getPlayerId())
           .build();
   verify(playerProfileService)
       .updatePassword(userProfile.getPlayerId(), expectedPasswordChangeForm);
 }
  @Test
  public void shouldOnUpdatePasswordIfErrorsReturnResetPasswordChangeForm() {
    PlayerProfile userProfile = setUpPlayerProfile();
    PasswordChangeRequest passwordChangeForm = setUpPasswordUpdate();
    passwordChangeForm =
        new PasswordChangeFormTestBuilder(passwordChangeForm).withConfirmNewPassword("bob").build();

    when(bindingResult.hasErrors()).thenReturn(true);
    underTest.updatedPassword(
        request, response, false, passwordChangeForm, bindingResult, modelMap);

    PasswordChangeRequest expectedPasswordChangeForm =
        new PasswordChangeFormTestBuilder(passwordChangeForm).build();
    expectedPasswordChangeForm.clear();

    assertEquals(expectedPasswordChangeForm, passwordChangeForm);
  }