Tabnine Logo
SphereTestUtils.englishSlugOf
Code IndexAdd Tabnine to your IDE (free)

How to use
englishSlugOf
method
in
io.sphere.sdk.test.SphereTestUtils

Best Java code snippets using io.sphere.sdk.test.SphereTestUtils.englishSlugOf (Showing top 5 results out of 315)

origin: commercetools/commercetools-jvm-sdk

public static void withCategories(final BlockingSphereClient client, final List<Supplier<? extends CategoryDraft>> creator, final Consumer<List<Category>> user) {
  List<Category> categories = creator.stream().map(singleCreator -> {
    final CategoryDraft categoryDraft = singleCreator.get();
    final String slug = englishSlugOf(categoryDraft);
    final PagedQueryResult<Category> pagedQueryResult = client.executeBlocking(CategoryQuery.of().bySlug(Locale.ENGLISH, slug));
    pagedQueryResult.head().ifPresent(
        category -> client.executeBlocking(CategoryDeleteCommand.of(category))
    );
    final Category category = client.executeBlocking(CategoryCreateCommand.of(categoryDraft));
    return category;
  }).collect(Collectors.toList());
  try {
    user.accept(categories);
  } finally {
    categories.forEach(category -> {
      client.executeBlocking(CategoryDeleteCommand.of(category));
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

public static void withUpdateableProduct(final BlockingSphereClient client, final Supplier<? extends ProductDraft> creator, final Function<Product, Product> user) {
  final ProductDraft productDraft = creator.get();
  final String slug = englishSlugOf(productDraft);
  final PagedQueryResult<Product> pagedQueryResult = client.executeBlocking(ProductQuery.of().bySlug(ProductProjectionType.CURRENT, Locale.ENGLISH, slug));
  delete(client, pagedQueryResult.getResults());
  final Product product = client.executeBlocking(ProductCreateCommand.of(productDraft));
  final Product possiblyUpdateProduct = user.apply(product);
  delete(client, possiblyUpdateProduct);
}
origin: commercetools/commercetools-jvm-sdk

public static void withCategory(final BlockingSphereClient client, final Supplier<? extends CategoryDraft> creator, final Consumer<Category> user) {
  final CategoryDraft categoryDraft = creator.get();
  final String slug = englishSlugOf(categoryDraft);
  final PagedQueryResult<Category> pagedQueryResult = client.executeBlocking(CategoryQuery.of().bySlug(Locale.ENGLISH, slug));
  pagedQueryResult.head().ifPresent(category -> client.executeBlocking(CategoryDeleteCommand.of(category)));
  final Category category = client.executeBlocking(CategoryCreateCommand.of(categoryDraft));
  LOGGER.debug(() -> "created category " + category.getSlug() + " id: " + category.getId());
  try {
    user.accept(category);
  } finally {
    final PagedQueryResult<Category> res = client.executeBlocking(CategoryQuery.of().byId(category.getId()));
    //need to update because category could be changed
    client.executeBlocking(CategoryDeleteCommand.of(res.head().get()));
    LOGGER.debug(() -> "deleted category " + category.getId());
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void productType() throws Exception {
  final Consumer<Product> user = product -> {
    final Query<Product> query = ProductQuery.of().
        bySlug(ProductProjectionType.CURRENT, Locale.ENGLISH, englishSlugOf(product.getMasterData().getStaged())).
        withExpansionPaths(ProductExpansionModel.of().productType()).
        toQuery();
    final PagedQueryResult<Product> queryResult = client().executeBlocking(query);
    final Reference<ProductType> productTypeReference = queryResult.head().get().getProductType();
    assertThat(productTypeReference).is(expanded());
  };
  withProduct(client(), "productTypeReferenceExpansion", user);
}
origin: commercetools/commercetools-jvm-sdk

  @Test
  public void taxCategory() throws Exception {
    TaxCategoryFixtures.withTransientTaxCategory(client(), taxCategory ->
      withProduct(client(), product -> {
        final Product productWithTaxCategory = client().executeBlocking(ProductUpdateCommand.of(product, SetTaxCategory.of(taxCategory)));
        assertThat(productWithTaxCategory.getTaxCategory()).isNotNull();
        final Query<Product> query = ProductQuery.of().
            bySlug(ProductProjectionType.CURRENT, Locale.ENGLISH, englishSlugOf(product.getMasterData().getStaged())).
            withExpansionPaths(ProductExpansionModel.of().taxCategory()).
            toQuery();
        final PagedQueryResult<Product> queryResult = client().executeBlocking(query);
        final Reference<TaxCategory> productTypeReference = firstOf(queryResult).getTaxCategory();
        assertThat(productTypeReference).is(expanded());
      })
    );
  }
}
io.sphere.sdk.testSphereTestUtilsenglishSlugOf

Popular methods of SphereTestUtils

  • randomKey
  • randomString
  • assertEventually
  • now
  • randomInt
  • en
  • jsonNodeFromResource
  • stringFromResource
  • asList
  • consumerToFunction
  • draftFromJsonResource
  • firstOf
  • draftFromJsonResource,
  • firstOf,
  • oneOf,
  • randomEmail,
  • randomLocalizedString,
  • randomLong,
  • randomMetaAttributes,
  • randomSlug,
  • randomSortOrder

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSharedPreferences (Context)
  • startActivity (Activity)
  • setRequestProperty (URLConnection)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Join (org.hibernate.mapping)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now