Search in sources :

Example 81 with JavaFileObject

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

the class StorIOSQLiteAnnotationsProcessorTest method shouldCompileWithMethodsReturningPrimitivesAndConstructorAsCreator.

@Test
public void shouldCompileWithMethodsReturningPrimitivesAndConstructorAsCreator() {
    JavaFileObject model = JavaFileObjects.forResource("PrimitiveMethodsConstructor.java");
    JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("PrimitiveMethodsConstructorSQLiteTypeMapping.java");
    JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("PrimitiveMethodsConstructorStorIOSQLiteDeleteResolver.java");
    JavaFileObject generatedGetResolver = JavaFileObjects.forResource("PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java");
    JavaFileObject generatedPutResolver = JavaFileObjects.forResource("PrimitiveMethodsConstructorStorIOSQLitePutResolver.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 82 with JavaFileObject

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

the class StorIOSQLiteAnnotationsProcessorTest method shouldCompileWithMethodsReturningBoxedTypesAndFactoryMethodAsCreator.

@Test
public void shouldCompileWithMethodsReturningBoxedTypesAndFactoryMethodAsCreator() {
    JavaFileObject model = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethod.java");
    JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodSQLiteTypeMapping.java");
    JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOSQLiteDeleteResolver.java");
    JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOSQLiteGetResolver.java");
    JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOSQLitePutResolver.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 83 with JavaFileObject

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

the class StorIOSQLiteAnnotationsProcessorTest method shouldCompileIfAnnotatedMethodIsFinal.

@Test
public void shouldCompileIfAnnotatedMethodIsFinal() {
    JavaFileObject model = JavaFileObjects.forResource("FinalMethod.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOSQLiteProcessor()).compilesWithoutError();
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOSQLiteProcessor(com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor) Test(org.junit.Test)

Example 84 with JavaFileObject

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

the class StorIOSQLiteAnnotationsProcessorTest method shouldNotCompileIfNestedClassAnnotatedWithTypeAnnotation.

@Test
public void shouldNotCompileIfNestedClassAnnotatedWithTypeAnnotation() {
    JavaFileObject model = JavaFileObjects.forResource("NestedClass.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOSQLiteProcessor()).failsToCompile().withErrorContaining("StorIOSQLiteType can't be applied to nested or inner classes: ActualClass");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOSQLiteProcessor(com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor) Test(org.junit.Test)

Example 85 with JavaFileObject

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

the class StorIOSQLiteAnnotationsProcessorTest method shouldNotCompileIfNotClassAnnotatedWithTypeAnnotations.

@Test
public void shouldNotCompileIfNotClassAnnotatedWithTypeAnnotations() {
    JavaFileObject model = JavaFileObjects.forResource("AnnotatedInterface.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOSQLiteProcessor()).failsToCompile().withErrorContaining("StorIOSQLiteType can be applied only to classes not to AnnotatedInterface");
}
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