ShopResource { public ShopResource(List<Product> products, OrderStorage orderStorage) { this.products = products; this.orderStorage = orderStorage; } ShopResource(List<Product> products, OrderStorage orderStorage); @GET @Produces(MediaType.TEXT_HTML) String index(); @GET @Path("products") @Produces(MediaType.APPLICATION_JSON) List<Product> getProducts(); @POST @Path("buy") @Consumes(MediaType.APPLICATION_JSON) void buyProducts(BuyProductRequest buyProductRequest);  }
@Test public void testShopResource() { ShopResource.BuyProductRequest buyProductRequest = new ShopResource.BuyProductRequest(); buyProductRequest.productName = "Car"; buyProductRequest.userName = "testuser"; shopResource.buyProducts(buyProductRequest); OrderStorage.Order order = orderStorage.getOrders().stream() .filter(o -> o.customerName.equals("testuser")) .findFirst() .get(); Assertions.assertEquals("Car",order.productName,"product should be 'Car'"); }