public ProductDraftDsl withDescription(@Nullable final LocalizedString description) { return newBuilder().description(description).build(); }
final String key = randomKey(); final ProductDraftBuilder productDraftBuilder = ProductDraftBuilder.of(productType, name, slug, masterVariant) .description(description) .metaTitle(metaTitle) .metaDescription(metaDescription)
@Test public void itShouldBePossibleToDeeplyNestNestedTypesInsideOfSetTypes() throws Exception { withProductType(client(), () -> createNutrientInformation(), nutrientInformationType -> { withProductType(client(), () -> createNutrient(nutrientInformationType), nutrientType -> { withProductType(client(), () -> createBanana(nutrientType), bananaType -> { final ProductDraftBuilder productDraftBuilder = ProductDraftBuilder .of(bananaType, en("Super Banana!"), en(slugify("super-banana")), createBananaVariant()) .description(en("Cool and refreshing blue banana!")); withProduct(client(), productDraftBuilder, product -> { final AttributeContainer attrs = product.getMasterData().getStaged().getMasterVariant(); assertThat(attrs.findAttribute(Banana.bananaColor)).contains("blue"); assertThat(attrs.findAttribute(Banana.nutrients).map(Set::size)).contains(2); final List<AttributeContainer> nutrients = getSortedNutrients(attrs); assertNutrient(nutrients.get(0), 0.05D, "KM", 1); assertNutrientInfo(getNutrientInfos(nutrients.get(0)).get(0), "FIBTG", "PRECISE", 1.3D, "GR"); assertNutrient(nutrients.get(1), 1.5D, "M", 2); assertNutrientInfo(getNutrientInfos(nutrients.get(1)).get(0), "FAT", "APPROXIMATELY", 0.06D, "KG"); assertNutrientInfo(getNutrientInfos(nutrients.get(1)).get(1), "FIBTG", "APPROXIMATELY", 3.8D, "GR"); }); }); }); }); }
@Override public ProductDraft get() { final ProductVariantDraft masterVariant = ProductVariantDraftBuilder.of() .attributes(Sizes.ATTRIBUTE.draftOf(Sizes.S), Colors.ATTRIBUTE.draftOf(Colors.GREEN)) .sku(UUID.randomUUID().toString()) .build(); final LocalizedString slug = en(name).slugifiedUnique(); return ProductDraftBuilder.of(productType, en(name), slug, masterVariant) .description(en(name)) .metaTitle(en("cotton t-shirt")) .metaDescription(en("cotton t-shirt description")) .metaKeywords(en("cotton, t-shirt, clothes")) .build(); }
@Override public ProductDraft get() { final ProductVariantDraft masterVariant = ProductVariantDraftBuilder.of() .attributes(Sizes.ATTRIBUTE.draftOf(Sizes.S), Colors.ATTRIBUTE.draftOf(Colors.GREEN)) .sku(UUID.randomUUID().toString()) .prices(PriceDraft.of(MoneyImpl.ofCents(1234, EUR))) .build(); final ProductVariantDraft secondVariant = ProductVariantDraftBuilder.of() .attributes(Sizes.ATTRIBUTE.draftOf(Sizes.M), Colors.ATTRIBUTE.draftOf(Colors.GREEN)) .sku(UUID.randomUUID().toString()) .prices(PriceDraft.of(MoneyImpl.ofCents(1234, EUR)), PriceDraft.of(MoneyImpl.ofCents(600, EUR)).withCustomerGroup(customerGroup)) .build(); final LocalizedString slug = en(name).slugifiedUnique(); return ProductDraftBuilder.of(productType, en(name), slug, masterVariant) .variants(asList(secondVariant)) .description(en(name)) .metaTitle(en("cotton t-shirt")) .metaDescription(en("cotton t-shirt description")) .metaKeywords(en("cotton, t-shirt, clothes")) .build(); }