Search in sources :

Example 11 with CustomerSyncOptions

use of com.commercetools.sync.customers.CustomerSyncOptions in project commercetools-sync-java by commercetools.

the class CustomerSyncIT method setUpCustomerSync.

private void setUpCustomerSync() {
    errorMessages = new ArrayList<>();
    exceptions = new ArrayList<>();
    warningMessages = new ArrayList<>();
    updateActionList = new ArrayList<>();
    CustomerSyncOptions customerSyncOptions = CustomerSyncOptionsBuilder.of(CTP_TARGET_CLIENT).errorCallback((exception, oldResource, newResource, actions) -> {
        errorMessages.add(exception.getMessage());
        exceptions.add(exception);
    }).warningCallback((exception, oldResource, newResource) -> warningMessages.add(exception.getMessage())).beforeUpdateCallback((updateActions, customerDraft, customer) -> {
        updateActionList.addAll(Objects.requireNonNull(updateActions));
        return updateActions;
    }).build();
    customerSync = new CustomerSync(customerSyncOptions);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Reference(io.sphere.sdk.models.Reference) AddBillingAddressId(io.sphere.sdk.customers.commands.updateactions.AddBillingAddressId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) UpdateAction(io.sphere.sdk.commands.UpdateAction) SetStores(io.sphere.sdk.customers.commands.updateactions.SetStores) CustomerSyncStatistics(com.commercetools.sync.customers.helpers.CustomerSyncStatistics) Address(io.sphere.sdk.models.Address) Collections.singletonList(java.util.Collections.singletonList) AfterAll(org.junit.jupiter.api.AfterAll) CUSTOMER_NUMBER_EXISTS_WARNING(com.commercetools.sync.customers.utils.CustomerUpdateActionUtils.CUSTOMER_NUMBER_EXISTS_WARNING) CustomerITUtils.createSampleCustomerJohnDoe(com.commercetools.sync.integration.commons.utils.CustomerITUtils.createSampleCustomerJohnDoe) Collectors.toMap(java.util.stream.Collectors.toMap) SetMiddleName(io.sphere.sdk.customers.commands.updateactions.SetMiddleName) SetFirstName(io.sphere.sdk.customers.commands.updateactions.SetFirstName) Arrays.asList(java.util.Arrays.asList) SetDateOfBirth(io.sphere.sdk.customers.commands.updateactions.SetDateOfBirth) Locale(java.util.Locale) Map(java.util.Map) SetLocale(io.sphere.sdk.customers.commands.updateactions.SetLocale) ChangeEmail(io.sphere.sdk.customers.commands.updateactions.ChangeEmail) RemoveBillingAddressId(io.sphere.sdk.customers.commands.updateactions.RemoveBillingAddressId) Store(io.sphere.sdk.stores.Store) Customer(io.sphere.sdk.customers.Customer) String.format(java.lang.String.format) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) CustomerSyncOptionsBuilder(com.commercetools.sync.customers.CustomerSyncOptionsBuilder) List(java.util.List) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) SetCustomerGroup(io.sphere.sdk.customers.commands.updateactions.SetCustomerGroup) SetVatId(io.sphere.sdk.customers.commands.updateactions.SetVatId) LocalDate(java.time.LocalDate) SetDefaultBillingAddress(io.sphere.sdk.customers.commands.updateactions.SetDefaultBillingAddress) SetCustomField(io.sphere.sdk.customers.commands.updateactions.SetCustomField) AddAddress(io.sphere.sdk.customers.commands.updateactions.AddAddress) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ResourceIdentifier(io.sphere.sdk.models.ResourceIdentifier) RemoveAddress(io.sphere.sdk.customers.commands.updateactions.RemoveAddress) SetTitle(io.sphere.sdk.customers.commands.updateactions.SetTitle) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) CustomerITUtils.deleteCustomerSyncTestData(com.commercetools.sync.integration.commons.utils.CustomerITUtils.deleteCustomerSyncTestData) ArrayList(java.util.ArrayList) BOOLEAN_CUSTOM_FIELD_NAME(com.commercetools.sync.integration.commons.utils.ITUtils.BOOLEAN_CUSTOM_FIELD_NAME) AddShippingAddressId(io.sphere.sdk.customers.commands.updateactions.AddShippingAddressId) CountryCode(com.neovisionaries.i18n.CountryCode) CustomerGroup(io.sphere.sdk.customergroups.CustomerGroup) SetCompanyName(io.sphere.sdk.customers.commands.updateactions.SetCompanyName) SetSalutation(io.sphere.sdk.customers.commands.updateactions.SetSalutation) StoreITUtils.createStore(com.commercetools.sync.integration.commons.utils.StoreITUtils.createStore) CustomerDraftBuilder(io.sphere.sdk.customers.CustomerDraftBuilder) CustomerSync(com.commercetools.sync.customers.CustomerSync) ITUtils.createCustomFieldsJsonMap(com.commercetools.sync.integration.commons.utils.ITUtils.createCustomFieldsJsonMap) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) CustomerGroupITUtils.createCustomerGroup(com.commercetools.sync.integration.commons.utils.CustomerGroupITUtils.createCustomerGroup) CustomFieldsDraft(io.sphere.sdk.types.CustomFieldsDraft) CustomerSyncOptions(com.commercetools.sync.customers.CustomerSyncOptions) AddStore(io.sphere.sdk.customers.commands.updateactions.AddStore) LOCALISED_STRING_CUSTOM_FIELD_NAME(com.commercetools.sync.integration.commons.utils.ITUtils.LOCALISED_STRING_CUSTOM_FIELD_NAME) CustomerDraft(io.sphere.sdk.customers.CustomerDraft) CustomerSyncOptions(com.commercetools.sync.customers.CustomerSyncOptions) CustomerSync(com.commercetools.sync.customers.CustomerSync)

Aggregations

CustomerSyncOptions (com.commercetools.sync.customers.CustomerSyncOptions)11 CustomerDraft (io.sphere.sdk.customers.CustomerDraft)10 CustomerSyncOptionsBuilder (com.commercetools.sync.customers.CustomerSyncOptionsBuilder)9 Customer (io.sphere.sdk.customers.Customer)9 List (java.util.List)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 Test (org.junit.jupiter.api.Test)9 CustomerDraftBuilder (io.sphere.sdk.customers.CustomerDraftBuilder)8 ArrayList (java.util.ArrayList)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 SphereClient (io.sphere.sdk.client.SphereClient)7 ChangeEmail (io.sphere.sdk.customers.commands.updateactions.ChangeEmail)7 UpdateAction (io.sphere.sdk.commands.UpdateAction)6 ResourceIdentifier (io.sphere.sdk.models.ResourceIdentifier)6 CUSTOMER_NUMBER_EXISTS_WARNING (com.commercetools.sync.customers.utils.CustomerUpdateActionUtils.CUSTOMER_NUMBER_EXISTS_WARNING)5 CustomerGroup (io.sphere.sdk.customergroups.CustomerGroup)5 SetCompanyName (io.sphere.sdk.customers.commands.updateactions.SetCompanyName)5 SetCustomerGroup (io.sphere.sdk.customers.commands.updateactions.SetCustomerGroup)5 SetDateOfBirth (io.sphere.sdk.customers.commands.updateactions.SetDateOfBirth)5 SetFirstName (io.sphere.sdk.customers.commands.updateactions.SetFirstName)5