Commit 3a5ff5a7 authored by Gustav Hedengran's avatar Gustav Hedengran Committed by Gustav Hedengran
Browse files

Catch and validate parameters that are not Primitive or Declared

No related merge requests found
Showing with 24 additions and 12 deletions
+24 -12
......@@ -20,8 +20,6 @@
package org.neo4j.tooling.procedure.visitors;
import java.util.function.Predicate;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.PrimitiveType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.SimpleTypeVisitor8;
import javax.lang.model.util.Types;
......@@ -40,15 +38,9 @@ class ParameterTypeVisitor extends SimpleTypeVisitor8<Boolean,Void>
}
@Override
public Boolean visitDeclared( DeclaredType parameterType, Void ignored )
protected Boolean defaultAction( TypeMirror type, Void ignored )
{
return validate( parameterType );
}
@Override
public Boolean visitPrimitive( PrimitiveType primitive, Void ignored )
{
return validate( primitive );
return validate( type );
}
private Boolean validate( TypeMirror typeMirror )
......
......@@ -107,7 +107,7 @@ public class ProcedureProcessorTest extends ExtensionTestBase
UnsuccessfulCompilationClause compilation =
assert_().about( javaSource() ).that( sproc ).processedWith( processor() ).failsToCompile()
.withErrorCount( 3 );
.withErrorCount( 4 );
compilation.withErrorContaining( "Unsupported parameter type " +
"<java.util.List<java.util.List<java.util.Map<java.lang.String,java.lang.Thread>>>>" +
......@@ -120,6 +120,10 @@ public class ProcedureProcessorTest extends ExtensionTestBase
compilation.withErrorContaining(
"Unsupported parameter type <java.util.Map> of procedure|function BadGenericInputSproc#doSomething3" )
.in( sproc ).onLine( 48 );
compilation.withErrorContaining(
"Unsupported parameter type <java.lang.String[]> of procedure|function BadGenericInputSproc#doSomething4" )
.in( sproc ).onLine( 54 );
}
@Test
......
......@@ -92,7 +92,7 @@ public class UserFunctionProcessorTest extends ExtensionTestBase
UnsuccessfulCompilationClause compilation =
assert_().about( javaSource() ).that( function ).processedWith( processor() ).failsToCompile()
.withErrorCount( 3 );
.withErrorCount( 4 );
compilation.withErrorContaining( "Unsupported parameter type " +
"<java.util.List<java.util.List<java.util.Map<java.lang.String,java.lang.Thread>>>>" +
......@@ -105,6 +105,10 @@ public class UserFunctionProcessorTest extends ExtensionTestBase
compilation.withErrorContaining(
"Unsupported parameter type <java.util.Map> of procedure|function BadGenericInputUserFunction#doSomething3" )
.in( function ).onLine( 48 );
compilation.withErrorContaining(
"Unsupported parameter type <java.lang.String[]> of procedure|function BadGenericInputUserFunction#doSomething4" )
.in( function ).onLine( 54 );
}
@Test
......
......@@ -50,6 +50,12 @@ public class BadGenericInputSproc
}
@Procedure
public void doSomething4( @Name( "test" ) String[] unsupportedType )
{
}
@Procedure
public void works1( @Name( "test" ) List<String> supported )
{
......
......@@ -50,6 +50,12 @@ public class BadGenericInputUserFunction
return "42";
}
@UserFunction
public String doSomething4( @Name( "test" ) String[] unsupportedType )
{
return "42";
}
@UserFunction
public String works1( @Name( "test" ) List<String> supported )
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment