use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class MergedAnnotationsTests method synthesizeFromAnnotationAttributesWithoutAttributeAliases.
@Test
void synthesizeFromAnnotationAttributesWithoutAttributeAliases() throws Exception {
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
Map<String, Object> attributes = MergedAnnotation.from(component).asMap();
Component synthesized = MergedAnnotation.of(Component.class, attributes).synthesize();
assertThat(synthesized).isInstanceOf(SynthesizedAnnotation.class);
assertThat(synthesized).isEqualTo(component);
}
use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class MergedAnnotationsTests method synthesizeWithoutAttributeAliases.
@Test
void synthesizeWithoutAttributeAliases() throws Exception {
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
Component synthesizedComponent = MergedAnnotation.from(component).synthesize();
assertThat(synthesizedComponent).isNotNull();
assertThat(synthesizedComponent).isEqualTo(component);
assertThat(synthesizedComponent.value()).isEqualTo("webController");
}
use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class AnnotationUtilsTests method synthesizeAnnotationFromMapWithoutAttributeAliases.
@Test
void synthesizeAnnotationFromMapWithoutAttributeAliases() throws Exception {
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
Map<String, Object> map = Collections.singletonMap(VALUE, "webController");
Component synthesizedComponent = synthesizeAnnotation(map, Component.class, WebController.class);
assertThat(synthesizedComponent).isNotNull();
assertThat(synthesizedComponent).isNotSameAs(component);
assertThat(component.value()).as("value from component: ").isEqualTo("webController");
assertThat(synthesizedComponent.value()).as("value from synthesized component: ").isEqualTo("webController");
}
use of org.springframework.core.testfixture.stereotype.Component in project spring-framework by spring-projects.
the class AnnotationUtilsTests method findClassAnnotationOnMetaMetaAnnotatedClass.
@Test
void findClassAnnotationOnMetaMetaAnnotatedClass() {
Component component = findAnnotation(MetaMetaAnnotatedClass.class, Component.class);
assertThat(component).as("Should find 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 synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases.
@Test
void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() throws Exception {
// 1) Get an annotation
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
// 2) Convert the annotation into AnnotationAttributes
AnnotationAttributes attributes = getAnnotationAttributes(WebController.class, component);
assertThat(attributes).isNotNull();
// 3) Synthesize the AnnotationAttributes back into an annotation
Component synthesizedComponent = synthesizeAnnotation(attributes, Component.class, WebController.class);
assertThat(synthesizedComponent).isNotNull();
// 4) Verify that the original and synthesized annotations are equivalent
assertThat(synthesizedComponent).isNotSameAs(component);
assertThat(synthesizedComponent).isEqualTo(component);
assertThat(component.value()).as("value from component: ").isEqualTo("webController");
assertThat(synthesizedComponent.value()).as("value from synthesized component: ").isEqualTo("webController");
}
Aggregations