Search in sources :

Example 31 with ProductTypeService

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

the class ProductTypeServiceImplTest method fetchProductType_WithEmptyKey_ShouldNotFetchProductType.

@Test
void fetchProductType_WithEmptyKey_ShouldNotFetchProductType() {
    // preparation
    final SphereClient sphereClient = mock(SphereClient.class);
    final ProductTypeSyncOptions syncOptions = ProductTypeSyncOptionsBuilder.of(sphereClient).build();
    final ProductTypeService productTypeService = new ProductTypeServiceImpl(syncOptions);
    // test
    final CompletionStage<Optional<ProductType>> result = productTypeService.fetchProductType("");
    // assertions
    assertThat(result).isCompletedWithValue(Optional.empty());
    verify(sphereClient, never()).execute(any());
}
Also used : ProductTypeService(com.commercetools.sync.services.ProductTypeService) ProductTypeSyncOptions(com.commercetools.sync.producttypes.ProductTypeSyncOptions) Optional(java.util.Optional) SphereClient(io.sphere.sdk.client.SphereClient) Test(org.junit.jupiter.api.Test)

Example 32 with ProductTypeService

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

the class ProductTypeServiceImplTest method fetchProductType_WithNullKey_ShouldNotFetchProductType.

@Test
void fetchProductType_WithNullKey_ShouldNotFetchProductType() {
    // preparation
    final SphereClient sphereClient = mock(SphereClient.class);
    final ProductTypeSyncOptions syncOptions = ProductTypeSyncOptionsBuilder.of(sphereClient).build();
    final ProductTypeService productTypeService = new ProductTypeServiceImpl(syncOptions);
    // test
    final CompletionStage<Optional<ProductType>> result = productTypeService.fetchProductType(null);
    // assertions
    assertThat(result).isCompletedWithValue(Optional.empty());
    verify(sphereClient, never()).execute(any());
}
Also used : ProductTypeService(com.commercetools.sync.services.ProductTypeService) ProductTypeSyncOptions(com.commercetools.sync.producttypes.ProductTypeSyncOptions) Optional(java.util.Optional) SphereClient(io.sphere.sdk.client.SphereClient) Test(org.junit.jupiter.api.Test)

Aggregations

ProductTypeService (com.commercetools.sync.services.ProductTypeService)32 Test (org.junit.jupiter.api.Test)31 ProductTypeDraft (io.sphere.sdk.producttypes.ProductTypeDraft)22 ProductTypeSyncOptions (com.commercetools.sync.producttypes.ProductTypeSyncOptions)20 AttributeDefinitionDraft (io.sphere.sdk.products.attributes.AttributeDefinitionDraft)20 SphereClient (io.sphere.sdk.client.SphereClient)18 NestedAttributeType (io.sphere.sdk.products.attributes.NestedAttributeType)18 ProductTypeQuery (io.sphere.sdk.producttypes.queries.ProductTypeQuery)16 Optional (java.util.Optional)16 ProductTypeServiceImpl (com.commercetools.sync.services.impl.ProductTypeServiceImpl)15 ProductType (io.sphere.sdk.producttypes.ProductType)15 ChangeName (io.sphere.sdk.producttypes.commands.updateactions.ChangeName)13 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13 Collections.singleton (java.util.Collections.singleton)13 Collections.singletonList (java.util.Collections.singletonList)13 List (java.util.List)13 ProductTypeCreateCommand (io.sphere.sdk.producttypes.commands.ProductTypeCreateCommand)10 ProductTypeUpdateCommand (io.sphere.sdk.producttypes.commands.ProductTypeUpdateCommand)10 Assertions.as (org.assertj.core.api.Assertions.as)7