@@ -1300,8 +1300,8 @@ void getDirectWithAttributeAliases2() throws Exception {
1300
1300
@ Test
1301
1301
void getDirectWithAttributeAliasesWithDifferentValues () throws Exception {
1302
1302
Method method = WebController .class .getMethod ("handleMappedWithDifferentPathAndValueAttributes" );
1303
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (() ->
1304
- MergedAnnotations .from (method ).get (RequestMapping .class ))
1303
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1304
+ . isThrownBy (() -> MergedAnnotations .from (method ).get (RequestMapping .class ))
1305
1305
.withMessageContaining ("attribute 'path' and its alias 'value'" )
1306
1306
.withMessageContaining ("values of [{/test}] and [{/enigma}]" );
1307
1307
}
@@ -1363,16 +1363,16 @@ void streamRepeatableDeclaredOnMethod() throws Exception {
1363
1363
@ Test
1364
1364
@ SuppressWarnings ("deprecation" )
1365
1365
void streamRepeatableDeclaredOnClassWithAttributeAliases () {
1366
- assertThat (MergedAnnotations .from (HierarchyClass .class ).stream (
1367
- TestConfiguration .class )).isEmpty ();
1368
- RepeatableContainers containers = RepeatableContainers .of (TestConfiguration .class ,
1369
- Hierarchy .class );
1366
+ assertThat (MergedAnnotations .from (HierarchyClass .class ).stream (TestConfiguration .class )).isEmpty ();
1367
+ RepeatableContainers containers = RepeatableContainers .of (TestConfiguration .class , Hierarchy .class );
1370
1368
MergedAnnotations annotations = MergedAnnotations .from (HierarchyClass .class ,
1371
1369
SearchStrategy .DIRECT , containers , AnnotationFilter .NONE );
1372
- assertThat (annotations .stream (TestConfiguration .class ).map (
1373
- annotation -> annotation .getString ("location" ))).containsExactly ("A" , "B" );
1374
- assertThat (annotations .stream (TestConfiguration .class ).map (
1375
- annotation -> annotation .getString ("value" ))).containsExactly ("A" , "B" );
1370
+ assertThat (annotations .stream (TestConfiguration .class )
1371
+ .map (annotation -> annotation .getString ("location" )))
1372
+ .containsExactly ("A" , "B" );
1373
+ assertThat (annotations .stream (TestConfiguration .class )
1374
+ .map (annotation -> annotation .getString ("value" )))
1375
+ .containsExactly ("A" , "B" );
1376
1376
}
1377
1377
1378
1378
@ Test
@@ -1435,14 +1435,12 @@ private void testJavaRepeatables(SearchStrategy searchStrategy, Class<?> element
1435
1435
MyRepeatable [] annotations = searchStrategy == SearchStrategy .DIRECT ?
1436
1436
element .getDeclaredAnnotationsByType (MyRepeatable .class ) :
1437
1437
element .getAnnotationsByType (MyRepeatable .class );
1438
- assertThat (Arrays .stream (annotations ).map (MyRepeatable ::value )).containsExactly (
1439
- expected );
1438
+ assertThat (annotations ).extracting (MyRepeatable ::value ).containsExactly (expected );
1440
1439
}
1441
1440
1442
1441
private void testExplicitRepeatables (SearchStrategy searchStrategy , Class <?> element , String [] expected ) {
1443
1442
MergedAnnotations annotations = MergedAnnotations .from (element , searchStrategy ,
1444
- RepeatableContainers .of (MyRepeatable .class , MyRepeatableContainer .class ),
1445
- AnnotationFilter .PLAIN );
1443
+ RepeatableContainers .of (MyRepeatable .class , MyRepeatableContainer .class ));
1446
1444
Stream <String > values = annotations .stream (MyRepeatable .class )
1447
1445
.filter (MergedAnnotationPredicates .firstRunOf (MergedAnnotation ::getAggregateIndex ))
1448
1446
.map (annotation -> annotation .getString ("value" ));
@@ -1594,8 +1592,8 @@ void synthesizeWhenAliasForIsMissingAttributeDeclaration() {
1594
1592
AliasForWithMissingAttributeDeclarationClass .class .getAnnotation (
1595
1593
AliasForWithMissingAttributeDeclaration .class );
1596
1594
1597
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (
1598
- () -> MergedAnnotation .from (annotation ))
1595
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1596
+ . isThrownBy ( () -> MergedAnnotation .from (annotation ))
1599
1597
.withMessageStartingWith ("@AliasFor declaration on attribute 'foo' in annotation" )
1600
1598
.withMessageContaining (AliasForWithMissingAttributeDeclaration .class .getName ())
1601
1599
.withMessageContaining ("points to itself" );
@@ -1607,8 +1605,8 @@ void synthesizeWhenAliasForHasDuplicateAttributeDeclaration() {
1607
1605
AliasForWithDuplicateAttributeDeclarationClass .class .getAnnotation (
1608
1606
AliasForWithDuplicateAttributeDeclaration .class );
1609
1607
1610
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (
1611
- () -> MergedAnnotation .from (annotation ))
1608
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1609
+ . isThrownBy ( () -> MergedAnnotation .from (annotation ))
1612
1610
.withMessageStartingWith ("In @AliasFor declared on attribute 'foo' in annotation" )
1613
1611
.withMessageContaining (AliasForWithDuplicateAttributeDeclaration .class .getName ())
1614
1612
.withMessageContaining ("attribute 'attribute' and its alias 'value' are present with values of 'baz' and 'bar'" );
@@ -1619,8 +1617,8 @@ void synthesizeWhenAttributeAliasForNonexistentAttribute() {
1619
1617
AliasForNonexistentAttribute annotation = AliasForNonexistentAttributeClass .class .getAnnotation (
1620
1618
AliasForNonexistentAttribute .class );
1621
1619
1622
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (
1623
- () -> MergedAnnotation .from (annotation ))
1620
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1621
+ . isThrownBy ( () -> MergedAnnotation .from (annotation ))
1624
1622
.withMessageStartingWith ("@AliasFor declaration on attribute 'foo' in annotation" )
1625
1623
.withMessageContaining (AliasForNonexistentAttribute .class .getName ())
1626
1624
.withMessageContaining ("declares an alias for 'bar' which is not present" );
@@ -1632,8 +1630,8 @@ void synthesizeWhenAttributeAliasWithMirroredAliasForWrongAttribute() {
1632
1630
AliasForWithMirroredAliasForWrongAttributeClass .class .getAnnotation (
1633
1631
AliasForWithMirroredAliasForWrongAttribute .class );
1634
1632
1635
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (
1636
- () -> MergedAnnotation .from (annotation ))
1633
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1634
+ . isThrownBy ( () -> MergedAnnotation .from (annotation ))
1637
1635
.withMessage ("@AliasFor declaration on attribute 'bar' in annotation [" +
1638
1636
AliasForWithMirroredAliasForWrongAttribute .class .getName () +
1639
1637
"] declares an alias for 'quux' which is not present." );
@@ -1688,8 +1686,8 @@ void synthesizeWhenAttributeAliasForMetaAnnotationThatIsNotMetaPresent() {
1688
1686
AliasedComposedTestConfigurationNotMetaPresentClass .class .getAnnotation (
1689
1687
AliasedComposedTestConfigurationNotMetaPresent .class );
1690
1688
1691
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (
1692
- () -> MergedAnnotation .from (annotation ))
1689
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1690
+ . isThrownBy ( () -> MergedAnnotation .from (annotation ))
1693
1691
.withMessageStartingWith ("@AliasFor declaration on attribute 'xmlConfigFile' in annotation" )
1694
1692
.withMessageContaining (AliasedComposedTestConfigurationNotMetaPresent .class .getName ())
1695
1693
.withMessageContaining ("declares an alias for attribute 'location' in annotation" )
@@ -1781,8 +1779,8 @@ void synthesizeWithImplicitAliasesWithMissingDefaultValues() {
1781
1779
ImplicitAliasesWithMissingDefaultValuesTestConfiguration .class ;
1782
1780
ImplicitAliasesWithMissingDefaultValuesTestConfiguration config = clazz .getAnnotation (annotationType );
1783
1781
1784
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (
1785
- () -> MergedAnnotation .from (clazz , config ))
1782
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1783
+ . isThrownBy ( () -> MergedAnnotation .from (clazz , config ))
1786
1784
.withMessageStartingWith ("Misconfigured aliases:" )
1787
1785
.withMessageContaining ("attribute 'location1' in annotation [" + annotationType .getName () + "]" )
1788
1786
.withMessageContaining ("attribute 'location2' in annotation [" + annotationType .getName () + "]" )
@@ -1796,8 +1794,8 @@ void synthesizeWithImplicitAliasesWithDifferentDefaultValues() {
1796
1794
ImplicitAliasesWithDifferentDefaultValuesTestConfiguration .class ;
1797
1795
ImplicitAliasesWithDifferentDefaultValuesTestConfiguration config = clazz .getAnnotation (annotationType );
1798
1796
1799
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (
1800
- () -> MergedAnnotation .from (clazz , config ))
1797
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1798
+ . isThrownBy ( () -> MergedAnnotation .from (clazz , config ))
1801
1799
.withMessageStartingWith ("Misconfigured aliases:" )
1802
1800
.withMessageContaining ("attribute 'location1' in annotation [" + annotationType .getName () + "]" )
1803
1801
.withMessageContaining ("attribute 'location2' in annotation [" + annotationType .getName () + "]" )
@@ -1893,8 +1891,8 @@ void synthesizeFromDefaultsWithAttributeAliases() {
1893
1891
1894
1892
@ Test
1895
1893
void synthesizeWhenAttributeAliasesWithDifferentValues () {
1896
- assertThatExceptionOfType (AnnotationConfigurationException .class ). isThrownBy (() ->
1897
- MergedAnnotation .from (TestConfigurationMismatch .class .getAnnotation (TestConfiguration .class )). synthesize ( ));
1894
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
1895
+ . isThrownBy (() -> MergedAnnotation .from (TestConfigurationMismatch .class .getAnnotation (TestConfiguration .class )));
1898
1896
}
1899
1897
1900
1898
@ Test
@@ -1958,8 +1956,8 @@ void synthesizeFromMapWithNullAttributeValue() {
1958
1956
}
1959
1957
1960
1958
private void testMissingTextAttribute (Map <String , Object > attributes ) {
1961
- assertThatExceptionOfType (NoSuchElementException .class ). isThrownBy (() ->
1962
- MergedAnnotation .of (AnnotationWithoutDefaults .class , attributes ).synthesize ().text ())
1959
+ assertThatExceptionOfType (NoSuchElementException .class )
1960
+ . isThrownBy (() -> MergedAnnotation .of (AnnotationWithoutDefaults .class , attributes ).synthesize ().text ())
1963
1961
.withMessage ("No value found for attribute named 'text' in merged annotation " +
1964
1962
AnnotationWithoutDefaults .class .getCanonicalName ());
1965
1963
}
@@ -1968,7 +1966,8 @@ private void testMissingTextAttribute(Map<String, Object> attributes) {
1968
1966
void synthesizeFromMapWithAttributeOfIncorrectType () {
1969
1967
Map <String , Object > map = Collections .singletonMap ("value" , 42L );
1970
1968
MergedAnnotation <Component > annotation = MergedAnnotation .of (Component .class , map );
1971
- assertThatIllegalStateException ().isThrownBy (() -> annotation .synthesize ().value ())
1969
+ assertThatIllegalStateException ()
1970
+ .isThrownBy (() -> annotation .synthesize ().value ())
1972
1971
.withMessage ("Attribute 'value' in annotation " +
1973
1972
"org.springframework.core.testfixture.stereotype.Component should be " +
1974
1973
"compatible with java.lang.String but a java.lang.Long value was returned" );
0 commit comments