public static Publish of() { return ofScope(null); }
public static Publish of() { return ofScope(null); }
@Test public void publishWithPriceScope() throws Exception { withUpdateableProduct(client(), (Product product) -> { final ProductData stagedData = product.getMasterData().getStaged(); final Product publishedProduct = client().executeBlocking(ProductUpdateCommand.of(product, Publish.of())); final ProductData currentData = publishedProduct.getMasterData().getCurrent(); assertThat(stagedData.getMasterVariant().getImages()).hasSize(0); assertThat(stagedData.getMasterVariant().getPrices()).hasSize(0); assertThat(currentData).isEqualTo(stagedData); final PriceDraft expectedPrice = PriceDraft.of(EURO_10); final Image image = createExternalImage(); final List<UpdateAction<Product>> updateActions = asList( AddExternalImage.of(image, MASTER_VARIANT_ID), AddPrice.of(MASTER_VARIANT_ID, expectedPrice), Publish.ofScope(PublishScope.PRICES) ); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(publishedProduct, updateActions)); List<Price> prices = updatedProduct.getMasterData().getCurrent().getMasterVariant().getPrices(); //Verify published price in the current product assertThat(prices).hasSize(1); assertThat(expectedPrice).isEqualTo(PriceDraft.of(prices.get(0))); //Verify that the image has not been published assertThat(updatedProduct.getMasterData().getCurrent().getMasterVariant().getImages()).hasSize(0); return updatedProduct; }); }
@Test public void publishWithAllScope() throws Exception { withUpdateableProduct(client(), (Product product) -> { final ProductData stagedData = product.getMasterData().getStaged(); final Product publishedProduct = client().executeBlocking(ProductUpdateCommand.of(product, Publish.of())); final ProductData currentData = publishedProduct.getMasterData().getCurrent(); assertThat(stagedData.getMasterVariant().getImages()).hasSize(0); assertThat(stagedData.getMasterVariant().getPrices()).hasSize(0); assertThat(currentData).isEqualTo(stagedData); final PriceDraft expectedPrice = PriceDraft.of(EURO_10); final Image image = createExternalImage(); final List<UpdateAction<Product>> updateActions = asList( AddExternalImage.of(image, MASTER_VARIANT_ID), AddPrice.of(MASTER_VARIANT_ID, expectedPrice), Publish.ofScope(PublishScope.ALL) ); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(publishedProduct, updateActions)); List<Price> prices = updatedProduct.getMasterData().getCurrent().getMasterVariant().getPrices(); assertThat(prices).hasSize(1); assertThat(expectedPrice).isEqualTo(PriceDraft.of(prices.get(0))); assertThat(updatedProduct.getMasterData().getCurrent().getMasterVariant().getImages()).isEqualTo(asList(image)); return updatedProduct; }); }