16
16
17
17
package org .springframework .core .annotation ;
18
18
19
- import java .io .Serializable ;
20
19
import java .lang .annotation .Annotation ;
21
20
import java .lang .annotation .Inherited ;
22
21
import java .lang .annotation .Retention ;
@@ -53,36 +52,31 @@ void directStrategyOnClassWhenNotAnnotatedScansNone() {
53
52
@ Test
54
53
void directStrategyOnClassScansAnnotations () {
55
54
Class <?> source = WithSingleAnnotation .class ;
56
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
57
- "0:TestAnnotation1" );
55
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
58
56
}
59
57
60
58
@ Test
61
59
void directStrategyOnClassWhenMultipleAnnotationsScansAnnotations () {
62
60
Class <?> source = WithMultipleAnnotations .class ;
63
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
64
- "0:TestAnnotation1" , "0:TestAnnotation2" );
61
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" , "0:TestAnnotation2" );
65
62
}
66
63
67
64
@ Test
68
65
void directStrategyOnClassWhenHasSuperclassScansOnlyDirect () {
69
66
Class <?> source = WithSingleSuperclass .class ;
70
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
71
- "0:TestAnnotation1" );
67
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
72
68
}
73
69
74
70
@ Test
75
71
void directStrategyOnClassWhenHasInterfaceScansOnlyDirect () {
76
72
Class <?> source = WithSingleInterface .class ;
77
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
78
- "0:TestAnnotation1" );
73
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
79
74
}
80
75
81
76
@ Test
82
77
void directStrategyOnClassHierarchyScansInCorrectOrder () {
83
78
Class <?> source = WithHierarchy .class ;
84
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
85
- "0:TestAnnotation1" );
79
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
86
80
}
87
81
88
82
@ Test
@@ -94,8 +88,7 @@ void inheritedAnnotationsStrategyOnClassWhenNotAnnotatedScansNone() {
94
88
@ Test
95
89
void inheritedAnnotationsStrategyOnClassScansAnnotations () {
96
90
Class <?> source = WithSingleAnnotation .class ;
97
- assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly (
98
- "0:TestAnnotation1" );
91
+ assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly ("0:TestAnnotation1" );
99
92
}
100
93
101
94
@ Test
@@ -115,8 +108,7 @@ void inheritedAnnotationsStrategyOnClassWhenHasSuperclassScansOnlyInherited() {
115
108
@ Test
116
109
void inheritedAnnotationsStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces () {
117
110
Class <?> source = WithSingleInterface .class ;
118
- assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly (
119
- "0:TestAnnotation1" );
111
+ assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly ("0:TestAnnotation1" );
120
112
}
121
113
122
114
@ Test
@@ -132,8 +124,7 @@ void inheritedAnnotationsStrategyOnClassWhenHasAnnotationOnBothClassesIncudesOnl
132
124
assertThat (Arrays .stream (source .getAnnotations ()).map (
133
125
Annotation ::annotationType ).map (Class ::getName )).containsExactly (
134
126
TestInheritedAnnotation2 .class .getName ());
135
- assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsOnly (
136
- "0:TestInheritedAnnotation2" );
127
+ assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsOnly ("0:TestInheritedAnnotation2" );
137
128
}
138
129
139
130
@ Test
@@ -145,15 +136,13 @@ void superclassStrategyOnClassWhenNotAnnotatedScansNone() {
145
136
@ Test
146
137
void superclassStrategyOnClassScansAnnotations () {
147
138
Class <?> source = WithSingleAnnotation .class ;
148
- assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly (
149
- "0:TestAnnotation1" );
139
+ assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly ("0:TestAnnotation1" );
150
140
}
151
141
152
142
@ Test
153
143
void superclassStrategyOnClassWhenMultipleAnnotationsScansAnnotations () {
154
144
Class <?> source = WithMultipleAnnotations .class ;
155
- assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly (
156
- "0:TestAnnotation1" , "0:TestAnnotation2" );
145
+ assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly ("0:TestAnnotation1" , "0:TestAnnotation2" );
157
146
}
158
147
159
148
@ Test
@@ -166,8 +155,7 @@ void superclassStrategyOnClassWhenHasSuperclassScansSuperclass() {
166
155
@ Test
167
156
void superclassStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces () {
168
157
Class <?> source = WithSingleInterface .class ;
169
- assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly (
170
- "0:TestAnnotation1" );
158
+ assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly ("0:TestAnnotation1" );
171
159
}
172
160
173
161
@ Test
@@ -187,8 +175,7 @@ void typeHierarchyStrategyOnClassWhenNotAnnotatedScansNone() {
187
175
@ Test
188
176
void typeHierarchyStrategyOnClassScansAnnotations () {
189
177
Class <?> source = WithSingleAnnotation .class ;
190
- assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly (
191
- "0:TestAnnotation1" );
178
+ assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly ("0:TestAnnotation1" );
192
179
}
193
180
194
181
@ Test
@@ -230,8 +217,7 @@ void directStrategyOnMethodWhenNotAnnotatedScansNone() {
230
217
@ Test
231
218
void directStrategyOnMethodScansAnnotations () {
232
219
Method source = methodFrom (WithSingleAnnotation .class );
233
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
234
- "0:TestAnnotation1" );
220
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
235
221
}
236
222
237
223
@ Test
@@ -244,22 +230,19 @@ void directStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
244
230
@ Test
245
231
void directStrategyOnMethodWhenHasSuperclassScansOnlyDirect () {
246
232
Method source = methodFrom (WithSingleSuperclass .class );
247
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
248
- "0:TestAnnotation1" );
233
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
249
234
}
250
235
251
236
@ Test
252
237
void directStrategyOnMethodWhenHasInterfaceScansOnlyDirect () {
253
238
Method source = methodFrom (WithSingleInterface .class );
254
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
255
- "0:TestAnnotation1" );
239
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
256
240
}
257
241
258
242
@ Test
259
243
void directStrategyOnMethodHierarchyScansInCorrectOrder () {
260
244
Method source = methodFrom (WithHierarchy .class );
261
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
262
- "0:TestAnnotation1" );
245
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
263
246
}
264
247
265
248
@ Test
@@ -271,8 +254,7 @@ void inheritedAnnotationsStrategyOnMethodWhenNotAnnotatedScansNone() {
271
254
@ Test
272
255
void inheritedAnnotationsStrategyOnMethodScansAnnotations () {
273
256
Method source = methodFrom (WithSingleAnnotation .class );
274
- assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly (
275
- "0:TestAnnotation1" );
257
+ assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly ("0:TestAnnotation1" );
276
258
}
277
259
278
260
@ Test
@@ -285,22 +267,19 @@ void inheritedAnnotationsStrategyOnMethodWhenMultipleAnnotationsScansAnnotations
285
267
@ Test
286
268
void inheritedAnnotationsMethodOnMethodWhenHasSuperclassIgnoresInherited () {
287
269
Method source = methodFrom (WithSingleSuperclass .class );
288
- assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly (
289
- "0:TestAnnotation1" );
270
+ assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly ("0:TestAnnotation1" );
290
271
}
291
272
292
273
@ Test
293
274
void inheritedAnnotationsStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces () {
294
275
Method source = methodFrom (WithSingleInterface .class );
295
- assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly (
296
- "0:TestAnnotation1" );
276
+ assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly ("0:TestAnnotation1" );
297
277
}
298
278
299
279
@ Test
300
280
void inheritedAnnotationsStrategyOnMethodHierarchyScansInCorrectOrder () {
301
281
Method source = methodFrom (WithHierarchy .class );
302
- assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly (
303
- "0:TestAnnotation1" );
282
+ assertThat (scan (source , SearchStrategy .INHERITED_ANNOTATIONS )).containsExactly ("0:TestAnnotation1" );
304
283
}
305
284
306
285
@ Test
@@ -312,8 +291,7 @@ void superclassStrategyOnMethodWhenNotAnnotatedScansNone() {
312
291
@ Test
313
292
void superclassStrategyOnMethodScansAnnotations () {
314
293
Method source = methodFrom (WithSingleAnnotation .class );
315
- assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly (
316
- "0:TestAnnotation1" );
294
+ assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly ("0:TestAnnotation1" );
317
295
}
318
296
319
297
@ Test
@@ -333,8 +311,7 @@ void superclassStrategyOnMethodWhenHasSuperclassScansSuperclass() {
333
311
@ Test
334
312
void superclassStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces () {
335
313
Method source = methodFrom (WithSingleInterface .class );
336
- assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly (
337
- "0:TestAnnotation1" );
314
+ assertThat (scan (source , SearchStrategy .SUPERCLASS )).containsExactly ("0:TestAnnotation1" );
338
315
}
339
316
340
317
@ Test
@@ -354,8 +331,7 @@ void typeHierarchyStrategyOnMethodWhenNotAnnotatedScansNone() {
354
331
@ Test
355
332
void typeHierarchyStrategyOnMethodScansAnnotations () {
356
333
Method source = methodFrom (WithSingleAnnotation .class );
357
- assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly (
358
- "0:TestAnnotation1" );
334
+ assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly ("0:TestAnnotation1" );
359
335
}
360
336
361
337
@ Test
@@ -408,50 +384,39 @@ void typeHierarchyStrategyOnBridgedMethodScansAnnotations() throws Exception {
408
384
void directStrategyOnBridgeMethodScansAnnotations () throws Exception {
409
385
Method source = BridgedMethod .class .getDeclaredMethod ("method" , Object .class );
410
386
assertThat (source .isBridge ()).isTrue ();
411
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
412
- "0:TestAnnotation1" );
387
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
413
388
}
414
389
415
390
@ Test
416
- void dirextStrategyOnBridgedMethodScansAnnotations () throws Exception {
391
+ void directStrategyOnBridgedMethodScansAnnotations () throws Exception {
417
392
Method source = BridgedMethod .class .getDeclaredMethod ("method" , String .class );
418
393
assertThat (source .isBridge ()).isFalse ();
419
- assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly (
420
- "0:TestAnnotation1" );
394
+ assertThat (scan (source , SearchStrategy .DIRECT )).containsExactly ("0:TestAnnotation1" );
421
395
}
422
396
423
397
@ Test
424
- void typeHierarchyStrategyOnMethodWithIgnorablesScansAnnotations ()
425
- throws Exception {
398
+ void typeHierarchyStrategyOnMethodWithIgnorablesScansAnnotations () {
426
399
Method source = methodFrom (Ignorable .class );
427
- assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly (
428
- "0:TestAnnotation1" );
400
+ assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly ("0:TestAnnotation1" );
429
401
}
430
402
431
403
@ Test
432
- void typeHierarchyStrategyOnMethodWithMultipleCandidatesScansAnnotations ()
433
- throws Exception {
404
+ void typeHierarchyStrategyOnMethodWithMultipleCandidatesScansAnnotations () {
434
405
Method source = methodFrom (MultipleMethods .class );
435
- assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly (
436
- "0:TestAnnotation1" );
406
+ assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly ("0:TestAnnotation1" );
437
407
}
438
408
439
409
@ Test
440
- void typeHierarchyStrategyOnMethodWithGenericParameterOverrideScansAnnotations ()
441
- throws Exception {
442
- Method source = ReflectionUtils .findMethod (GenericOverride .class , "method" ,
443
- String .class );
410
+ void typeHierarchyStrategyOnMethodWithGenericParameterOverrideScansAnnotations () {
411
+ Method source = ReflectionUtils .findMethod (GenericOverride .class , "method" , String .class );
444
412
assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly (
445
413
"0:TestAnnotation1" , "1:TestAnnotation2" );
446
414
}
447
415
448
416
@ Test
449
- void typeHierarchyStrategyOnMethodWithGenericParameterNonOverrideScansAnnotations ()
450
- throws Exception {
451
- Method source = ReflectionUtils .findMethod (GenericNonOverride .class , "method" ,
452
- StringBuilder .class );
453
- assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly (
454
- "0:TestAnnotation1" );
417
+ void typeHierarchyStrategyOnMethodWithGenericParameterNonOverrideScansAnnotations () {
418
+ Method source = ReflectionUtils .findMethod (GenericNonOverride .class , "method" , StringBuilder .class );
419
+ assertThat (scan (source , SearchStrategy .TYPE_HIERARCHY )).containsExactly ("0:TestAnnotation1" );
455
420
}
456
421
457
422
@ Test
@@ -751,8 +716,7 @@ interface BridgeMethod<T> {
751
716
void method (T arg );
752
717
}
753
718
754
- @ SuppressWarnings ("serial" )
755
- static class Ignorable implements IgnorableOverrideInterface1 , IgnorableOverrideInterface2 , Serializable {
719
+ static class Ignorable implements IgnorableOverrideInterface1 , IgnorableOverrideInterface2 {
756
720
757
721
@ Override
758
722
@ TestAnnotation1
@@ -802,8 +766,7 @@ interface GenericOverrideInterface<T extends CharSequence> {
802
766
void method (T argument );
803
767
}
804
768
805
- static abstract class GenericNonOverride
806
- implements GenericNonOverrideInterface <String > {
769
+ static abstract class GenericNonOverride implements GenericNonOverrideInterface <String > {
807
770
808
771
@ TestAnnotation1
809
772
public void method (StringBuilder argument ) {
0 commit comments