From ece8a057a8a6f828b2e1b9a08f77ed48edaa488e Mon Sep 17 00:00:00 2001 From: lojzatran Date: Thu, 21 Dec 2023 15:46:33 +0000 Subject: [PATCH] Add integration test for NPE in category order hints in product --- .../products/ProductReferenceResolverIT.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/products/ProductReferenceResolverIT.java b/src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/products/ProductReferenceResolverIT.java index 0b37ffcad6..cfb05fac3f 100644 --- a/src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/products/ProductReferenceResolverIT.java +++ b/src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/products/ProductReferenceResolverIT.java @@ -188,6 +188,45 @@ void sync_withNewProductWithExistingCategoryAndProductTypeReferences_ShouldCreat assertThat(warningCallBackMessages).isEmpty(); } + @Test + void sync_withNewProductWithNoCategoryOrderHints_ShouldCreateProduct() { + // preparation + final ProductDraft productDraft = + createProductDraft( + PRODUCT_KEY_1_RESOURCE_PATH, + productTypeSource.toReference(), + oldTaxCategory.toReference(), + oldProductState.toReference(), + categoryReferencesWithIds, + null); + TestClientUtils.CTP_SOURCE_CLIENT.products().create(productDraft).executeBlocking(); + + final List products = + TestClientUtils.CTP_SOURCE_CLIENT + .productProjections() + .get() + .withStaged(true) + .execute() + .thenApply(ApiHttpResponse::getBody) + .thenApply(ProductProjectionPagedQueryResponse::getResults) + .join(); + + final List productDrafts = + ProductTransformUtils.toProductDrafts( + TestClientUtils.CTP_SOURCE_CLIENT, referenceIdToKeyCache, products) + .join(); + + // test + final ProductSyncStatistics syncStatistics = + productSync.sync(productDrafts).toCompletableFuture().join(); + + // assertion + assertThat(syncStatistics).hasValues(1, 1, 0, 0); + assertThat(errorCallBackMessages).isEmpty(); + assertThat(errorCallBackExceptions).isEmpty(); + assertThat(warningCallBackMessages).isEmpty(); + } + @Test void sync_withNewProductWithNoProductTypeKey_ShouldFailCreatingTheProduct() { // preparation