List of usage examples for org.springframework.web.servlet ModelAndView getViewName
@Nullable
public String getViewName()
From source file:de.appsolve.padelcampus.spring.RedirectInterceptor.java
@Override public final void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws SystemException { String redirectHeader = (String) request.getSession().getAttribute(REDIRECT_HEADER); if (!StringUtils.isEmpty(redirectHeader)) { response.addHeader(REDIRECT_HEADER, redirectHeader); request.getSession().removeAttribute(REDIRECT_HEADER); } else if (modelAndView != null) { String viewName = null;//ww w .ja va 2s .co m if (modelAndView.getViewName() != null && modelAndView.getViewName().startsWith(REDIRECT_PREFIX)) { viewName = modelAndView.getViewName().substring(REDIRECT_PREFIX.length()); } else if (modelAndView.getView() != null && modelAndView.getView() instanceof RedirectView) { viewName = modelAndView.getViewName(); } if (!StringUtils.isEmpty(viewName)) { request.getSession().setAttribute(REDIRECT_HEADER, viewName); } } }
From source file:org.duracloud.account.app.controller.UserControllerTest.java
@Test public void testGetForgotPasswordForm() { replayMocks();//w w w.j a v a 2 s . c o m ModelAndView mv = userController.getForgotPasswordForm(null); Assert.assertEquals(UserController.FORGOT_PASSWORD_VIEW, mv.getViewName()); Map<String, Object> map = mv.getModel(); Assert.assertNotNull(map); Assert.assertTrue(map.containsKey(UserController.FORGOT_PASSWORD_FORM_KEY)); Object obj = map.get(UserController.FORGOT_PASSWORD_FORM_KEY); Assert.assertNotNull(obj); Assert.assertTrue(obj instanceof ForgotPasswordForm); }
From source file:edu.duke.cabig.c3pr.web.admin.CreateNotificationController.java
protected boolean isAjaxResponseFreeText(ModelAndView modelAndView) { if (StringUtils.isBlank(modelAndView.getViewName())) { return true; }/*from w w w . ja va 2 s . c o m*/ return false; }
From source file:org.duracloud.account.app.controller.UserControllerTest.java
@Test public void testGetUser() throws Exception { HttpServletRequest request = createMock(HttpServletRequest.class); HttpSession session = createMock(HttpSession.class); EasyMock.expect(session.getAttribute("redemptionCode")).andReturn(null).anyTimes(); EasyMock.expect(request.getSession()).andReturn(session).anyTimes(); DuracloudUser u = createUser();//ww w . j av a2 s . c om EasyMock.expect(userService.loadDuracloudUserByUsernameInternal(TEST_USERNAME)).andReturn(u).anyTimes(); Set<AccountInfo> accounts = createAccountSet(); EasyMock.expect(accountManagerService.findAccountsByUserId(u.getId())).andReturn(accounts); replayMocks(); ModelAndView mv = userController.getUser(TEST_USERNAME, request); Assert.assertEquals(UserController.USER_ACCOUNTS, mv.getViewName()); Map<String, Object> map = mv.getModel(); Assert.assertNotNull(map); Assert.assertTrue(map.containsKey(UserController.USER_KEY)); Object obj = map.get(UserController.USER_KEY); Assert.assertNotNull(obj); Assert.assertTrue(obj instanceof DuracloudUser); obj = map.get("activeAccounts"); Assert.assertNotNull(obj); Assert.assertTrue(obj instanceof List); obj = map.get("pendingAccounts"); Assert.assertNotNull(obj); Assert.assertTrue(obj instanceof List); obj = map.get("inactiveAccounts"); Assert.assertNotNull(obj); Assert.assertTrue(obj instanceof List); }
From source file:org.duracloud.account.app.controller.UserControllerTest.java
@Test public void testAddUserErrors() throws Exception { setupHasBindingResultErrors(true);/*from ww w . j a v a 2s . c o m*/ replayMocks(); ModelAndView mav = userController.add(null, result, model, null); Assert.assertNotNull(mav); Assert.assertEquals(UserController.NEW_USER_VIEW, mav.getViewName()); }
From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java
@Test public void testNextOutboxMessage() { String voiceMessageTypeName = "voicemessagetypename"; OutboundVoiceMessage voiceMessage = new OutboundVoiceMessage(); VoiceMessageType voiceMessageType = new VoiceMessageType(); voiceMessageType.setVoiceMessageTypeName(voiceMessageTypeName); voiceMessage.setVoiceMessageType(voiceMessageType); when(voiceOutboxService.getNextPendingMessage(anyString())).thenReturn(voiceMessage); ModelAndView modelAndView = vxmlOutboxController.outboxMessage(request, response); Assert.assertEquals(voiceMessageTypeName, modelAndView.getViewName()); }
From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java
@Test public void testSavedMessage() { String partyId = "1"; String voiceMessageTypeName = "voicemessagetypename"; OutboundVoiceMessage voiceMessage = new OutboundVoiceMessage(); VoiceMessageType voiceMessageType = new VoiceMessageType(); voiceMessageType.setVoiceMessageTypeName(voiceMessageTypeName); voiceMessage.setVoiceMessageType(voiceMessageType); when(request.getParameter("pId")).thenReturn(partyId); when(voiceOutboxService.getNextSavedMessage(partyId)).thenReturn(voiceMessage); ModelAndView modelAndView = vxmlOutboxController.savedMessage(request, response); Assert.assertEquals(voiceMessageTypeName, modelAndView.getViewName()); }
From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java
@Test public void testOutboxMessage() { String messageId = "mID"; String voiceMessageTypeName = "voicemessagetypename"; OutboundVoiceMessage voiceMessage = new OutboundVoiceMessage(); VoiceMessageType voiceMessageType = new VoiceMessageType(); voiceMessageType.setVoiceMessageTypeName(voiceMessageTypeName); voiceMessage.setVoiceMessageType(voiceMessageType); Mockito.when(request.getParameter("mId")).thenReturn(messageId); when(voiceOutboxService.getMessageById(messageId)).thenReturn(voiceMessage); ModelAndView modelAndView = vxmlOutboxController.outboxMessage(request, response); Assert.assertEquals(voiceMessageTypeName, modelAndView.getViewName()); }
From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java
@Test public void testSaveOutboxMessageNoMessageId() { Mockito.when(request.getParameter(VxmlOutboxController.MESSAGE_ID_PARAM)).thenReturn(null); ModelAndView modelAndView = vxmlOutboxController.save(request, response); Assert.assertEquals(VxmlOutboxController.ERROR_MESSAGE_TEMPLATE_NAME, modelAndView.getViewName()); verify(voiceOutboxService, times(0)).saveMessage(anyString()); }