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.openmrs.web.controller.patient.PatientIdentifierTypeFormControllerTest.java

@Test
public void shouldNotUnretirePatientIdentifierTypeWhenPatientIdentifierTypesAreLocked() throws Exception {
    request.addParameter("unretire", "Unretire Identifier Type");

    ModelAndView mav = controller.handleRequest(request, response);
    Assert.assertEquals("The unretire attempt should have failed!", "index.htm", mav.getViewName());
    Assert.assertNotEquals("patientIdentifierType.form", mav.getViewName());
    Assert.assertNotNull(Context.getPersonService().getPersonAttributeType(1));
}

From source file:org.openmrs.web.controller.person.PersonAttributeTypeFormControllerTest.java

@Test
public void shouldNotRetirePersonAttributeTypeWhenPersonAttributeTypesAreLocked() throws Exception {
    request.addParameter("retire", "Retire Person Attribute Type");
    request.addParameter("retireReason", "Same reason");

    ModelAndView mav = controller.handleRequest(request, response);
    Assert.assertEquals("The retire attempt should have failed!", "index.htm", mav.getViewName());
    Assert.assertNotEquals("PersonAttributeType.form", mav.getViewName());
    Assert.assertNotNull(Context.getPersonService().getPersonAttributeType(1));
}

From source file:org.openmrs.web.controller.person.PersonAttributeTypeFormControllerTest.java

@Test
public void shouldNotUnretirePersonAttributeTypeWhenPersonAttributeTypesAreLocked() throws Exception {
    request.addParameter("unretire", "Unretire Person Attribute Type");

    ModelAndView mav = controller.handleRequest(request, response);
    Assert.assertEquals("The unretire attempt should have failed!", "index.htm", mav.getViewName());
    Assert.assertNotEquals("PersonAttributeType.form", mav.getViewName());
    Assert.assertNotNull(Context.getPersonService().getPersonAttributeType(1));
}

From source file:org.zols.web.interceptor.PagePopulationInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    if (modelAndView != null) {
        modelAndView.addObject("links", linkService.getApplicationLinks());
        modelAndView.addObject("viewName", modelAndView.getViewName());
        modelAndView.setViewName("index");
    }/*from ww  w . j  a v a 2  s  .co  m*/
}

From source file:org.openmrs.web.controller.form.FormFormControllerTest.java

@Test
public void shouldNotSaveAFormWhenFormsAreLocked() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("POST", "/admin/forms/formEdit.form?formId=1");
    request.setSession(new MockHttpSession(null));
    HttpServletResponse response = new MockHttpServletResponse();
    controller.handleRequest(request, response);

    request.addParameter("name", "TRUNK");
    request.addParameter("version", "1");
    request.addParameter("action", "Form.save");
    request.setContentType("application/x-www-form-urlencoded");

    ModelAndView mav = controller.handleRequest(request, response);
    Assert.assertEquals("The save attempt should have failed!", "index.htm", mav.getViewName());
    Assert.assertNotEquals("formEdit.form", mav.getViewName());
    Assert.assertSame(controller.getFormView(), mav.getViewName());
    Assert.assertNotNull(formService.getForm(1));
}

From source file:gov.nih.nci.cabig.caaers.tools.spring.tabbedflow.AutomaticSaveAjaxableFormController.java

protected boolean isAjaxResponseFreeText(ModelAndView modelAndView) {
    return StringUtils.isBlank(modelAndView.getViewName());
    /*if (StringUtils.getBlankIfNull(modelAndView.getViewName()).equals("")) {
    return true;/* www  .j  a  va2s.c  o  m*/
    }
    return false;*/
}

From source file:com.epam.training.taranovski.web.project.controller.LoginControllerTest.java

/**
 * Test of login method, of class LoginController.
 *//*ww  w. j a va  2s . c  om*/
@Test
@Ignore
public void testLogin() {
    System.out.println("login");
    String userName = "testSubjectAdmin";
    String password = "12345678";

    ModelAndView modelAndView = new ModelAndView();

    instance.login(userName, password, modelAndView);
    assertTrue("admin.jsp".equals(modelAndView.getViewName()));
    assertTrue(modelAndView.getModel().containsKey("user"));
    assertTrue("testSubjectAdminName".equals(((Admin) modelAndView.getModel().get("user")).getAdminName()));
}

From source file:com.cisco.ca.cstg.pdi.controllers.license.LicenseControllerTest.java

@Test
public void licenseUpload_returnTypeCheck() throws Exception {
    MockMultipartFile file = new MockMultipartFile("data", "filename.txt", "text/plain", "some xml".getBytes());
    ModelAndView mv = licenseController.licenseUpload(file);
    assertEquals("license/license", mv.getViewName());
}

From source file:fm.last.citrine.web.TaskControllerTest.java

private Map<String, Object> getModel() throws Exception {
    ModelAndView modelAndView = taskController.list(mockRequest, mockResponse);
    assertEquals("tasks_list", modelAndView.getViewName());
    Map<String, Object> model = modelAndView.getModel();
    return model;
}

From source file:org.openmrs.web.controller.form.FormFormControllerTest.java

@Test
public void shouldNotDuplicateAFormWhenFormsAreLocked() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("POST",
            "/admin/forms/formEdit.form?duplicate=true&formId=1");
    request.setSession(new MockHttpSession(null));
    HttpServletResponse response = new MockHttpServletResponse();
    controller.handleRequest(request, response);

    request.addParameter("name", "TRUNK");
    request.addParameter("version", "1");
    request.addParameter("action", "Form.Duplicate");
    request.setContentType("application/x-www-form-urlencoded");

    ModelAndView mav = controller.handleRequest(request, response);
    Assert.assertEquals("The duplicate attempt should have failed!", "index.htm", mav.getViewName());
    Assert.assertNotEquals("formEdit.form", mav.getViewName());
    Assert.assertSame(controller.getFormView(), mav.getViewName());
    Assert.assertNotNull(formService.getForm(1));
}