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

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

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

origin: commercetools/commercetools-jvm-sdk

  @Test
  public void checkProductVaiantAtributes() throws Exception {

    assertThat(productVariant.getSku().equals("1f92d491-2180-489c-bcef-3966cdc68c0b"));
    assertThat(productVariant.getPrices())
        .as("comparing prices ")
        .isEqualTo(asList(Price.of(BigDecimal.valueOf(12.34), DefaultCurrencyUnits.EUR).withCountry(CountryCode.DE).withId("70a56289-bd20-4c47-8364-47b498ad993b")));

    assertThat(productVariant.getImages().isEmpty());
    assertThat(productVariant.getAssets().isEmpty());
    assertThat(productVariant.getAttributes().isEmpty());

  }
}
origin: commercetools/commercetools-jvm-sdk

  @Test
  public void checkProductVaiantAtributes() throws Exception {

    assertThat(productVariant.getSku().equals("1f92d491-2180-489c-bcef-3966cdc68c0b"));
    assertThat(productVariant.getPrices())
        .as("comparing prices ")
        .isEqualTo(asList(Price.of(BigDecimal.valueOf(12.34), DefaultCurrencyUnits.EUR).withCountry(CountryCode.DE).withId("70a56289-bd20-4c47-8364-47b498ad993b")));

    assertThat(productVariant.getImages().isEmpty());
    assertThat(productVariant.getAssets().isEmpty());
    assertThat(productVariant.getAttributes().isEmpty());

  }
}
origin: commercetools/commercetools-jvm-sdk

  private void locationCheck(final Location searchLocation, final Zone ... expected) {
    final PagedQueryResult<Zone> result = client().executeBlocking(ZoneQuery.of().byLocation(searchLocation));
    final Set<Zone> actual = new HashSet<>(result.getResults());
    assertThat(actual).isEqualTo(new HashSet<>(asList(expected)));
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void testExtensionForOrder(){
  ExtensionResourceType extensionResourceType = ExtensionResourceType.ORDER;
  final List<Trigger> triggers = asList(TriggerBuilder.of(extensionResourceType, asList(TriggerType.CREATE, TriggerType.UPDATE)).build());
  final Destination destination =getDestination();
  withExtensionDraft(client(), ExtensionDraftBuilder.of(randomKey(), destination, triggers).build(), extension -> {
    assertThat(extension.getTriggers()).hasSize(1);
    assertThat(extension.getTriggers().get(0).getResourceTypeId()).isEqualByComparingTo(extensionResourceType);
    return extension;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void sortProductProjectionsOnSearchByCategory1() {
  final Comparator<ProductProjection> comparator = comparingCategoryOrderHints(category1Id);
  final List<String> expectedOrder = asList(id1, id3, id2, id5, id4);
  assertWithQueryResult(result -> {
    assertThat(productProjectionsSortedBy(result.productProjections, comparator)).isEqualTo(expectedOrder);
    assertThat(result.sortedFromSearchForCategory1).extracting("id").as("search").isEqualTo(expectedOrder);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void changeTriggers(){
  withExtension(client(), extension -> {
    final List<Trigger> triggers = asList(TriggerBuilder.of(ExtensionResourceType.CART, asList(TriggerType.CREATE)).build());
    Extension updatedExtension = client().executeBlocking(ExtensionUpdateCommand.of(extension, ChangeTriggers.of(triggers)));
    assertThat(updatedExtension.getTriggers()).containsAll(triggers);
    return updatedExtension;
  });
}
origin: commercetools/commercetools-jvm-sdk

public static void withUpdateableShippingMethod(final BlockingSphereClient client, final UnaryOperator<ShippingMethodDraftBuilder> builderMapper, final Function<ShippingMethod, ShippingMethod> f) {
  withTaxCategory(client, taxCategory -> {
    final ShippingMethodDraftBuilder builder = ShippingMethodDraftBuilder.of(randomString(), "test shipping method", taxCategory.toReference(), asList(), false);
    final ShippingMethodDraft draft = builderMapper.apply(builder).build();
    final ShippingMethod shippingMethod = client.executeBlocking(ShippingMethodCreateCommand.of(draft));
    final ShippingMethod possiblyUpdatedShippingMethod = f.apply(shippingMethod);
    client.executeBlocking(ShippingMethodDeleteCommand.of(possiblyUpdatedShippingMethod));
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void changeGroups() throws Exception {
  withPersistentDiscountCode(client(), discountCode -> {
    final long maxApplications = randomLong();
    final String GROUP_NAME = "GroupName";
    final DiscountCode updatedDiscountCode =
        client().executeBlocking(DiscountCodeUpdateCommand.of(discountCode, ChangeGroups.of(asList(GROUP_NAME))));
    assertThat(updatedDiscountCode.getGroups()).containsExactly(GROUP_NAME);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void changeValidFromUntil() throws Exception {
  withPersistentCartDiscount(client(), cartDiscount -> {
    final ZonedDateTime start = ZonedDateTime.parse("2015-07-09T07:46:40.230Z");
    final ZonedDateTime end = start.plusYears(100);
    final CartDiscount updatedDiscount =
        client().executeBlocking(CartDiscountUpdateCommand.of(cartDiscount, asList(SetValidFrom.of(start),SetValidUntil.of(end))));
    assertThat(updatedDiscount.getValidFrom()).isEqualTo(start);
    assertThat(updatedDiscount.getValidUntil()).isEqualTo(end);
  });
}
origin: commercetools/commercetools-jvm-sdk

public static ShoppingListDraftDsl newShoppingListDraftWithTextLineItem(final Long quantity) {
  final List<TextLineItemDraft> textLineItemDrafts = asList(
      TextLineItemDraftBuilder.of(en(randomString()), quantity).build());
  final ShoppingListDraftDsl shoppingListDraft = newShoppingListDraftBuilder().textLineItems(textLineItemDrafts).build();
  return shoppingListDraft;
}
origin: commercetools/commercetools-jvm-sdk

public static ShoppingListDraftDsl newShoppingListDraftWithLineItem(final Product product, final Long quantity) {
  final List<LineItemDraft> lineItemDrafts = asList(
      LineItemDraftBuilder.of(product.getId()).quantity(quantity).build());
  final ShoppingListDraftDsl shoppingListDraft = newShoppingListDraftBuilder().lineItems(lineItemDrafts).build();
  return shoppingListDraft;
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void addExternalImage() throws Exception {
  withUpdateableProduct(client(), (Product product) -> {
    assertThat(product.getMasterData().getStaged().getMasterVariant().getImages()).hasSize(0);
    final Image image = createExternalImage();
    final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, AddExternalImage.of(image, MASTER_VARIANT_ID)));
    assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getImages()).isEqualTo(asList(image));
    return updatedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void selectAPriceByCurrencyInProductProjectionByIdGet() {
  final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20));
  withProductOfPrices(prices, product -> {
    final ProductProjectionByIdGet request = ProductProjectionByIdGet.ofStaged(product)
        .withPriceSelection(PriceSelection.of(EUR));//price selection config
    final ProductProjection result = client().executeBlocking(request);
    final ProductVariant masterVariant = result.getMasterVariant();
    assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30)));
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void selectAPriceByCurrencyInProductByIdGet() {
  final List<PriceDraft> prices = asList(PriceDraft.of(EURO_30), PriceDraft.of(USD_20));
  withProductOfPrices(prices, product -> {
    final ProductByIdGet request = ProductByIdGet.of(product)
        .withPriceSelection(PriceSelection.of(EUR));//price selection config
    final Product result = client().executeBlocking(request);
    final ProductVariant masterVariant = result.getMasterData().getStaged().getMasterVariant();
    assertThat(masterVariant.getPrice()).isNotNull().has(price(PriceDraft.of(EURO_30)));
  });
}
origin: commercetools/commercetools-jvm-sdk

public static ProductType productReferenceProductType(final BlockingSphereClient client) {
  final AttributeDefinition productReferenceDefinition = AttributeDefinitionBuilder
      .of("productreference", en("suggested product"), ReferenceAttributeType.ofProduct())
      .required(true)
      .build();
  final ProductTypeDraft productTypeDraft = ProductTypeDraft.of(randomKey(), productReferenceProductTypeName, "has an attribute which is reference to a product", asList(productReferenceDefinition));
  final Optional<ProductType> productTypeOptional = client.executeBlocking(ProductTypeQuery.of().byName(productReferenceProductTypeName)).head();
  return productTypeOptional.orElseGet(() -> client.executeBlocking(ProductTypeCreateCommand.of(productTypeDraft)));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void removeImageByVariantId() throws Exception {
  final Image image = createExternalImage();
  withUpdateableProduct(client(), product -> {
    final Product productWithImage = client().executeBlocking(ProductUpdateCommand.of(product, AddExternalImage.ofVariantId(MASTER_VARIANT_ID, image)));
    assertThat(productWithImage.getMasterData().getStaged().getMasterVariant().getImages()).isEqualTo(asList(image));
    final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(productWithImage, RemoveImage.ofVariantId(MASTER_VARIANT_ID, image)));
    assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getImages()).hasSize(0);
    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: commercetools/commercetools-jvm-sdk

@Test
public void byCountry() throws Exception {
  ZoneFixtures.withUpdateableZone(client(), zoneA -> {
    ZoneFixtures.withUpdateableZone(client(), zoneB -> {
      final Set<Location> locations = zoneA.getLocations();
      final PagedQueryResult<Zone> result = client().executeBlocking(ZoneQuery.of().byCountry(oneOf(locations).getCountry()));
      assertThat(result.getResults()).isEqualTo(asList(zoneA));
      return zoneB;
    }, CF);
    return zoneA;
  }, CG);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void removeImageBySku() throws Exception {
  final Image image = createExternalImage();
  withUpdateableProduct(client(), product -> {
    final String sku = product.getMasterData().getStaged().getMasterVariant().getSku();
    final Product productWithImage = client().executeBlocking(ProductUpdateCommand.of(product, AddExternalImage.ofSku(sku, image)));
    assertThat(productWithImage.getMasterData().getStaged().getMasterVariant().getImages()).isEqualTo(asList(image));
    final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(productWithImage, RemoveImage.ofSku(sku, image)));
    assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getImages()).hasSize(0);
    return updatedProduct;
  });
}
origin: commercetools/commercetools-jvm-sdk

public static TypeDraftBuilder createTypeDraftBuilder() {
  final String typeKey = randomKey();
  return TypeDraftBuilder.of(typeKey, en(TYPE_NAME), TYPE_IDS)
      .description(en("description"))
      .fieldDefinitions(asList(stringfieldDefinition(), enumFieldDefinition(), localizedEnumFieldDefinition(), catRefDefinition(),
          booleanDefinition(), LocalizedStringDefinition(), intDefinition(), doubleDefinition(), bigDecimalDefinition(), moneyDefinition(),
          dateDefinition(), dateTimeDefinition(), timeDefinition(), stringSetDefinition()));
}
io.sphere.sdk.testSphereTestUtilsasList

Popular methods of SphereTestUtils

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

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
  • 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