Search in sources :

Example 16 with CallableUserFunction

use of org.neo4j.kernel.api.proc.CallableUserFunction in project neo4j by neo4j.

the class ResourceInjectionTest method shouldCompileAndRunUserFunctions.

@Test
public void shouldCompileAndRunUserFunctions() throws Throwable {
    // Given
    CallableUserFunction proc = compiler.compileFunction(FunctionWithInjectedAPI.class).get(0);
    // When
    Object out = proc.apply(new BasicContext(), new Object[0]);
    // Then
    assertThat(out, equalTo("[Bonnie, Clyde]"));
}
Also used : CallableUserFunction(org.neo4j.kernel.api.proc.CallableUserFunction) BasicContext(org.neo4j.kernel.api.proc.BasicContext) Test(org.junit.Test)

Example 17 with CallableUserFunction

use of org.neo4j.kernel.api.proc.CallableUserFunction in project neo4j by neo4j.

the class ReflectiveUserFunctionTest method shouldNotLoadNoneWhiteListedFunction.

@Test
public void shouldNotLoadNoneWhiteListedFunction() throws Throwable {
    // Given
    Log log = spy(Log.class);
    procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, new ComponentRegistry(), log, new ProcedureConfig(Config.defaults().with(MapUtil.stringMap(GraphDatabaseSettings.procedure_whitelist.name(), "WrongName"))));
    List<CallableUserFunction> method = compile(SingleReadOnlyFunction.class);
    verify(log).warn("The function 'org.neo4j.kernel.impl.proc.listCoolPeople' is not on the whitelist and won't be loaded.");
    assertThat(method.size(), equalTo(0));
}
Also used : CallableUserFunction(org.neo4j.kernel.api.proc.CallableUserFunction) Log(org.neo4j.logging.Log) NullLog(org.neo4j.logging.NullLog) Test(org.junit.Test)

Aggregations

CallableUserFunction (org.neo4j.kernel.api.proc.CallableUserFunction)17 Test (org.junit.Test)12 BasicContext (org.neo4j.kernel.api.proc.BasicContext)9 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)5 UserFunctionSignature (org.neo4j.kernel.api.proc.UserFunctionSignature)5 Log (org.neo4j.logging.Log)5 NullLog (org.neo4j.logging.NullLog)4 CallableProcedure (org.neo4j.kernel.api.proc.CallableProcedure)3 QualifiedName (org.neo4j.kernel.api.proc.QualifiedName)3 MethodHandle (java.lang.invoke.MethodHandle)2 ComponentInjectionException (org.neo4j.kernel.api.exceptions.ComponentInjectionException)2 CallableUserAggregationFunction (org.neo4j.kernel.api.proc.CallableUserAggregationFunction)2 FailedLoadFunction (org.neo4j.kernel.api.proc.FailedLoadFunction)2 FieldSignature (org.neo4j.kernel.api.proc.FieldSignature)2 ProcedureSignature (org.neo4j.kernel.api.proc.ProcedureSignature)2 UserFunction (org.neo4j.procedure.UserFunction)2 MethodHandles (java.lang.invoke.MethodHandles)1 Method (java.lang.reflect.Method)1 Modifier (java.lang.reflect.Modifier)1 URL (java.net.URL)1