@Test public void getProductsRequest() { Book book = new Book(UUID.randomUUID().toString(), "1234567890", "Book Title", ""); Product product = new Product(UUID.randomUUID().toString(), book, 1000L, null); when(productRepository.getProducts()).thenReturn(asList(product)); Collection<ProductDto> products = resources.client() .target(PRODUCT_RESOURCE) .request(APPLICATION_JSON_TYPE) .get(PRODUCTS_COLLECTION_TYPE); assertThat(products, hasItem(ProductDtoFactory.fromProduct(product))); }
@GET public Collection<ProductDto> getProducts() { Collection<ProductDto> products = new ArrayList<>(); for (Product product : productRepository.getProducts()) { products.add(ProductDtoFactory.fromProduct(product)); } logger.info("Returning [{}] products", products.size()); return products; }
ProductResource { @GET public Collection<ProductDto> getProducts() { Collection<ProductDto> products = new ArrayList<>(); for (Product product : productRepository.getProducts()) { products.add(ProductDtoFactory.fromProduct(product)); } logger.info("Returning [{}] products", products.size()); return products; } }
ProductResource { @GET public Collection<ProductDto> getProducts() { Collection<ProductDto> products = new ArrayList<>(); for (Product product : productRepository.getProducts()) { products.add(ProductDtoFactory.fromProduct(product)); } logger.info("Returning [{}] products", products.size()); return products; } ProductResource(ProductRepository productRepository); }
ProductResource { @GET public Collection<ProductDto> getProducts() { Collection<ProductDto> products = new ArrayList<>(); for (Product product : productRepository.getProducts()) { products.add(ProductDtoFactory.fromProduct(product)); } logger.info("Returning [{}] products", products.size()); return products; } ProductResource(ProductRepository productRepository); @GET @Path("{productId}") ProductDto getProduct(@PathParam("productId") String productId); @POST void createProduct(@Valid ProductDto request); @GET Collection<ProductDto> getProducts(); }
ProductResource { @GET public Collection<ProductDto> getProducts() { Collection<ProductDto> products = new ArrayList<>(); for (Product product : productRepository.getProducts()) { products.add(ProductDtoFactory.fromProduct(product)); } logger.info("Returning [{}] products", products.size()); return products; } ProductResource(ProductRepository productRepository); @GET @Path("{productId}") ProductDto getProduct(@PathParam("productId") String productId); @POST void createProduct(@Valid ProductDto request); @GET Collection<ProductDto> getProducts();  }