/** * 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 ProductVariantDraft template) { return new ProductVariantDraftBuilder(template.getAssets(), template.getAttributes(), template.getImages(), template.getKey(), template.getPrices(), template.getSku()); }
@Test public void createsWithAllVariants() { final List<ProductVariantDraft> allVariants = IntStream.range(0, 9) .mapToObj(i -> ProductVariantDraftBuilder.of().sku("sku-" + i).build()) .collect(toList()); final Reference<ProductType> productType = ProductType.referenceOfId("product-type-id"); final ProductDraft productDraft = ProductDraftBuilder.of(productType, randomSlug(), randomSlug(), allVariants).build(); assertThat(productDraft.getMasterVariant().getSku()).isEqualTo("sku-0"); assertThat(productDraft.getVariants().get(3).getSku()).isEqualTo("sku-4"); }
assertThat(productDraft.getSlug()).isEqualTo(slug); assertThat(productDraft.getProductType()).isEqualTo(productType); assertThat(productDraft.getMasterVariant().getSku()).isEqualTo("master-variant-sku"); assertThat(productDraft.getVariants()).isEmpty(); assertThat(productDraft.getDescription()).isEqualTo(description);
/** * 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 ProductVariantDraftDsl of(final ProductVariantDraft template) { return new ProductVariantDraftDsl(template.getAssets(), template.getAttributes(), template.getImages(), template.getKey(), template.getPrices(), template.getSku()); } }