@@ -330,7 +330,7 @@ public void findAnnotationDeclaringClassForAllScenarios() throws Exception {
330
330
@ Test
331
331
public void findAnnotationDeclaringClassForTypesWithSingleCandidateType () {
332
332
// no class-level annotation
333
- List <Class <? extends Annotation >> transactionalCandidateList = asList (Transactional .class );
333
+ List <Class <? extends Annotation >> transactionalCandidateList = Collections . singletonList (Transactional .class );
334
334
assertNull (findAnnotationDeclaringClassForTypes (transactionalCandidateList , NonAnnotatedInterface .class ));
335
335
assertNull (findAnnotationDeclaringClassForTypes (transactionalCandidateList , NonAnnotatedClass .class ));
336
336
@@ -345,7 +345,7 @@ public void findAnnotationDeclaringClassForTypesWithSingleCandidateType() {
345
345
346
346
// non-inherited class-level annotation; note: @Order is not inherited,
347
347
// but findAnnotationDeclaringClassForTypes() should still find it on classes.
348
- List <Class <? extends Annotation >> orderCandidateList = asList (Order .class );
348
+ List <Class <? extends Annotation >> orderCandidateList = Collections . singletonList (Order .class );
349
349
assertEquals (NonInheritedAnnotationInterface .class ,
350
350
findAnnotationDeclaringClassForTypes (orderCandidateList , NonInheritedAnnotationInterface .class ));
351
351
assertNull (findAnnotationDeclaringClassForTypes (orderCandidateList , SubNonInheritedAnnotationInterface .class ));
@@ -478,12 +478,12 @@ public void getAnnotationAttributesWithAttributeAliases() throws Exception {
478
478
assertEquals ("value attribute: " , "/test" , attributes .getString (VALUE ));
479
479
assertEquals ("path attribute: " , "/test" , attributes .getString ("path" ));
480
480
481
- method = WebController .class .getMethod ("handleMappedWithDifferentPathAndValueAttributes" );
482
- webMapping = method .getAnnotation (WebMapping .class );
483
481
exception .expect (AnnotationConfigurationException .class );
484
482
exception .expectMessage (containsString ("attribute 'value' and its alias 'path'" ));
485
483
exception .expectMessage (containsString ("values of [/enigma] and [/test]" ));
486
- exception .expectMessage (endsWith ("but only one is permitted." ));
484
+
485
+ method = WebController .class .getMethod ("handleMappedWithDifferentPathAndValueAttributes" );
486
+ webMapping = method .getAnnotation (WebMapping .class );
487
487
getAnnotationAttributes (webMapping );
488
488
}
489
489
@@ -554,7 +554,8 @@ public void getRepeatableAnnotationsDeclaredOnClassWithMissingAttributeAliasDecl
554
554
exception .expect (AnnotationConfigurationException .class );
555
555
exception .expectMessage (startsWith ("Attribute [value] in" ));
556
556
exception .expectMessage (containsString (BrokenContextConfig .class .getName ()));
557
- exception .expectMessage (endsWith ("must be declared as an @AliasFor [location]." ));
557
+ exception .expectMessage (containsString ("@AliasFor [location]" ));
558
+
558
559
getRepeatableAnnotations (BrokenConfigHierarchyTestCase .class , BrokenContextConfig .class , BrokenHierarchy .class );
559
560
}
560
561
@@ -845,7 +846,7 @@ public void synthesizeAnnotationWhereAliasForIsMissingAttributeDeclaration() thr
845
846
exception .expect (AnnotationConfigurationException .class );
846
847
exception .expectMessage (startsWith ("@AliasFor declaration on attribute [foo] in annotation" ));
847
848
exception .expectMessage (containsString (AliasForWithMissingAttributeDeclaration .class .getName ()));
848
- exception .expectMessage (endsWith ( "is missing required 'attribute' value. " ));
849
+ exception .expectMessage (containsString ( "points to itself " ));
849
850
synthesizeAnnotation (annotation );
850
851
}
851
852
@@ -856,7 +857,6 @@ public void synthesizeAnnotationWhereAliasForHasDuplicateAttributeDeclaration()
856
857
exception .expectMessage (startsWith ("In @AliasFor declared on attribute [foo] in annotation" ));
857
858
exception .expectMessage (containsString (AliasForWithDuplicateAttributeDeclaration .class .getName ()));
858
859
exception .expectMessage (containsString ("attribute 'attribute' and its alias 'value' are present with values of [baz] and [bar]" ));
859
- exception .expectMessage (endsWith ("but only one is permitted." ));
860
860
synthesizeAnnotation (annotation );
861
861
}
862
862
@@ -877,7 +877,7 @@ public void synthesizeAnnotationWithAttributeAliasWithoutMirroredAliasFor() thro
877
877
exception .expect (AnnotationConfigurationException .class );
878
878
exception .expectMessage (startsWith ("Attribute [bar] in" ));
879
879
exception .expectMessage (containsString (AliasForWithoutMirroredAliasFor .class .getName ()));
880
- exception .expectMessage (endsWith ( "must be declared as an @AliasFor [foo]. " ));
880
+ exception .expectMessage (containsString ( " @AliasFor [foo]" ));
881
881
synthesizeAnnotation (annotation );
882
882
}
883
883
@@ -903,7 +903,7 @@ public void synthesizeAnnotationWithAttributeAliasForAttributeOfDifferentType()
903
903
exception .expectMessage (containsString (AliasForAttributeOfDifferentType .class .getName ()));
904
904
exception .expectMessage (containsString ("attribute [foo]" ));
905
905
exception .expectMessage (containsString ("attribute [bar]" ));
906
- exception .expectMessage (endsWith ( "must declare the same return type. " ));
906
+ exception .expectMessage (containsString ( " same return type" ));
907
907
synthesizeAnnotation (annotation );
908
908
}
909
909
@@ -916,7 +916,7 @@ public void synthesizeAnnotationWithAttributeAliasForWithMissingDefaultValues()
916
916
exception .expectMessage (containsString (AliasForWithMissingDefaultValues .class .getName ()));
917
917
exception .expectMessage (containsString ("attribute [foo] in annotation" ));
918
918
exception .expectMessage (containsString ("attribute [bar] in annotation" ));
919
- exception .expectMessage (endsWith ( "must declare default values. " ));
919
+ exception .expectMessage (containsString ( " default values" ));
920
920
synthesizeAnnotation (annotation );
921
921
}
922
922
@@ -929,19 +929,20 @@ public void synthesizeAnnotationWithAttributeAliasForAttributeWithDifferentDefau
929
929
exception .expectMessage (containsString (AliasForAttributeWithDifferentDefaultValue .class .getName ()));
930
930
exception .expectMessage (containsString ("attribute [foo] in annotation" ));
931
931
exception .expectMessage (containsString ("attribute [bar] in annotation" ));
932
- exception .expectMessage (endsWith ( "must declare the same default value. " ));
932
+ exception .expectMessage (containsString ( " same default value" ));
933
933
synthesizeAnnotation (annotation );
934
934
}
935
935
936
936
@ Test
937
937
public void synthesizeAnnotationWithAttributeAliasForMetaAnnotationThatIsNotMetaPresent () throws Exception {
938
- AliasedComposedContextConfigNotMetaPresent annotation = AliasedComposedContextConfigNotMetaPresentClass .class .getAnnotation (AliasedComposedContextConfigNotMetaPresent .class );
938
+ AliasedComposedContextConfigNotMetaPresent annotation =
939
+ AliasedComposedContextConfigNotMetaPresentClass .class .getAnnotation (AliasedComposedContextConfigNotMetaPresent .class );
939
940
exception .expect (AnnotationConfigurationException .class );
940
941
exception .expectMessage (startsWith ("@AliasFor declaration on attribute [xmlConfigFile] in annotation" ));
941
942
exception .expectMessage (containsString (AliasedComposedContextConfigNotMetaPresent .class .getName ()));
942
943
exception .expectMessage (containsString ("declares an alias for attribute [location] in meta-annotation" ));
943
944
exception .expectMessage (containsString (ContextConfig .class .getName ()));
944
- exception .expectMessage (endsWith ( "which is not meta-present. " ));
945
+ exception .expectMessage (containsString ( " not meta-present" ));
945
946
synthesizeAnnotation (annotation );
946
947
}
947
948
@@ -1039,7 +1040,7 @@ public void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() th
1039
1040
exception .expectMessage (startsWith ("Misconfigured aliases:" ));
1040
1041
exception .expectMessage (containsString ("attribute [location1] in annotation [" + annotationType .getName () + "]" ));
1041
1042
exception .expectMessage (containsString ("attribute [location2] in annotation [" + annotationType .getName () + "]" ));
1042
- exception .expectMessage (endsWith ( "must declare default values. " ));
1043
+ exception .expectMessage (containsString ( " default values" ));
1043
1044
1044
1045
synthesizeAnnotation (config , clazz );
1045
1046
}
@@ -1055,7 +1056,7 @@ public void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues()
1055
1056
exception .expectMessage (startsWith ("Misconfigured aliases:" ));
1056
1057
exception .expectMessage (containsString ("attribute [location1] in annotation [" + annotationType .getName () + "]" ));
1057
1058
exception .expectMessage (containsString ("attribute [location2] in annotation [" + annotationType .getName () + "]" ));
1058
- exception .expectMessage (endsWith ( "must declare the same default value. " ));
1059
+ exception .expectMessage (containsString ( " same default value" ));
1059
1060
1060
1061
synthesizeAnnotation (config , clazz );
1061
1062
}
@@ -1077,10 +1078,9 @@ public void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws
1077
1078
exception .expectMessage (containsString (clazz .getName ()));
1078
1079
exception .expectMessage (containsString ("and synthesized from" ));
1079
1080
exception .expectMessage (either (containsString ("attribute 'location1' and its alias 'location2'" )).or (
1080
- containsString ("attribute 'location2' and its alias 'location1'" )));
1081
+ containsString ("attribute 'location2' and its alias 'location1'" )));
1081
1082
exception .expectMessage (either (containsString ("are present with values of [1] and [2]" )).or (
1082
- containsString ("are present with values of [2] and [1]" )));
1083
- exception .expectMessage (endsWith ("but only one is permitted." ));
1083
+ containsString ("are present with values of [2] and [1]" )));
1084
1084
1085
1085
synthesizedConfig .location1 ();
1086
1086
}
@@ -1106,8 +1106,8 @@ public void synthesizeAnnotationFromMapWithNestedMap() throws Exception {
1106
1106
assertNotNull (componentScan );
1107
1107
assertEquals ("value from ComponentScan: " , "*Foo" , componentScan .value ().pattern ());
1108
1108
1109
- AnnotationAttributes attributes = getAnnotationAttributes (ComponentScanSingleFilterClass . class , componentScan ,
1110
- false , true );
1109
+ AnnotationAttributes attributes = getAnnotationAttributes (
1110
+ ComponentScanSingleFilterClass . class , componentScan , false , true );
1111
1111
assertNotNull (attributes );
1112
1112
assertEquals (ComponentScanSingleFilter .class , attributes .annotationType ());
1113
1113
@@ -1119,8 +1119,8 @@ public void synthesizeAnnotationFromMapWithNestedMap() throws Exception {
1119
1119
filterMap .put ("pattern" , "newFoo" );
1120
1120
filterMap .put ("enigma" , 42 );
1121
1121
1122
- ComponentScanSingleFilter synthesizedComponentScan = synthesizeAnnotation (attributes ,
1123
- ComponentScanSingleFilter .class , ComponentScanSingleFilterClass .class );
1122
+ ComponentScanSingleFilter synthesizedComponentScan = synthesizeAnnotation (
1123
+ attributes , ComponentScanSingleFilter .class , ComponentScanSingleFilterClass .class );
1124
1124
assertNotNull (synthesizedComponentScan );
1125
1125
1126
1126
assertNotSame (componentScan , synthesizedComponentScan );
@@ -1235,6 +1235,7 @@ public void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exc
1235
1235
exception .expectMessage (containsString ("for attribute [value]" ));
1236
1236
exception .expectMessage (containsString ("but a value of type [java.lang.String] is required" ));
1237
1237
exception .expectMessage (containsString ("as defined by annotation type [" + Component .class .getName () + "]" ));
1238
+
1238
1239
synthesizeAnnotation (map , Component .class , null );
1239
1240
}
1240
1241
@@ -1410,7 +1411,7 @@ public void synthesizeAnnotationWithAttributeAliasesInNestedAnnotations() throws
1410
1411
ContextConfig [] configs = synthesizedHierarchy .value ();
1411
1412
assertNotNull (configs );
1412
1413
assertTrue ("nested annotations must be synthesized" ,
1413
- stream (configs ).allMatch (c -> c instanceof SynthesizedAnnotation ));
1414
+ stream (configs ).allMatch (c -> c instanceof SynthesizedAnnotation ));
1414
1415
1415
1416
List <String > locations = stream (configs ).map (ContextConfig ::location ).collect (toList ());
1416
1417
assertThat (locations , is (expectedLocations ));
0 commit comments