public ProductDraftDsl withSearchKeywords(final SearchKeywords searchKeywords) { return newBuilder().searchKeywords(searchKeywords).build(); }
public static void withSuggestProduct(final BlockingSphereClient client, final Consumer<Product> consumer) { withEmptyProductType(client, randomKey(), productType -> { final SearchKeywords searchKeywords = SearchKeywords.of( Locale.ENGLISH, asList(SearchKeyword.of("Multi tool"), SearchKeyword.of("Swiss Army Knife", WhiteSpaceSuggestTokenizer.of())), Locale.GERMAN, singletonList(SearchKeyword.of("Schweizer Messer", CustomSuggestTokenizer.of(asList("schweizer messer", "offiziersmesser", "sackmesser")))) ); final ProductDraftBuilder productDraftBuilder = ProductDraftBuilder.of(productType, randomSlug(), randomSlug(), ProductVariantDraftBuilder.of().build()) .searchKeywords(searchKeywords); withProduct(client, productDraftBuilder, consumer); }); }
.categories(categories) .taxCategory(taxCategory) .searchKeywords(searchKeywords) .state(state) .categoryOrderHints(categoryOrderHints)
@Test public void createProductWithExternalImage() throws Exception { withStateByBuilder(client(), stateBuilder -> stateBuilder.initial(true).type(PRODUCT_STATE), initialProductState -> { final ProductType productType = ProductTypeFixtures.defaultProductType(client()); final Image image = Image.ofWidthAndHeight("http://www.commercetools.com/assets/img/ct_logo_farbe.gif", 460, 102, "commercetools logo"); final ProductVariantDraft masterVariant = ProductVariantDraftBuilder.of() .images(image) .build(); final TaxCategory taxCategory = defaultTaxCategory(client()); final SearchKeywords searchKeywords = SearchKeywords.of(Locale.ENGLISH, asList(SearchKeyword.of("foo bar baz", CustomSuggestTokenizer.of(asList("foo, baz"))))); final ProductDraft productDraft = ProductDraftBuilder .of(productType, en("product with external image"), randomSlug(), masterVariant) .taxCategory(taxCategory) .searchKeywords(searchKeywords) .state(initialProductState) .build(); final Product product = client().executeBlocking(ProductCreateCommand.of(productDraft)); final Image loadedImage = product.getMasterData().getStaged().getMasterVariant().getImages().get(0); assertThat(loadedImage).isEqualTo(image); assertThat(product.getTaxCategory()).isEqualTo(taxCategory.toReference()); assertThat(product.getMasterData().getStaged().getSearchKeywords()).isEqualTo(searchKeywords); assertThat(product.getState()).isEqualTo(initialProductState.toReference()); //clean up test client().executeBlocking(ProductDeleteCommand.of(product)); }); }