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:se.vgregion.pubsub.admin.controller.AdminControllerTest.java

@Test
public void newSubscriber() throws Exception {
    ModelAndView mav = controller.newPushSubscriber();

    Assert.assertEquals("admin/push-edit", mav.getViewName());
}

From source file:com.enonic.cms.server.service.portal.mvc.controller.AbstractSiteController.java

private ModelAndView logAndReturn(ModelAndView modelAndView) {
    if (modelAndView != null) {
        LOG.trace(modelAndView.getViewName());
    }//from   w  w  w .  j av a 2 s  . com
    return modelAndView;
}

From source file:nl.eveoh.sakai.mytimetable.tool.ToolControllerTest.java

@Test
public void testIndexPage() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setMethod("GET");

    ModelAndView modelAndView = toolController.handleRequest(request, response);

    Assert.assertEquals("Should get index page.", "index", modelAndView.getViewName());
    Assert.assertEquals(200, response.getStatus());
}

From source file:se.vgregion.pubsub.admin.controller.AdminControllerTest.java

@Test
public void newPolledPublisher() throws Exception {
    ModelAndView mav = controller.newPolledPublisher();

    Assert.assertEquals("admin/polled-edit", mav.getViewName());
}

From source file:se.vgregion.urlservice.controllers.BookmarkControllerTest.java

@Test
public void shortenLongUrl() throws IOException {
    ModelAndView mav = controller.create(LONG_URL, null, null, authentication);

    Assert.assertEquals("redirect:/u/roblu/b/foo/edit", mav.getViewName());
}

From source file:org.openmrs.web.controller.encounter.EncounterTypeFormControllerTest.java

@Test
public void shouldNotDeleteEncounterTypeWhenEncounterTypesAreLocked() throws Exception {
    // dataset to lock encounter types
    executeDataSet("org/openmrs/web/encounter/include/EncounterTypeFormControllerTest.xml");

    EncounterService es = Context.getEncounterService();

    EncounterTypeFormController controller = (EncounterTypeFormController) applicationContext
            .getBean("encounterTypeForm");
    controller.setApplicationContext(applicationContext);
    controller.setSuccessView("index.htm");
    controller.setFormView("EncounterType.form");

    // setting up the request and doing an initial "get" equivalent to the user loading the page for the first time
    MockHttpServletRequest request = new MockHttpServletRequest("GET",
            "/admin/encounters/encounterType.form?encounterTypeId=1");
    request.setSession(new MockHttpSession(null));
    HttpServletResponse response = new MockHttpServletResponse();
    controller.handleRequest(request, response);

    // set this to be a page submission
    request.setMethod("POST");

    request.addParameter("action", "Delete EncounterType"); // so that the form is processed

    // send the parameters to the controller
    ModelAndView mav = controller.handleRequest(request, response);

    Assert.assertEquals("The purge attempt should have failed!", "EncounterType.form", mav.getViewName());
    Assert.assertSame(controller.getFormView(), mav.getViewName());
    Assert.assertNotNull(es.getEncounterType(1));
}

From source file:se.vgregion.pubsub.admin.controller.AdminControllerTest.java

@Test
public void createPolledPublisher() throws Exception {
    ModelAndView mav = controller.createPolledPublisher(TOPIC);

    Assert.assertEquals("redirect:..", mav.getViewName());
    Mockito.verify(adminService).createPolledPublishers(TOPIC);
}

From source file:se.vgregion.urlservice.controllers.BookmarkControllerTest.java

@Test
public void shortenLongUrlWithSlug() throws IOException {
    ModelAndView mav = controller.create(LONG_URL, "slug", null, authentication);

    Assert.assertEquals("redirect:/u/roblu/b/slug/edit", mav.getViewName());
}

From source file:se.vgregion.urlservice.controllers.BookmarkControllerTest.java

@Test
public void shortenLongUrlWithSlugAndOwner() throws IOException {
    ModelAndView mav = controller.create(LONG_URL, "slug", null, authentication);

    Assert.assertEquals("redirect:/u/roblu/b/slug/edit", mav.getViewName());
}

From source file:se.vgregion.pubsub.admin.controller.AdminControllerTest.java

@Test
public void editSubscriber() throws Exception {
    UUID id = UUID.randomUUID();
    PushSubscriber subscriber = mock(PushSubscriber.class);
    when(adminService.getPushSubscriber(id)).thenReturn(subscriber);

    ModelAndView mav = controller.editPushSubscriber(id);

    Assert.assertEquals("admin/push-edit", mav.getViewName());
    Assert.assertEquals(subscriber, mav.getModel().get("subscriber"));
}