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

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

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

origin: commercetools/commercetools-jvm-sdk

@Test
public void changeOrderHint() throws Exception {
  withCategory(client(), category -> {
    final String newOrderHint = randomSortOrder();
    final CategoryUpdateCommand command = CategoryUpdateCommand.of(category, ChangeOrderHint.of(newOrderHint));
    final Category updatedCategory = client().executeBlocking(command);
    assertThat(updatedCategory.getOrderHint()).isEqualTo(newOrderHint);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void changeSortOrder() throws Exception {
  withPersistentCartDiscount(client(), cartDiscount -> {
    final String newSortOrder = randomSortOrder();
    assertThat(cartDiscount.getSortOrder()).isNotEqualTo(newSortOrder);
    final CartDiscount updatedDiscount =
        client().executeBlocking(CartDiscountUpdateCommand.of(cartDiscount, ChangeSortOrder.of(newSortOrder)));
    assertThat(updatedDiscount.getSortOrder()).isEqualTo(newSortOrder);
  });
}
origin: commercetools/commercetools-jvm-sdk

  @Test
  public void changeSortOrder() throws Exception {
    withUpdateableProductDiscount(client(), discount -> {
      final String newSortOrder = randomSortOrder();

      final ProductDiscount updatedDiscount = client().executeBlocking(ProductDiscountUpdateCommand.of(discount, ChangeSortOrder.of(newSortOrder)));

      assertThat(updatedDiscount.getSortOrder()).isEqualTo(newSortOrder);
      return updatedDiscount;
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

private ProductDiscountDraft discountDraftOfAbsoluteValue(final Product product, final MonetaryAmount amount) {
  final AbsoluteProductDiscountValue value = ProductDiscountValue.ofAbsolute(amount);
  final ProductDiscountPredicate predicate =
      ProductDiscountPredicate.of("product.id = \"" + product.getId() + "\"");
  return ProductDiscountDraft.of(randomSlug(), randomSlug(), predicate, value, randomSortOrder(), true);
}
origin: commercetools/commercetools-jvm-sdk

public void setDiscountedPriceWithStaged(final Boolean staged) {
  final ProductDiscountPredicate predicate = ProductDiscountPredicate.of("1 = 1");//can be used for all products
  final ProductDiscountDraft productDiscountDraft = ProductDiscountDraft.of(randomSlug(), randomSlug(),
      predicate, ExternalProductDiscountValue.of(), randomSortOrder(), true);
  //don't forget that one product discount can be used for multiple products
  withProductDiscount(client(), productDiscountDraft, externalProductDiscount -> {
    withProductOfPrices(client(), singletonList(PriceDraft.of(EURO_40)), product -> {
      final Product publishedProduct = client().executeBlocking(ProductUpdateCommand.of(product, Publish.of()));
      final Price originalPrice = publishedProduct.getMasterData().getStaged().getMasterVariant().getPrices().get(0);
      assertThat(originalPrice.getDiscounted()).isNull();
      final String priceId = originalPrice.getId();
      final SetDiscountedPrice action =
          SetDiscountedPrice.of(priceId, DiscountedPrice.of(EURO_5, externalProductDiscount.toReference()), staged);
      final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(publishedProduct, action));
      final Price stagedPrice = updatedProduct.getMasterData().getStaged().getMasterVariant().getPrices().get(0);
      assertThat(stagedPrice.getValue()).isEqualTo(EURO_40);
      assertThat(stagedPrice.getDiscounted().getValue()).isEqualTo(EURO_5);
      assertThat(stagedPrice.getDiscounted().getDiscount()).isEqualTo(externalProductDiscount.toReference());
      final Price currentPrice = updatedProduct.getMasterData().getCurrent().getMasterVariant().getPrices().get(0);
      if (staged) {
        assertThat(stagedPrice).isNotEqualTo(currentPrice);
      } else {
        assertThat(stagedPrice).isEqualTo(currentPrice);
      }
    });
  });
}
origin: commercetools/commercetools-jvm-sdk

private static CartDiscountDraftBuilder newCartDiscountDraftBuilder(final String predicate) {
  final ZonedDateTime validFrom = ZonedDateTime.now().minusHours(1);
  final ZonedDateTime validUntil = validFrom.plusSeconds(8000);
  final LocalizedString name = en("discount name");
  final LocalizedString description = en("discount descriptions");
  final AbsoluteCartDiscountValue value = CartDiscountValue.ofAbsolute(MoneyImpl.of(10, EUR));
  final LineItemsTarget target = LineItemsTarget.of("1 = 1");
  final String sortOrder = randomSortOrder();
  final boolean requiresDiscountCode = false;
  return CartDiscountDraftBuilder.of(name, CartPredicate.of(predicate),
      value, target, sortOrder, requiresDiscountCode)
      .validFrom(validFrom)
      .validUntil(validUntil)
      .description(description);
}
origin: commercetools/commercetools-jvm-sdk

final ProductDiscountPredicate predicate = ProductDiscountPredicate.of("1 = 1");//can be used for all products
final ProductDiscountDraft productDiscountDraft = ProductDiscountDraft.of(randomSlug(), randomSlug(),
    predicate, ExternalProductDiscountValue.of(), randomSortOrder(), true);
origin: commercetools/commercetools-jvm-sdk

final MonetaryAmount discountAmount = EURO_1;
final AbsoluteCartDiscountValue value = CartDiscountValue.ofAbsolute(discountAmount);
final CartDiscountDraft discountDraft = CartDiscountDraftBuilder.of(name, cartPredicate, value, LineItemsTarget.ofAll(), randomSortOrder(), false)
    .build();
final CartDiscount cartDiscount = client().executeBlocking(CartDiscountCreateCommand.of(discountDraft));
origin: commercetools/commercetools-jvm-sdk

final LocalizedString description = en("description");
final boolean active = true;
final String sortOrder = randomSortOrder();
final ProductDiscountDraft discountDraft =
    ProductDiscountDraftBuilder.of()
origin: commercetools/commercetools-jvm-sdk

public static void withUpdateableProductDiscount(final BlockingSphereClient client, final BiFunction<ProductDiscount, Product, ProductDiscount> function) {
  withUpdateableProduct(client, builder -> builder.masterVariant(ProductVariantDraftBuilder.of().price(PRICE).build()), product -> {
    final ProductDiscountPredicate predicate =
        ProductDiscountPredicate.of("product.id = \"" + product.getId() + "\"");
    final AbsoluteProductDiscountValue discountValue = AbsoluteProductDiscountValue.of(EURO_1);
    final LocalizedString name = en("demo product discount");
    final LocalizedString description = en("description");
    final boolean active = true;
    final String sortOrder = randomSortOrder();
    final ProductDiscountDraft discountDraft =
        ProductDiscountDraft.of(name, description, predicate, discountValue, sortOrder, active);
    final ProductDiscount productDiscount = client.executeBlocking(ProductDiscountCreateCommand.of(discountDraft));
    final ProductDiscount updatedDiscount = function.apply(productDiscount, product);
    client.executeBlocking(ProductDiscountDeleteCommand.of(updatedDiscount));
    return client.executeBlocking(ProductByIdGet.of(product));
  });
}
io.sphere.sdk.testSphereTestUtilsrandomSortOrder

Popular methods of SphereTestUtils

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

Popular in Java

  • Reactive rest calls using spring rest template
  • onRequestPermissionsResult (Fragment)
  • getSupportFragmentManager (FragmentActivity)
  • putExtra (Intent)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top PhpStorm 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