private void changeMasterVariantWithVariantIdWithStaged(final Boolean staged) { withUpdateableProductOfMultipleVariants(client(), product -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final ProductVariant variantSupposedToBeMaster = product.getMasterData().getStaged().getAllVariants().get(2); final Integer variantId = variantSupposedToBeMaster.getId(); final ChangeMasterVariant updateAction = ChangeMasterVariant.ofVariantId(variantId, staged); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, updateAction)); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getId()).isEqualTo(variantId); return updatedProduct; }); }
@Test @SuppressWarnings({"varargs", "unchecked"}) public void ofUnsetAttribute() { assertThat(product.getMasterData().getStaged().getAllVariants()) .extracting(variant -> variant.getAttribute(ATTR_NAME).getValueAsLocalizedEnumValueSet()) .as("product attributes present") .contains(new HashSet<>(ALL_ATTRIBUTE_VALUES)); final UpdateAction<Product> action = SetAttributeInAllVariants.ofUnsetAttribute("ProductFlags"); product = client().executeBlocking(ProductUpdateCommand.of(product, action)); assertThat(product.getMasterData().getStaged().getAllVariants()) .extracting(variant -> variant.hasAttribute(ATTR_NAME)) .as("attribute is deleted") .containsExactly(false, false); }
private void changeMasterVariantWithSkuWithStaged(final Boolean staged) { withUpdateableProductOfMultipleVariants(client(), product -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final int originalMasterVariantId = product.getMasterData().getStaged().getMasterVariant().getId(); final ProductVariant variantSupposedToBeMaster = product.getMasterData().getStaged().getAllVariants().get(2); final String sku = variantSupposedToBeMaster.getSku(); final ChangeMasterVariant updateAction = ChangeMasterVariant.ofSku(sku, staged); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, updateAction)); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getSku()).isEqualTo(sku); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getId()) .as("variant IDs don't change in reordering") .isNotEqualTo(originalMasterVariantId) .isEqualTo(variantSupposedToBeMaster.getId()); return updatedProduct; }); }