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

How to use
ProductUpdateCommand
in
io.sphere.sdk.products.commands

Best Java code snippets using io.sphere.sdk.products.commands.ProductUpdateCommand (Showing top 20 results out of 315)

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

static ProductUpdateCommand of(final Versioned<Product> versioned, final UpdateAction<Product> updateAction) {
  return of(versioned, Collections.singletonList(updateAction));
}
origin: com.commercetools.sdk.jvm.core/commercetools-models

  static ProductUpdateCommand ofKey(final String key, final Long version, final UpdateAction<Product> updateAction) {
    return ofKey(key, version, Collections.singletonList(updateAction));
  }
}
origin: io.sphere.sdk.jvm/models

  public static ProductUpdateCommand of(final Versioned<Product> versioned, final List<? extends UpdateAction<Product>> updateActions) {
    return new ProductUpdateCommand(versioned, updateActions);
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void updateCommandPlusUpdateActions() {
  withUpdateableProduct(client(), (Product product) -> {
    assertThat(product.getMasterData().getStaged().getMasterVariant().getImages()).hasSize(0);
    final Image image = createExternalImage();
    final AddExternalImage updateAction1 = AddExternalImage.of(image, MASTER_VARIANT_ID);
    final ProductUpdateCommand command = ProductUpdateCommand.of(product, updateAction1);
    assertThat(command.getUpdateActions()).hasSize(1);
    assertThat(command.getUpdateActions().get(0)).isEqualTo(updateAction1);
    final LocalizedString localizedName = en("New Name");
    final ChangeName updateAction2 = ChangeName.of(localizedName);
    final ProductUpdateCommand updatedCommand = command.plusUpdateActions(asList(updateAction2));
    assertThat(updatedCommand.getUpdateActions()).hasSize(2);
    assertThat(updatedCommand.getUpdateActions().get(1)).isEqualTo(updateAction2);
    final Product updatedProduct = client().executeBlocking(updatedCommand);
    assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getImages()).isEqualTo(asList(image));
    assertThat(updatedProduct.getMasterData().getStaged().getName()).isEqualTo(localizedName);
    return updatedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void selectAPriceByCurrencyInProductUpdateCommand() {
  ProductFixtures.withProduct(client(), product -> {
    final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20));
    final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetPrices.of(1, prices))
        .withPriceSelection(PriceSelection.of(EUR));
    final Product updatedProduct = client().executeBlocking(cmd);
    final ProductVariant masterVariant = updatedProduct.getMasterData().getStaged().getMasterVariant();
    assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30)));
  });
}
origin: com.commercetools.sdk.jvm.core/commercetools-models

static ProductUpdateCommand of(final Versioned<Product> versioned, final UpdateAction<Product> updateAction) {
  return of(versioned, Collections.singletonList(updateAction));
}
origin: commercetools/commercetools-jvm-sdk

  static ProductUpdateCommand ofKey(final String key, final Long version, final UpdateAction<Product> updateAction) {
    return ofKey(key, version, Collections.singletonList(updateAction));
  }
}
origin: io.sphere.sdk.jvm/models

