Skip to content

Commit cb28904

Browse files
fix: category reference resolver
1 parent 732aa56 commit cb28904

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,15 @@ void syncDrafts_fromCategoriesWithoutKeys_ShouldNotUpdateCategories() {
459459

460460
final CategoryDraft oldCategoryDraft1 =
461461
CategoryDraftBuilder.of()
462-
.name(LocalizedString.of(Locale.ENGLISH, "cat1"))
462+
.name(LocalizedString.of(Locale.ENGLISH, key1))
463463
.slug(LocalizedString.of(Locale.ENGLISH, slug1))
464464
.key(key1)
465465
.custom(CategoryITUtils.getCustomFieldsDraft())
466466
.build();
467467

468468
final CategoryDraft oldCategoryDraft2 =
469469
CategoryDraftBuilder.of()
470-
.name(LocalizedString.of(Locale.ENGLISH, "cat2"))
470+
.name(LocalizedString.of(Locale.ENGLISH, key2))
471471
.slug(LocalizedString.of(Locale.ENGLISH, slug2))
472472
.key(key2)
473473
.custom(CategoryITUtils.getCustomFieldsDraft())
@@ -483,6 +483,11 @@ void syncDrafts_fromCategoriesWithoutKeys_ShouldNotUpdateCategories() {
483483
final CategoryDraft newCategoryDraft2 =
484484
CategoryDraftBuilder.of(oldCategoryDraft2).key(null).build();
485485

486+
assertThat(oldCategoryDraft1.getKey()).isNotEqualTo(newCategoryDraft2.getKey());
487+
assertThat(oldCategoryDraft2.getKey()).isNotEqualTo(newCategoryDraft2.getKey());
488+
assertThat(oldCategoryDraft1.getSlug().get(Locale.ENGLISH)).isEqualTo(newCategoryDraft1.getSlug().get(Locale.ENGLISH));
489+
assertThat(oldCategoryDraft2.getSlug().get(Locale.ENGLISH)).isEqualTo(newCategoryDraft2.getSlug().get(Locale.ENGLISH));
490+
486491
final Category targetCat1 =
487492
TestClientUtils.CTP_TARGET_CLIENT
488493
.categories()

src/main/java/com/commercetools/sync/categories/helpers/CategoryReferenceResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,6 @@ public CompletableFuture<Map<String, String>> populateKeyToIdCachesForReferenced
189189
}
190190

191191
return collectionOfFuturesToFutureOfCollection(futures, toList())
192-
.thenApply(maps -> maps.get(0));
192+
.thenApply(maps -> maps.isEmpty() ? java.util.Collections.emptyMap() : maps.get(0));
193193
}
194194
}

0 commit comments

Comments
 (0)