### Question:
ProductController { @RequestMapping("/product") public String getProductById(Model model, @RequestParam("id") String productId) { Product product = productService.getProductById(productId); model.addAttribute("product", product); return "product"; }  @RequestMapping String list(Model model); @RequestMapping("/all") ModelAndView allProducts(); @RequestMapping("/{category}") String getProductsByCategory(Model model, @PathVariable("category") String category); @RequestMapping("/filter/{ByCriteria}") String getProductsByFilter(@MatrixVariable(pathVar="ByCriteria") Map<String,List<String>> filterParams, Model model); @RequestMapping("/product") String getProductById(Model model, @RequestParam("id") String productId); @RequestMapping(value = "/add", method = RequestMethod.GET) String getAddNewProductForm(@ModelAttribute("newProduct") Product newProduct); @RequestMapping(value = "/add", method = RequestMethod.POST) String processAddNewProductForm(@ModelAttribute("newProduct") @Valid Product productToBeAdded, BindingResult result, HttpServletRequest request); @InitBinder void initialiseBinder(WebDataBinder binder); @ExceptionHandler(ProductNotFoundException.class) ModelAndView handleError(HttpServletRequest req, ProductNotFoundException exception); @RequestMapping("/invalidPromoCode") String invalidPromoCode();  }### Answer:
@Test public void testGetProductById() throws Exception { Product product = new Product("P1234","iPhone 5s", new BigDecimal(500)); this.mockMvc.perform(get("/products/product") .param("id", "P1234")) .andExpect(model().attributeExists("product")) .andExpect(model().attribute("product", product)); }