Skip to content

Commit

Permalink
Add integration test for NPE in category order hints in product
Browse files Browse the repository at this point in the history
  • Loading branch information
lojzatran committed Dec 21, 2023
1 parent 3d603f6 commit ece8a05
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProductProjection> products =
TestClientUtils.CTP_SOURCE_CLIENT
.productProjections()
.get()
.withStaged(true)
.execute()
.thenApply(ApiHttpResponse::getBody)
.thenApply(ProductProjectionPagedQueryResponse::getResults)
.join();

final List<ProductDraft> 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
Expand Down

0 comments on commit ece8a05

Please sign in to comment.