コード例 #1
0
 @Test
 public void shouldOnUpdateDisplayNameNotUpdateAnythingIfErrors() {
   DisplayName expectedDisplayName = new DisplayName("Super Cool New Name");
   setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(true);
   underTest.updateDisplayName(
       request, response, false, expectedDisplayName, bindingResult, modelMap);
   verifyNoUpdatesDone();
 }
コード例 #2
0
 @Test
 public void shouldOnErrorsForDisplayNameReturnPlayerObjectAgain() {
   DisplayName expectedDisplayName = new DisplayName("Super Cool New Name");
   PlayerProfile expectedUserProfile = setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(true);
   underTest.updateDisplayName(
       request, response, false, expectedDisplayName, bindingResult, modelMap);
   assertModelMapContainsPlayerObject(expectedUserProfile);
 }
コード例 #3
0
 @Test
 public void shouldOnErrorsForDisplayNameReturnMainFormAgain() {
   DisplayName expectedDisplayName = new DisplayName("Super Cool New Name");
   setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(true);
   assertMainProfilePageViewName(
       underTest.updateDisplayName(
           request, response, false, expectedDisplayName, bindingResult, modelMap));
 }
コード例 #4
0
 @Test
 public void shouldOnUpdateDisplayNameReturnCorrectPartialValue() {
   DisplayName expectedDisplayName = new DisplayName("Super Cool New Name");
   setUpPlayerProfile();
   when(bindingResult.hasErrors()).thenReturn(false);
   ModelAndView modelAndView =
       underTest.updateDisplayName(
           request, response, true, expectedDisplayName, bindingResult, modelMap);
   assertTrue(((RedirectView) modelAndView.getView()).getUrl().endsWith("?partial=true"));
 }
コード例 #5
0
  @Test
  public void shouldUpdateDisplayNameForUserAndRedirectToOriginalForm() {
    DisplayName expectedDisplayName = new DisplayName("Super Cool New Name");
    setupUpdateDisplayName(expectedDisplayName.getDisplayName());

    assertRedirectToMainProfilePage(
        underTest.updateDisplayName(
            request, response, false, expectedDisplayName, bindingResult, modelMap));
    assertModelMapIsEmptyToAvoidQueryStringOnRedirect(modelMap);
  }
コード例 #6
0
  @Test
  public void shouldClearPlayerProfileCacheOnUpdateOfDisplayNameForUser() {
    final DisplayName expectedDisplayName = new DisplayName("Super Cool New Name");
    final PlayerProfile userProfile = setupUpdateDisplayName(expectedDisplayName.getDisplayName());

    underTest.updateDisplayName(
        request, response, false, expectedDisplayName, bindingResult, modelMap);

    verify(playerProfileCacheRemovalListener).playerUpdated(userProfile.getPlayerId());
  }
コード例 #7
0
  @Test
  public void shouldUpdateDisplayNameForUser() {
    DisplayName expectedDisplayName = new DisplayName("Super Cool New Name");
    PlayerProfile userProfile = setupUpdateDisplayName(expectedDisplayName.getDisplayName());

    underTest.updateDisplayName(
        request, response, false, expectedDisplayName, bindingResult, modelMap);

    verify(playerProfileService)
        .updateDisplayName(userProfile.getPlayerId(), expectedDisplayName.getDisplayName());
  }