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.motechproject.server.outbox.web.VxmlOutboxControllerTest.java

@Test
public void testNextOutboxMessageInvalidMessageNoMessageType() {

    OutboundVoiceMessage voiceMessage = new OutboundVoiceMessage();

    when(voiceOutboxService.getNextPendingMessage(anyString())).thenReturn(voiceMessage);

    ModelAndView modelAndView = vxmlOutboxController.outboxMessage(request, response);

    Assert.assertEquals(VxmlOutboxController.ERROR_MESSAGE_TEMPLATE_NAME, modelAndView.getViewName());

}

From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java

@Test
public void testSavedMessageNoMessage() {

    String partyId = "1";
    when(voiceOutboxService.getNextSavedMessage(partyId)).thenReturn(null);

    ModelAndView modelAndView = vxmlOutboxController.savedMessage(request, response);

    Assert.assertEquals(VxmlOutboxController.NO_SAVED_MESSAGE_TEMPLATE_NAME, modelAndView.getViewName());

}

From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java

@Test
public void testMessageMenu() {

    String messageId = "mID";

    OutboundVoiceMessage voiceMessage = new OutboundVoiceMessage();
    voiceMessage.setStatus(OutboundVoiceMessageStatus.PENDING);

    when(request.getParameter("mId")).thenReturn(messageId);
    when(voiceOutboxService.getMessageById(messageId)).thenReturn(voiceMessage);

    ModelAndView modelAndView = vxmlOutboxController.messageMenu(request, response);

    Assert.assertEquals(VxmlOutboxController.MESSAGE_MENU_TEMPLATE_NAME, modelAndView.getViewName());
    verify(voiceOutboxService).setMessageStatus(messageId, OutboundVoiceMessageStatus.PLAYED);
}

From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java

@Test
public void testOutboxMessageException() {

    String messageId = "mID";
    String voiceMessageTypeName = "voicemessagetypename";

    Mockito.when(request.getParameter("mId")).thenReturn(messageId);
    when(voiceOutboxService.getMessageById(messageId)).thenThrow(new RuntimeException());

    ModelAndView modelAndView = vxmlOutboxController.outboxMessage(request, response);

    Assert.assertEquals(VxmlOutboxController.ERROR_MESSAGE_TEMPLATE_NAME, modelAndView.getViewName());

}

From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java

@Test
public void testSavedMessageInvalidNoMessageType() {

    String partyId = "1";

    OutboundVoiceMessage voiceMessage = new OutboundVoiceMessage();

    when(request.getParameter("pId")).thenReturn(partyId);
    when(voiceOutboxService.getNextSavedMessage(partyId)).thenReturn(voiceMessage);

    ModelAndView modelAndView = vxmlOutboxController.savedMessage(request, response);

    Assert.assertEquals(VxmlOutboxController.ERROR_MESSAGE_TEMPLATE_NAME, modelAndView.getViewName());

}

From source file:org.jasig.cas.support.oauth.web.OAuth20AuthorizeCallbackActionControllerTests.java

@Test
public void verifyNoClientIdError() throws Exception {
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET",
            CONTEXT + OAuthConstants.CALLBACK_AUTHORIZE_ACTION_URL);
    final MockHttpSession mockSession = new MockHttpSession();
    mockSession.putValue(OAuthConstants.OAUTH20_RESPONSE_TYPE, RESPONSE_TYPE);
    mockSession.putValue(OAuthConstants.OAUTH20_STATE, STATE);
    mockSession.putValue(OAuthConstants.OAUTH20_REDIRECT_URI, REDIRECT_URI);
    mockSession.putValue(OAuthConstants.OAUTH20_TOKEN_TYPE, TokenType.OFFLINE);
    mockSession.putValue(OAuthConstants.OAUTH20_LOGIN_TICKET_ID, TICKET_GRANTING_TICKET_ID);
    mockSession.putValue(OAuthConstants.OAUTH20_SCOPE, SCOPE);
    mockRequest.setSession(mockSession);
    mockRequest.setParameter(OAuthConstants.OAUTH20_APPROVAL_PROMPT_ACTION,
            OAuthConstants.OAUTH20_APPROVAL_PROMPT_ACTION_ALLOW);

    final MockHttpServletResponse mockResponse = new MockHttpServletResponse();

    final OAuth20WrapperController oauth20WrapperController = new OAuth20WrapperController();
    oauth20WrapperController.afterPropertiesSet();

    final ModelAndView modelAndView = oauth20WrapperController.handleRequest(mockRequest, mockResponse);
    assertEquals(OAuthConstants.ERROR_VIEW, modelAndView.getViewName());

    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_RESPONSE_TYPE));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_CLIENT_ID));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_STATE));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_REDIRECT_URI));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_TOKEN_TYPE));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_LOGIN_TICKET_ID));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_SCOPE_SET));
}