public static ProductUpdateCommand of(final Versioned<Product> versioned, final UpdateAction<Product> updateAction) {
  return of(versioned, asList(updateAction));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void productUpdateByKey() throws Exception {
  final String key = randomKey();
  withUpdateableProduct(client(), builder -> builder.key(key), product -> {
    final LocalizedString newName = LocalizedString.ofEnglish("newName " + RANDOM.nextInt());
    final ProductUpdateCommand cmd =
        ProductUpdateCommand.ofKey(key, product.getVersion(), ChangeName.of(newName));
    final Product updatedProduct = client().executeBlocking(cmd);
    assertThat(updatedProduct.getMasterData().getStaged().getName()).isEqualTo(newName);
    assertThat(updatedProduct.getKey()).isEqualTo(key);
    return updatedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

static ProductUpdateCommand of(final Versioned<Product> versioned, final UpdateAction<Product> updateAction) {
  return of(versioned, Collections.singletonList(updateAction));
}
origin: com.commercetools.sdk.jvm.core/commercetools-models

static ProductUpdateCommand ofKey(final String key, final Long version, final List<? extends UpdateAction<Product>> updateActions) {
  final Versioned<Product> versioned = Versioned.of("key=" + key, version);//hack for simple reuse
  return of(versioned, updateActions);
}
origin: commercetools/commercetools-jvm-sdk

static ProductUpdateCommand ofKey(final String key, final Long version, final List<? extends UpdateAction<Product>> updateActions) {
  final Versioned<Product> versioned = Versioned.of("key=" + key, version);//hack for simple reuse
  return of(versioned, updateActions);
}
origin: commercetools/commercetools-jvm-sdk

public static void withProductInCategory(final BlockingSphereClient client, final BiConsumer<Product, Category> consumer) {
  withCategory(client, category -> {
    final Consumer<Product> user = product -> consumer.accept(product, category);
    withProduct(client, "withProductAndCategory", product -> {
      final Product productWithCategory = client.executeBlocking(ProductUpdateCommand.of(product, AddToCategory.of(category)));
      consumer.accept(productWithCategory, category);
    });
  });
}
origin: commercetools/commercetools-jvm-sdk

public static void withUpdateablePricedProduct(final BlockingSphereClient client, final PriceDraft expectedPrice, final Function<Product, Product> f) {
  withUpdateableProduct(client, product -> {
    final ProductUpdateCommand command = ProductUpdateCommand.of(product, AddPrice.of(1, expectedPrice));
    return f.apply(client.executeBlocking(command));
  });
}
origin: commercetools/commercetools-jvm-sdk

private static ProductUpdateCommand createSetTaxesCommand(final TaxCategory taxCategory, final Product product) {
  return ProductUpdateCommand.of(product, asList(AddPrice.of(MASTER_VARIANT_ID, PRICE), SetTaxCategory.of(taxCategory), Publish.of()));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void publish() throws Exception {
  withUpdateableProduct(client(), product -> {
    assertThat(product.getMasterData().isPublished()).isFalse();
    final Product publishedProduct = client().executeBlocking(ProductUpdateCommand.of(product, Publish.of()));
    assertThat(publishedProduct.getMasterData().isPublished()).isTrue();
    final Product unpublishedProduct = client().executeBlocking(ProductUpdateCommand.of(publishedProduct, Unpublish.of()));
    assertThat(unpublishedProduct.getMasterData().isPublished()).isFalse();
    return unpublishedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

public void changeSlugWithStaged(final Boolean staged) {
  withUpdateableProduct(client(), product -> {
    assertThat(product.getMasterData().hasStagedChanges()).isFalse();
    final LocalizedString newSlug = LocalizedString.ofEnglish("new-slug-" + RANDOM.nextInt());
    final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, ChangeSlug.of(newSlug, staged)));
    assertThat(updatedProduct.getMasterData().getStaged().getSlug()).isEqualTo(newSlug);
    assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged);
    return updatedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

public void setDescriptionWithStaged(final Boolean staged) {
  withUpdateableProduct(client(), product -> {
    assertThat(product.getMasterData().hasStagedChanges()).isFalse();
    final LocalizedString newDescription = LocalizedString.ofEnglish("new description " + RANDOM.nextInt());
    final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetDescription.of(newDescription, staged));
    final Product updatedProduct = client().executeBlocking(cmd);
    assertThat(updatedProduct.getMasterData().getStaged().getDescription()).isEqualTo(newDescription);
    assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged);
    return updatedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

private void testAddPrice(final PriceDraft expectedPrice) throws Exception {
  withUpdateableProduct(client(), product -> {
    final Product updatedProduct = client()
        .executeBlocking(ProductUpdateCommand.of(product, AddPrice.of(1, expectedPrice)));
    final List<Price> prices = updatedProduct.getMasterData().getStaged().getMasterVariant().getPrices();
    assertThat(prices).hasSize(1);
    final Price actualPrice = prices.get(0);
    assertThat(expectedPrice).isEqualTo(PriceDraft.of(actualPrice));
    return updatedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void removePrice() throws Exception {
  withUpdateablePricedProduct(client(), product -> {
    final Price oldPrice = getFirstPrice(product);
    final Product updatedProduct = client()
        .executeBlocking(ProductUpdateCommand.of(product, RemovePrice.of(oldPrice)));
    assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant()
        .getPrices().stream().anyMatch(p -> p.equals(oldPrice))).isFalse();
    return updatedProduct;
  });
}
io.sphere.sdk.products.commandsProductUpdateCommand

Javadoc

list actions

Most used methods

  • of
  • ofKey
  • <init>
  • getUpdateActions
  • plusUpdateActions
  • withPriceSelection

Popular in Java

  • Reading from database using SQL prepared statement
  • findViewById (Activity)
  • getContentResolver (Context)
  • getSystemService (Context)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • CodeWhisperer alternatives
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