Search in sources :

Example 1 with CART_DISCOUNT_DRAFT_1

use of com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1 in project commercetools-sync-java by commercetools.

the class CartDiscountSyncIT method sync_WithUpdatedCartDiscount_WithNewCartPredicate_ShouldUpdateCartDiscountWithNewCartPredicate.

@Test
void sync_WithUpdatedCartDiscount_WithNewCartPredicate_ShouldUpdateCartDiscountWithNewCartPredicate() {
    // preparation
    final CartDiscountDraft newCartDiscountDraftWithExistingKey = CartDiscountDraftBuilder.of(CART_DISCOUNT_DRAFT_1).cartPredicate(CART_DISCOUNT_CART_PREDICATE_2).build();
    final List<String> errorMessages = new ArrayList<>();
    final List<Throwable> exceptions = new ArrayList<>();
    final List<UpdateAction<CartDiscount>> updateActionsList = new ArrayList<>();
    final CartDiscountSyncOptions cartDiscountSyncOptions = CartDiscountSyncOptionsBuilder.of(CTP_TARGET_CLIENT).errorCallback((exception, oldResource, newResource, actions) -> {
        errorMessages.add(exception.getMessage());
        exceptions.add(exception);
    }).beforeUpdateCallback((updateActions, newCartDiscount, oldCartDiscount) -> {
        updateActionsList.addAll(updateActions);
        return updateActions;
    }).build();
    final CartDiscountSync cartDiscountSync = new CartDiscountSync(cartDiscountSyncOptions);
    // test
    final CartDiscountSyncStatistics cartDiscountSyncStatistics = cartDiscountSync.sync(singletonList(newCartDiscountDraftWithExistingKey)).toCompletableFuture().join();
    // assertions
    assertThat(errorMessages).isEmpty();
    assertThat(exceptions).isEmpty();
    assertThat(updateActionsList).containsExactly(ChangeCartPredicate.of(CART_DISCOUNT_CART_PREDICATE_2));
    assertThat(cartDiscountSyncStatistics.getReportMessage()).isEqualTo("Summary: 1 cart discounts were processed in total" + " (0 created, 1 updated and 0 failed to sync).");
    assertThat(cartDiscountSyncStatistics).hasValues(1, 0, 1, 0);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) JANUARY_FROM(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_FROM) CartDiscountITUtils.deleteCartDiscounts(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.deleteCartDiscounts) ReferenceResolutionException(com.commercetools.sync.commons.exceptions.ReferenceResolutionException) SyncException(com.commercetools.sync.commons.exceptions.SyncException) CartDiscount(io.sphere.sdk.cartdiscounts.CartDiscount) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) UpdateAction(io.sphere.sdk.commands.UpdateAction) ChangeCartPredicate(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeCartPredicate) Collections.singletonList(java.util.Collections.singletonList) CartDiscountQuery(io.sphere.sdk.cartdiscounts.queries.CartDiscountQuery) AfterAll(org.junit.jupiter.api.AfterAll) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) CartDiscountDraftBuilder(io.sphere.sdk.cartdiscounts.CartDiscountDraftBuilder) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) Locale(java.util.Locale) Map(java.util.Map) SphereClient(io.sphere.sdk.client.SphereClient) CompletableFutureUtils.exceptionallyCompletedFuture(io.sphere.sdk.utils.CompletableFutureUtils.exceptionallyCompletedFuture) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) JsonNode(com.fasterxml.jackson.databind.JsonNode) ChangeTarget(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeTarget) CartDiscountITUtils.populateTargetProject(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.populateTargetProject) ITUtils.deleteTypes(com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypes) CART_DISCOUNT_TARGET_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_1) BadGatewayException(io.sphere.sdk.client.BadGatewayException) CART_DISCOUNT_TARGET_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_2) CART_DISCOUNT_DESC_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DESC_1) CompletionException(java.util.concurrent.CompletionException) SetCustomType(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomType) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Test(org.junit.jupiter.api.Test) List(java.util.List) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Optional(java.util.Optional) JANUARY_UNTIL(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_UNTIL) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) CART_DISCOUNT_KEY_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_2) CART_DISCOUNT_NAME_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_1) CART_DISCOUNT_KEY_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_1) CART_DISCOUNT_NAME_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_2) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) CART_DISCOUNT_DRAFT_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_2) CART_DISCOUNT_VALUE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_1) CartDiscountSyncOptionsBuilder(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptionsBuilder) CART_DISCOUNT_DRAFT_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1) CART_DISCOUNT_VALUE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_2) Mockito.spy(org.mockito.Mockito.spy) CartDiscountCreateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountCreateCommand) ArrayList(java.util.ArrayList) BOOLEAN_CUSTOM_FIELD_NAME(com.commercetools.sync.integration.commons.utils.ITUtils.BOOLEAN_CUSTOM_FIELD_NAME) Assertions.as(org.assertj.core.api.Assertions.as) ChangeValue(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeValue) Nonnull(javax.annotation.Nonnull) CartDiscountITUtils.getCartDiscountByKey(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getCartDiscountByKey) SORT_ORDER_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.SORT_ORDER_1) Collections.emptyMap(java.util.Collections.emptyMap) CartDiscountITUtils.getSortOrders(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getSortOrders) CartDiscountUpdateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountUpdateCommand) Mockito.when(org.mockito.Mockito.when) ITUtils.createCustomFieldsJsonMap(com.commercetools.sync.integration.commons.utils.ITUtils.createCustomFieldsJsonMap) CartDiscountITUtils.createCartDiscountCustomType(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.createCartDiscountCustomType) OLD_CART_DISCOUNT_TYPE_KEY(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.OLD_CART_DISCOUNT_TYPE_KEY) CART_DISCOUNT_CART_PREDICATE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_2) CustomFieldsDraft(io.sphere.sdk.types.CustomFieldsDraft) ErrorResponseException(io.sphere.sdk.client.ErrorResponseException) SetCustomField(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomField) PagedQueryResult(io.sphere.sdk.queries.PagedQueryResult) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) STRING(org.assertj.core.api.InstanceOfAssertFactories.STRING) CART_DISCOUNT_CART_PREDICATE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_1) Type(io.sphere.sdk.types.Type) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) UpdateAction(io.sphere.sdk.commands.UpdateAction) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) ArrayList(java.util.ArrayList) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) Test(org.junit.jupiter.api.Test)

