提交 73170224 编写于 作者: S Sam Brannen

Polish annotation utility tests

上级 91ed5b6b
......@@ -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();
......
......@@ -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<MyRepeatable> annotations = getRepeatableAnnotation(method, MyRepeatableContainer.class, MyRepeatable.class);
assertNotNull(annotations);
List<String> values = annotations.stream().map(MyRepeatable::value).collect(Collectors.toList());
List<String> 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<ContextConfig> annotations = getRepeatableAnnotation(TestCase.class, Hierarchy.class, ContextConfig.class);
assertNotNull(annotations);
List<String> locations = annotations.stream().map(ContextConfig::locations).collect(Collectors.toList());
List<String> locations = annotations.stream().map(ContextConfig::locations).collect(toList());
assertThat(locations, equalTo(Arrays.asList("A", "B")));
List<String> values = annotations.stream().map(ContextConfig::value).collect(Collectors.toList());
List<String> 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<String> locations = Arrays.stream(configs).map(ContextConfig::locations).collect(Collectors.toList());
List<String> locations = Arrays.stream(configs).map(ContextConfig::locations).collect(toList());
assertThat(locations, equalTo(Arrays.asList("A", "B")));
List<String> values = Arrays.stream(configs).map(ContextConfig::value).collect(Collectors.toList());
List<String> values = Arrays.stream(configs).map(ContextConfig::value).collect(toList());
assertThat(values, equalTo(Arrays.asList("A", "B")));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册