@Test public void filterByProductVariantKey() { final List<String> keys = Stream.of(product1, product2) .map(product -> product.getMasterData().getStaged().getMasterVariant().getKey()) .collect(toList()); final ProductProjectionSearch search = ProductProjectionSearch.ofStaged() .plusQueryFilters(m -> m.allVariants().key().isIn(keys)); assertEventually(Duration.ofSeconds(45), Duration.ofMillis(200), () -> { final List<ProductProjection> results = client().executeBlocking(search).getResults(); assertThat(results) .extracting(m -> m.getMasterVariant().getKey()) .containsOnly(keys.get(0), keys.get(1)); }); }
/** * Creates a new object initialized with the fields of the template parameter. * * @param template the template * @return a new object initialized from the template */ public static ProductVariantDraftBuilder of(final ProductVariant template) { return new ProductVariantDraftBuilder(copyAssets(template.getAssets()), copyAttributes(template.getAttributes()), template.getImages(), template.getKey(), copyPrices(template.getPrices()), template.getSku()); } }
public void setProductVariantKeyByVariantIdWithStaged(final Boolean staged) { final String key = randomKey(); withProduct(client(), (Product product) -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final Integer variantId = product.getMasterData().getStaged().getMasterVariant().getId(); final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetProductVariantKey.ofKeyAndVariantId(key, variantId, staged)); final Product updatedProduct = client().executeBlocking(cmd); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getKey()).isEqualTo(key); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged); }); }
public void setProductVariantKeyBySkuWithStaged(final Boolean staged) { final String key = randomKey(); withProduct(client(), (Product product) -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final String sku = product.getMasterData().getStaged().getMasterVariant().getSku(); final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetProductVariantKey.ofKeyAndSku(key, sku, staged)); final Product updatedProduct = client().executeBlocking(cmd); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getKey()).isEqualTo(key); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged); }); }
@Test public void setProductVariantKeyByVariantId() throws Exception { final String key = randomKey(); withProduct(client(), (Product product) -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final Integer variantId = product.getMasterData().getStaged().getMasterVariant().getId(); final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetProductVariantKey.ofKeyAndVariantId(key, variantId)); final Product updatedProduct = client().executeBlocking(cmd); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getKey()).isEqualTo(key); assertThat(updatedProduct.getKey()).isNotEqualTo(key); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isTrue(); }); }
@Test public void setProductVariantKeyBySku() throws Exception { final String key = randomKey(); withProduct(client(), (Product product) -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final String sku = product.getMasterData().getStaged().getMasterVariant().getSku(); final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetProductVariantKey.ofKeyAndSku(key, sku)); final Product updatedProduct = client().executeBlocking(cmd); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getKey()).isEqualTo(key); assertThat(updatedProduct.getKey()).isNotEqualTo(key); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isTrue(); }); }
assertThat(variant.findAttribute(sizeAttribute).get()).isEqualTo(Sizes.M); assertThat(variant.getSku()).isEqualTo(sku); assertThat(variant.getKey()).isEqualTo(key); assertThat(variant.getImages()).containsExactly(image);
assertThat(variant.findAttribute(sizeAttribute).get()).isEqualTo(Sizes.M); assertThat(variant.getSku()).isEqualTo(sku); assertThat(variant.getKey()).isEqualTo(key); assertThat(variant.getImages()).containsExactly(image); assertThat(variant.getAssets().get(0).getKey()).isEqualTo(assets.get(0).getKey());