Example usage for org.springframework.web.servlet ModelAndView getViewName

List of usage examples for org.springframework.web.servlet ModelAndView getViewName

Introduction

In this page you can find the example usage for org.springframework.web.servlet ModelAndView getViewName.

Prototype

@Nullable
public String getViewName() 

Source Link

Document

Return the view name to be resolved by the DispatcherServlet via a ViewResolver, or null if we are using a View object.

Usage

From source file:org.n52.sensorweb.series.policy.editor.ctrl.SimplePermissionEditorControllerTest.java

@Test
public void testListPermission() {
    ModelAndView mav = controller.listPermissions(null);
    Assert.assertThat(mav.getViewName(), is("listPermissionSets"));
    Assert.assertTrue(mav.getModel().containsKey("permissionSets"));

    Map<String, Object> modelMap = mav.getModelMap();
    List<PermissionSet> permissionSets = (List<PermissionSet>) modelMap.get("permissionSets");
    Assert.assertNotNull(permissionSets);
    Assert.assertThat(permissionSets, is(not(empty())));
}

From source file:shiver.me.timbers.security.web.controller.HomeControllerTest.java

@Test
public void Can_display_home_page() {

    final String username = "User Name";
    final User user = mock(User.class);

    // Given//from   w w w . j  a v a 2  s  .c om
    given(user.getUsername()).willReturn(username);

    // When
    final ModelAndView actual = new HomeController().display(user);

    // Then
    assertThat(actual.getViewName(), equalTo("home"));
    assertThat(actual.getModel().get("username").toString(), equalTo(username));
}

From source file:org.hobsoft.contacts.server.controller.AuthenticationControllerTest.java

@Test
public void loginFormReturnsView() {
    ModelAndView actual = controller.loginForm(null, null);

    assertEquals("auth/login", actual.getViewName());
}

From source file:com.benfante.minimark.controllers.HomeControllerTest.java

public void testWelcome() throws Exception {
    resetRequestAndResponse();/*from   w  w w .  ja v  a2s .  c o  m*/
    req.setMethod("GET");
    req.setRequestURI("/home/welcome.html");
    req = new MockHttpServletRequest("GET", "/home/welcome.html");
    ModelAndView mv = methodHandler.handle(req, res, controller);
    assertEquals("welcome", mv.getViewName());
    assertNotNull(mv.getModel().get("assessments"));
}

From source file:nl.surfnet.coin.selfservice.control.LogoutControllerTest.java

@Test
public void testLogout() throws Exception {
    SessionStatus status = new SimpleSessionStatus();
    final ModelAndView modelAndView = controller.logout(new MockHttpServletRequest(), status);
    assertEquals("logout", modelAndView.getViewName());
    assertTrue(modelAndView.getModelMap().isEmpty());
}

From source file:de.hybris.platform.b2bpunchoutaddon.interceptors.PunchOutBeforeViewHandler.java

@Override
public void beforeView(final HttpServletRequest request, final HttpServletResponse response,
        final ModelAndView modelAndView) throws PunchOutException {
    final String viewName = modelAndView.getViewName();
    try {//from   w  w  w  . jav  a  2s  . c  o  m
        if (StringUtils.isNotBlank(
                (String) request.getSession().getAttribute(B2bpunchoutaddonConstants.PUNCHOUT_USER))) {
            modelAndView.setViewName(getPunchoutView(viewName));
            setPunchoutModeInModel(modelAndView.getModelMap());
        }
    } catch (final Exception e) {
        throw new PunchOutException(PunchOutResponseCode.INTERNAL_SERVER_ERROR, e.getMessage(), e);
    }
}

From source file:com.carlos.projects.billing.ui.controllers.NewDocumentControllerTest.java

@Test
public void shouldForwardToNewDocumentPage() throws Exception {
    //given//from   w w  w .  j a  va2  s.c  o m
    NewDocumentController controller = new NewDocumentController();
    controller.setViewName("newDocument");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();

    //when
    ModelAndView modelAndView = controller.handleRequest(request, response);

    //then
    assertThat(modelAndView.getViewName(), is("newDocument"));
}

From source file:InventoryControllerTests.java

@Test
public void testHandleRequestView() throws Exception {
    InventoryController controller = new InventoryController();
    SimpleProductManager spm = new SimpleProductManager();
    spm.setProductDao(new InMemoryProductDao(new ArrayList<Product>()));
    controller.setProductManager(spm);// w  ww  .j  a v  a 2  s  . com
    //controller.setProductManager(new SimpleProductManager());
    ModelAndView modelAndView = controller.handleRequest(null, null);
    assertEquals("hello", modelAndView.getViewName());
    assertNotNull(modelAndView.getModel());
    Map modelMap = (Map) modelAndView.getModel().get("model");
    String nowValue = (String) modelMap.get("now");
    assertNotNull(nowValue);
}

From source file:com.carlos.projects.billing.ui.controllers.ShowComponentsControllerTest.java

@Test
public void shouldForwardToNewDocumentPage() throws Exception {
    //given/*from w  w  w. j a v  a  2 s. c om*/
    ShowComponentsController controller = new ShowComponentsController();
    controller.setViewName("showComponents");
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();

    //when
    ModelAndView modelAndView = controller.handleRequest(request, response);

    //then
    assertThat(modelAndView.getViewName(), is("showComponents"));
}

From source file:com.sarm.aussiepayslipgenerator.view.PaySlipControllerTest.java

/**
 * Test of publishEmployeeForm method, of class PaySlipController.
 *//*w  ww. j  a  v a 2 s . c  o m*/
@Test
public void testEmployeeInfoInput() {
    System.out.println("employeeInfoInput");

    ModelAndView result = instance.publishEmployeeForm();
    assertEquals("employeeInputform", result.getViewName());

}