Example 2 with CART_DISCOUNT_DRAFT_1

use of com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1 in project commercetools-sync-java by commercetools.

the class CartDiscountSyncIT method sync_WithUpdatedCartDiscount_WithNewCustomField_ShouldUpdateCartDiscountWithNewCustomField.

@Test
void sync_WithUpdatedCartDiscount_WithNewCustomField_ShouldUpdateCartDiscountWithNewCustomField() {
    // preparation
    final Map<String, JsonNode> customFieldsJsons = createCustomFieldsJsonMap();
    customFieldsJsons.put(BOOLEAN_CUSTOM_FIELD_NAME, JsonNodeFactory.instance.booleanNode(true));
    final CartDiscountDraft newCartDiscountDraftWithExistingKey = CartDiscountDraftBuilder.of(CART_DISCOUNT_DRAFT_1).custom(CustomFieldsDraft.ofTypeKeyAndJson(OLD_CART_DISCOUNT_TYPE_KEY, customFieldsJsons)).build();
    final List<String> errorMessages = new ArrayList<>();
    final List<Throwable> exceptions = new ArrayList<>();
    final List<UpdateAction<CartDiscount>> updateActionsList = new ArrayList<>();
    final CartDiscountSyncOptions cartDiscountSyncOptions = CartDiscountSyncOptionsBuilder.of(CTP_TARGET_CLIENT).errorCallback((exception, oldResource, newResource, actions) -> {
        errorMessages.add(exception.getMessage());
        exceptions.add(exception);
    }).beforeUpdateCallback((updateActions, newCartDiscount, oldCartDiscount) -> {
        updateActionsList.addAll(updateActions);
        return updateActions;
    }).build();
    final CartDiscountSync cartDiscountSync = new CartDiscountSync(cartDiscountSyncOptions);
    // test
    final CartDiscountSyncStatistics cartDiscountSyncStatistics = cartDiscountSync.sync(singletonList(newCartDiscountDraftWithExistingKey)).toCompletableFuture().join();
    // assertions
    assertThat(errorMessages).isEmpty();
    assertThat(exceptions).isEmpty();
    assertThat(updateActionsList).containsExactly(SetCustomField.ofJson(BOOLEAN_CUSTOM_FIELD_NAME, JsonNodeFactory.instance.booleanNode(true)));
    assertThat(cartDiscountSyncStatistics.getReportMessage()).isEqualTo("Summary: 1 cart discounts were processed in total" + " (0 created, 1 updated and 0 failed to sync).");
    assertThat(cartDiscountSyncStatistics).hasValues(1, 0, 1, 0);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) JANUARY_FROM(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_FROM) CartDiscountITUtils.deleteCartDiscounts(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.deleteCartDiscounts) ReferenceResolutionException(com.commercetools.sync.commons.exceptions.ReferenceResolutionException) SyncException(com.commercetools.sync.commons.exceptions.SyncException) CartDiscount(io.sphere.sdk.cartdiscounts.CartDiscount) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) UpdateAction(io.sphere.sdk.commands.UpdateAction) ChangeCartPredicate(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeCartPredicate) Collections.singletonList(java.util.Collections.singletonList) CartDiscountQuery(io.sphere.sdk.cartdiscounts.queries.CartDiscountQuery) AfterAll(org.junit.jupiter.api.AfterAll) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) CartDiscountDraftBuilder(io.sphere.sdk.cartdiscounts.CartDiscountDraftBuilder) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) Locale(java.util.Locale) Map(java.util.Map) SphereClient(io.sphere.sdk.client.SphereClient) CompletableFutureUtils.exceptionallyCompletedFuture(io.sphere.sdk.utils.CompletableFutureUtils.exceptionallyCompletedFuture) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) JsonNode(com.fasterxml.jackson.databind.JsonNode) ChangeTarget(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeTarget) CartDiscountITUtils.populateTargetProject(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.populateTargetProject) ITUtils.deleteTypes(com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypes) CART_DISCOUNT_TARGET_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_1) BadGatewayException(io.sphere.sdk.client.BadGatewayException) CART_DISCOUNT_TARGET_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_2) CART_DISCOUNT_DESC_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DESC_1) CompletionException(java.util.concurrent.CompletionException) SetCustomType(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomType) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Test(org.junit.jupiter.api.Test) List(java.util.List) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Optional(java.util.Optional) JANUARY_UNTIL(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_UNTIL) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) CART_DISCOUNT_KEY_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_2) CART_DISCOUNT_NAME_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_1) CART_DISCOUNT_KEY_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_1) CART_DISCOUNT_NAME_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_2) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) CART_DISCOUNT_DRAFT_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_2) CART_DISCOUNT_VALUE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_1) CartDiscountSyncOptionsBuilder(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptionsBuilder) CART_DISCOUNT_DRAFT_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1) CART_DISCOUNT_VALUE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_2) Mockito.spy(org.mockito.Mockito.spy) CartDiscountCreateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountCreateCommand) ArrayList(java.util.ArrayList) BOOLEAN_CUSTOM_FIELD_NAME(com.commercetools.sync.integration.commons.utils.ITUtils.BOOLEAN_CUSTOM_FIELD_NAME) Assertions.as(org.assertj.core.api.Assertions.as) ChangeValue(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeValue) Nonnull(javax.annotation.Nonnull) CartDiscountITUtils.getCartDiscountByKey(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getCartDiscountByKey) SORT_ORDER_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.SORT_ORDER_1) Collections.emptyMap(java.util.Collections.emptyMap) CartDiscountITUtils.getSortOrders(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getSortOrders) CartDiscountUpdateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountUpdateCommand) Mockito.when(org.mockito.Mockito.when) ITUtils.createCustomFieldsJsonMap(com.commercetools.sync.integration.commons.utils.ITUtils.createCustomFieldsJsonMap) CartDiscountITUtils.createCartDiscountCustomType(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.createCartDiscountCustomType) OLD_CART_DISCOUNT_TYPE_KEY(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.OLD_CART_DISCOUNT_TYPE_KEY) CART_DISCOUNT_CART_PREDICATE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_2) CustomFieldsDraft(io.sphere.sdk.types.CustomFieldsDraft) ErrorResponseException(io.sphere.sdk.client.ErrorResponseException) SetCustomField(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomField) PagedQueryResult(io.sphere.sdk.queries.PagedQueryResult) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) STRING(org.assertj.core.api.InstanceOfAssertFactories.STRING) CART_DISCOUNT_CART_PREDICATE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_1) Type(io.sphere.sdk.types.Type) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) UpdateAction(io.sphere.sdk.commands.UpdateAction) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) Test(org.junit.jupiter.api.Test)

