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 testRemoveOutboxMessageNoMessageId() {

    Mockito.when(request.getParameter(VxmlOutboxController.MESSAGE_ID_PARAM)).thenReturn(null);

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

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

From source file:org.duracloud.account.app.controller.UserControllerTest.java

@Test
public void testChangePasswordErrors() throws Exception {
    setupHasBindingResultErrors(true);//from  w  w w .j a v a  2 s  .  co m
    replayMocks();
    ModelAndView mav = userController.changePassword(TEST_USERNAME, null, result, model);

    Assert.assertNotNull(mav);
    Assert.assertEquals(UserController.USER_EDIT_VIEW, mav.getViewName());

    Map<String, Object> map = model.asMap();
    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);
}

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

@Test
public void testNextOutboxMessageNoMessage() {

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

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

}

From source file:org.duracloud.account.app.controller.UserControllerTest.java

@Test
public void testUpdateUserErrors() throws Exception {
    setupHasBindingResultErrors(true);/*from   w w w.  j av  a 2s . c o  m*/
    replayMocks();
    ModelAndView mav = userController.update(TEST_USERNAME, null, result, new ExtendedModelMap());

    Assert.assertNotNull(mav);
    Assert.assertEquals(UserController.USER_EDIT_VIEW, mav.getViewName());
}

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

@Test
public void testSavedMessageException() {

    when(voiceOutboxService.getNextSavedMessage(anyString())).thenThrow(new RuntimeException());

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

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

}

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

@Test
public void testMessageMenuNoMessageId() {

    String messageId = "mID";

    Mockito.when(request.getParameter("mId")).thenReturn(null);

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

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

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

@Test
public void testNextOutboxMessageException() {

    when(voiceOutboxService.getNextPendingMessage(anyString())).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 testMessageMenuException() {

    String messageId = "mID";

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

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

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

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

@Test
public void testMessageMenuNoMessage() {

    String messageId = "mID";

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

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

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

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

@Test
public void testSaveOutboxMessageException() {

    String messageId = "mID";

    Mockito.when(request.getParameter(VxmlOutboxController.MESSAGE_ID_PARAM)).thenReturn(messageId);
    when(voiceOutboxService.getMessageById(messageId)).thenReturn(new OutboundVoiceMessage());
    doThrow(new RuntimeException()).when(voiceOutboxService).saveMessage(messageId);

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

    Assert.assertEquals(VxmlOutboxController.SAVE_MESSAGE_ERROR_TEMPLATE_NAME, modelAndView.getViewName());
    verify(voiceOutboxService).saveMessage(messageId);

}