use of spoon.testing.utils.ModelUtils.createFactory in project spoon by INRIA.
the class AnnotationValuesTest method testCtAnnotationAPI.
@Test
public void testCtAnnotationAPI() throws Exception {
Factory factory = ModelUtils.createFactory();
CtAnnotation<Annotation> annotation = factory.Core().createAnnotation();
annotation.addValue("integers", 7);
on(annotation).giveMeAnnotationValue("integers").isTypedBy(CtLiteral.class);
annotation.addValue("integers", 42);
on(annotation).giveMeAnnotationValue("integers").isTypedBy(CtNewArray.class);
annotation.addValue("classes", String.class);
on(annotation).giveMeAnnotationValue("classes").isTypedBy(CtFieldAccess.class);
annotation.addValue("classes", Integer.class);
on(annotation).giveMeAnnotationValue("classes").isTypedBy(CtNewArray.class);
annotation.addValue("field", AnnotationValuesTest.class.getDeclaredField("i"));
on(annotation).giveMeAnnotationValue("field").isTypedBy(CtFieldAccess.class);
}
Aggregations