Search in sources :

Example 86 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method multiple2.

@Test(expected = BugInCF.class)
public void multiple2() {
    AnnotationBuilder builder = new AnnotationBuilder(env, Mult.class);
    builder.setValue("a", "m");
    Assert.assertEquals(1, builder.build().getElementValues().size());
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 87 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method testEnumPositive.

@Test
public void testEnumPositive() {
    AnnotationBuilder builder = new AnnotationBuilder(env, EnumElt.class);
    builder.setValue("value", MyEnum.OK);
    builder.setValue("value", MyEnum.NOT);
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 88 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method testToString1.

@Test
public void testToString1() {
    AnnotationBuilder builder = new AnnotationBuilder(env, Anno.class);
    Assert.assertEquals("@org.checkerframework.framework.test.junit.AnnotationBuilderTest.Anno", builder.build().toString());
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 89 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method listArrayPrimitive.

@Test
public void listArrayPrimitive() {
    AnnotationBuilder builder = new AnnotationBuilder(env, A.class);
    builder.setValue("numbers", new Integer[] { 34, 32, 43 });
    Assert.assertEquals(1, builder.build().getElementValues().size());
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 90 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method testRetClassNegative.

// Failing test for now.  AnnotationBuilder is a bit permissive
// It doesn't not check type argument subtyping
@Test(expected = BugInCF.class)
// bug for now
@Ignore
public void testRetClassNegative() {
    AnnotationBuilder builder = new AnnotationBuilder(env, RestrictedClassElt.class);
    builder.setValue("value", String.class);
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AnnotationBuilder (org.checkerframework.javacutil.AnnotationBuilder)117 Test (org.junit.Test)60 AnnotationMirror (javax.lang.model.element.AnnotationMirror)21 Nullable (org.checkerframework.checker.nullness.qual.Nullable)6 ArrayList (java.util.ArrayList)5 Elements (javax.lang.model.util.Elements)4 QualifierHierarchy (org.checkerframework.framework.type.QualifierHierarchy)4 List (java.util.List)3 TypeElement (javax.lang.model.element.TypeElement)3 NodeList (com.github.javaparser.ast.NodeList)2 Expression (com.github.javaparser.ast.expr.Expression)2 MarkerAnnotationExpr (com.github.javaparser.ast.expr.MarkerAnnotationExpr)2 MemberValuePair (com.github.javaparser.ast.expr.MemberValuePair)2 NormalAnnotationExpr (com.github.javaparser.ast.expr.NormalAnnotationExpr)2 SingleMemberAnnotationExpr (com.github.javaparser.ast.expr.SingleMemberAnnotationExpr)2 TreeSet (java.util.TreeSet)2 TypeMirror (javax.lang.model.type.TypeMirror)2 FormatterTreeUtil (org.checkerframework.checker.formatter.FormatterTreeUtil)2 ConversionCategory (org.checkerframework.checker.formatter.qual.ConversionCategory)2 InvalidFormat (org.checkerframework.checker.formatter.qual.InvalidFormat)2