/** * 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()); } }
@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 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()); } }
.key(key); final ProductDraft productDraft = productDraftBuilder.build(); assertThat(productDraft.getName()).isEqualTo(name); 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); assertThat(productDraft.getMetaTitle()).isEqualTo(metaTitle); assertThat(productDraft.getMetaDescription()).isEqualTo(metaDescription); assertThat(productDraft.getMetaKeywords()).isEqualTo(metaKeywords); assertThat(productDraft.getCategories()).isEqualTo(categories); assertThat(productDraft.getTaxCategory()).isEqualTo(taxCategory); assertThat(productDraft.getSearchKeywords()).isEqualTo(searchKeywords); assertThat(productDraft.getState()).isEqualTo(state); assertThat(productDraft.getCategoryOrderHints()).isEqualTo(categoryOrderHints); assertThat(productDraft.isPublish()).isTrue(); assertThat(productDraft.getKey()).isEqualTo(key); assertThat(ProductDraftBuilder.of(productDraft)).isEqualTo(productDraftBuilder);