Example 3 with CART_DISCOUNT_DRAFT_1

use of com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1 in project commercetools-sync-java by commercetools.

the class CartDiscountSyncIT method sync_WithUpdatedCartDiscount_WithNewTarget_ShouldUpdateCartDiscountWithNewTarget.

@Test
void sync_WithUpdatedCartDiscount_WithNewTarget_ShouldUpdateCartDiscountWithNewTarget() {
    // preparation
    final CartDiscountDraft newCartDiscountDraftWithExistingKey = CartDiscountDraftBuilder.of(CART_DISCOUNT_DRAFT_1).target(CART_DISCOUNT_TARGET_2).build();
    final List<String> errorMessages = new ArrayList<>();
    final List<Throwable> exceptions = new ArrayList<>();
    final List<UpdateAction<CartDiscount>> updateActionsList = new ArrayList<>();
    final CartDiscountSyncOptions cartDiscountSyncOptions = CartDiscountSyncOptionsBuilder.of(CTP_TARGET_CLIENT).errorCallback((exception, oldResource, newResource, actions) -> {
        errorMessages.add(exception.getMessage());
        exceptions.add(exception);
    }).beforeUpdateCallback((updateActions, newCartDiscount, oldCartDiscount) -> {
        updateActionsList.addAll(updateActions);
        return updateActions;
    }).build();
    final CartDiscountSync cartDiscountSync = new CartDiscountSync(cartDiscountSyncOptions);
    // test
    final CartDiscountSyncStatistics cartDiscountSyncStatistics = cartDiscountSync.sync(singletonList(newCartDiscountDraftWithExistingKey)).toCompletableFuture().join();
    // assertions
    assertThat(errorMessages).isEmpty();
    assertThat(exceptions).isEmpty();
    assertThat(updateActionsList).containsExactly(ChangeTarget.of(CART_DISCOUNT_TARGET_2));
    assertThat(cartDiscountSyncStatistics.getReportMessage()).isEqualTo("Summary: 1 cart discounts were processed in total" + " (0 created, 1 updated and 0 failed to sync).");
    assertThat(cartDiscountSyncStatistics).hasValues(1, 0, 1, 0);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) JANUARY_FROM(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_FROM) CartDiscountITUtils.deleteCartDiscounts(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.deleteCartDiscounts) ReferenceResolutionException(com.commercetools.sync.commons.exceptions.ReferenceResolutionException) SyncException(com.commercetools.sync.commons.exceptions.SyncException) CartDiscount(io.sphere.sdk.cartdiscounts.CartDiscount) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) UpdateAction(io.sphere.sdk.commands.UpdateAction) ChangeCartPredicate(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeCartPredicate) Collections.singletonList(java.util.Collections.singletonList) CartDiscountQuery(io.sphere.sdk.cartdiscounts.queries.CartDiscountQuery) AfterAll(org.junit.jupiter.api.AfterAll) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) CartDiscountDraftBuilder(io.sphere.sdk.cartdiscounts.CartDiscountDraftBuilder) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) Locale(java.util.Locale) Map(java.util.Map) SphereClient(io.sphere.sdk.client.SphereClient) CompletableFutureUtils.exceptionallyCompletedFuture(io.sphere.sdk.utils.CompletableFutureUtils.exceptionallyCompletedFuture) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) JsonNode(com.fasterxml.jackson.databind.JsonNode) ChangeTarget(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeTarget) CartDiscountITUtils.populateTargetProject(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.populateTargetProject) ITUtils.deleteTypes(com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypes) CART_DISCOUNT_TARGET_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_1) BadGatewayException(io.sphere.sdk.client.BadGatewayException) CART_DISCOUNT_TARGET_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_2) CART_DISCOUNT_DESC_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DESC_1) CompletionException(java.util.concurrent.CompletionException) SetCustomType(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomType) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Test(org.junit.jupiter.api.Test) List(java.util.List) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Optional(java.util.Optional) JANUARY_UNTIL(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_UNTIL) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) CART_DISCOUNT_KEY_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_2) CART_DISCOUNT_NAME_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_1) CART_DISCOUNT_KEY_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_1) CART_DISCOUNT_NAME_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_2) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) CART_DISCOUNT_DRAFT_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_2) CART_DISCOUNT_VALUE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_1) CartDiscountSyncOptionsBuilder(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptionsBuilder) CART_DISCOUNT_DRAFT_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1) CART_DISCOUNT_VALUE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_2) Mockito.spy(org.mockito.Mockito.spy) CartDiscountCreateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountCreateCommand) ArrayList(java.util.ArrayList) BOOLEAN_CUSTOM_FIELD_NAME(com.commercetools.sync.integration.commons.utils.ITUtils.BOOLEAN_CUSTOM_FIELD_NAME) Assertions.as(org.assertj.core.api.Assertions.as) ChangeValue(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeValue) Nonnull(javax.annotation.Nonnull) CartDiscountITUtils.getCartDiscountByKey(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getCartDiscountByKey) SORT_ORDER_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.SORT_ORDER_1) Collections.emptyMap(java.util.Collections.emptyMap) CartDiscountITUtils.getSortOrders(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getSortOrders) CartDiscountUpdateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountUpdateCommand) Mockito.when(org.mockito.Mockito.when) ITUtils.createCustomFieldsJsonMap(com.commercetools.sync.integration.commons.utils.ITUtils.createCustomFieldsJsonMap) CartDiscountITUtils.createCartDiscountCustomType(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.createCartDiscountCustomType) OLD_CART_DISCOUNT_TYPE_KEY(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.OLD_CART_DISCOUNT_TYPE_KEY) CART_DISCOUNT_CART_PREDICATE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_2) CustomFieldsDraft(io.sphere.sdk.types.CustomFieldsDraft) ErrorResponseException(io.sphere.sdk.client.ErrorResponseException) SetCustomField(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomField) PagedQueryResult(io.sphere.sdk.queries.PagedQueryResult) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) STRING(org.assertj.core.api.InstanceOfAssertFactories.STRING) CART_DISCOUNT_CART_PREDICATE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_1) Type(io.sphere.sdk.types.Type) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) UpdateAction(io.sphere.sdk.commands.UpdateAction) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) ArrayList(java.util.ArrayList) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) Test(org.junit.jupiter.api.Test)

