use of com.commercetools.sync.products.helpers.ProductReferenceResolver in project commercetools-sync-java by commercetools.
the class CategoryReferenceResolverTest method resolveCategoryReferences_WithIdOnCategoryReference_ShouldNotResolveReference.
@Test
void resolveCategoryReferences_WithIdOnCategoryReference_ShouldNotResolveReference() {
// preparation
final CategoryService mockCategoryService = mockCategoryService(emptySet(), null);
final ProductDraftBuilder productBuilder = getBuilderWithRandomProductType().categories(asSet(ResourceIdentifier.ofId("existing-id"), null));
final ProductReferenceResolver productReferenceResolver = createProductReferenceResolver(mockCategoryService);
// test and assertion
assertThat(productReferenceResolver.resolveCategoryReferences(productBuilder).toCompletableFuture()).matches(f -> !f.isCompletedExceptionally() || f.isCancelled()).isCompletedWithValueMatching(resolvedDraft -> Objects.equals(resolvedDraft.getCategories(), productBuilder.getCategories()));
}
use of com.commercetools.sync.products.helpers.ProductReferenceResolver in project commercetools-sync-java by commercetools.
the class CategoryReferenceResolverTest method resolveCategoryReferences_WithEmptyKeyOnCategoryReference_ShouldNotResolveReference.
@Test
void resolveCategoryReferences_WithEmptyKeyOnCategoryReference_ShouldNotResolveReference() {
// preparation
final CategoryService mockCategoryService = mockCategoryService(emptySet(), null);
final ProductDraftBuilder productBuilder = getBuilderWithRandomProductType().categories(singleton(ResourceIdentifier.ofKey("")));
final ProductReferenceResolver productReferenceResolver = createProductReferenceResolver(mockCategoryService);
// test and assertion
assertThat(productReferenceResolver.resolveCategoryReferences(productBuilder)).failsWithin(1, TimeUnit.SECONDS).withThrowableOfType(ExecutionException.class).withCauseExactlyInstanceOf(ReferenceResolutionException.class).withMessageContaining(format("Failed to resolve 'category' resource identifier on ProductDraft with " + "key:'%s'. Reason: %s", productBuilder.getKey(), BLANK_KEY_VALUE_ON_RESOURCE_IDENTIFIER));
}
use of com.commercetools.sync.products.helpers.ProductReferenceResolver in project commercetools-sync-java by commercetools.
the class TaxCategoryReferenceResolverTest method setup.
/**
* Sets up the services and the options needed for reference resolution.
*/
@BeforeEach
void setup() {
taxCategoryService = getMockTaxCategoryService(TAX_CATEGORY_ID);
final ProductSyncOptions syncOptions = ProductSyncOptionsBuilder.of(mock(SphereClient.class)).build();
referenceResolver = new ProductReferenceResolver(syncOptions, getMockProductTypeService(PRODUCT_TYPE_ID), mock(CategoryService.class), getMockTypeService(), getMockChannelService(getMockSupplyChannel(CHANNEL_ID, CHANNEL_KEY)), mock(CustomerGroupService.class), taxCategoryService, getMockStateService(STATE_ID), getMockProductService(PRODUCT_ID), getMockCustomObjectService(CUSTOM_OBJECT_ID), getMockCustomerService(CUSTOMER_ID));
}
Aggregations