@Test public void findAnnotationDescriptorWithLocalAndMetaComponentAnnotation() throws Exception { Class<Component> annotationType = Component.class; AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(HasLocalAndMetaComponentAnnotation.class, annotationType); assertEquals(HasLocalAndMetaComponentAnnotation.class, descriptor.getRootDeclaringClass()); assertEquals(annotationType, descriptor.getAnnotationType()); assertNull(descriptor.getComposedAnnotation()); assertNull(descriptor.getComposedAnnotationType()); }
private void assertAtComponentOnComposedAnnotation( Class<?> startClass, Class<?> rootDeclaringClass, Class<?> declaringClass, String name, Class<? extends Annotation> composedAnnotationType) { AnnotationDescriptor<Component> descriptor = findAnnotationDescriptor(startClass, Component.class); assertNotNull("AnnotationDescriptor should not be null", descriptor); assertEquals("rootDeclaringClass", rootDeclaringClass, descriptor.getRootDeclaringClass()); assertEquals("declaringClass", declaringClass, descriptor.getDeclaringClass()); assertEquals("annotationType", Component.class, descriptor.getAnnotationType()); assertEquals("component name", name, descriptor.getAnnotation().value()); assertNotNull("composedAnnotation should not be null", descriptor.getComposedAnnotation()); assertEquals( "composedAnnotationType", composedAnnotationType, descriptor.getComposedAnnotationType()); }
@Test public void findAnnotationDescriptorForClassWithLocalMetaAnnotationAndAnnotatedSuperclass() { AnnotationDescriptor<ContextConfiguration> descriptor = findAnnotationDescriptor( MetaAnnotatedAndSuperAnnotatedContextConfigClass.class, ContextConfiguration.class); assertNotNull("AnnotationDescriptor should not be null", descriptor); assertEquals( "rootDeclaringClass", MetaAnnotatedAndSuperAnnotatedContextConfigClass.class, descriptor.getRootDeclaringClass()); assertEquals("declaringClass", MetaConfig.class, descriptor.getDeclaringClass()); assertEquals("annotationType", ContextConfiguration.class, descriptor.getAnnotationType()); assertNotNull("composedAnnotation should not be null", descriptor.getComposedAnnotation()); assertEquals( "composedAnnotationType", MetaConfig.class, descriptor.getComposedAnnotationType()); assertArrayEquals( "configured classes", new Class[] {String.class}, descriptor.getAnnotationAttributes().getClassArray("classes")); }