Example 4 with CART_DISCOUNT_DRAFT_1

use of com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1 in project commercetools-sync-java by commercetools.

the class CartDiscountSyncIT method sync_WithUpdatedCartDiscount_WithNewCustomType_ShouldUpdateCartDiscountWithNewCustomType.

@Test
void sync_WithUpdatedCartDiscount_WithNewCustomType_ShouldUpdateCartDiscountWithNewCustomType() {
    // preparation
    final Type newCustomType = createCartDiscountCustomType("new-type", Locale.ENGLISH, "new-type", CTP_TARGET_CLIENT);
    final CartDiscountDraft newCartDiscountDraftWithExistingKey = CartDiscountDraftBuilder.of(CART_DISCOUNT_DRAFT_1).custom(CustomFieldsDraft.ofTypeKeyAndJson(newCustomType.getKey(), emptyMap())).build();
    final List<String> errorMessages = new ArrayList<>();
    final List<Throwable> exceptions = new ArrayList<>();
    final List<UpdateAction<CartDiscount>> updateActionsList = new ArrayList<>();
    final CartDiscountSyncOptions cartDiscountSyncOptions = CartDiscountSyncOptionsBuilder.of(CTP_TARGET_CLIENT).errorCallback((exception, oldResource, newResource, actions) -> {
        errorMessages.add(exception.getMessage());
        exceptions.add(exception);
    }).beforeUpdateCallback((updateActions, newCartDiscount, oldCartDiscount) -> {
        updateActionsList.addAll(updateActions);
        return updateActions;
    }).build();
    final CartDiscountSync cartDiscountSync = new CartDiscountSync(cartDiscountSyncOptions);
    // test
    final CartDiscountSyncStatistics cartDiscountSyncStatistics = cartDiscountSync.sync(singletonList(newCartDiscountDraftWithExistingKey)).toCompletableFuture().join();
    // assertions
    assertThat(errorMessages).isEmpty();
    assertThat(exceptions).isEmpty();
    assertThat(updateActionsList).containsExactly(SetCustomType.ofTypeIdAndJson(newCustomType.getId(), emptyMap()));
    assertThat(cartDiscountSyncStatistics.getReportMessage()).isEqualTo("Summary: 1 cart discounts were processed in total" + " (0 created, 1 updated and 0 failed to sync).");
    assertThat(cartDiscountSyncStatistics).hasValues(1, 0, 1, 0);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) JANUARY_FROM(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_FROM) CartDiscountITUtils.deleteCartDiscounts(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.deleteCartDiscounts) ReferenceResolutionException(com.commercetools.sync.commons.exceptions.ReferenceResolutionException) SyncException(com.commercetools.sync.commons.exceptions.SyncException) CartDiscount(io.sphere.sdk.cartdiscounts.CartDiscount) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) UpdateAction(io.sphere.sdk.commands.UpdateAction) ChangeCartPredicate(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeCartPredicate) Collections.singletonList(java.util.Collections.singletonList) CartDiscountQuery(io.sphere.sdk.cartdiscounts.queries.CartDiscountQuery) AfterAll(org.junit.jupiter.api.AfterAll) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) CartDiscountDraftBuilder(io.sphere.sdk.cartdiscounts.CartDiscountDraftBuilder) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) Locale(java.util.Locale) Map(java.util.Map) SphereClient(io.sphere.sdk.client.SphereClient) CompletableFutureUtils.exceptionallyCompletedFuture(io.sphere.sdk.utils.CompletableFutureUtils.exceptionallyCompletedFuture) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) JsonNode(com.fasterxml.jackson.databind.JsonNode) ChangeTarget(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeTarget) CartDiscountITUtils.populateTargetProject(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.populateTargetProject) ITUtils.deleteTypes(com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypes) CART_DISCOUNT_TARGET_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_1) BadGatewayException(io.sphere.sdk.client.BadGatewayException) CART_DISCOUNT_TARGET_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_2) CART_DISCOUNT_DESC_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DESC_1) CompletionException(java.util.concurrent.CompletionException) SetCustomType(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomType) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Test(org.junit.jupiter.api.Test) List(java.util.List) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Optional(java.util.Optional) JANUARY_UNTIL(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_UNTIL) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) CART_DISCOUNT_KEY_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_2) CART_DISCOUNT_NAME_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_1) CART_DISCOUNT_KEY_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_1) CART_DISCOUNT_NAME_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_2) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) CART_DISCOUNT_DRAFT_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_2) CART_DISCOUNT_VALUE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_1) CartDiscountSyncOptionsBuilder(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptionsBuilder) CART_DISCOUNT_DRAFT_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1) CART_DISCOUNT_VALUE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_2) Mockito.spy(org.mockito.Mockito.spy) CartDiscountCreateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountCreateCommand) ArrayList(java.util.ArrayList) BOOLEAN_CUSTOM_FIELD_NAME(com.commercetools.sync.integration.commons.utils.ITUtils.BOOLEAN_CUSTOM_FIELD_NAME) Assertions.as(org.assertj.core.api.Assertions.as) ChangeValue(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeValue) Nonnull(javax.annotation.Nonnull) CartDiscountITUtils.getCartDiscountByKey(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getCartDiscountByKey) SORT_ORDER_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.SORT_ORDER_1) Collections.emptyMap(java.util.Collections.emptyMap) CartDiscountITUtils.getSortOrders(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getSortOrders) CartDiscountUpdateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountUpdateCommand) Mockito.when(org.mockito.Mockito.when) ITUtils.createCustomFieldsJsonMap(com.commercetools.sync.integration.commons.utils.ITUtils.createCustomFieldsJsonMap) CartDiscountITUtils.createCartDiscountCustomType(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.createCartDiscountCustomType) OLD_CART_DISCOUNT_TYPE_KEY(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.OLD_CART_DISCOUNT_TYPE_KEY) CART_DISCOUNT_CART_PREDICATE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_2) CustomFieldsDraft(io.sphere.sdk.types.CustomFieldsDraft) ErrorResponseException(io.sphere.sdk.client.ErrorResponseException) SetCustomField(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomField) PagedQueryResult(io.sphere.sdk.queries.PagedQueryResult) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) STRING(org.assertj.core.api.InstanceOfAssertFactories.STRING) CART_DISCOUNT_CART_PREDICATE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_1) Type(io.sphere.sdk.types.Type) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) UpdateAction(io.sphere.sdk.commands.UpdateAction) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) ArrayList(java.util.ArrayList) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) SetCustomType(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomType) CartDiscountITUtils.createCartDiscountCustomType(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.createCartDiscountCustomType) Type(io.sphere.sdk.types.Type) Test(org.junit.jupiter.api.Test)

