Skip to content

Commit e43d53b

Browse files
fix: filter source
1 parent f5320c1 commit e43d53b

File tree

1 file changed

+9
-16
lines changed
  • src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/categories

1 file changed

+9
-16
lines changed

src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/categories/CategorySyncIT.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -508,40 +508,33 @@ void syncDrafts_fromCategoriesWithoutKeys_ShouldNotUpdateCategories() {
508508
Locale.ENGLISH,
509509
List.of("furniture1-project-source", "furniture2-project-source"));
510510

511-
// Create two categories in the target without Keys.
512-
futureCreations = new ArrayList<>();
511+
// Create two categories in the target without Keys (sequentially to ensure both are created).
513512
final CategoryDraft newCategoryDraft1 =
514513
CategoryDraftBuilder.of(oldCategoryDraft1).key(null).build();
515514
final CategoryDraft newCategoryDraft2 =
516515
CategoryDraftBuilder.of(oldCategoryDraft2).key(null).build();
517-
futureCreations.add(
518-
TestClientUtils.CTP_TARGET_CLIENT
519-
.categories()
520-
.create(newCategoryDraft1)
521-
.execute()
522-
.toCompletableFuture());
523-
futureCreations.add(
524-
TestClientUtils.CTP_TARGET_CLIENT
525-
.categories()
526-
.create(newCategoryDraft2)
527-
.execute()
528-
.toCompletableFuture());
529516

530-
CompletableFuture.allOf(futureCreations.toArray(new CompletableFuture[futureCreations.size()]))
531-
.join();
517+
TestClientUtils.CTP_TARGET_CLIENT.categories().create(newCategoryDraft1).executeBlocking();
518+
TestClientUtils.CTP_TARGET_CLIENT.categories().create(newCategoryDraft2).executeBlocking();
532519

533520
// ---------
534521

522+
// Fetch only the categories we created for this test (by keys)
535523
final List<Category> categories =
536524
TestClientUtils.CTP_SOURCE_CLIENT
537525
.categories()
538526
.get()
527+
.withWhere("key in :keys")
528+
.withPredicateVar("keys", List.of("newKey1", "newKey2"))
539529
.execute()
540530
.toCompletableFuture()
541531
.join()
542532
.getBody()
543533
.getResults();
544534

535+
// Verify we have exactly 2 categories from SOURCE
536+
assertThat(categories).hasSize(2);
537+
545538
final List<CategoryDraft> categoryDrafts =
546539
CategoryTransformUtils.toCategoryDrafts(
547540
TestClientUtils.CTP_SOURCE_CLIENT, referenceIdToKeyCache, categories)

0 commit comments

Comments
 (0)