コード例 #1
0
 @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);
 }
コード例 #2
0
 @Test
 public void shouldOnErrorsForPlayerInfoReturnMainFormAgain() {
   PlayerProfile expectedUserProfile = setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(true);
   assertMainProfilePageViewName(
       underTest.updateUserProfileInfo(
           request,
           response,
           false,
           new PlayerProfileSummaryBuilder(expectedUserProfile).build(),
           bindingResult,
           modelMap));
 }
コード例 #3
0
 @Test
 public void shouldOnUpdateUserProfileInfoNotUpdateAnythingIfErrors() {
   PlayerProfile expectedUserProfile = setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(true);
   underTest.updateUserProfileInfo(
       request,
       response,
       false,
       new PlayerProfileSummaryBuilder(expectedUserProfile).build(),
       bindingResult,
       modelMap);
   verifyNoUpdatesDone();
 }
コード例 #4
0
 @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"));
 }
コード例 #5
0
  @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());
  }
コード例 #6
0
  @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);
  }