use of com.commercetools.sync.categories.helpers.CategorySyncStatistics in project commercetools-sync-java by commercetools.
the class CategorySyncIT method syncDrafts_withExistingCategoriesThatChangeParents_ShouldUpdateCategories.
@Test
void syncDrafts_withExistingCategoriesThatChangeParents_ShouldUpdateCategories() {
// -----------------Test Setup------------------------------------
// Delete all categories in target project
deleteAllCategories(CTP_TARGET_CLIENT);
// Create a total of 3 categories in the target project (2 roots and 1 child to the first root)
final List<Category> subFamily = createChildren(2, null, "root", CTP_TARGET_CLIENT);
final Category firstRoot = subFamily.get(0);
createChildren(1, firstRoot, "child", CTP_TARGET_CLIENT);
// ---------------------------------------------------------------
// Create a total of 2 categories in the source project (2 roots and 1 child to the second root)
final List<Category> sourceSubFamily = createChildren(2, null, "root", CTP_SOURCE_CLIENT);
final Category secondRoot = sourceSubFamily.get(1);
createChildren(1, secondRoot, "child", CTP_SOURCE_CLIENT);
// ---------------------------------------------------------------
// Fetch categories from source project
final List<Category> categories = CTP_SOURCE_CLIENT.execute(CategoryQuery.of()).toCompletableFuture().join().getResults();
final List<CategoryDraft> categoryDrafts = CategoryTransformUtils.toCategoryDrafts(CTP_SOURCE_CLIENT, referenceIdToKeyCache, categories).join();
Collections.shuffle(categoryDrafts);
CategorySync categorySyncWith1BatchSize = new CategorySync(buildCategorySyncOptions(1));
final CategorySyncStatistics syncStatistics = categorySyncWith1BatchSize.sync(categoryDrafts).toCompletableFuture().join();
assertThat(syncStatistics).hasValues(3, 0, 1, 0, 0);
assertThat(callBackErrorResponses).isEmpty();
assertThat(callBackExceptions).isEmpty();
assertThat(callBackWarningResponses).isEmpty();
}
Aggregations