### Question:
SpittleController { @RequestMapping(value="/{spittleId}", method=RequestMethod.GET) public String spittle( @PathVariable("spittleId") long spittleId, Model model) { model.addAttribute(spittleRepository.findOne(spittleId)); return "spittle"; } @Autowired  SpittleController(SpittleRepository spittleRepository); @RequestMapping(method=RequestMethod.GET) List<Spittle> spittles(
      @RequestParam(value="max", defaultValue=MAX_LONG_AS_STRING) long max,
      @RequestParam(value="count", defaultValue="20") int count); @RequestMapping(value="/{spittleId}", method=RequestMethod.GET) String spittle(
      @PathVariable("spittleId") long spittleId, 
      Model model); @RequestMapping(method=RequestMethod.POST) String saveSpittle(SpittleForm form, Model model);  }### Answer:
@Test public void testSpittle() throws Exception { Spittle expectedSpittle = new Spittle("Hello", new Date()); SpittleRepository mockRepository = mock(SpittleRepository.class); when(mockRepository.findOne(12345)).thenReturn(expectedSpittle); SpittleController controller = new SpittleController(mockRepository); MockMvc mockMvc = standaloneSetup(controller).build(); mockMvc.perform(get("/spittles/12345")) .andExpect(view().name("spittle")) .andExpect(model().attributeExists("spittle")) .andExpect(model().attribute("spittle", expectedSpittle)); }