use of org.springframework.core.annotation.MergedAnnotations.SearchStrategy in project spring-framework by spring-projects.
the class MergedAnnotationsTests method fromPreconditions.
@Test
void fromPreconditions() {
SearchStrategy strategy = SearchStrategy.DIRECT;
RepeatableContainers containers = RepeatableContainers.standardRepeatables();
assertThatIllegalArgumentException().isThrownBy(() -> MergedAnnotations.from(getClass(), strategy, null, AnnotationFilter.PLAIN)).withMessage("RepeatableContainers must not be null");
assertThatIllegalArgumentException().isThrownBy(() -> MergedAnnotations.from(getClass(), strategy, containers, null)).withMessage("AnnotationFilter must not be null");
assertThatIllegalArgumentException().isThrownBy(() -> MergedAnnotations.from(getClass(), new Annotation[0], null, AnnotationFilter.PLAIN)).withMessage("RepeatableContainers must not be null");
assertThatIllegalArgumentException().isThrownBy(() -> MergedAnnotations.from(getClass(), new Annotation[0], containers, null)).withMessage("AnnotationFilter must not be null");
}
use of org.springframework.core.annotation.MergedAnnotations.SearchStrategy in project spring-framework by spring-projects.
the class MergedAnnotationsRepeatableAnnotationTests method typeHierarchyAnnotationsWithLocalComposedAnnotationWhoseRepeatableMetaAnnotationsAreFiltered.
@Test
void typeHierarchyAnnotationsWithLocalComposedAnnotationWhoseRepeatableMetaAnnotationsAreFiltered() {
Class<WithRepeatedMetaAnnotationsClass> element = WithRepeatedMetaAnnotationsClass.class;
SearchStrategy searchStrategy = SearchStrategy.TYPE_HIERARCHY;
AnnotationFilter annotationFilter = PeteRepeat.class.getName()::equals;
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class, searchStrategy, element, annotationFilter);
assertThat(annotations).isEmpty();
MergedAnnotations mergedAnnotations = MergedAnnotations.from(element, searchStrategy, RepeatableContainers.standardRepeatables(), annotationFilter);
Stream<Class<? extends Annotation>> annotationTypes = mergedAnnotations.stream().map(MergedAnnotation::synthesize).map(Annotation::annotationType);
assertThat(annotationTypes).containsExactly(WithRepeatedMetaAnnotations.class, Noninherited.class, Noninherited.class);
}
Aggregations