Search in sources :

Example 1 with Bound

use of spoon.test.annotation.testclasses.Bound in project spoon by INRIA.

the class AnnotationTest method testModelBuildingAnnotationBoundUsage.

@Test
public void testModelBuildingAnnotationBoundUsage() throws Exception {
    final Launcher launcher = new Launcher();
    launcher.addInputResource("./src/test/java/spoon/test/annotation/testclasses/Main.java");
    launcher.buildModel();
    Factory factory = launcher.getFactory();
    CtType<?> type = factory.Type().get("spoon.test.annotation.testclasses.Main");
    assertEquals("Main", type.getSimpleName());
    CtParameter<?> param = type.getElements(new TypeFilter<CtParameter<?>>(CtParameter.class)).get(0);
    assertEquals("a", param.getSimpleName());
    List<CtAnnotation<? extends Annotation>> annotations = param.getAnnotations();
    assertEquals(1, annotations.size());
    CtAnnotation<?> a = annotations.get(0);
    Bound actualAnnotation = (Bound) a.getActualAnnotation();
    assertEquals(8, actualAnnotation.max());
}
Also used : CtAnnotation(spoon.reflect.declaration.CtAnnotation) Bound(spoon.test.annotation.testclasses.Bound) Launcher(spoon.Launcher) Factory(spoon.reflect.factory.Factory) TypeFilter(spoon.reflect.visitor.filter.TypeFilter) TypeAnnotation(spoon.test.annotation.testclasses.TypeAnnotation) GlobalAnnotation(spoon.test.annotation.testclasses.GlobalAnnotation) SuperAnnotation(spoon.test.annotation.testclasses.SuperAnnotation) AnnotationDefaultAnnotation(spoon.test.annotation.testclasses.AnnotationDefaultAnnotation) InnerAnnotation(spoon.test.annotation.testclasses.Foo.InnerAnnotation) Annotation(java.lang.annotation.Annotation) MiddleAnnotation(spoon.test.annotation.testclasses.Foo.MiddleAnnotation) OuterAnnotation(spoon.test.annotation.testclasses.Foo.OuterAnnotation) CtAnnotation(spoon.reflect.declaration.CtAnnotation) Test(org.junit.Test)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Test (org.junit.Test)1 Launcher (spoon.Launcher)1 CtAnnotation (spoon.reflect.declaration.CtAnnotation)1 Factory (spoon.reflect.factory.Factory)1 TypeFilter (spoon.reflect.visitor.filter.TypeFilter)1 AnnotationDefaultAnnotation (spoon.test.annotation.testclasses.AnnotationDefaultAnnotation)1 Bound (spoon.test.annotation.testclasses.Bound)1 InnerAnnotation (spoon.test.annotation.testclasses.Foo.InnerAnnotation)1 MiddleAnnotation (spoon.test.annotation.testclasses.Foo.MiddleAnnotation)1 OuterAnnotation (spoon.test.annotation.testclasses.Foo.OuterAnnotation)1 GlobalAnnotation (spoon.test.annotation.testclasses.GlobalAnnotation)1 SuperAnnotation (spoon.test.annotation.testclasses.SuperAnnotation)1 TypeAnnotation (spoon.test.annotation.testclasses.TypeAnnotation)1