public static RemoveImage ofSku(final String sku, final String imageUrl) { return ofSku(sku, imageUrl, null); }
public static RemoveImage ofSku(final String sku, final String imageUrl) { return ofSku(sku, imageUrl, null); }
public static RemoveImage ofSku(final String sku, final Image image) { return ofSku(sku, image.getUrl(), null); }
public static RemoveImage ofSku(final String sku, final Image image, @Nullable final Boolean staged) { return ofSku(sku, image.getUrl(), staged); }
public static RemoveImage ofSku(final String sku, final Image image, @Nullable final Boolean staged) { return ofSku(sku, image.getUrl(), staged); }
public static RemoveImage ofSku(final String sku, final Image image) { return ofSku(sku, image.getUrl(), null); }
public void removeImageBySkuWithStaged(final Boolean staged) { final Image image = createExternalImage(); withUpdateableProduct(client(), product -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final String sku = product.getMasterData().getStaged().getMasterVariant().getSku(); final Product productWithImage = client().executeBlocking(ProductUpdateCommand.of(product, AddExternalImage.ofSku(sku, image, staged))); assertThat(productWithImage.getMasterData().getStaged().getMasterVariant().getImages()).isEqualTo(asList(image)); assertThat(productWithImage.getMasterData().hasStagedChanges()).isEqualTo(staged); final Product publishedProduct = client().executeBlocking(ProductUpdateCommand.of(productWithImage, Publish.of())); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(publishedProduct, RemoveImage.ofSku(sku, image, staged))); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getImages()).hasSize(0); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged); return updatedProduct; }); }
@Test public void removeImageBySku() throws Exception { final Image image = createExternalImage(); withUpdateableProduct(client(), product -> { final String sku = product.getMasterData().getStaged().getMasterVariant().getSku(); final Product productWithImage = client().executeBlocking(ProductUpdateCommand.of(product, AddExternalImage.ofSku(sku, image))); assertThat(productWithImage.getMasterData().getStaged().getMasterVariant().getImages()).isEqualTo(asList(image)); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(productWithImage, RemoveImage.ofSku(sku, image))); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getImages()).hasSize(0); return updatedProduct; }); }