Example usage for org.springframework.mock.web MockHttpServletResponse getLocale

List of usage examples for org.springframework.mock.web MockHttpServletResponse getLocale

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpServletResponse getLocale.

Prototype

@Override
    public Locale getLocale() 

Source Link

Usage

From source file:org.jtalks.jcommune.web.controller.UserProfileControllerTest.java

@Test(enabled = false)
public void saveEditedProfileWithCorrectEnteredDataShouldMoveUserInUpdatedProfile() throws NotFoundException {
    JCUser user = getUser();//from w  ww .j av  a  2 s.c o m
    EditUserProfileDto userDto = getEditUserProfileDto();
    MockHttpServletResponse response = new MockHttpServletResponse();
    //
    when(userService.saveEditedUserProfile(anyLong(), any(UserInfoContainer.class))).thenReturn(user);
    when(userService.getCurrentUser()).thenReturn(user);

    BindingResult bindingResult = new BeanPropertyBindingResult(userDto, "editedUser");

    ModelAndView mav = profileController.saveEditedProfile(userDto, bindingResult, response);

    String expectedUrl = "redirect:/users/" + user.getId();
    assertViewName(mav, expectedUrl);
    assertEquals(response.getLocale().getLanguage(), user.getLanguage().getLocale().getLanguage());
    verify(userService).saveEditedUserProfile(anyLong(), any(UserInfoContainer.class));
}