@@ -62,16 +62,13 @@ class SpecimenTypeTest {
62
62
63
63
@ Test
64
64
void asClass () {
65
- assertThat (new SpecimenType <String >() {
66
- }.asClass ()).isEqualTo (String .class );
65
+ assertThat (new SpecimenType <String >() {}.asClass ()).isEqualTo (String .class );
67
66
}
68
67
69
68
@ Test
70
69
void isParametrized () {
71
- assertThat (new SpecimenType <String >() {
72
- }.isParameterized ()).isFalse ();
73
- assertThat (new SpecimenType <Optional <String >>() {
74
- }.isParameterized ()).isTrue ();
70
+ assertThat (new SpecimenType <String >() {}.isParameterized ()).isFalse ();
71
+ assertThat (new SpecimenType <Optional <String >>() {}.isParameterized ()).isTrue ();
75
72
}
76
73
77
74
@ Test
@@ -91,42 +88,24 @@ void isParameterizedStatic() throws NoSuchFieldException {
91
88
92
89
@ Test
93
90
void isCollection () {
94
- assertThat (new SpecimenType <Collection <String >>() {
95
- }.isCollection ()).isTrue ();
96
- assertThat (new SpecimenType <List <String >>() {
97
- }.isCollection ()).isTrue ();
98
- assertThat (new SpecimenType <NavigableSet <String >>() {
99
- }.isCollection ()).isTrue ();
100
- assertThat (new SpecimenType <SortedSet <String >>() {
101
- }.isCollection ()).isTrue ();
102
- assertThat (new SpecimenType <Set <String >>() {
103
- }.isCollection ()).isTrue ();
104
- assertThat (new SpecimenType <Deque <String >>() {
105
- }.isCollection ()).isTrue ();
106
- assertThat (new SpecimenType <BlockingDeque <String >>() {
107
- }.isCollection ()).isTrue ();
108
- assertThat (new SpecimenType <Queue <String >>() {
109
- }.isCollection ()).isTrue ();
110
- assertThat (new SpecimenType <BlockingQueue <String >>() {
111
- }.isCollection ()).isTrue ();
112
- assertThat (new SpecimenType <TransferQueue <String >>() {
113
- }.isCollection ()).isTrue ();
114
- assertThat (new SpecimenType <ArrayList <String >>() {
115
- }.isCollection ()).isTrue ();
116
- assertThat (new SpecimenType <HashSet <String >>() {
117
- }.isCollection ()).isTrue ();
118
- assertThat (new SpecimenType <TreeSet <String >>() {
119
- }.isCollection ()).isTrue ();
120
- assertThat (new SpecimenType <ArrayDeque <String >>() {
121
- }.isCollection ()).isTrue ();
122
- assertThat (new SpecimenType <LinkedBlockingDeque <String >>() {
123
- }.isCollection ()).isTrue ();
124
- assertThat (new SpecimenType <LinkedList <String >>() {
125
- }.isCollection ()).isTrue ();
126
- assertThat (new SpecimenType <LinkedBlockingQueue <String >>() {
127
- }.isCollection ()).isTrue ();
128
- assertThat (new SpecimenType <LinkedTransferQueue <String >>() {
129
- }.isCollection ()).isTrue ();
91
+ assertThat (new SpecimenType <Collection <String >>() {}.isCollection ()).isTrue ();
92
+ assertThat (new SpecimenType <List <String >>() {}.isCollection ()).isTrue ();
93
+ assertThat (new SpecimenType <NavigableSet <String >>() {}.isCollection ()).isTrue ();
94
+ assertThat (new SpecimenType <SortedSet <String >>() {}.isCollection ()).isTrue ();
95
+ assertThat (new SpecimenType <Set <String >>() {}.isCollection ()).isTrue ();
96
+ assertThat (new SpecimenType <Deque <String >>() {}.isCollection ()).isTrue ();
97
+ assertThat (new SpecimenType <BlockingDeque <String >>() {}.isCollection ()).isTrue ();
98
+ assertThat (new SpecimenType <Queue <String >>() {}.isCollection ()).isTrue ();
99
+ assertThat (new SpecimenType <BlockingQueue <String >>() {}.isCollection ()).isTrue ();
100
+ assertThat (new SpecimenType <TransferQueue <String >>() {}.isCollection ()).isTrue ();
101
+ assertThat (new SpecimenType <ArrayList <String >>() {}.isCollection ()).isTrue ();
102
+ assertThat (new SpecimenType <HashSet <String >>() {}.isCollection ()).isTrue ();
103
+ assertThat (new SpecimenType <TreeSet <String >>() {}.isCollection ()).isTrue ();
104
+ assertThat (new SpecimenType <ArrayDeque <String >>() {}.isCollection ()).isTrue ();
105
+ assertThat (new SpecimenType <LinkedBlockingDeque <String >>() {}.isCollection ()).isTrue ();
106
+ assertThat (new SpecimenType <LinkedList <String >>() {}.isCollection ()).isTrue ();
107
+ assertThat (new SpecimenType <LinkedBlockingQueue <String >>() {}.isCollection ()).isTrue ();
108
+ assertThat (new SpecimenType <LinkedTransferQueue <String >>() {}.isCollection ()).isTrue ();
130
109
}
131
110
132
111
@ TestWithCases
@@ -154,24 +133,15 @@ void isCollectionFromClass(Class<Collection> collectionType) {
154
133
155
134
@ Test
156
135
void isMap () {
157
- assertThat (new SpecimenType <Map >() {
158
- }.isMap ()).isTrue ();
159
- assertThat (new SpecimenType <ConcurrentNavigableMap >() {
160
- }.isMap ()).isTrue ();
161
- assertThat (new SpecimenType <ConcurrentMap >() {
162
- }.isMap ()).isTrue ();
163
- assertThat (new SpecimenType <NavigableMap >() {
164
- }.isMap ()).isTrue ();
165
- assertThat (new SpecimenType <SortedMap >() {
166
- }.isMap ()).isTrue ();
167
- assertThat (new SpecimenType <TreeMap >() {
168
- }.isMap ()).isTrue ();
169
- assertThat (new SpecimenType <ConcurrentSkipListMap >() {
170
- }.isMap ()).isTrue ();
171
- assertThat (new SpecimenType <ConcurrentHashMap >() {
172
- }.isMap ()).isTrue ();
173
- assertThat (new SpecimenType <HashMap >() {
174
- }.isMap ()).isTrue ();
136
+ assertThat (new SpecimenType <Map >() {}.isMap ()).isTrue ();
137
+ assertThat (new SpecimenType <ConcurrentNavigableMap >() {}.isMap ()).isTrue ();
138
+ assertThat (new SpecimenType <ConcurrentMap >() {}.isMap ()).isTrue ();
139
+ assertThat (new SpecimenType <NavigableMap >() {}.isMap ()).isTrue ();
140
+ assertThat (new SpecimenType <SortedMap >() {}.isMap ()).isTrue ();
141
+ assertThat (new SpecimenType <TreeMap >() {}.isMap ()).isTrue ();
142
+ assertThat (new SpecimenType <ConcurrentSkipListMap >() {}.isMap ()).isTrue ();
143
+ assertThat (new SpecimenType <ConcurrentHashMap >() {}.isMap ()).isTrue ();
144
+ assertThat (new SpecimenType <HashMap >() {}.isMap ()).isTrue ();
175
145
}
176
146
177
147
@ TestWithCases
@@ -190,24 +160,15 @@ void isMapFromClass(Class<Map> mapType) {
190
160
191
161
@ Test
192
162
void isBoxed () {
193
- assertThat (new SpecimenType <String >() {
194
- }.isBoxed ()).isFalse (); // false!
195
- assertThat (new SpecimenType <Byte >() {
196
- }.isBoxed ()).isTrue ();
197
- assertThat (new SpecimenType <Short >() {
198
- }.isBoxed ()).isTrue ();
199
- assertThat (new SpecimenType <Integer >() {
200
- }.isBoxed ()).isTrue ();
201
- assertThat (new SpecimenType <Long >() {
202
- }.isBoxed ()).isTrue ();
203
- assertThat (new SpecimenType <Float >() {
204
- }.isBoxed ()).isTrue ();
205
- assertThat (new SpecimenType <Double >() {
206
- }.isBoxed ()).isTrue ();
207
- assertThat (new SpecimenType <Character >() {
208
- }.isBoxed ()).isTrue ();
209
- assertThat (new SpecimenType <Boolean >() {
210
- }.isBoxed ()).isTrue ();
163
+ assertThat (new SpecimenType <String >() {}.isBoxed ()).isFalse (); // false!
164
+ assertThat (new SpecimenType <Byte >() {}.isBoxed ()).isTrue ();
165
+ assertThat (new SpecimenType <Short >() {}.isBoxed ()).isTrue ();
166
+ assertThat (new SpecimenType <Integer >() {}.isBoxed ()).isTrue ();
167
+ assertThat (new SpecimenType <Long >() {}.isBoxed ()).isTrue ();
168
+ assertThat (new SpecimenType <Float >() {}.isBoxed ()).isTrue ();
169
+ assertThat (new SpecimenType <Double >() {}.isBoxed ()).isTrue ();
170
+ assertThat (new SpecimenType <Character >() {}.isBoxed ()).isTrue ();
171
+ assertThat (new SpecimenType <Boolean >() {}.isBoxed ()).isTrue ();
211
172
}
212
173
213
174
@ TestWithCases
@@ -242,24 +203,21 @@ void isPrimitive(Class<?> value, boolean expected) {
242
203
void isEnum () {
243
204
assertThat (SpecimenType .fromClass (String .class ).isEnum ()).isFalse ();
244
205
assertThat (SpecimenType .fromClass (TestEnum .class ).isEnum ()).isTrue ();
245
- assertThat (new SpecimenType <TestEnum >() {
246
- }.isEnum ()).isTrue ();
206
+ assertThat (new SpecimenType <TestEnum >() {}.isEnum ()).isTrue ();
247
207
}
248
208
249
209
@ Test
250
210
void isArray () {
251
211
assertThat (SpecimenType .fromClass (List .class ).isArray ()).isFalse ();
252
212
assertThat (SpecimenType .fromClass (int [].class ).isArray ()).isTrue ();
253
- assertThat (new SpecimenType <Integer []>() {
254
- }.isArray ()).isTrue ();
213
+ assertThat (new SpecimenType <Integer []>() {}.isArray ()).isTrue ();
255
214
}
256
215
257
216
@ Test
258
217
void isInterface () {
259
218
assertThat (SpecimenType .fromClass (String .class ).isInterface ()).isFalse ();
260
219
assertThat (SpecimenType .fromClass (List .class ).isInterface ()).isTrue ();
261
- assertThat (new SpecimenType <ITestGeneric <String , List <Optional >>>() {
262
- }.isInterface ()).isTrue ();
220
+ assertThat (new SpecimenType <ITestGeneric <String , List <Optional >>>() {}.isInterface ()).isTrue ();
263
221
}
264
222
265
223
@ Test
@@ -270,14 +228,14 @@ void isAbstract() {
270
228
271
229
@ Test
272
230
void isTimeType () {
273
- assertThat (new SpecimenType <String >(){}.isTimeType ()).isFalse (); // false
274
- assertThat (new SpecimenType <Duration >(){}.isTimeType ()).isTrue ();
275
- assertThat (new SpecimenType <JapaneseEra >(){}.isTimeType ()).isTrue ();
276
- assertThat (new SpecimenType <MonthDay >(){}.isTimeType ()).isTrue ();
277
- assertThat (new SpecimenType <Period >(){}.isTimeType ()).isTrue ();
278
- assertThat (new SpecimenType <ZoneId >(){}.isTimeType ()).isTrue ();
279
- assertThat (new SpecimenType <ZoneOffset >(){}.isTimeType ()).isTrue ();
280
- assertThat (new SpecimenType <ZonedDateTime >(){}.isTimeType ()).isTrue ();
231
+ assertThat (new SpecimenType <String >() {}.isTimeType ()).isFalse (); // false
232
+ assertThat (new SpecimenType <Duration >() {}.isTimeType ()).isTrue ();
233
+ assertThat (new SpecimenType <JapaneseEra >() {}.isTimeType ()).isTrue ();
234
+ assertThat (new SpecimenType <MonthDay >() {}.isTimeType ()).isTrue ();
235
+ assertThat (new SpecimenType <Period >() {}.isTimeType ()).isTrue ();
236
+ assertThat (new SpecimenType <ZoneId >() {}.isTimeType ()).isTrue ();
237
+ assertThat (new SpecimenType <ZoneOffset >() {}.isTimeType ()).isTrue ();
238
+ assertThat (new SpecimenType <ZonedDateTime >() {}.isTimeType ()).isTrue ();
281
239
}
282
240
283
241
@ TestWithCases
@@ -299,9 +257,9 @@ void isTimeTypeFromClass(Class<?> value, boolean expected) {
299
257
300
258
@ Test
301
259
void isSpecialType () {
302
- assertThat (new SpecimenType <String >(){}.isSpecialType ()).isFalse (); // false
303
- assertThat (new SpecimenType <URI >(){}.isSpecialType ()).isTrue ();
304
- assertThat (new SpecimenType <File >(){}.isSpecialType ()).isTrue ();
260
+ assertThat (new SpecimenType <String >() {}.isSpecialType ()).isFalse (); // false
261
+ assertThat (new SpecimenType <URI >() {}.isSpecialType ()).isTrue ();
262
+ assertThat (new SpecimenType <File >() {}.isSpecialType ()).isTrue ();
305
263
}
306
264
307
265
@ TestWithCases
@@ -314,8 +272,7 @@ void isSpecialTypeFromClass(Class<?> value, boolean expected) {
314
272
315
273
@ Test
316
274
void getGenericTypeArgument () {
317
- var sut = new SpecimenType <Map <String , Optional <Integer >>>() {
318
- };
275
+ var sut = new SpecimenType <Map <String , Optional <Integer >>>() {};
319
276
320
277
assertThat (sut .getGenericTypeArgument (0 )).isEqualTo (String .class );
321
278
assertThat (sut .getGenericTypeArgument (1 )).isInstanceOf (ParameterizedType .class );
@@ -330,8 +287,7 @@ void getGenericTypeArgument() {
330
287
331
288
@ Test
332
289
void getGenericTypeArguments () {
333
- var sut = new SpecimenType <Map <String , Optional <Integer >>>() {
334
- };
290
+ var sut = new SpecimenType <Map <String , Optional <Integer >>>() {};
335
291
336
292
assertThat (sut .getGenericTypeArguments ()).hasSize (2 );
337
293
assertThat (sut .getGenericTypeArguments ()[0 ]).isEqualTo (String .class );
@@ -347,8 +303,7 @@ void getGenericTypeArguments() {
347
303
348
304
@ Test
349
305
void getTypeParameterName () {
350
- var sut = new SpecimenType <TestObjectGeneric <String , Optional <Integer >>>() {
351
- };
306
+ var sut = new SpecimenType <TestObjectGeneric <String , Optional <Integer >>>() {};
352
307
353
308
assertThat (sut .getTypeParameterName (0 )).isEqualTo ("T" );
354
309
assertThat (sut .getTypeParameterName (1 )).isEqualTo ("U" );
@@ -361,8 +316,7 @@ void getTypeParameterName() {
361
316
362
317
@ Test
363
318
void getTypeParameterNames () {
364
- var sut = new SpecimenType <TestObjectGeneric <String , Optional <Integer >>>() {
365
- };
319
+ var sut = new SpecimenType <TestObjectGeneric <String , Optional <Integer >>>() {};
366
320
367
321
assertThat (sut .getTypeParameterNames ()).hasSize (2 );
368
322
assertThat (sut .getTypeParameterNames ()[0 ]).isEqualTo ("T" );
@@ -376,10 +330,8 @@ void getTypeParameterNames() {
376
330
377
331
@ Test
378
332
void getComponentType () {
379
- assertThat (new SpecimenType <int []>() {
380
- }.getComponentType ()).isEqualTo (int .class );
381
- assertThat (new SpecimenType <Integer []>() {
382
- }.getComponentType ()).isEqualTo (Integer .class );
333
+ assertThat (new SpecimenType <int []>() {}.getComponentType ()).isEqualTo (int .class );
334
+ assertThat (new SpecimenType <Integer []>() {}.getComponentType ()).isEqualTo (Integer .class );
383
335
384
336
assertThatExceptionOfType (SpecimenTypeException .class )
385
337
.isThrownBy (() -> SpecimenType .fromClass (String .class ).getComponentType ())
@@ -397,8 +349,7 @@ void getComponentTypeFromClass(Class<?> value, Class<?> expected) {
397
349
@ Test
398
350
void getEnumConstants () {
399
351
assertThat (SpecimenType .fromClass (TestEnum .class ).getEnumConstants ().length ).isEqualTo (3 );
400
- assertThat (new SpecimenType <TestEnum >() {
401
- }.getEnumConstants ().length ).isEqualTo (3 );
352
+ assertThat (new SpecimenType <TestEnum >() {}.getEnumConstants ().length ).isEqualTo (3 );
402
353
403
354
assertThatExceptionOfType (SpecimenTypeException .class )
404
355
.isThrownBy (() -> SpecimenType .fromClass (String .class ).getEnumConstants ())
@@ -409,18 +360,14 @@ void getEnumConstants() {
409
360
@ Test
410
361
void getName () {
411
362
assertThat (SpecimenType .fromClass (Optional .class ).getName ()).isEqualTo ("java.util.Optional" );
412
- assertThat (new SpecimenType <Optional <String >>() {
413
- }.getName ()).isEqualTo ("java.util.Optional<java.lang.String>" );
363
+ assertThat (new SpecimenType <Optional <String >>() {}.getName ()).isEqualTo ("java.util.Optional<java.lang.String>" );
414
364
}
415
365
416
366
@ Test
417
367
void asParameterizedType () {
418
- assertThat (new SpecimenType <Optional <String >>() {
419
- }.asParameterizedType ().getRawType ()).isEqualTo (Optional .class );
420
- assertThat (new SpecimenType <Optional <String >>() {
421
- }.asParameterizedType ().getActualTypeArguments ().length ).isEqualTo (1 );
422
- assertThat (new SpecimenType <Optional <String >>() {
423
- }.asParameterizedType ().getActualTypeArguments ()[0 ].getTypeName ()).isEqualTo (String .class .getName ());
368
+ assertThat (new SpecimenType <Optional <String >>() {}.asParameterizedType ().getRawType ()).isEqualTo (Optional .class );
369
+ assertThat (new SpecimenType <Optional <String >>() {}.asParameterizedType ().getActualTypeArguments ().length ).isEqualTo (1 );
370
+ assertThat (new SpecimenType <Optional <String >>() {}.asParameterizedType ().getActualTypeArguments ()[0 ].getTypeName ()).isEqualTo (String .class .getName ());
424
371
}
425
372
426
373
@ TestWithCases
@@ -440,8 +387,7 @@ void fromClass(Class<?> type) {
440
387
441
388
@ Test
442
389
void fromType () {
443
- Type type = new SpecimenType <Optional <String >>() {
444
- }.asParameterizedType ();
390
+ Type type = new SpecimenType <Optional <String >>() {}.asParameterizedType ();
445
391
446
392
var sut = SpecimenType .fromClass (type );
447
393
@@ -452,8 +398,7 @@ void fromType() {
452
398
453
399
@ Test
454
400
void createForObjectClass () {
455
- var sut = new SpecimenType <String >() {
456
- };
401
+ var sut = new SpecimenType <String >() {};
457
402
458
403
assertThat (sut .asClass ()).isEqualTo (String .class );
459
404
assertThat (sut .isParameterized ()).isFalse ();
@@ -464,8 +409,7 @@ void createForObjectClass() {
464
409
465
410
@ Test
466
411
void createForGenericClass () {
467
- var sut = new SpecimenType <Optional <String >>() {
468
- };
412
+ var sut = new SpecimenType <Optional <String >>() {};
469
413
470
414
assertThat (sut .asClass ()).isEqualTo (Optional .class );
471
415
assertThat (sut .isParameterized ()).isTrue ();
@@ -476,8 +420,7 @@ void createForGenericClass() {
476
420
477
421
@ Test
478
422
void createForListInterface () {
479
- var sut = new SpecimenType <List <String >>() {
480
- };
423
+ var sut = new SpecimenType <List <String >>() {};
481
424
482
425
assertThat (sut .asClass ()).isEqualTo (List .class );
483
426
assertThat (sut .isParameterized ()).isTrue ();
@@ -488,8 +431,7 @@ void createForListInterface() {
488
431
489
432
@ Test
490
433
void createForMapInterface () {
491
- var sut = new SpecimenType <Map <String , Integer >>() {
492
- };
434
+ var sut = new SpecimenType <Map <String , Integer >>() {};
493
435
494
436
assertThat (sut .asClass ()).isEqualTo (Map .class );
495
437
assertThat (sut .isParameterized ()).isTrue ();
@@ -501,8 +443,7 @@ void createForMapInterface() {
501
443
502
444
@ Test
503
445
void getDeclaredConstructors () {
504
- var sut = new SpecimenType <TestObjectWithAllConstructors >() {
505
- };
446
+ var sut = new SpecimenType <TestObjectWithAllConstructors >() {};
506
447
507
448
var actual = sut .getDeclaredConstructors ();
508
449
@@ -511,8 +452,7 @@ void getDeclaredConstructors() {
511
452
512
453
@ Test
513
454
void getFactoryMethods () {
514
- var sut = new SpecimenType <TestObjectWithStaticMethods >() {
515
- };
455
+ var sut = new SpecimenType <TestObjectWithStaticMethods >() {};
516
456
517
457
var actual = sut .getFactoryMethods ();
518
458
0 commit comments