/** * Action to remove a price * * @param price the price to remove including an ID * @return action */ public static RemovePrice of(final Price price) { return of(price, null); }
/** * Action to remove a price * * @param price the price to remove including an ID * @return action */ public static RemovePrice of(final Price price) { return of(price, null); }
public static RemovePrice of(final String priceId) { return of(priceId, null); }
public static RemovePrice of(final String priceId) { return of(priceId, null); }
/** * Action to remove a price * @param price the price to remove including an ID * @return action */ public static RemovePrice of(final Price price) { return of(Optional.ofNullable(price.getId()).orElseThrow(() -> new IllegalArgumentException("Expected price with ID."))); }
public static RemovePrice of(final Price price, @Nullable final Boolean staged) { return of(Optional.ofNullable(price.getId()).orElseThrow(() -> new IllegalArgumentException("Expected price with ID.")), staged); }
public static RemovePrice of(final Price price, @Nullable final Boolean staged) { return of(Optional.ofNullable(price.getId()).orElseThrow(() -> new IllegalArgumentException("Expected price with ID.")), staged); }
@Test public void removePrice() throws Exception { withUpdateablePricedProduct(client(), product -> { final Price oldPrice = getFirstPrice(product); final Product updatedProduct = client() .executeBlocking(ProductUpdateCommand.of(product, RemovePrice.of(oldPrice))); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant() .getPrices().stream().anyMatch(p -> p.equals(oldPrice))).isFalse(); return updatedProduct; }); }
public void removePriceWithStaged(final Boolean staged) { withUpdateableProduct(client(), product -> { final ProductUpdateCommand command = ProductUpdateCommand.of(product, AddPrice.ofVariantId(1, PriceDraft.of(MoneyImpl.of(123, EUR)), false)); final Product productWithPrice = client().executeBlocking(command); assertThat(productWithPrice.getMasterData().hasStagedChanges()).isFalse(); final Price oldPrice = getFirstPrice(productWithPrice); final Product updatedProduct = client() .executeBlocking(ProductUpdateCommand.of(productWithPrice, RemovePrice.of(oldPrice, staged))); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant() .getPrices().stream().anyMatch(p -> p.equals(oldPrice))).isFalse(); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged); return updatedProduct; }); }
@Test public void assignPricesToMasterVariantAccordingToAChannel() throws Exception { final String channelKey = "assignPricesToMasterVariantAccordingToAChannel"; cleanUpChannelByKey(client(), channelKey); final Product product = createInBackendByName("assignPricesToMasterVariantAccordingToAChannel"); final Channel channel = client().executeBlocking(ChannelCreateCommand.of(ChannelDraft.of(channelKey))); final PriceDraft price = PriceDraft.of(MoneyImpl.of(523, EUR)).withChannel(channel); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, AddPrice.of(MASTER_VARIANT_ID, price))); final Price readPrice = updatedProduct.getMasterData().getStaged().getMasterVariant().getPrices().get(0); assertThat(readPrice.getChannel()).isEqualTo(channel.toReference()); client().executeBlocking(ProductUpdateCommand.of(updatedProduct, RemovePrice.of(readPrice))); cleanUpChannelByKey(client(), channelKey); }