ItemController { @RequestMapping(value = "/items/createItem", method = RequestMethod.POST) public ModelAndView createItem( @Valid @ModelAttribute("createItemForm") Item item, BindingResult result) { ModelAndView modelAndView = new ModelAndView(); if(result.hasErrors()) { modelAndView.setViewName("items-create"); return modelAndView; } if(itemService.addItem(item)) { logger.info("Successfully added item"); modelAndView.setViewName("redirect:/items"); } else { logger.warn("Unable to add item"); } return modelAndView; }  @RequestMapping(value = "/items", method = RequestMethod.GET) String showItemsList(ModelMap model); @RequestMapping(value = "/items/create", method = RequestMethod.GET) String showCreateItemPage(ModelMap modelMap); @RequestMapping(value = "/items/createItem", method = RequestMethod.POST) ModelAndView createItem(
			@Valid @ModelAttribute("createItemForm") Item item,
			BindingResult result);  }
@Test public void testCreateItem() { Mockito.when(itemService.addItem(Matchers.any(Item.class))).thenReturn(true); ModelAndView modelAndView = itemController.createItem(new Item(), new DirectFieldBindingResult(null, null)); assertNotNull(modelAndView); assertEquals("redirect:/items", modelAndView.getViewName()); }