Code example for ModelAndView

Methods: getModelgetViewName

0
	@Test 
	public void handleRequestWithViewName() throws Exception { 
		String viewName = "testView"; 
		this.controller.setViewName(viewName); 
		ModelAndView mav = this.controller.handleRequest(this.request, new MockHttpServletResponse()); 
		assertEquals(viewName, mav.getViewName()); 
		assertTrue(mav.getModel().isEmpty()); 
	} 
 
	@Test 
	public void handleRequestWithoutViewName() throws Exception { 
		ModelAndView mav = this.controller.handleRequest(this.request, new MockHttpServletResponse()); 
		assertNull(mav.getViewName()); 
		assertTrue(mav.getModel().isEmpty()); 
	} 
 
	@Test 
	public void handleRequestWithFlashAttributes() throws Exception { 
		this.request.setAttribute(DispatcherServlet.INPUT_FLASH_MAP_ATTRIBUTE, new ModelMap("name", "value")); 
		ModelAndView mav = this.controller.handleRequest(this.request, new MockHttpServletResponse()); 
Experience pair programming with AI  Get Codota for Java