1
1
/*
2
- * Copyright 2002-2021 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -83,19 +83,19 @@ void noneReturnValues() throws Exception {
83
83
assertThat (none .asMap ()).isEqualTo (ResolvableType .NONE );
84
84
assertThat (none .getComponentType ()).isEqualTo (ResolvableType .NONE );
85
85
assertThat (none .getGeneric (0 )).isEqualTo (ResolvableType .NONE );
86
- assertThat (none .getGenerics (). length ). isEqualTo ( 0 );
87
- assertThat (none .getInterfaces (). length ). isEqualTo ( 0 );
86
+ assertThat (none .getGenerics ()). isEmpty ( );
87
+ assertThat (none .getInterfaces ()). isEmpty ( );
88
88
assertThat (none .getSuperType ()).isEqualTo (ResolvableType .NONE );
89
89
assertThat (none .getType ()).isEqualTo (ResolvableType .EmptyType .INSTANCE );
90
- assertThat (none .hasGenerics ()).isEqualTo ( false );
91
- assertThat (none .isArray ()).isEqualTo ( false );
90
+ assertThat (none .hasGenerics ()).isFalse ( );
91
+ assertThat (none .isArray ()).isFalse ( );
92
92
assertThat (none .resolve ()).isNull ();
93
93
assertThat (none .resolve (String .class )).isEqualTo (String .class );
94
94
assertThat (none .resolveGeneric (0 )).isNull ();
95
- assertThat (none .resolveGenerics (). length ). isEqualTo ( 0 );
95
+ assertThat (none .resolveGenerics ()). isEmpty ( );
96
96
assertThat (none .toString ()).isEqualTo ("?" );
97
- assertThat (none .hasUnresolvableGenerics ()).isEqualTo ( false );
98
- assertThat (none .isAssignableFrom (ResolvableType .forClass (Object .class ))).isEqualTo ( false );
97
+ assertThat (none .hasUnresolvableGenerics ()).isFalse ( );
98
+ assertThat (none .isAssignableFrom (ResolvableType .forClass (Object .class ))).isFalse ( );
99
99
}
100
100
101
101
@ Test
@@ -148,9 +148,9 @@ void forRawClassAssignableFromTypeVariable() throws Exception {
148
148
149
149
@ Test
150
150
void forInstanceMustNotBeNull () throws Exception {
151
- assertThatIllegalArgumentException (). isThrownBy (() ->
152
- ResolvableType .forInstance (null ))
153
- .withMessageContaining ("Instance must not be null" );
151
+ assertThatIllegalArgumentException ()
152
+ . isThrownBy (() -> ResolvableType .forInstance (null ))
153
+ .withMessage ("Instance must not be null" );
154
154
}
155
155
156
156
@ Test
@@ -201,9 +201,9 @@ void forPrivateField() throws Exception {
201
201
202
202
@ Test
203
203
void forFieldMustNotBeNull () throws Exception {
204
- assertThatIllegalArgumentException (). isThrownBy (() ->
205
- ResolvableType .forField (null ))
206
- .withMessageContaining ("Field must not be null" );
204
+ assertThatIllegalArgumentException ()
205
+ . isThrownBy (() -> ResolvableType .forField (null ))
206
+ .withMessage ("Field must not be null" );
207
207
}
208
208
209
209
@ Test
@@ -215,9 +215,9 @@ void forConstructorParameter() throws Exception {
215
215
216
216
@ Test
217
217
void forConstructorParameterMustNotBeNull () throws Exception {
218
- assertThatIllegalArgumentException (). isThrownBy (() ->
219
- ResolvableType .forConstructorParameter (null , 0 ))
220
- .withMessageContaining ("Constructor must not be null" );
218
+ assertThatIllegalArgumentException ()
219
+ . isThrownBy (() -> ResolvableType .forConstructorParameter (null , 0 ))
220
+ .withMessage ("Constructor must not be null" );
221
221
}
222
222
223
223
@ Test
@@ -229,9 +229,9 @@ void forMethodParameterByIndex() throws Exception {
229
229
230
230
@ Test
231
231
void forMethodParameterByIndexMustNotBeNull () throws Exception {
232
- assertThatIllegalArgumentException (). isThrownBy (() ->
233
- ResolvableType .forMethodParameter (null , 0 ))
234
- .withMessageContaining ("Method must not be null" );
232
+ assertThatIllegalArgumentException ()
233
+ . isThrownBy (() -> ResolvableType .forMethodParameter (null , 0 ))
234
+ .withMessage ("Method must not be null" );
235
235
}
236
236
237
237
@ Test
@@ -269,9 +269,9 @@ void forMethodParameterWithNestingAndLevels() throws Exception {
269
269
270
270
@ Test
271
271
void forMethodParameterMustNotBeNull () throws Exception {
272
- assertThatIllegalArgumentException (). isThrownBy (() ->
273
- ResolvableType .forMethodParameter (null ))
274
- .withMessageContaining ("MethodParameter must not be null" );
272
+ assertThatIllegalArgumentException ()
273
+ . isThrownBy (() -> ResolvableType .forMethodParameter (null ))
274
+ .withMessage ("MethodParameter must not be null" );
275
275
}
276
276
277
277
@ Test // SPR-16210
@@ -296,9 +296,9 @@ void forMethodReturn() throws Exception {
296
296
297
297
@ Test
298
298
void forMethodReturnMustNotBeNull () throws Exception {
299
- assertThatIllegalArgumentException (). isThrownBy (() ->
300
- ResolvableType .forMethodReturnType (null ))
301
- .withMessageContaining ("Method must not be null" );
299
+ assertThatIllegalArgumentException ()
300
+ . isThrownBy (() -> ResolvableType .forMethodReturnType (null ))
301
+ .withMessage ("Method must not be null" );
302
302
}
303
303
304
304
@ Test
@@ -317,7 +317,7 @@ void parameterizedType() throws Exception {
317
317
void arrayClassType () throws Exception {
318
318
ResolvableType type = ResolvableType .forField (Fields .class .getField ("arrayClassType" ));
319
319
assertThat (type .getType ()).isInstanceOf (Class .class );
320
- assertThat (((Class ) type .getType ()).isArray ()).isEqualTo ( true );
320
+ assertThat (((Class ) type .getType ()).isArray ()).isTrue ( );
321
321
}
322
322
323
323
@ Test
@@ -343,23 +343,23 @@ void typeVariableType() throws Exception {
343
343
void getComponentTypeForClassArray () throws Exception {
344
344
Field field = Fields .class .getField ("arrayClassType" );
345
345
ResolvableType type = ResolvableType .forField (field );
346
- assertThat (type .isArray ()).isEqualTo ( true );
346
+ assertThat (type .isArray ()).isTrue ( );
347
347
assertThat (type .getComponentType ().getType ())
348
348
.isEqualTo (((Class ) field .getGenericType ()).getComponentType ());
349
349
}
350
350
351
351
@ Test
352
352
void getComponentTypeForGenericArrayType () throws Exception {
353
353
ResolvableType type = ResolvableType .forField (Fields .class .getField ("genericArrayType" ));
354
- assertThat (type .isArray ()).isEqualTo ( true );
354
+ assertThat (type .isArray ()).isTrue ( );
355
355
assertThat (type .getComponentType ().getType ()).isEqualTo (
356
356
((GenericArrayType ) type .getType ()).getGenericComponentType ());
357
357
}
358
358
359
359
@ Test
360
360
void getComponentTypeForVariableThatResolvesToGenericArray () throws Exception {
361
361
ResolvableType type = ResolvableType .forClass (ListOfGenericArray .class ).asCollection ().getGeneric ();
362
- assertThat (type .isArray ()).isEqualTo ( true );
362
+ assertThat (type .isArray ()).isTrue ( );
363
363
assertThat (type .getType ()).isInstanceOf (TypeVariable .class );
364
364
assertThat (type .getComponentType ().getType ().toString ()).isEqualTo (
365
365
"java.util.List<java.lang.String>" );
@@ -368,7 +368,7 @@ void getComponentTypeForVariableThatResolvesToGenericArray() throws Exception {
368
368
@ Test
369
369
void getComponentTypeForNonArray () throws Exception {
370
370
ResolvableType type = ResolvableType .forClass (String .class );
371
- assertThat (type .isArray ()).isEqualTo ( false );
371
+ assertThat (type .isArray ()).isFalse ( );
372
372
assertThat (type .getComponentType ()).isEqualTo (ResolvableType .NONE );
373
373
}
374
374
@@ -438,7 +438,7 @@ void getSuperType() throws Exception {
438
438
@ Test
439
439
void getInterfaces () throws Exception {
440
440
ResolvableType type = ResolvableType .forClass (ExtendsList .class );
441
- assertThat (type .getInterfaces (). length ). isEqualTo ( 0 );
441
+ assertThat (type .getInterfaces ()). isEmpty ( );
442
442
SortedSet <String > interfaces = new TreeSet <>();
443
443
for (ResolvableType interfaceType : type .getSuperType ().getInterfaces ()) {
444
444
interfaces .add (interfaceType .toString ());
@@ -529,8 +529,8 @@ void getGenericOutOfBounds() throws Exception {
529
529
@ Test
530
530
void hasGenerics () throws Exception {
531
531
ResolvableType type = ResolvableType .forClass (ExtendsList .class );
532
- assertThat (type .hasGenerics ()).isEqualTo ( false );
533
- assertThat (type .asCollection ().hasGenerics ()).isEqualTo ( true );
532
+ assertThat (type .hasGenerics ()).isFalse ( );
533
+ assertThat (type .asCollection ().hasGenerics ()).isTrue ( );
534
534
}
535
535
536
536
@ Test
@@ -553,7 +553,7 @@ void getGenericsFromClass() throws Exception {
553
553
void noGetGenerics () throws Exception {
554
554
ResolvableType type = ResolvableType .forClass (ExtendsList .class );
555
555
ResolvableType [] generics = type .getGenerics ();
556
- assertThat (generics . length ). isEqualTo ( 0 );
556
+ assertThat (generics ). isEmpty ( );
557
557
}
558
558
559
559
@ Test
@@ -602,31 +602,31 @@ void resolveGenericArrayFromGeneric() throws Exception {
602
602
ResolvableType type = ResolvableType .forField (Fields .class .getField ("stringArrayList" ));
603
603
ResolvableType generic = type .asCollection ().getGeneric ();
604
604
assertThat (generic .getType ().toString ()).isEqualTo ("E" );
605
- assertThat (generic .isArray ()).isEqualTo ( true );
605
+ assertThat (generic .isArray ()).isTrue ( );
606
606
assertThat (generic .resolve ()).isEqualTo (String [].class );
607
607
}
608
608
609
609
@ Test
610
610
void resolveVariableGenericArray () throws Exception {
611
611
ResolvableType type = ResolvableType .forField (Fields .class .getField ("variableTypeGenericArray" ), TypedFields .class );
612
612
assertThat (type .getType ().toString ()).isEqualTo ("T[]" );
613
- assertThat (type .isArray ()).isEqualTo ( true );
613
+ assertThat (type .isArray ()).isTrue ( );
614
614
assertThat (type .resolve ()).isEqualTo (String [].class );
615
615
}
616
616
617
617
@ Test
618
618
void resolveVariableGenericArrayUnknown () throws Exception {
619
619
ResolvableType type = ResolvableType .forField (Fields .class .getField ("variableTypeGenericArray" ));
620
620
assertThat (type .getType ().toString ()).isEqualTo ("T[]" );
621
- assertThat (type .isArray ()).isEqualTo ( true );
621
+ assertThat (type .isArray ()).isTrue ( );
622
622
assertThat (type .resolve ()).isNull ();
623
623
}
624
624
625
625
@ Test
626
626
void resolveVariableGenericArrayUnknownWithFallback () throws Exception {
627
627
ResolvableType type = ResolvableType .forField (Fields .class .getField ("variableTypeGenericArray" ));
628
628
assertThat (type .getType ().toString ()).isEqualTo ("T[]" );
629
- assertThat (type .isArray ()).isEqualTo ( true );
629
+ assertThat (type .isArray ()).isTrue ( );
630
630
assertThat (type .toClass ()).isEqualTo (Object .class );
631
631
}
632
632
@@ -965,16 +965,16 @@ void resolveFromClassWithGenerics() throws Exception {
965
965
966
966
@ Test
967
967
void isAssignableFromMustNotBeNull () throws Exception {
968
- assertThatIllegalArgumentException (). isThrownBy (() ->
969
- ResolvableType .forClass (Object .class ).isAssignableFrom ((ResolvableType ) null ))
970
- .withMessageContaining ( "Type must not be null" );
968
+ assertThatIllegalArgumentException ()
969
+ . isThrownBy (() -> ResolvableType .forClass (Object .class ).isAssignableFrom ((ResolvableType ) null ))
970
+ .withMessage ( "ResolvableType must not be null" );
971
971
}
972
972
973
973
@ Test
974
974
void isAssignableFromForNone () throws Exception {
975
975
ResolvableType objectType = ResolvableType .forClass (Object .class );
976
- assertThat (objectType .isAssignableFrom (ResolvableType .NONE )).isEqualTo ( false );
977
- assertThat (ResolvableType .NONE .isAssignableFrom (objectType )).isEqualTo ( false );
976
+ assertThat (objectType .isAssignableFrom (ResolvableType .NONE )).isFalse ( );
977
+ assertThat (ResolvableType .NONE .isAssignableFrom (objectType )).isFalse ( );
978
978
}
979
979
980
980
@ Test
@@ -1262,19 +1262,19 @@ void narrow() throws Exception {
1262
1262
@ Test
1263
1263
void hasUnresolvableGenerics () throws Exception {
1264
1264
ResolvableType type = ResolvableType .forField (Fields .class .getField ("stringList" ));
1265
- assertThat (type .hasUnresolvableGenerics ()).isEqualTo ( false );
1265
+ assertThat (type .hasUnresolvableGenerics ()).isFalse ( );
1266
1266
}
1267
1267
1268
1268
@ Test
1269
1269
void hasUnresolvableGenericsBasedOnOwnGenerics () throws Exception {
1270
1270
ResolvableType type = ResolvableType .forClass (List .class );
1271
- assertThat (type .hasUnresolvableGenerics ()).isEqualTo ( true );
1271
+ assertThat (type .hasUnresolvableGenerics ()).isTrue ( );
1272
1272
}
1273
1273
1274
1274
@ Test
1275
1275
void hasUnresolvableGenericsWhenSelfNotResolvable () throws Exception {
1276
1276
ResolvableType type = ResolvableType .forClass (List .class ).getGeneric ();
1277
- assertThat (type .hasUnresolvableGenerics ()).isEqualTo ( false );
1277
+ assertThat (type .hasUnresolvableGenerics ()).isFalse ( );
1278
1278
}
1279
1279
1280
1280
@ Test
@@ -1283,7 +1283,7 @@ void hasUnresolvableGenericsWhenImplementesRawInterface() throws Exception {
1283
1283
for (ResolvableType generic : type .getGenerics ()) {
1284
1284
assertThat (generic .resolve ()).isNotNull ();
1285
1285
}
1286
- assertThat (type .hasUnresolvableGenerics ()).isEqualTo ( true );
1286
+ assertThat (type .hasUnresolvableGenerics ()).isTrue ( );
1287
1287
}
1288
1288
1289
1289
@ Test
@@ -1292,7 +1292,7 @@ void hasUnresolvableGenericsWhenExtends() throws Exception {
1292
1292
for (ResolvableType generic : type .getGenerics ()) {
1293
1293
assertThat (generic .resolve ()).isNotNull ();
1294
1294
}
1295
- assertThat (type .hasUnresolvableGenerics ()).isEqualTo ( true );
1295
+ assertThat (type .hasUnresolvableGenerics ()).isTrue ( );
1296
1296
}
1297
1297
1298
1298
@ Test
0 commit comments