Tabnine Logo
ProductTypeDeleteCommand
Code IndexAdd Tabnine to your IDE (free)

How to use
ProductTypeDeleteCommand
in
io.sphere.sdk.producttypes.commands

Best Java code snippets using io.sphere.sdk.producttypes.commands.ProductTypeDeleteCommand (Showing top 13 results out of 315)

origin: io.sphere.sdk.jvm/sphere-models

  static ProductTypeDeleteCommand ofKey(final String key, final Long version) {
    final Versioned<ProductType> versioned = Versioned.of("key=" + key, version);//hack for simple reuse
    return of(versioned);
  }
}
origin: io.sphere.sdk.jvm/models

  public static DeleteCommand<ProductType> of(final Versioned<ProductType> versioned) {
    return new ProductTypeDeleteCommand(versioned);
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void executionByKey() throws Exception {
  final ProductType productType = client().executeBlocking(ProductTypeCreateCommand.of(getDraft()));
  client().executeBlocking(ProductTypeDeleteCommand.ofKey(productType.getKey(), productType.getVersion()));
  final Query<ProductType> query = ProductTypeQuery.of()
      .withPredicates(m -> m.id().is(productType.getId()));
  assertThat(client().executeBlocking(query).head()).isEmpty();
}
origin: com.commercetools.sdk.jvm.core/commercetools-models

/**
  Creates a command object to delete a {@link ProductType} by its key.
  @param key the key of the ProductType to delete, see {@link ProductType#getKey()}
  @param version `the current version of the ProductType, see {@link ProductType#getVersion()}
  @return delete command
*/
static ProductTypeDeleteCommand ofKey(final String key, final Long version) {
  final Versioned<ProductType> versioned = Versioned.of("key=" + urlEncode(key), version);//hack for simple reuse
  return of(versioned);
}
origin: commercetools/commercetools-jvm-sdk

public static void destroy(final BlockingSphereClient client, final Data data) {
  final List<CompletionStage<Product>> productDeletions = data.getAllProducts().stream()
      .map(product -> client.execute(ProductDeleteCommand.of(product)))
      .collect(toList());
  productDeletions.forEach(stage -> SphereClientUtils.blockingWait(stage, 2, TimeUnit.SECONDS));
  client.executeBlocking(ProductTypeDeleteCommand.of(data.getProductType()));
}
origin: commercetools/commercetools-jvm-sdk

public static void deleteProductType(final BlockingSphereClient client, final ProductType productType) {
  try {
    client.executeBlocking(ProductTypeDeleteCommand.of(productType));
  } catch (Exception e) {
    getLogger("test.fixtures").debug(() -> "no product type to delete");
  }
}
origin: commercetools/commercetools-jvm-sdk

  public static void removeProductTypeByKey(final BlockingSphereClient client, final String productTypeKey) {
    final ProductType productType = client.executeBlocking(ProductTypeByKeyGet.of(productTypeKey));
    if (productType != null) {
      client.executeBlocking(ProductTypeDeleteCommand.of(productType));
    }
  }
}
origin: commercetools/commercetools-jvm-sdk

@After
public void tearDown() throws Exception {
  if (product != null) {
    client().executeBlocking(ProductDeleteCommand.of(product));
  }
  if (productType != null) {
    client().executeBlocking(ProductTypeDeleteCommand.of(productType));
  }
}
origin: commercetools/commercetools-jvm-sdk

@Before
@After
public void setUp() throws Exception {
  client().executeBlocking(ProductTypeQuery.of().byName(getName())).getResults().forEach(pt -> client().executeBlocking(ProductTypeDeleteCommand.of(pt)));
}
origin: commercetools/commercetools-jvm-sdk