From source file:org.jasig.cas.support.oauth.web.OAuth20AuthorizeCallbackActionControllerTests.java

@Test
public void verifyNoRedirectError() throws Exception {
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET",
            CONTEXT + OAuthConstants.CALLBACK_AUTHORIZE_ACTION_URL);
    final MockHttpSession mockSession = new MockHttpSession();
    mockSession.putValue(OAuthConstants.OAUTH20_RESPONSE_TYPE, RESPONSE_TYPE);
    mockSession.putValue(OAuthConstants.OAUTH20_STATE, STATE);
    mockSession.putValue(OAuthConstants.OAUTH20_CLIENT_ID, CLIENT_ID);
    mockSession.putValue(OAuthConstants.OAUTH20_TOKEN_TYPE, TokenType.OFFLINE);
    mockSession.putValue(OAuthConstants.OAUTH20_LOGIN_TICKET_ID, TICKET_GRANTING_TICKET_ID);
    mockSession.putValue(OAuthConstants.OAUTH20_SCOPE, SCOPE);
    mockRequest.setSession(mockSession);
    mockRequest.setParameter(OAuthConstants.OAUTH20_APPROVAL_PROMPT_ACTION,
            OAuthConstants.OAUTH20_APPROVAL_PROMPT_ACTION_ALLOW);

    final MockHttpServletResponse mockResponse = new MockHttpServletResponse();

    final OAuth20WrapperController oauth20WrapperController = new OAuth20WrapperController();
    oauth20WrapperController.afterPropertiesSet();

    final ModelAndView modelAndView = oauth20WrapperController.handleRequest(mockRequest, mockResponse);
    assertEquals(OAuthConstants.ERROR_VIEW, modelAndView.getViewName());

    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_RESPONSE_TYPE));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_CLIENT_ID));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_STATE));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_REDIRECT_URI));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_TOKEN_TYPE));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_LOGIN_TICKET_ID));
    assertNull(mockSession.getAttribute(OAuthConstants.OAUTH20_SCOPE_SET));
}

From source file:org.jnap.core.mvc.async.AsyncRequestInterceptor.java

@Override
public void onStateChange(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event)
        throws IOException {
    System.out.println("AsyncRequestInterceptor.onStateChange()");
    System.out.println(event.getMessage());
    HttpServletRequest req = event.getResource().getRequest();
    HttpServletResponse res = event.getResource().getResponse();
    try {//from www.jav  a  2s  .  c  o m
        ModelAndView mv = (ModelAndView) event.getMessage();
        View view = null;
        if (mv.isReference()) {
            view = this.viewResolver.resolveViewName(mv.getViewName(), this.localeResolver.resolveLocale(req));
        } else {
            view = mv.getView();
            if (view == null) {

            }
        }
        view.render(mv.getModelMap(), req, res);
    } catch (Exception e) {
        throw new IOException(e.getMessage(), e);
    }
}

From source file:org.motechproject.server.outbox.web.VxmlOutboxControllerTest.java

@Test
public void testSavedMessageMenu() {

    String messageId = "mID";

    OutboundVoiceMessage voiceMessage = new OutboundVoiceMessage();
    voiceMessage.setStatus(OutboundVoiceMessageStatus.SAVED);

    when(request.getParameter("mId")).thenReturn(messageId);
    when(voiceOutboxService.getMessageById(messageId)).thenReturn(voiceMessage);

    ModelAndView modelAndView = vxmlOutboxController.messageMenu(request, response);

    Assert.assertEquals(VxmlOutboxController.SAVED_MESSAGE_MENU_TEMPLATE_NAME, modelAndView.getViewName());
    verify(voiceOutboxService, times(0)).setMessageStatus(anyString(),
            Matchers.<OutboundVoiceMessageStatus>any());
}

From source file:gov.nih.nci.cabig.caaers.web.ae.SubmitReportController.java

@Override
@SuppressWarnings("unchecked")
protected ModelAndView processFinish(HttpServletRequest request, HttpServletResponse response, Object oCommand,
        BindException errors) throws Exception {
    log.debug("In processFinish");
    SubmitExpeditedAdverseEventCommand command = (SubmitExpeditedAdverseEventCommand) oCommand;
    ModelAndView modelAndView;
    Map<String, Object> model = new ModelMap("participant",
            command.getReport().getAeReport().getParticipant().getId());
    model.put("study", command.getReport().getAeReport().getStudy().getId());
    modelAndView = new ModelAndView("redirectToAeList", model);
    log.debug("Returning the viewname as :" + modelAndView.getViewName());
    return modelAndView;
}