SearchTourController { @RequestMapping(method = RequestMethod.GET, params = "form") public String searchForm() { return "searchtour/searchForm"; }  @InitBinder("searchTourForm") void initBinder(WebDataBinder webDataBinder); @ModelAttribute SearchTourForm setUpSearchTourForm(); @RequestMapping(method = RequestMethod.GET, params = "initForm") String searchInitForm(SessionStatus status); @RequestMapping(method = RequestMethod.GET, params = "form") String searchForm(); @RequestMapping(method = RequestMethod.GET) String search(@Validated SearchTourForm searchTourForm,
            BindingResult result, Model model,
            @PageableDefault Pageable pageable);  }
@Test public void testSearchForm() { MockHttpServletRequestBuilder getRequest = MockMvcRequestBuilders.get( "/tours").param("form", ""); try { ResultActions results = mockMvc.perform(getRequest); results.andExpect(status().isOk()); results.andExpect(view().name("searchtour/searchForm")); DateTime dateTime = dateFactory.newDateTime(); DateTime nextWeekDate = dateTime.plusWeeks(1); results.andExpect(model().attribute("searchTourForm", hasProperty( "depYear", is(nextWeekDate.getYear())))); results.andExpect(model().attribute("searchTourForm", hasProperty( "depMonth", is(nextWeekDate.getMonthOfYear())))); results.andExpect(model().attribute("searchTourForm", hasProperty( "depDay", is(nextWeekDate.getDayOfMonth())))); return; } catch (Exception e) { e.printStackTrace(); } fail(); }