@@ -66,4 +66,63 @@ public void testCategoryTree() {
6666 var result = tree .findBySlug (Locale .ENGLISH , "women" );
6767 Assertions .assertThat (result ).isNotEmpty ();
6868 }
69+
70+ @ Test
71+ public void testGetLocalizedStringEntryCategoryMap () {
72+ List <Category > allCategoriesAsFlatList = List .of (
73+ Category .builder ()
74+ .name (LocalizedString .of (Locale .forLanguageTag ("en-US" ), "Women" ))
75+ .slug (LocalizedString .of (Locale .forLanguageTag ("en-US" ), "women" ))
76+ .id ("1" )
77+ .version (1L )
78+ .createdAt (ZonedDateTime .now ())
79+ .lastModifiedAt (ZonedDateTime .now ())
80+ .ancestors ()
81+ .orderHint ("c2" )
82+ .build (),
83+ Category .builder ()
84+ .name (LocalizedString .of (Locale .forLanguageTag ("en" ), "Men" ))
85+ .slug (LocalizedString .of (Locale .forLanguageTag ("en" ), "men" ))
86+ .id ("2" )
87+ .version (1L )
88+ .createdAt (ZonedDateTime .now ())
89+ .lastModifiedAt (ZonedDateTime .now ())
90+ .ancestors ()
91+ .orderHint ("c2" )
92+ .build (),
93+ Category .builder ()
94+ .name (LocalizedString .of (Locale .forLanguageTag ("en-us" ), "Kids" ))
95+ .slug (LocalizedString .of (Locale .forLanguageTag ("en-us" ), "kids" ))
96+ .id ("3" )
97+ .version (1L )
98+ .createdAt (ZonedDateTime .now ())
99+ .lastModifiedAt (ZonedDateTime .now ())
100+ .ancestors ()
101+ .orderHint ("c2" )
102+ .build ());
103+ CategoryTreeFactory factory = CategoryTreeFactory .of ();
104+
105+ var tree = factory .create (allCategoriesAsFlatList );
106+ var result = tree .findBySlug (Locale .forLanguageTag ("en-US" ), "women" );
107+ Assertions .assertThat (result ).isNotEmpty ();
108+ var enUsResult = tree .findBySlug (Locale .forLanguageTag ("en-us" ), "women" );
109+ Assertions .assertThat (enUsResult ).isNotEmpty ();
110+
111+ var enResult = tree .findBySlug (Locale .forLanguageTag ("en" ), "women" );
112+ Assertions .assertThat (enResult ).isEmpty ();
113+
114+ var menResult = tree .findBySlug (Locale .forLanguageTag ("en-US" ), "men" );
115+ Assertions .assertThat (menResult ).isEmpty ();
116+ var menEnUsResult = tree .findBySlug (Locale .forLanguageTag ("en-us" ), "men" );
117+ Assertions .assertThat (menEnUsResult ).isEmpty ();
118+ var menEnResult = tree .findBySlug (Locale .forLanguageTag ("en" ), "men" );
119+ Assertions .assertThat (menEnResult ).isNotEmpty ();
120+
121+ var kidsResult = tree .findBySlug (Locale .forLanguageTag ("en-US" ), "kids" );
122+ Assertions .assertThat (kidsResult ).isNotEmpty ();
123+ var kidsEnUsResult = tree .findBySlug (Locale .forLanguageTag ("en-us" ), "kids" );
124+ Assertions .assertThat (kidsEnUsResult ).isNotEmpty ();
125+ var kidsEnResult = tree .findBySlug (Locale .forLanguageTag ("en" ), "kids" );
126+ Assertions .assertThat (kidsEnResult ).isEmpty ();
127+ }
69128}
0 commit comments