diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index c9bfe2876ead3c9715d37a218f714422cfae08bb..77ba824b5a38902dabbc626084b3065cda177909 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -573,7 +573,7 @@ public class AnnotatedElementUtilsTests { * Mock of {@link org.springframework.test.context.ContextConfiguration}. */ @Retention(RetentionPolicy.RUNTIME) - static @interface ContextConfig { + @interface ContextConfig { @AliasFor(attribute = "locations") String[] value() default {}; @@ -584,21 +584,21 @@ public class AnnotatedElementUtilsTests { @ContextConfig @Retention(RetentionPolicy.RUNTIME) - static @interface ConventionBasedComposedContextConfig { + @interface ConventionBasedComposedContextConfig { String[] locations() default {}; } @ContextConfig(value = "duplicateDeclaration") @Retention(RetentionPolicy.RUNTIME) - static @interface InvalidConventionBasedComposedContextConfig { + @interface InvalidConventionBasedComposedContextConfig { String[] locations(); } @ContextConfig @Retention(RetentionPolicy.RUNTIME) - static @interface AliasedComposedContextConfig { + @interface AliasedComposedContextConfig { @AliasFor(annotation = ContextConfig.class, attribute = "locations") String[] xmlConfigFiles(); @@ -606,7 +606,7 @@ public class AnnotatedElementUtilsTests { @ContextConfig @Retention(RetentionPolicy.RUNTIME) - static @interface AliasedValueComposedContextConfig { + @interface AliasedValueComposedContextConfig { @AliasFor(annotation = ContextConfig.class, attribute = "value") String[] locations(); @@ -620,7 +620,7 @@ public class AnnotatedElementUtilsTests { */ @ContextConfig(value = "duplicateDeclaration") @Retention(RetentionPolicy.RUNTIME) - static @interface InvalidAliasedComposedContextConfig { + @interface InvalidAliasedComposedContextConfig { @AliasFor(annotation = ContextConfig.class, attribute = "locations") String[] xmlConfigFiles(); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 24ea05a04bb2ad4a0dc892509aa729f841c1fef0..4fe618a728d6e6b0de1d112ffb8883a80dcffd22 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -25,7 +25,6 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import org.junit.Rule; import org.junit.Test; @@ -36,6 +35,7 @@ import org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass; import org.springframework.stereotype.Component; import org.springframework.util.ClassUtils; +import static java.util.stream.Collectors.*; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.springframework.core.annotation.AnnotationUtils.*; @@ -480,7 +480,7 @@ public class AnnotationUtilsTests { Method method = InterfaceWithRepeated.class.getMethod("foo"); Set annotations = getRepeatableAnnotation(method, MyRepeatableContainer.class, MyRepeatable.class); assertNotNull(annotations); - List values = annotations.stream().map(MyRepeatable::value).collect(Collectors.toList()); + List values = annotations.stream().map(MyRepeatable::value).collect(toList()); assertThat(values, equalTo(Arrays.asList("a", "b", "c", "meta"))); } @@ -489,10 +489,10 @@ public class AnnotationUtilsTests { Set annotations = getRepeatableAnnotation(TestCase.class, Hierarchy.class, ContextConfig.class); assertNotNull(annotations); - List locations = annotations.stream().map(ContextConfig::locations).collect(Collectors.toList()); + List locations = annotations.stream().map(ContextConfig::locations).collect(toList()); assertThat(locations, equalTo(Arrays.asList("A", "B"))); - List values = annotations.stream().map(ContextConfig::value).collect(Collectors.toList()); + List values = annotations.stream().map(ContextConfig::value).collect(toList()); assertThat(values, equalTo(Arrays.asList("A", "B"))); } @@ -646,14 +646,13 @@ public class AnnotationUtilsTests { ContextConfig[] configs = synthesizedHierarchy.value(); assertNotNull(configs); - for (ContextConfig contextConfig : configs) { - assertThat(contextConfig, instanceOf(SynthesizedAnnotation.class)); - } + assertTrue("nested annotations must be synthesized", + Arrays.stream(configs).allMatch(c -> c instanceof SynthesizedAnnotation)); - List locations = Arrays.stream(configs).map(ContextConfig::locations).collect(Collectors.toList()); + List locations = Arrays.stream(configs).map(ContextConfig::locations).collect(toList()); assertThat(locations, equalTo(Arrays.asList("A", "B"))); - List values = Arrays.stream(configs).map(ContextConfig::value).collect(Collectors.toList()); + List values = Arrays.stream(configs).map(ContextConfig::value).collect(toList()); assertThat(values, equalTo(Arrays.asList("A", "B"))); }