### Question:
ProductService { public Optional<Product> findProductById(final long productId) { return productRepository.findById(productId); }  Optional<Product> findProductById(final long productId); Iterable<Product> findProductsByCategoryId(long categoryId);  }### Answer:
@Test public void shouldFindAProductByItsId() { long productId = 1; Product product = TestDataFactory.getProduct(productId); when(productRepository.findById(productId)).thenReturn(Optional.of(product)); assertThat(productService.findProductById(productId).orElse(null)).isEqualTo(product); }