2828import java .util .HashMap ;
2929import java .util .HashSet ;
3030import java .util .Hashtable ;
31+ import java .util .IdentityHashMap ;
3132import java .util .LinkedHashMap ;
3233import java .util .LinkedHashSet ;
3334import java .util .List ;
3435import java .util .Map ;
3536import java .util .Optional ;
3637import java .util .Set ;
38+ import java .util .Stack ;
39+ import java .util .TreeMap ;
40+ import java .util .TreeSet ;
3741import java .util .Vector ;
42+ import java .util .WeakHashMap ;
3843import java .util .function .Consumer ;
3944import java .util .function .Function ;
4045import java .util .stream .Stream ;
4651
4752public final class TypesData
4853{
49- public record ListOfTestArguments (List <TestArguments > testArguments )
54+ public record ListOfTestArguments (List <TestArguments <?> > testArguments )
5055 {
5156 public Stream <Arguments > toArguments ()
5257 {
@@ -55,7 +60,7 @@ public Stream<Arguments> toArguments()
5560 }
5661
5762
58- public record TestArguments <T extends ComplexObject >(
63+ public record TestArguments <T extends ComplexObject <?> >(
5964 Class <? extends EclipseStoreRepository <T , Integer >> repositoryClass ,
6065 Function <Integer , T > objectCreator ,
6166 Consumer <T > objectChanger )
@@ -68,8 +73,9 @@ public Arguments toArguments()
6873
6974 public static Stream <Arguments > generateData ()
7075 {
76+ // noinspection RedundantTypeArguments (explicit type arguments speedup compilation and analysis time)
7177 return new ListOfTestArguments (
72- List .of (
78+ List .< TestArguments <?>> of (
7379 new TestArguments <>(
7480 SetRepository .class ,
7581 id -> new SetDaoObject (id , Set .of ()),
@@ -100,6 +106,21 @@ public static Stream<Arguments> generateData()
100106 id -> new SetDaoObject (id , new HashSet <>(List .of ("1" , "2" ))),
101107 set -> set .getValue ().add ("3" )
102108 ),
109+ new TestArguments <>(
110+ SetRepository .class ,
111+ id -> new SetDaoObject (id , new TreeSet <>()),
112+ set -> set .getValue ().add ("1" )
113+ ),
114+ new TestArguments <>(
115+ SetRepository .class ,
116+ id -> new SetDaoObject (id , new TreeSet <>(List .of ("1" ))),
117+ set -> set .getValue ().add ("2" )
118+ ),
119+ new TestArguments <>(
120+ SetRepository .class ,
121+ id -> new SetDaoObject (id , new TreeSet <>(List .of ("1" , "2" ))),
122+ set -> set .getValue ().add ("3" )
123+ ),
103124 new TestArguments <>(
104125 SetRepository .class ,
105126 id -> new SetDaoObject (id , new LinkedHashSet <>()),
@@ -118,12 +139,12 @@ public static Stream<Arguments> generateData()
118139 new TestArguments <>(
119140 BigDecimalRepository .class ,
120141 id -> new BigDecimalDaoObject (id , BigDecimal .ONE ),
121- object -> object .getValue ().add (BigDecimal .ONE )
142+ object -> object .setValue ( object . getValue ().add (BigDecimal .ONE ) )
122143 ),
123144 new TestArguments <>(
124145 BigDecimalRepository .class ,
125146 id -> new BigDecimalDaoObject (id , BigDecimal .ZERO ),
126- object -> object .getValue ().add (BigDecimal .ONE )
147+ object -> object .setValue ( object . getValue ().add (BigDecimal .ONE ) )
127148 ),
128149 new TestArguments <>(
129150 BigDecimalRepository .class ,
@@ -133,12 +154,12 @@ public static Stream<Arguments> generateData()
133154 new TestArguments <>(
134155 BigIntegerRepository .class ,
135156 id -> new BigIntegerDaoObject (id , BigInteger .ONE ),
136- object -> object .getValue ().add (BigInteger .ONE )
157+ object -> object .setValue ( object . getValue ().add (BigInteger .ONE ) )
137158 ),
138159 new TestArguments <>(
139160 BigIntegerRepository .class ,
140161 id -> new BigIntegerDaoObject (id , BigInteger .ZERO ),
141- object -> object .getValue ().add (BigInteger .ONE )
162+ object -> object .setValue ( object . getValue ().add (BigInteger .ONE ) )
142163 ),
143164 new TestArguments <>(
144165 BigIntegerRepository .class ,
@@ -195,6 +216,32 @@ public static Stream<Arguments> generateData()
195216 id -> new ListDaoObject (id , new ArrayList <>(Set .of ("1" , "2" ))),
196217 object -> object .getValue ().add ("3" )
197218 ),
219+ new TestArguments <>(
220+ ListRepository .class ,
221+ id -> new ListDaoObject (id , new Stack <>()),
222+ object -> object .getValue ().add ("1" )
223+ ),
224+ new TestArguments <>(
225+ ListRepository .class ,
226+ id ->
227+ {
228+ final Stack <String > stack = new Stack <>();
229+ stack .add ("1" );
230+ return new ListDaoObject (id , stack );
231+ },
232+ object -> object .getValue ().add ("2" )
233+ ),
234+ new TestArguments <>(
235+ ListRepository .class ,
236+ id ->
237+ {
238+ final Stack <String > stack = new Stack <>();
239+ stack .push ("1" );
240+ stack .push ("2" );
241+ return new ListDaoObject (id , stack );
242+ },
243+ object -> object .getValue ().add ("3" )
244+ ),
198245 new TestArguments <>(
199246 ListRepository .class ,
200247 id -> new ListDaoObject (id , new ArrayList <>(Set .of ("1" ))),
@@ -213,17 +260,17 @@ public static Stream<Arguments> generateData()
213260 new TestArguments <>(
214261 LocalDateRepository .class ,
215262 id -> new LocalDateDaoObject (id , LocalDate .of (2000 , 1 , 1 )),
216- object -> object .getValue ().plusDays (1 )
263+ object -> object .setValue ( object . getValue ().plusDays (1 ) )
217264 ),
218265 new TestArguments <>(
219266 LocalDateTimeRepository .class ,
220267 id -> new LocalDateTimeDaoObject (id , LocalDateTime .of (2000 , 1 , 1 , 1 , 1 , 1 )),
221- object -> object .getValue ().plusDays (1 )
268+ object -> object .setValue ( object . getValue ().plusDays (1 ) )
222269 ),
223270 new TestArguments <>(
224271 LocalTimeRepository .class ,
225272 id -> new LocalTimeDaoObject (id , LocalTime .of (1 , 1 , 1 )),
226- object -> object .getValue ().plusHours (1 )
273+ object -> object .setValue ( object . getValue ().plusHours (1 ) )
227274 ),
228275 new TestArguments <>(
229276 MapRepository .class ,
@@ -285,6 +332,36 @@ public static Stream<Arguments> generateData()
285332 id -> new MapDaoObject (id , new Hashtable <>(Map .of ("1" , "1" , "2" , "2" ))),
286333 set -> set .getValue ().put ("3" , "3" )
287334 ),
335+ new TestArguments <>(
336+ MapRepository .class ,
337+ id -> new MapDaoObject (id , new TreeMap <>()),
338+ set -> set .getValue ().put ("1" , "1" )
339+ ),
340+ new TestArguments <>(
341+ MapRepository .class ,
342+ id -> new MapDaoObject (id , new TreeMap <>(Map .of ("1" , "1" ))),
343+ set -> set .getValue ().put ("2" , "2" )
344+ ),
345+ new TestArguments <>(
346+ MapRepository .class ,
347+ id -> new MapDaoObject (id , new TreeMap <>(Map .of ("1" , "1" , "2" , "2" ))),
348+ set -> set .getValue ().put ("3" , "3" )
349+ ),
350+ new TestArguments <>(
351+ MapRepository .class ,
352+ id -> new MapDaoObject (id , new IdentityHashMap <>()),
353+ set -> set .getValue ().put ("1" , "1" )
354+ ),
355+ new TestArguments <>(
356+ MapRepository .class ,
357+ id -> new MapDaoObject (id , new IdentityHashMap <>(Map .of ("1" , "1" ))),
358+ set -> set .getValue ().put ("2" , "2" )
359+ ),
360+ new TestArguments <>(
361+ MapRepository .class ,
362+ id -> new MapDaoObject (id , new IdentityHashMap <>(Map .of ("1" , "1" , "2" , "2" ))),
363+ set -> set .getValue ().put ("3" , "3" )
364+ ),
288365 new TestArguments <>(
289366 OptionalRepository .class ,
290367 id -> new OptionalDaoObject (id , Optional .of ("1" )),
@@ -334,6 +411,21 @@ public static Stream<Arguments> generateNotWorkingData()
334411 id -> new EnumMapDaoObject (id , new EnumMap <>(Map .of (EnumMapDaoObject .Album .RUMOURS , "1" ))),
335412 object -> object .getValue ().remove (EnumMapDaoObject .Album .RUMOURS )
336413 ),
414+ new TestArguments <>(
415+ MapRepository .class ,
416+ id -> new MapDaoObject (id , new WeakHashMap <>()),
417+ set -> set .getValue ().put ("1" , "1" )
418+ ),
419+ new TestArguments <>(
420+ MapRepository .class ,
421+ id -> new MapDaoObject (id , new WeakHashMap <>(Map .of ("1" , "1" ))),
422+ set -> set .getValue ().put ("2" , "2" )
423+ ),
424+ new TestArguments <>(
425+ MapRepository .class ,
426+ id -> new MapDaoObject (id , new WeakHashMap <>(Map .of ("1" , "1" , "2" , "2" ))),
427+ set -> set .getValue ().put ("3" , "3" )
428+ ),
337429 // Here EclipseStore has problems: https://github.com/microstream-one/microstream/issues/173
338430 new TestArguments <>(
339431 CalendarRepository .class ,
0 commit comments