public static AddPrice ofSku(final String sku, final PriceDraft price) { return ofSku(sku, price, null); }
public static AddPrice ofSku(final String sku, final PriceDraft price) { return ofSku(sku, price, null); }
public void addPriceBySkuWithStaged(final Boolean staged) { final PriceDraft priceDraft = PriceDraft.of(MoneyImpl.of(new BigDecimal("12345"), "JPY")); withUpdateableProduct(client(), product -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final String sku = product.getMasterData().getStaged().getMasterVariant().getSku(); final Product updatedProduct = client() .executeBlocking(ProductUpdateCommand.of(product, AddPrice.ofSku(sku, priceDraft, staged))); final List<Price> prices = updatedProduct.getMasterData().getStaged().getMasterVariant().getPrices(); assertThat(prices).hasSize(1); final Price actualPrice = prices.get(0); assertThat(priceDraft).isEqualTo(PriceDraft.of(actualPrice)); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged); return updatedProduct; }); }
@Test public void addPriceBySku() throws Exception { final PriceDraft priceDraft = PriceDraft.of(MoneyImpl.of(new BigDecimal("12345"), "JPY")); withUpdateableProduct(client(), product -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final String sku = product.getMasterData().getStaged().getMasterVariant().getSku(); final Product updatedProduct = client() .executeBlocking(ProductUpdateCommand.of(product, AddPrice.ofSku(sku, priceDraft))); final List<Price> prices = updatedProduct.getMasterData().getStaged().getMasterVariant().getPrices(); assertThat(prices).hasSize(1); final Price actualPrice = prices.get(0); assertThat(priceDraft).isEqualTo(PriceDraft.of(actualPrice)); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isTrue(); return updatedProduct; }); }