Search in sources :

Example 66 with JavaFileObject

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

the class StorIOContentResolverAnnotationsProcessorTest method shouldCompileIfAnnotatedMethodIsFinal.

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

Example 67 with JavaFileObject

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

the class StorIOContentResolverAnnotationsProcessorTest method shouldNotCompileIfIgnoreNullIsUsedOnPrimitive.

@Test
public void shouldNotCompileIfIgnoreNullIsUsedOnPrimitive() {
    JavaFileObject model = JavaFileObjects.forResource("IgnoreNullOnPrimitive.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOContentResolverProcessor()).failsToCompile().withErrorContaining("ignoreNull should not be used for primitive type: id");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOContentResolverProcessor(com.pushtorefresh.storio.contentresolver.annotations.processor.StorIOContentResolverProcessor) Test(org.junit.Test)

Example 68 with JavaFileObject

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

the class StorIOContentResolverAnnotationsProcessorTest method shouldCompileWithMethodsReturningBoxedTypesAndFactoryMethodAsCreator.

@Test
public void shouldCompileWithMethodsReturningBoxedTypesAndFactoryMethodAsCreator() {
    JavaFileObject model = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethod.java");
    JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodContentResolverTypeMapping.java");
    JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOContentResolverDeleteResolver.java");
    JavaFileObject generatedGetResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOContentResolverGetResolver.java");
    JavaFileObject generatedPutResolver = JavaFileObjects.forResource("BoxedTypesMethodsFactoryMethodStorIOContentResolverPutResolver.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOContentResolverProcessor()).compilesWithoutError().and().generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOContentResolverProcessor(com.pushtorefresh.storio.contentresolver.annotations.processor.StorIOContentResolverProcessor) Test(org.junit.Test)

Example 69 with JavaFileObject

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

the class StorIOContentResolverAnnotationsProcessorTest method shouldCompileWithMethodsReturningPrimitivesAndFactoryMethodAsCreator.

@Test
public void shouldCompileWithMethodsReturningPrimitivesAndFactoryMethodAsCreator() {
    JavaFileObject model = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethod.java");
    JavaFileObject generatedTypeMapping = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethodContentResolverTypeMapping.java");
    JavaFileObject generatedDeleteResolver = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethodStorIOContentResolverDeleteResolver.java");
    JavaFileObject generatedGetResolver = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethodStorIOContentResolverGetResolver.java");
    JavaFileObject generatedPutResolver = JavaFileObjects.forResource("PrimitiveMethodsFactoryMethodStorIOContentResolverPutResolver.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOContentResolverProcessor()).compilesWithoutError().and().generatesSources(generatedTypeMapping, generatedDeleteResolver, generatedGetResolver, generatedPutResolver);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOContentResolverProcessor(com.pushtorefresh.storio.contentresolver.annotations.processor.StorIOContentResolverProcessor) Test(org.junit.Test)

Example 70 with JavaFileObject

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

the class StorIOContentResolverAnnotationsProcessorTest method shouldNotCompileIfTypeIsUnsupported.

@Test
public void shouldNotCompileIfTypeIsUnsupported() {
    JavaFileObject model = JavaFileObjects.forResource("UnsupportedType.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOContentResolverProcessor()).failsToCompile().withErrorContaining("Unsupported type of field or method for StorIOContentResolverColumn annotation," + " if you need to serialize/deserialize field of that type -> please write your own resolver");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOContentResolverProcessor(com.pushtorefresh.storio.contentresolver.annotations.processor.StorIOContentResolverProcessor) 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