Search in sources :

Example 1 with AnnotationValues

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

the class AnnotationValuesTest method testValuesOnJava8Annotation.

@Test
public void testValuesOnJava8Annotation() throws Exception {
    CtType<AnnotationValues> aClass = buildClass(AnnotationValues.class);
    CtConstructorCall aConstructorCall = aClass.getMethod("method").getElements(new TypeFilter<>(CtConstructorCall.class)).get(0);
    CtAnnotation<?> ctAnnotation = on(aConstructorCall.getType()).giveMeAnnotation(AnnotationValues.Annotation.class);
    on(ctAnnotation).giveMeAnnotationValue("integer").isTypedBy(CtLiteral.class);
    on(ctAnnotation).giveMeAnnotationValue("integers").isTypedBy(CtNewArray.class);
    on(ctAnnotation).giveMeAnnotationValue("string").isTypedBy(CtLiteral.class);
    on(ctAnnotation).giveMeAnnotationValue("strings").isTypedBy(CtLiteral.class);
    on(ctAnnotation).giveMeAnnotationValue("clazz").isTypedBy(CtFieldAccess.class);
    on(ctAnnotation).giveMeAnnotationValue("classes").isTypedBy(CtNewArray.class);
    on(ctAnnotation).giveMeAnnotationValue("b").isTypedBy(CtLiteral.class);
    on(ctAnnotation).giveMeAnnotationValue("e").isTypedBy(CtFieldAccess.class);
    on(ctAnnotation).giveMeAnnotationValue("ia").isTypedBy(CtAnnotation.class);
    on(ctAnnotation).giveMeAnnotationValue("ias").isTypedBy(CtNewArray.class);
}
Also used : CtConstructorCall(spoon.reflect.code.CtConstructorCall) AnnotationValues(spoon.test.annotation.testclasses.AnnotationValues) TypeFilter(spoon.reflect.visitor.filter.TypeFilter) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CtConstructorCall (spoon.reflect.code.CtConstructorCall)1 TypeFilter (spoon.reflect.visitor.filter.TypeFilter)1 AnnotationValues (spoon.test.annotation.testclasses.AnnotationValues)1