@Test
 public void shouldOnErrorsForPlayerInfoReturnPlayerObjectAgain() {
   PlayerProfile expectedUserProfile = setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(true);
   underTest.updateUserProfileInfo(
       request,
       response,
       false,
       new PlayerProfileSummaryBuilder(expectedUserProfile).build(),
       bindingResult,
       modelMap);
   assertModelMapContainsPlayerObject(expectedUserProfile);
 }
 @Test
 public void shouldOnErrorsForPlayerInfoReturnMainFormAgain() {
   PlayerProfile expectedUserProfile = setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(true);
   assertMainProfilePageViewName(
       underTest.updateUserProfileInfo(
           request,
           response,
           false,
           new PlayerProfileSummaryBuilder(expectedUserProfile).build(),
           bindingResult,
           modelMap));
 }
 @Test
 public void shouldOnUpdateUserProfileInfoNotUpdateAnythingIfErrors() {
   PlayerProfile expectedUserProfile = setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(true);
   underTest.updateUserProfileInfo(
       request,
       response,
       false,
       new PlayerProfileSummaryBuilder(expectedUserProfile).build(),
       bindingResult,
       modelMap);
   verifyNoUpdatesDone();
 }
 @Test
 public void shouldOnUpdateUserProfileReturnCorrectPartialValue() {
   PlayerProfile expectedUserProfile = setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(false);
   ModelAndView modelAndView =
       underTest.updateUserProfileInfo(
           request,
           response,
           true,
           new PlayerProfileSummaryBuilder(expectedUserProfile).build(),
           bindingResult,
           modelMap);
   assertTrue(((RedirectView) modelAndView.getView()).getUrl().endsWith("?partial=true"));
 }
  @Test
  public void shouldClearPlayerProfileCacheOnUpdateUserProfileInfoForUser() {
    String expectedAvatarUrl = "http://lol/avatar";
    String expectedGender = "M";
    String expectedCountry = "Brerea";
    DateTime expectedDateOfBirth = new DateTime(System.currentTimeMillis());

    PlayerProfile expectedUserProfile =
        setUpUserProfileInfo(
            expectedAvatarUrl, expectedGender, expectedCountry, expectedDateOfBirth);
    PlayerProfileSummary expectedUserProfileInfo =
        new PlayerProfileSummaryBuilder(expectedUserProfile).build();
    underTest.updateUserProfileInfo(
        request, response, false, expectedUserProfileInfo, bindingResult, modelMap);

    verify(playerProfileCacheRemovalListener).playerUpdated(expectedUserProfile.getPlayerId());
  }
  @Test
  public void shouldUpdateUserProfileInfoForUserAndReturnCorrectView() {
    String expectedAvatarUrl = "http://lol/avatar";
    String expectedGender = "M";
    String expectedCountry = "Brerea";
    DateTime expectedDateOfBirth = new DateTime(System.currentTimeMillis());

    PlayerProfile expectedUserProfile =
        setUpUserProfileInfo(
            expectedAvatarUrl, expectedGender, expectedCountry, expectedDateOfBirth);
    PlayerProfileSummary expectedUserProfileInfo =
        new PlayerProfileSummaryBuilder(expectedUserProfile).build();
    when(bindingResult.hasErrors()).thenReturn(false);

    assertRedirectToMainProfilePage(
        underTest.updateUserProfileInfo(
            request, response, false, expectedUserProfileInfo, bindingResult, modelMap));
    assertModelMapIsEmptyToAvoidQueryStringOnRedirect(modelMap);
  }