Example 5 with CART_DISCOUNT_DRAFT_1

use of com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1 in project commercetools-sync-java by commercetools.

the class CartDiscountSyncIT method sync_WithUpdatedCartDiscount_WithNonExistingResIdentifier_ShouldFailToResolveReference.

@Test
void sync_WithUpdatedCartDiscount_WithNonExistingResIdentifier_ShouldFailToResolveReference() {
    // preparation
    final CartDiscountDraft newCartDiscountDraftWithExistingKey = CartDiscountDraftBuilder.of(CART_DISCOUNT_DRAFT_1).custom(CustomFieldsDraft.ofTypeKeyAndJson("not-existing-key", emptyMap())).build();
    final List<String> errorMessages = new ArrayList<>();
    final List<Throwable> exceptions = new ArrayList<>();
    final CartDiscountSyncOptions cartDiscountSyncOptions = CartDiscountSyncOptionsBuilder.of(CTP_TARGET_CLIENT).errorCallback((exception, oldResource, newResource, actions) -> {
        errorMessages.add(exception.getMessage());
        exceptions.add(exception);
    }).build();
    final CartDiscountSync cartDiscountSync = new CartDiscountSync(cartDiscountSyncOptions);
    // test
    final CartDiscountSyncStatistics cartDiscountSyncStatistics = cartDiscountSync.sync(singletonList(newCartDiscountDraftWithExistingKey)).toCompletableFuture().join();
    // assertions
    assertThat(cartDiscountSyncStatistics).hasValues(1, 0, 0, 1);
    assertThat(errorMessages).containsExactly("Failed to process the CartDiscountDraft with key:'key_1'. Reason: " + ReferenceResolutionException.class.getCanonicalName() + ": " + "Failed to resolve custom type reference on CartDiscountDraft with key:'key_1'. " + "Reason: Type with key 'not-existing-key' doesn't exist.");
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) JANUARY_FROM(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_FROM) CartDiscountITUtils.deleteCartDiscounts(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.deleteCartDiscounts) ReferenceResolutionException(com.commercetools.sync.commons.exceptions.ReferenceResolutionException) SyncException(com.commercetools.sync.commons.exceptions.SyncException) CartDiscount(io.sphere.sdk.cartdiscounts.CartDiscount) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) UpdateAction(io.sphere.sdk.commands.UpdateAction) ChangeCartPredicate(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeCartPredicate) Collections.singletonList(java.util.Collections.singletonList) CartDiscountQuery(io.sphere.sdk.cartdiscounts.queries.CartDiscountQuery) AfterAll(org.junit.jupiter.api.AfterAll) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) CartDiscountDraftBuilder(io.sphere.sdk.cartdiscounts.CartDiscountDraftBuilder) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) Locale(java.util.Locale) Map(java.util.Map) SphereClient(io.sphere.sdk.client.SphereClient) CompletableFutureUtils.exceptionallyCompletedFuture(io.sphere.sdk.utils.CompletableFutureUtils.exceptionallyCompletedFuture) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) JsonNode(com.fasterxml.jackson.databind.JsonNode) ChangeTarget(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeTarget) CartDiscountITUtils.populateTargetProject(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.populateTargetProject) ITUtils.deleteTypes(com.commercetools.sync.integration.commons.utils.ITUtils.deleteTypes) CART_DISCOUNT_TARGET_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_1) BadGatewayException(io.sphere.sdk.client.BadGatewayException) CART_DISCOUNT_TARGET_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_2) CART_DISCOUNT_DESC_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DESC_1) CompletionException(java.util.concurrent.CompletionException) SetCustomType(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomType) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Test(org.junit.jupiter.api.Test) List(java.util.List) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Optional(java.util.Optional) JANUARY_UNTIL(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.JANUARY_UNTIL) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) CART_DISCOUNT_KEY_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_2) CART_DISCOUNT_NAME_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_1) CART_DISCOUNT_KEY_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_1) CART_DISCOUNT_NAME_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_2) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) CART_DISCOUNT_DRAFT_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_2) CART_DISCOUNT_VALUE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_1) CartDiscountSyncOptionsBuilder(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptionsBuilder) CART_DISCOUNT_DRAFT_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1) CART_DISCOUNT_VALUE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_2) Mockito.spy(org.mockito.Mockito.spy) CartDiscountCreateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountCreateCommand) ArrayList(java.util.ArrayList) BOOLEAN_CUSTOM_FIELD_NAME(com.commercetools.sync.integration.commons.utils.ITUtils.BOOLEAN_CUSTOM_FIELD_NAME) Assertions.as(org.assertj.core.api.Assertions.as) ChangeValue(io.sphere.sdk.cartdiscounts.commands.updateactions.ChangeValue) Nonnull(javax.annotation.Nonnull) CartDiscountITUtils.getCartDiscountByKey(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getCartDiscountByKey) SORT_ORDER_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.SORT_ORDER_1) Collections.emptyMap(java.util.Collections.emptyMap) CartDiscountITUtils.getSortOrders(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.getSortOrders) CartDiscountUpdateCommand(io.sphere.sdk.cartdiscounts.commands.CartDiscountUpdateCommand) Mockito.when(org.mockito.Mockito.when) ITUtils.createCustomFieldsJsonMap(com.commercetools.sync.integration.commons.utils.ITUtils.createCustomFieldsJsonMap) CartDiscountITUtils.createCartDiscountCustomType(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.createCartDiscountCustomType) OLD_CART_DISCOUNT_TYPE_KEY(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.OLD_CART_DISCOUNT_TYPE_KEY) CART_DISCOUNT_CART_PREDICATE_2(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_2) CustomFieldsDraft(io.sphere.sdk.types.CustomFieldsDraft) ErrorResponseException(io.sphere.sdk.client.ErrorResponseException) SetCustomField(io.sphere.sdk.cartdiscounts.commands.updateactions.SetCustomField) PagedQueryResult(io.sphere.sdk.queries.PagedQueryResult) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) STRING(org.assertj.core.api.InstanceOfAssertFactories.STRING) CART_DISCOUNT_CART_PREDICATE_1(com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_1) Type(io.sphere.sdk.types.Type) CartDiscountSync(com.commercetools.sync.cartdiscounts.CartDiscountSync) CartDiscountDraft(io.sphere.sdk.cartdiscounts.CartDiscountDraft) CartDiscountSyncStatistics(com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics) ArrayList(java.util.ArrayList) ReferenceResolutionException(com.commercetools.sync.commons.exceptions.ReferenceResolutionException) CartDiscountSyncOptions(com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions) Test(org.junit.jupiter.api.Test)