private static void withProductInCategory(final BlockingSphereClient client, final Referenceable<Category> category, final Consumer<Product> user) {
  final ProductType productType = client.executeBlocking(ProductTypeCreateCommand.of(ProductTypeDraft.of(randomKey(), CategoryDocumentationIntegrationTest.class.getSimpleName(), "", asList())));
  final LocalizedString name = LocalizedString.of(ENGLISH, "foo");
  final Product product = client.executeBlocking(ProductCreateCommand.of(ProductDraftBuilder.of(productType, name, name.slugifiedUnique(), ProductVariantDraftBuilder.of().build()).categories(asSet(category.toReference())).build()));
  user.accept(product);
  client.executeBlocking(ProductDeleteCommand.of(product));
  client.executeBlocking(ProductTypeDeleteCommand.of(productType));
}
origin: commercetools/commercetools-jvm-sdk

public static void withUpdateableProductType(final BlockingSphereClient client, final Supplier<ProductTypeDraft> creator, final UnaryOperator<ProductType> user) {
  final SphereInternalLogger logger = SphereInternalLogger.getLogger("product-types.fixtures");
  final ProductTypeDraft productTypeDraft = creator.get();
  final String name = productTypeDraft.getName();
  final PagedQueryResult<ProductType> queryResult = client.executeBlocking(ProductTypeQuery.of().byName(name));
  queryResult.getResults().forEach(productType -> {
    final PagedQueryResult<Product> pagedQueryResult = client.executeBlocking(ProductQuery.of().byProductType(productType));
    delete(client, pagedQueryResult.getResults());
    client.executeBlocking(ProductTypeDeleteCommand.of(productType));
  });
  final ProductType productType = client.executeBlocking(ProductTypeCreateCommand.of(productTypeDraft));
  logger.debug(() -> "created product type " + productType.getName() + " " + productType.getId());
  final ProductType updated = user.apply(productType);
  logger.debug(() -> "attempt to delete product type " + productType.getName() + " " + productType.getId());
  try {
    client.executeBlocking(ProductTypeDeleteCommand.of(updated));
  } catch (final Exception e) {
    final PagedQueryResult<Product> pagedQueryResult = client.executeBlocking(ProductQuery.of().byProductType(productType));
    delete(client, pagedQueryResult.getResults());
    client.executeBlocking(ProductTypeDeleteCommand.of(productType));
  }
}
origin: commercetools/commercetools-jvm-sdk

@AfterClass
@BeforeClass
public static void deleteProductsAndProductType() {
  final List<ProductType> productTypes = client().executeBlocking(ProductTypeQuery.of().byName(PRODUCT_TYPE_NAME)).getResults();
  if (!productTypes.isEmpty()) {
    final ProductQuery productQuery = ProductQuery.of()
        .withPredicates(m -> m.productType().isIn(productTypes))
        .withLimit(500L);
    client().executeBlocking(productQuery).getResults().forEach(p -> client().executeBlocking(ProductDeleteCommand.of(p)));
    productTypes.forEach(p -> client().executeBlocking(ProductTypeDeleteCommand.of(p)));
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void execution() throws Exception {
  final ProductType productType = client().executeBlocking(ProductTypeCreateCommand.of(getDraft()));
  client().executeBlocking(ProductTypeDeleteCommand.of(productType));
  final Query<ProductType> query = ProductTypeQuery.of()
      .withPredicates(m -> m.id().is(productType.getId()));
  assertThat(client().executeBlocking(query).head()).isEmpty();
}
io.sphere.sdk.producttypes.commandsProductTypeDeleteCommand

Javadoc

Deletes a product type.

Delete by ID:

io.sphere.sdk.producttypes.commands.ProductTypeDeleteCommandTest#execution()

Delete by key:

io.sphere.sdk.producttypes.commands.ProductTypeDeleteCommandTest#executionByKey()

Most used methods

  • of
    Creates a command object to delete a ProductType by ID.
  • <init>
  • ofKey
    Creates a command object to delete a ProductType by its key.

Popular in Java

  • Creating JSON documents from java classes using gson
  • requestLocationUpdates (LocationManager)
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top Sublime Text plugins
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