Tabnine Logo
ProductData.getSlug
Code IndexAdd Tabnine to your IDE (free)

How to use
getSlug
method
in
io.sphere.sdk.products.ProductData

Best Java code snippets using io.sphere.sdk.products.ProductData.getSlug (Showing top 14 results out of 315)

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

@Override
public LocalizedString getSlug() {
  return productData.getSlug();
}
origin: io.sphere.sdk.jvm/products

@Override
public LocalizedStrings getSlug() {
  return productData.getSlug();
}
origin: com.commercetools.sdk.jvm.core/commercetools-models

@Override
public LocalizedString getSlug() {
  return productData.getSlug();
}
origin: io.sphere.sdk.jvm/models

@Override
public LocalizedStrings getSlug() {
  return productData.getSlug();
}
origin: commercetools/commercetools-jvm-sdk

@Override
public LocalizedString getSlug() {
  return productData.getSlug();
}
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

@Test
public void addLineItem() throws Exception {
  withEmptyCartAndProduct(client(), (cart, product) -> {
    assertThat(cart.getLineItems()).isEmpty();
    final long quantity = 3;
    final String productId = product.getId();
    final AddLineItem action = AddLineItem.of(productId, MASTER_VARIANT_ID, quantity);
    final Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart, action));
    assertThat(updatedCart.getLineItems()).hasSize(1);
    final LineItem lineItem = updatedCart.getLineItems().get(0);
    assertThat(lineItem.getName()).isEqualTo(product.getMasterData().getStaged().getName());
    assertThat(lineItem.getQuantity()).isEqualTo(quantity);
    assertThat(lineItem.getProductSlug()).isEqualTo(product.getMasterData().getStaged().getSlug());
    assertThat(lineItem.getVariant().getIdentifier()).isEqualTo(ByIdVariantIdentifier.of(lineItem.getProductId(), lineItem.getVariant().getId()));
    assertThat(lineItem.getDiscountedPricePerQuantity()).isNotNull().isEmpty();
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void changeSlug() throws Exception {
  withUpdateableProduct(client(), product -> {
    final LocalizedString newSlug = LocalizedString.ofEnglish("new-slug-" + RANDOM.nextInt());
    final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, ChangeSlug.of(newSlug)));
    assertThat(updatedProduct.getMasterData().getStaged().getSlug()).isEqualTo(newSlug);
    //query message
    assertEventually(() -> {
      final Query<ProductSlugChangedMessage> query = MessageQuery.of()
          .withPredicates(m -> m.resource().is(product))
          .forMessageType(ProductSlugChangedMessage.MESSAGE_HINT);
      final List<ProductSlugChangedMessage> results =
          client().executeBlocking(query).getResults();
      assertThat(results).hasSize(1);
      final ProductSlugChangedMessage message = results.get(0);
      assertThat(message.getSlug()).isEqualTo(newSlug);
    });
    return updatedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

  @Test
  public void execution2() throws Exception {
    withProduct(client(), product -> {
      final String slug = product.getMasterData().getStaged().getSlug().get(Locale.ENGLISH);
      final ProductProjectionQuery normalSphereRequest = ProductProjectionQuery.ofStaged()
          .withPredicates(m -> m.slug().locale(Locale.ENGLISH).is(slug))
          .plusExpansionPaths(m -> m.productType());
      final JsonNodeSphereRequest jsonNodeSphereRequest = JsonNodeSphereRequest.of(normalSphereRequest);
      assertThat(normalSphereRequest.httpRequestIntent())
          .as("a JsonNodeSphereRequest creates the same request to the platform, but differs in the response")
          .isEqualTo(jsonNodeSphereRequest.httpRequestIntent());
      final PagedQueryResult<ProductProjection> productProjectionPagedSearchResult =
          client().executeBlocking(normalSphereRequest);
      final JsonNode jsonNode = client().executeBlocking(jsonNodeSphereRequest);//all will be returned as JSON
      assertThat(jsonNode.get("results").get(0).get("productType").get("obj").get("description").asText())
          .as("the expansion paths are honored")
          .isEqualTo("a 'T' shaped cloth");
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void addLineItemOfDraftOfSku() throws Exception {
  withEmptyCartAndProduct(client(), (cart, product) -> {
    assertThat(cart.getLineItems()).isEmpty();
    final long quantity = 3;
    final Channel inventorySupplyChannel = ChannelFixtures.persistentChannelOfRole(client(), ChannelRole.INVENTORY_SUPPLY);
    final Channel distributionChannel = ChannelFixtures.persistentChannelOfRole(client(), ChannelRole.PRODUCT_DISTRIBUTION);
    final String sku = product.getMasterData().getStaged().getMasterVariant().getSku();
    final LineItemDraft lineItemDraft =
        io.sphere.sdk.carts.LineItemDraftBuilder.ofSku(sku, quantity)
            .distributionChannel(distributionChannel)
            .supplyChannel(inventorySupplyChannel)
            .build();
    final AddLineItem action = AddLineItem.of(lineItemDraft);
    final Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart, action));
    assertThat(updatedCart.getLineItems()).hasSize(1);
    final LineItem lineItem = updatedCart.getLineItems().get(0);
    assertThat(lineItem.getName()).isEqualTo(product.getMasterData().getStaged().getName());
    assertThat(lineItem.getQuantity()).isEqualTo(quantity);
    assertThat(lineItem.getProductSlug()).isEqualTo(product.getMasterData().getStaged().getSlug());
    assertThat(lineItem.getVariant().getIdentifier()).isEqualTo(ByIdVariantIdentifier.of(lineItem.getProductId(), lineItem.getVariant().getId()));
    assertThat(lineItem.getSupplyChannel().toReference()).isEqualTo(inventorySupplyChannel.toReference());
    assertThat(lineItem.getDistributionChannel().toReference()).isEqualTo(distributionChannel.toReference());
    assertThat(lineItem.getDiscountedPricePerQuantity()).isNotNull().isEmpty();
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void addLineItemOfDraftOfVariantIdentifier() throws Exception {
  withEmptyCartAndProduct(client(), (cart, product) -> {
    assertThat(cart.getLineItems()).isEmpty();
    final long quantity = 3;
    final Channel inventorySupplyChannel = ChannelFixtures.persistentChannelOfRole(client(), ChannelRole.INVENTORY_SUPPLY);
    final Channel distributionChannel = ChannelFixtures.persistentChannelOfRole(client(), ChannelRole.PRODUCT_DISTRIBUTION);
    ByIdVariantIdentifier variantIdentifier = product.getMasterData().getStaged().getMasterVariant().getIdentifier();
    final LineItemDraft lineItemDraft =
        io.sphere.sdk.carts.LineItemDraftBuilder.ofVariantIdentifier(variantIdentifier, quantity)
            .distributionChannel(distributionChannel)
            .supplyChannel(inventorySupplyChannel)
            .build();
    final AddLineItem action = AddLineItem.of(lineItemDraft);
    final Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart, action));
    assertThat(updatedCart.getLineItems()).hasSize(1);
    final LineItem lineItem = updatedCart.getLineItems().get(0);
    assertThat(lineItem.getName()).isEqualTo(product.getMasterData().getStaged().getName());
    assertThat(lineItem.getQuantity()).isEqualTo(quantity);
    assertThat(lineItem.getProductSlug()).isEqualTo(product.getMasterData().getStaged().getSlug());
    assertThat(lineItem.getVariant().getIdentifier()).isEqualTo(ByIdVariantIdentifier.of(lineItem.getProductId(), lineItem.getVariant().getId()));
    assertThat(lineItem.getSupplyChannel().toReference()).isEqualTo(inventorySupplyChannel.toReference());
    assertThat(lineItem.getDistributionChannel().toReference()).isEqualTo(distributionChannel.toReference());
    assertThat(lineItem.getDiscountedPricePerQuantity()).isNotNull().isEmpty();
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void queryBySlug() throws Exception {
  with2products("queryBySlug", (p1, p2) ->{
    final Query<ProductProjection> query1 = ProductProjectionQuery.of(STAGED).bySlug(ENGLISH, p1.getMasterData().getStaged().getSlug().get(ENGLISH));
    assertThat(ids(client().executeBlocking(query1))).containsOnly(p1.getId());
  });
}
origin: commercetools/commercetools-jvm-sdk

  @Test
  public void message() {
    ProductFixtures.withUpdateableProduct(client(), product -> {
      assertThat(product.getMasterData().isPublished()).isFalse();
      final Product publishedProduct = client().executeBlocking(ProductUpdateCommand.of(product, Publish.of()));
      Query<ProductPublishedMessage> messageQuery = MessageQuery.of()
          .withPredicates(m -> m.resource().is(product))
          .withSort(m -> m.createdAt().sort().desc())
          .withExpansionPaths(m -> m.resource())
          .withLimit(1L)
          .forMessageType(ProductPublishedMessage.MESSAGE_HINT);

      assertEventually(() -> {
        final PagedQueryResult<ProductPublishedMessage> queryResult = client().executeBlocking(messageQuery);

        assertThat(queryResult.head()).isPresent();
        final ProductPublishedMessage message = queryResult.head().get();
        assertThat(message.getResource().getId()).isEqualTo(product.getId());
        assertThat(message.getProductProjection().getMasterVariant()).isEqualTo(publishedProduct.getMasterData().getCurrent().getMasterVariant());
        assertThat(message.getResource().getObj().getMasterData().getCurrent().getSlug()).isEqualTo(message.getProductProjection().getSlug());
        assertThat(message.getRemovedImageUrls().size()).isEqualTo(0);
      });
      return publishedProduct;
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void createPublishedProduct() {
  withEmptyProductType(client(), randomKey(), productType -> {
    final ProductVariantDraft masterVariant = ProductVariantDraftBuilder.of().build();
    final LocalizedString name = randomSlug();
    final LocalizedString slug = randomSlug();
    final ProductDraft productDraft = ProductDraftBuilder.of(productType, name, slug, masterVariant)
        .publish(true)
        .build();
    final Product product = client().executeBlocking(ProductCreateCommand.of(productDraft));
    assertThat(product.getMasterData().isPublished()).isTrue();
    assertThat(product.getMasterData().getCurrent().getSlug()).isEqualTo(slug);
    assertEventually(() -> {
      final ProductProjectionSearch search = ProductProjectionSearch.ofCurrent()
          .withQueryFilters(m -> m.id().is(product.getId()));
      final PagedSearchResult<ProductProjection> searchResult = client().executeBlocking(search);
      assertThat(searchResult.getResults()).hasSize(1);
    });
    unpublishAndDelete(product);
  });
}
io.sphere.sdk.productsProductDatagetSlug

Popular methods of ProductData

  • getCategories
  • getDescription
  • getMasterVariant
  • getMetaDescription
  • getMetaKeywords
  • getMetaTitle
  • getName
  • getVariants
  • getSearchKeywords
  • getCategoryOrderHints
  • getAllVariants
  • getAllVariants

Popular in Java

  • Making http post requests using okhttp
  • setScale (BigDecimal)
  • getSystemService (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JButton (javax.swing)
  • JLabel (javax.swing)
  • Best IntelliJ 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