### Question:
ProductController { @RequestMapping(path = "/{productId}", method = RequestMethod.GET) public Product getProductDetail(@PathVariable("productId") long productId) { return productService.findProductById(productId).orElse(null); }  @RequestMapping(path = "/{productId}", method = RequestMethod.GET) Product getProductDetail(@PathVariable("productId") long productId); @RequestMapping(method = RequestMethod.GET) Iterable<Product> getProducts(@RequestParam("category") long categoryId);  }### Answer:
@Test public void shouldReturnAProduct() { long productId = 1; Product product = TestDataFactory.getProduct(productId); when(productService.findProductById(productId)).thenReturn(Optional.of(product)); assertThat(productController.getProductDetail(productId)).isEqualTo(product); }