use of com.commercetools.sync.cartdiscounts.CartDiscountSyncOptionsBuilder in project commercetools-sync-java by commercetools.
the class CartDiscountSyncIT method sync_WithSeveralBatches_ShouldReturnProperStatistics.
@Test
void sync_WithSeveralBatches_ShouldReturnProperStatistics() {
// preparation
final List<String> sortOrders = getSortOrders(100);
// Default batch size is 50 (check CartDiscountSyncOptionsBuilder) so we have 2 batches of 50
final List<CartDiscountDraft> cartDiscountDrafts = IntStream.range(0, 100).mapToObj(i -> CartDiscountDraftBuilder.of(CART_DISCOUNT_NAME_2, CART_DISCOUNT_CART_PREDICATE_2, CART_DISCOUNT_VALUE_2, CART_DISCOUNT_TARGET_2, sortOrders.get(i), false).key(format("key__%s", Integer.toString(i))).active(false).build()).collect(Collectors.toList());
final CartDiscountSyncOptions cartDiscountSyncOptions = CartDiscountSyncOptionsBuilder.of(CTP_TARGET_CLIENT).build();
final CartDiscountSync cartDiscountSync = new CartDiscountSync(cartDiscountSyncOptions);
// test
final CartDiscountSyncStatistics cartDiscountSyncStatistics = cartDiscountSync.sync(cartDiscountDrafts).toCompletableFuture().join();
// assertion
assertThat(cartDiscountSyncStatistics).hasValues(100, 100, 0, 0);
}
Aggregations