Revert "Remove deprecated "enclosing classes" search strategy for MergedAnnotations"
This reverts commit 819d4256b7.
See gh-28080
This commit is contained in:
@@ -420,6 +420,32 @@ class AnnotationsScannerTests {
|
||||
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly("0:TestAnnotation1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void typeHierarchyWithEnclosedStrategyOnEnclosedStaticClassScansAnnotations() {
|
||||
Class<?> source = AnnotationEnclosingClassSample.EnclosedStatic.EnclosedStaticStatic.class;
|
||||
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES))
|
||||
.containsExactly("0:EnclosedThree", "1:EnclosedTwo", "2:EnclosedOne");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void typeHierarchyWithEnclosedStrategyOnEnclosedInnerClassScansAnnotations() {
|
||||
Class<?> source = AnnotationEnclosingClassSample.EnclosedInner.EnclosedInnerInner.class;
|
||||
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES))
|
||||
.containsExactly("0:EnclosedThree", "1:EnclosedTwo", "2:EnclosedOne");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void typeHierarchyWithEnclosedStrategyOnMethodHierarchyUsesTypeHierarchyScan() {
|
||||
Method source = methodFrom(WithHierarchy.class);
|
||||
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES)).containsExactly(
|
||||
"0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5",
|
||||
"2:TestAnnotation6", "3:TestAnnotation2", "3:TestInheritedAnnotation2",
|
||||
"4:TestAnnotation3", "5:TestAnnotation4");
|
||||
}
|
||||
|
||||
@Test
|
||||
void scanWhenProcessorReturnsFromDoWithAggregateExitsEarly() {
|
||||
String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class,
|
||||
|
||||
@@ -710,6 +710,22 @@ class MergedAnnotationsTests {
|
||||
Transactional.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedInnerClassWithAnnotatedEnclosingClass() {
|
||||
Stream<Class<?>> classes = MergedAnnotations.from(AnnotatedClass.NonAnnotatedInnerClass.class,
|
||||
SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType);
|
||||
assertThat(classes).containsExactly(Component.class, Indexed.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedStaticNestedClassWithAnnotatedEnclosingClass() {
|
||||
Stream<Class<?>> classes = MergedAnnotations.from(AnnotatedClass.NonAnnotatedStaticNestedClass.class,
|
||||
SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType);
|
||||
assertThat(classes).containsExactly(Component.class, Indexed.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getFromMethodWithMethodAnnotationOnLeaf() throws Exception {
|
||||
Method method = Leaf.class.getMethod("annotatedOnLeaf");
|
||||
|
||||
Reference in New Issue
Block a user