use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class AnnotationUtilsTests method getAnnotationAttributesWithoutAttributeAliases.
@Test
void getAnnotationAttributesWithoutAttributeAliases() {
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
AnnotationAttributes attributes = (AnnotationAttributes) getAnnotationAttributes(component);
assertThat(attributes).isNotNull();
assertThat(attributes.getString(VALUE)).as("value attribute: ").isEqualTo("webController");
assertThat(attributes.annotationType()).isEqualTo(Component.class);
}
use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class AnnotationUtilsTests method findClassAnnotationOnMetaMetaMetaAnnotatedClass.
@Test
void findClassAnnotationOnMetaMetaMetaAnnotatedClass() {
Component component = findAnnotation(MetaMetaMetaAnnotatedClass.class, Component.class);
assertThat(component).as("Should find meta-annotation on meta-annotation on composed annotation on class").isNotNull();
assertThat(component.value()).isEqualTo("meta2");
}
use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class AnnotationUtilsTests method findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations.
// @since 4.0.3
@Test
void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations() {
Component component = findAnnotation(SubSubClassWithInheritedMetaAnnotation.class, Component.class);
assertThat(component).isNotNull();
assertThat(component.value()).isEqualTo("meta2");
}
use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class AnnotationUtilsTests method findClassAnnotationOnAnnotatedClassWithMissingTargetMetaAnnotation.
@Test
void findClassAnnotationOnAnnotatedClassWithMissingTargetMetaAnnotation() {
// TransactionalClass is NOT annotated or meta-annotated with @Component
Component component = findAnnotation(TransactionalClass.class, Component.class);
assertThat(component).as("Should not find @Component on TransactionalClass").isNull();
}
use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class MergedAnnotationsTests method synthesizeFromMapWithoutAttributeAliases.
@Test
void synthesizeFromMapWithoutAttributeAliases() throws Exception {
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
Map<String, Object> map = Collections.singletonMap("value", "webController");
MergedAnnotation<Component> annotation = MergedAnnotation.of(Component.class, map);
Component synthesizedComponent = annotation.synthesize();
assertThat(synthesizedComponent).isInstanceOf(SynthesizedAnnotation.class);
assertThat(synthesizedComponent.value()).isEqualTo("webController");
}
Aggregations