Skip to content

Commit

Permalink
#99: Add test for syncing prices and reference resolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
heshamMassoud committed Sep 27, 2017
1 parent b794368 commit 3791536
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,44 @@ public void sync_withChangesOnlyAndUnPublish_ShouldUpdateProducts() {
CTP_SOURCE_CLIENT.execute(ProductCreateCommand.of(newProductDraft)).toCompletableFuture().join();

final List<Product> products = CTP_SOURCE_CLIENT.execute(getProductQuery())
.toCompletableFuture().join().getResults();

final List<ProductDraft> productDrafts = replaceProductsReferenceIdsWithKeys(products);

final ProductSyncStatistics syncStatistics = productSync.sync(productDrafts).toCompletableFuture().join();

assertThat(syncStatistics.getReportMessage())
.isEqualTo(format("Summary: %d products were processed in total (%d created, %d updated and %d products"
+ " failed to sync).", 1, 0, 1, 0));

Assertions.assertThat(errorCallBackMessages).isEmpty();
Assertions.assertThat(errorCallBackExceptions).isEmpty();
Assertions.assertThat(warningCallBackMessages).isEmpty();
}

@Test
public void sync_withPriceChannels_ShouldUpdateProducts() {
final ProductDraft existingProductDraft = createProductDraft(PRODUCT_KEY_1_WITH_PRICES_RESOURCE_PATH,
targetProductType.toReference(), targetCategoryResourcesWithIds,
createRandomCategoryOrderHints(targetCategories));

final ProductDraft existingDraftWithPriceChannelReferences =
getDraftWithPriceChannelReferences(existingProductDraft, targetPriceChannel.toReference());

CTP_TARGET_CLIENT.execute(ProductCreateCommand.of(existingDraftWithPriceChannelReferences))
.toCompletableFuture().join();

final ProductDraft newProductDraft = createProductDraftBuilder(PRODUCT_KEY_1_CHANGED_WITH_PRICES_RESOURCE_PATH,
sourceProductType.toReference())
.categories(sourceCategoryResourcesWithIds)
.categoryOrderHints(createRandomCategoryOrderHints(sourceCategories))
.publish(false).build();

final ProductDraft newDraftWithPriceChannelReferences =
getDraftWithPriceChannelReferences(newProductDraft, sourcePriceChannel.toReference());

CTP_SOURCE_CLIENT.execute(ProductCreateCommand.of(newDraftWithPriceChannelReferences))
.toCompletableFuture().join();

final List<Product> products = CTP_SOURCE_CLIENT.execute(getProductQuery())
.toCompletableFuture().join().getResults();
Expand Down

0 comments on commit 3791536

Please sign in to comment.