use of spoon.reflect.factory.AnnotationFactory in project spoon by INRIA.
the class SampleAnnotation method testAnnotate.
@Test
public void testAnnotate() throws Exception {
CtClass<?> type = build("spoon.test.testclasses", "SampleClass");
AnnotationFactory af = type.getFactory().Annotation();
af.annotate(type, SampleAnnotation.class, "names", new String[] { "foo", "bar" });
final CtAnnotation<SampleAnnotation> annotation = type.getAnnotation(type.getFactory().Annotation().createReference(SampleAnnotation.class));
assertTrue(annotation.getValue("names") instanceof CtNewArray);
final CtNewArray names = annotation.getValue("names");
assertEquals(2, names.getElements().size());
assertEquals("foo", ((CtLiteral) names.getElements().get(0)).getValue());
assertEquals("bar", ((CtLiteral) names.getElements().get(1)).getValue());
}
Aggregations