Search in sources :

Example 1 with BoundNumber

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

the class AnnotationValuesTest method testAnnotateWithEnum.

@Test
public void testAnnotateWithEnum() throws Exception {
    final Factory factory = createFactory();
    final CtClass<Object> target = factory.Class().create("org.example.Tacos");
    final CtField<String> field = factory.Field().create(target, new HashSet<>(), factory.Type().STRING, "field");
    target.addField(field);
    final CtAnnotation<BoundNumber> byteOrder = factory.Annotation().annotate(field, BoundNumber.class, "byteOrder", BoundNumber.ByteOrder.LittleEndian);
    assertEquals(byteOrder, on(field).giveMeAnnotation(BoundNumber.class));
    assertTrue(on(byteOrder).giveMeAnnotationValue("byteOrder").element instanceof CtFieldRead);
}
Also used : CtFieldRead(spoon.reflect.code.CtFieldRead) BoundNumber(spoon.test.annotation.testclasses.BoundNumber) ModelUtils.createFactory(spoon.testing.utils.ModelUtils.createFactory) Factory(spoon.reflect.factory.Factory) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CtFieldRead (spoon.reflect.code.CtFieldRead)1 Factory (spoon.reflect.factory.Factory)1 BoundNumber (spoon.test.annotation.testclasses.BoundNumber)1 ModelUtils.createFactory (spoon.testing.utils.ModelUtils.createFactory)1