Search in sources :

Example 86 with JavaFileObject

use of javax.tools.JavaFileObject in project storio by pushtorefresh.

the class StorIOSQLiteAnnotationsProcessorTest method shouldNotCompileIfNoArgConstructorIsAbsent.

@Test
public void shouldNotCompileIfNoArgConstructorIsAbsent() {
    JavaFileObject model = JavaFileObjects.forResource("AbsenceOfNoArgConstructor.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOSQLiteProcessor()).failsToCompile().withErrorContaining("constructor AbsenceOfNoArgConstructor in class " + "com.pushtorefresh.storio.sqlite.annotations.AbsenceOfNoArgConstructor cannot be applied to given types;\n" + "  required: long\n" + "  found: no arguments\n" + "  reason: actual and formal argument lists differ in length");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOSQLiteProcessor(com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor) Test(org.junit.Test)

Example 87 with JavaFileObject

use of javax.tools.JavaFileObject in project storio by pushtorefresh.

the class StorIOSQLiteAnnotationsProcessorTest method shouldCompileWithBoxedTypesFieldsMarkedAsIgnoreNull.

@Test
public void shouldCompileWithBoxedTypesFieldsMarkedAsIgnoreNull() {
    JavaFileObject model = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNull.java");
    JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNullSQLiteTypeMapping.java");
    JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNullStorIOSQLiteDeleteResolver.java");
    JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNullStorIOSQLiteGetResolver.java");
    JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesFieldsIgnoreNullStorIOSQLitePutResolver.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOSQLiteProcessor()).compilesWithoutError().and().generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOSQLiteProcessor(com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor) Test(org.junit.Test)

Example 88 with JavaFileObject

use of javax.tools.JavaFileObject in project storio by pushtorefresh.

the class StorIOSQLiteAnnotationsProcessorTest method shouldNotCompileIfCreatorsNumberOfArgumentsDoNotMatchWithColumnsNumber.

@Test
public void shouldNotCompileIfCreatorsNumberOfArgumentsDoNotMatchWithColumnsNumber() {
    JavaFileObject model = JavaFileObjects.forResource("CreatorWithWrongNumberOfArguments.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOSQLiteProcessor()).failsToCompile().withErrorContaining("Class marked with StorIOSQLiteType annotation needs factory method or constructor marked with " + "StorIOSQLiteCreator annotation with the same amount of parameters as the number of columns: " + "CreatorWithWrongNumberOfArguments");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOSQLiteProcessor(com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor) Test(org.junit.Test)

Example 89 with JavaFileObject

use of javax.tools.JavaFileObject in project storio by pushtorefresh.

the class StorIOSQLiteAnnotationsProcessorTest method shouldNotCompileIfCreatorMethodIsNotStatic.

@Test
public void shouldNotCompileIfCreatorMethodIsNotStatic() {
    JavaFileObject model = JavaFileObjects.forResource("NonStaticCreatorMethod.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOSQLiteProcessor()).failsToCompile().withErrorContaining("StorIOSQLiteCreator can not be applied to non-static methods: creator");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOSQLiteProcessor(com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor) Test(org.junit.Test)

Example 90 with JavaFileObject

use of javax.tools.JavaFileObject in project storio by pushtorefresh.

the class StorIOSQLiteAnnotationsProcessorTest method shouldNotCompileIfClassContainsBothAnnotatedFieldsAndMethods.

@Test
public void shouldNotCompileIfClassContainsBothAnnotatedFieldsAndMethods() {
    JavaFileObject model = JavaFileObjects.forResource("MixedFieldsAndMethods.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOSQLiteProcessor()).failsToCompile().withErrorContaining("Can't apply StorIOSQLiteColumn annotation to both fields and methods in a same class: MixedFieldsAndMethods");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOSQLiteProcessor(com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor) Test(org.junit.Test)

Aggregations

JavaFileObject (javax.tools.JavaFileObject)663 Test (org.junit.Test)473 ButterKnifeProcessor (butterknife.compiler.ButterKnifeProcessor)121 IOException (java.io.IOException)52 JavaCompiler (javax.tools.JavaCompiler)40 StorIOContentResolverProcessor (com.pushtorefresh.storio.contentresolver.annotations.processor.StorIOContentResolverProcessor)38 StorIOSQLiteProcessor (com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor)35 File (java.io.File)32 Diagnostic (javax.tools.Diagnostic)30 DiagnosticCollector (javax.tools.DiagnosticCollector)28 SimpleJavaFileObject (javax.tools.SimpleJavaFileObject)25 StandardJavaFileManager (javax.tools.StandardJavaFileManager)25 ArrayList (java.util.ArrayList)24 TypeElement (javax.lang.model.element.TypeElement)21 Result (com.sun.tools.javac.main.Main.Result)20 Writer (java.io.Writer)17 PrintWriter (java.io.PrintWriter)16 CompilationTask (javax.tools.JavaCompiler.CompilationTask)14 JCTree (com.sun.tools.javac.tree.JCTree)10 StringWriter (java.io.StringWriter)10