Search in sources :

Example 61 with JavaFileObject

use of javax.tools.JavaFileObject in project neo4j by neo4j.

the class ProcedureProcessorTest method emits_warnings_if_context_injected_field_types_are_unsupported.

@Test
public void emits_warnings_if_context_injected_field_types_are_unsupported() {
    JavaFileObject sproc = JavaFileObjectUtils.INSTANCE.procedureSource("invalid/bad_context_field/BadContextTypeSproc.java");
    assert_().about(javaSource()).that(sproc).processedWith(processor).compilesWithoutError().withWarningCount(2).withWarningContaining("@org.neo4j.procedure.Context usage warning: found type: <org.neo4j.kernel.internal.GraphDatabaseAPI>, expected one of: <org.neo4j.graphdb.GraphDatabaseService>, <org.neo4j.logging.Log>").in(sproc).onLine(30);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Example 62 with JavaFileObject

use of javax.tools.JavaFileObject in project neo4j by neo4j.

the class UserFunctionProcessorTest method fails_if_parameters_are_not_properly_annotated.

@Test
public void fails_if_parameters_are_not_properly_annotated() {
    JavaFileObject function = JavaFileObjectUtils.INSTANCE.procedureSource("invalid/missing_name/MissingNameUserFunction.java");
    UnsuccessfulCompilationClause compilation = assert_().about(javaSource()).that(function).processedWith(processor).failsToCompile().withErrorCount(2);
    compilation.withErrorContaining("@org.neo4j.procedure.Name usage error: missing on parameter <parameter>").in(function).onLine(28);
    compilation.withErrorContaining("@org.neo4j.procedure.Name usage error: missing on parameter <otherParam>").in(function).onLine(28);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) UnsuccessfulCompilationClause(com.google.testing.compile.CompileTester.UnsuccessfulCompilationClause) Test(org.junit.Test)

Example 63 with JavaFileObject

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

the class StorIOContentResolverAnnotationsProcessorTest method shouldNotCompileIfCreatorMethodIsNotStatic.

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

Example 64 with JavaFileObject

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

the class StorIOContentResolverAnnotationsProcessorTest method shouldNotCompileIfColumnNameIsEmpty.

@Test
public void shouldNotCompileIfColumnNameIsEmpty() {
    JavaFileObject model = JavaFileObjects.forResource("EmptyColumnName.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOContentResolverProcessor()).failsToCompile().withErrorContaining("Column name is empty: id");
}
Also used : JavaFileObject(javax.tools.JavaFileObject) StorIOContentResolverProcessor(com.pushtorefresh.storio.contentresolver.annotations.processor.StorIOContentResolverProcessor) Test(org.junit.Test)

Example 65 with JavaFileObject

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

the class StorIOContentResolverAnnotationsProcessorTest method shouldNotCompileIfAnnotatedFieldIsFinal.

@Test
public void shouldNotCompileIfAnnotatedFieldIsFinal() {
    JavaFileObject model = JavaFileObjects.forResource("FinalField.java");
    assert_().about(javaSource()).that(model).processedWith(new StorIOContentResolverProcessor()).failsToCompile().withErrorContaining("StorIOContentResolverColumn can not be applied to final field: id");
}
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