Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ c4e2bf407aa0b7a3d34605134791013ba8a2d376
062fb57831db2e3e25afc1bd63cf8b09d46ffa67
13fa17ad575aadf0ef823d63d86fbbdd4a37cd9b
f00f4fe6ed5e22cdd2e3f68370c2da96e6bbc8e7
899ed51a7b6607161fcda5c1000115a076cc4fe7
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private Map<LocalizedStringEntry, Category> getLocalizedStringEntryCategoryMap(
.values()
.keySet()
.stream()
.map(Locale::new)
.map(Locale::forLanguageTag)
.collect(Collectors.toSet());
localesForTheCategory.forEach(locale -> {
final LocalizedStringEntry stringsEntry = LocalizedStringEntry.of(locale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,63 @@ public void testCategoryTree() {
var result = tree.findBySlug(Locale.ENGLISH, "women");
Assertions.assertThat(result).isNotEmpty();
}

@Test
public void testGetLocalizedStringEntryCategoryMap() {
List<Category> allCategoriesAsFlatList = List.of(
Category.builder()
.name(LocalizedString.of(Locale.forLanguageTag("en-US"), "Women"))
.slug(LocalizedString.of(Locale.forLanguageTag("en-US"), "women"))
.id("1")
.version(1L)
.createdAt(ZonedDateTime.now())
.lastModifiedAt(ZonedDateTime.now())
.ancestors()
.orderHint("c2")
.build(),
Category.builder()
.name(LocalizedString.of(Locale.forLanguageTag("en"), "Men"))
.slug(LocalizedString.of(Locale.forLanguageTag("en"), "men"))
.id("2")
.version(1L)
.createdAt(ZonedDateTime.now())
.lastModifiedAt(ZonedDateTime.now())
.ancestors()
.orderHint("c2")
.build(),
Category.builder()
.name(LocalizedString.of(Locale.forLanguageTag("en-us"), "Kids"))
.slug(LocalizedString.of(Locale.forLanguageTag("en-us"), "kids"))
.id("3")
.version(1L)
.createdAt(ZonedDateTime.now())
.lastModifiedAt(ZonedDateTime.now())
.ancestors()
.orderHint("c2")
.build());
CategoryTreeFactory factory = CategoryTreeFactory.of();

var tree = factory.create(allCategoriesAsFlatList);
var result = tree.findBySlug(Locale.forLanguageTag("en-US"), "women");
Assertions.assertThat(result).isNotEmpty();
var enUsResult = tree.findBySlug(Locale.forLanguageTag("en-us"), "women");
Assertions.assertThat(enUsResult).isNotEmpty();

var enResult = tree.findBySlug(Locale.forLanguageTag("en"), "women");
Assertions.assertThat(enResult).isEmpty();

var menResult = tree.findBySlug(Locale.forLanguageTag("en-US"), "men");
Assertions.assertThat(menResult).isEmpty();
var menEnUsResult = tree.findBySlug(Locale.forLanguageTag("en-us"), "men");
Assertions.assertThat(menEnUsResult).isEmpty();
var menEnResult = tree.findBySlug(Locale.forLanguageTag("en"), "men");
Assertions.assertThat(menEnResult).isNotEmpty();

var kidsResult = tree.findBySlug(Locale.forLanguageTag("en-US"), "kids");
Assertions.assertThat(kidsResult).isNotEmpty();
var kidsEnUsResult = tree.findBySlug(Locale.forLanguageTag("en-us"), "kids");
Assertions.assertThat(kidsEnUsResult).isNotEmpty();
var kidsEnResult = tree.findBySlug(Locale.forLanguageTag("en"), "kids");
Assertions.assertThat(kidsEnResult).isEmpty();
}
}