Code example for ModelAndView

Methods: getViewName

0
        dto.setRecipient(USERNAME);
        BindingResult bindingResult = new BeanPropertyBindingResult(dto, "privateMessageDto");
 
        ModelAndView mav = controller.sendMessage(dto, bindingResult);
 
        assertEquals(mav.getViewName(), "redirect:/outbox");
        verify(pmService).sendMessage(dto.getTitle(), dto.getBody(), JC_USER, JC_USER);
    } 
 
    @Test
    public void sendDraftMessage() throws NotFoundException { 
        when(userService.getByUsername(USERNAME)).thenReturn(JC_USER);
        when(userService.getCurrentUser()).thenReturn(JC_USER);
        PrivateMessageDto dto = getPrivateMessageDto();
        dto.setRecipient(USERNAME);
        dto.setId(4);
        BindingResult bindingResult = new BeanPropertyBindingResult(dto, "privateMessageDto");
 
        ModelAndView mav = controller.sendMessage(dto, bindingResult);
 
Experience pair programming with AI  Get Codota for Java