use of cn.taketoday.core.annotation.MergedAnnotations.SearchStrategy in project today-infrastructure by TAKETODAY.
the class MergedAnnotationsTests method fromPreconditions.
@Test
void fromPreconditions() {
SearchStrategy strategy = SearchStrategy.DIRECT;
RepeatableContainers containers = RepeatableContainers.standard();
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 cn.taketoday.core.annotation.MergedAnnotations.SearchStrategy in project today-infrastructure by TAKETODAY.
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.standard(), annotationFilter);
Stream<Class<? extends Annotation>> annotationTypes = mergedAnnotations.stream().map(MergedAnnotation::synthesize).map(Annotation::annotationType);
assertThat(annotationTypes).containsExactly(WithRepeatedMetaAnnotations.class, Noninherited.class, Noninherited.class);
}
use of cn.taketoday.core.annotation.MergedAnnotations.SearchStrategy in project today-framework by TAKETODAY.
the class MergedAnnotationsTests method fromPreconditions.
@Test
void fromPreconditions() {
SearchStrategy strategy = SearchStrategy.DIRECT;
RepeatableContainers containers = RepeatableContainers.standard();
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 cn.taketoday.core.annotation.MergedAnnotations.SearchStrategy in project today-framework by TAKETODAY.
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.standard(), annotationFilter);
Stream<Class<? extends Annotation>> annotationTypes = mergedAnnotations.stream().map(MergedAnnotation::synthesize).map(Annotation::annotationType);
assertThat(annotationTypes).containsExactly(WithRepeatedMetaAnnotations.class, Noninherited.class, Noninherited.class);
}
Aggregations