@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"); }
/** * 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 ProductDraftDsl of(final ProductDraft template) { return new ProductDraftDsl(template.getCategories(), template.getCategoryOrderHints(), template.getDescription(), template.getKey(), template.getMasterVariant(), template.getMetaDescription(), template.getMetaKeywords(), template.getMetaTitle(), template.getName(), template.getProductType(), template.isPublish(), template.getSearchKeywords(), template.getSlug(), template.getState(), template.getTaxCategory(), template.getVariants()); } }
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 ProductDraftBuilder of(final ProductDraft template) { return new ProductDraftBuilder(template.getCategories(), template.getCategoryOrderHints(), template.getDescription(), template.getKey(), template.getMasterVariant(), template.getMetaDescription(), template.getMetaKeywords(), template.getMetaTitle(), template.getName(), template.getProductType(), template.isPublish(), template.getSearchKeywords(), template.getSlug(), template.getState(), template.getTaxCategory(), template.getVariants()); } }