Search in sources :

Example 1 with CustomerGroupService

use of com.commercetools.sync.services.CustomerGroupService in project commercetools-sync-java by commercetools.

the class ProductSyncMockUtils method getMockCustomerGroupService.

/**
 * Creates a mock {@link CustomerGroupService} that returns a completed {@link CompletableFuture}
 * containing an {@link Optional} containing the id of the supplied value whenever the following
 * method is called on the service:
 *
 * <ul>
 *   <li>{@link CustomerGroupService#fetchCachedCustomerGroupId(String)}
 * </ul>
 *
 * @return the created mock of the {@link CustomerGroupService}.
 */
public static CustomerGroupService getMockCustomerGroupService(@Nonnull final CustomerGroup customerGroup) {
    final String customerGroupId = customerGroup.getId();
    final CustomerGroupService customerGroupService = mock(CustomerGroupService.class);
    when(customerGroupService.fetchCachedCustomerGroupId(anyString())).thenReturn(completedFuture(Optional.of(customerGroupId)));
    return customerGroupService;
}
Also used : LocalizedString(io.sphere.sdk.models.LocalizedString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CustomerGroupService(com.commercetools.sync.services.CustomerGroupService)

Example 2 with CustomerGroupService

use of com.commercetools.sync.services.CustomerGroupService in project commercetools-sync-java by commercetools.

the class CustomerGroupServiceImplIT method setup.

/**
 * Deletes customer group from the target CTP projects, then it populates the project with test
 * data.
 */
@BeforeEach
void setup() {
    deleteCustomerGroups(CTP_TARGET_CLIENT);
    warnings = new ArrayList<>();
    oldCustomerGroup = createCustomerGroup(CTP_TARGET_CLIENT, CUSTOMER_GROUP_NAME, CUSTOMER_GROUP_KEY);
    final ProductSyncOptions productSyncOptions = ProductSyncOptionsBuilder.of(CTP_TARGET_CLIENT).warningCallback((exception, oldResource, newResource) -> warnings.add(exception.getMessage())).build();
    customerGroupService = new CustomerGroupServiceImpl(productSyncOptions);
}
Also used : CustomerGroupITUtils.deleteCustomerGroups(com.commercetools.sync.integration.commons.utils.CustomerGroupITUtils.deleteCustomerGroups) BeforeEach(org.junit.jupiter.api.BeforeEach) CustomerGroup(io.sphere.sdk.customergroups.CustomerGroup) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CustomerGroupITUtils.createCustomerGroup(com.commercetools.sync.integration.commons.utils.CustomerGroupITUtils.createCustomerGroup) ArrayList(java.util.ArrayList) AfterAll(org.junit.jupiter.api.AfterAll) Test(org.junit.jupiter.api.Test) CustomerGroupServiceImpl(com.commercetools.sync.services.impl.CustomerGroupServiceImpl) ProductSyncOptionsBuilder(com.commercetools.sync.products.ProductSyncOptionsBuilder) CustomerGroupService(com.commercetools.sync.services.CustomerGroupService) Optional(java.util.Optional) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ProductSyncOptions(com.commercetools.sync.products.ProductSyncOptions) CustomerGroupServiceImpl(com.commercetools.sync.services.impl.CustomerGroupServiceImpl) ProductSyncOptions(com.commercetools.sync.products.ProductSyncOptions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CustomerGroupService (com.commercetools.sync.services.CustomerGroupService)2 CustomerGroupITUtils.createCustomerGroup (com.commercetools.sync.integration.commons.utils.CustomerGroupITUtils.createCustomerGroup)1 CustomerGroupITUtils.deleteCustomerGroups (com.commercetools.sync.integration.commons.utils.CustomerGroupITUtils.deleteCustomerGroups)1 CTP_TARGET_CLIENT (com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT)1 ProductSyncOptions (com.commercetools.sync.products.ProductSyncOptions)1 ProductSyncOptionsBuilder (com.commercetools.sync.products.ProductSyncOptionsBuilder)1 CustomerGroupServiceImpl (com.commercetools.sync.services.impl.CustomerGroupServiceImpl)1 CustomerGroup (io.sphere.sdk.customergroups.CustomerGroup)1 LocalizedString (io.sphere.sdk.models.LocalizedString)1 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 AfterAll (org.junit.jupiter.api.AfterAll)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1