List of usage examples for org.springframework.web.servlet ModelAndView getViewName
@Nullable
public String getViewName()
From source file:org.unidle.web.SegmentIoApiKeyInterceptor.java
@Override public void postHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final ModelAndView modelAndView) throws Exception { if (modelAndView.getView() instanceof RedirectView) { return;/*from w w w. j av a 2 s . c om*/ } if (modelAndView.getViewName() != null && modelAndView.getViewName().startsWith(REDIRECT_URL_PREFIX)) { return; } String packageName = ""; if (handler instanceof HandlerMethod) { packageName = ClassUtils.getPackageName(((HandlerMethod) handler).getBean().getClass()); } if (packageName.startsWith("org.unidle")) { modelAndView.addObject(SEGMENT_IO_API_KEY.getName(), segmentIoApiKey); } }
From source file:org.unidle.web.CurrentUserInterceptor.java
@Override public void postHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final ModelAndView modelAndView) throws Exception { if (modelAndView.getView() instanceof RedirectView) { return;/*from ww w. j a v a 2 s.c om*/ } if (modelAndView.getViewName() != null && modelAndView.getViewName().startsWith(REDIRECT_URL_PREFIX)) { return; } String packageName = ""; if (handler instanceof HandlerMethod) { packageName = ClassUtils.getPackageName(((HandlerMethod) handler).getBean().getClass()); } if (packageName.startsWith("org.unidle")) { modelAndView.addObject(CURRENT_USER.getName(), userService.currentUser()); } }
From source file:org.openmrs.web.controller.patient.PatientIdentifierTypeFormControllerTest.java
@Test public void shouldNotSavePatientIdentifierTypeWhenPatientIdentifierTypesAreLocked() throws Exception { request.addParameter("save", "Save Identifier Type"); ModelAndView mav = controller.handleRequest(request, response); Assert.assertEquals("The save attempt should have failed!", "index.htm", mav.getViewName()); Assert.assertNotEquals("patientIdentifierType.form", mav.getViewName()); Assert.assertNotNull(Context.getPersonService().getPersonAttributeType(1)); }
From source file:com.ge.predix.acs.commons.web.BaseRestApiTest.java
@Test public void testBaseRestApi() { RestErrorHandler errorHandler = Mockito.mock(RestErrorHandler.class); HttpServletRequest request = new MockHttpServletRequest(); HttpServletResponse response = new MockHttpServletResponse(); Exception e = new Exception(); ModelAndView errorResponse = new ModelAndView(); errorResponse.setViewName("ErrorDetails"); Mockito.when(errorHandler.createApiErrorResponse(e, request, response)).thenReturn(errorResponse); BaseRestApi baseRestApi = new BaseRestApi(); baseRestApi.setRestErrorHandler(errorHandler); ModelAndView actualErrorResponse = baseRestApi.handleException(e, request, response); Assert.assertNotNull(actualErrorResponse); Assert.assertEquals(actualErrorResponse.getViewName(), "ErrorDetails"); Mockito.verify(errorHandler, Mockito.times(1)).createApiErrorResponse(e, request, response); }
From source file:org.openmrs.web.controller.person.PersonAttributeTypeFormControllerTest.java
@Test public void shouldNotSavePersonAttributeTypeWhenPersonAttributeTypesAreLocked() throws Exception { request.addParameter("save", "Save Person Attribute Type"); ModelAndView mav = controller.handleRequest(request, response); Assert.assertEquals("The save attempt should have failed!", "index.htm", mav.getViewName()); Assert.assertNotEquals("PersonAttributeType.form", mav.getViewName()); Assert.assertNotNull(Context.getPersonService().getPersonAttributeType(1)); }
From source file:com.carlos.projects.billing.ui.controllers.DocumentControllerTest.java
@Test public void shouldRenderTheCorrectView() throws Exception { //Given/*from w w w .j ava2 s. c o m*/ documentController.setViewName(DOCUMENT_VIEW_NAME); //When ModelAndView modelAndView = documentController.handleRequestInternal(request, response); //Then assertThat("The view name is wrong", modelAndView.getViewName(), is(DOCUMENT_VIEW_NAME)); }
From source file:org.openmrs.web.controller.patient.PatientIdentifierTypeFormControllerTest.java
@Test public void shouldNotDeletePatientIdentifierTypeWhenPatientIdentifierTypesAreLocked() throws Exception { request.addParameter("purge", "Delete Identifier Type"); ModelAndView mav = controller.handleRequest(request, response); Assert.assertEquals("The delete attempt should have failed!", "index.htm", mav.getViewName()); Assert.assertNotEquals("patientIdentifierType.form", mav.getViewName()); Assert.assertNotNull(Context.getPersonService().getPersonAttributeType(1)); }
From source file:org.unidle.web.BuildTimestampInterceptor.java
@Override public void postHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final ModelAndView modelAndView) throws Exception { if (modelAndView.getView() instanceof RedirectView) { return;/*from w w w .j a va 2 s. c o m*/ } if (modelAndView.getViewName() != null && modelAndView.getViewName().startsWith(REDIRECT_URL_PREFIX)) { return; } String packageName = ""; if (handler instanceof HandlerMethod) { packageName = ClassUtils.getPackageName(((HandlerMethod) handler).getBean().getClass()); } if (packageName.startsWith("org.unidle")) { modelAndView.addObject(BUILD_TIMESTAMP.getName(), timestamp); } }
From source file:org.openmrs.web.controller.patient.PatientIdentifierTypeFormControllerTest.java
@Test public void shouldNotRetirePatientIdentifierTypeWhenPatientIdentifierTypesAreLocked() throws Exception { request.addParameter("retire", "Retire Identifier 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("patientIdentifierType.form", mav.getViewName()); Assert.assertNotNull(Context.getPersonService().getPersonAttributeType(1)); }
From source file:org.openmrs.web.controller.person.PersonAttributeTypeFormControllerTest.java
@Test public void shouldNotDeletePersonAttributeTypeWhenPersonAttributeTypesAreLocked() throws Exception { request.addParameter("purge", "Delete Person Attribute Type"); ModelAndView mav = controller.handleRequest(request, response); Assert.assertEquals("The delete attempt should have failed!", "index.htm", mav.getViewName()); Assert.assertNotEquals("PersonAttributeType.form", mav.getViewName()); Assert.assertNotNull(Context.getPersonService().getPersonAttributeType(1)); }