Aggregations

CartDiscountSync (com.commercetools.sync.cartdiscounts.CartDiscountSync)6 CartDiscountSyncOptions (com.commercetools.sync.cartdiscounts.CartDiscountSyncOptions)6 CartDiscountSyncOptionsBuilder (com.commercetools.sync.cartdiscounts.CartDiscountSyncOptionsBuilder)6 CartDiscountSyncStatistics (com.commercetools.sync.cartdiscounts.helpers.CartDiscountSyncStatistics)6 AssertionsForStatistics.assertThat (com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat)6 ReferenceResolutionException (com.commercetools.sync.commons.exceptions.ReferenceResolutionException)6 SyncException (com.commercetools.sync.commons.exceptions.SyncException)6 CART_DISCOUNT_CART_PREDICATE_1 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_1)6 CART_DISCOUNT_CART_PREDICATE_2 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_CART_PREDICATE_2)6 CART_DISCOUNT_DESC_1 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DESC_1)6 CART_DISCOUNT_DRAFT_1 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_1)6 CART_DISCOUNT_DRAFT_2 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_DRAFT_2)6 CART_DISCOUNT_KEY_1 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_1)6 CART_DISCOUNT_KEY_2 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_KEY_2)6 CART_DISCOUNT_NAME_1 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_1)6 CART_DISCOUNT_NAME_2 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_NAME_2)6 CART_DISCOUNT_TARGET_1 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_1)6 CART_DISCOUNT_TARGET_2 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_TARGET_2)6 CART_DISCOUNT_VALUE_1 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_1)6 CART_DISCOUNT_VALUE_2 (com.commercetools.sync.integration.commons.utils.CartDiscountITUtils.CART_DISCOUNT_VALUE_2)6