Search in sources :

Example 11 with CallableUserAggregationFunction

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

the class ReflectiveUserAggregationFunctionTest method shouldNotLoadAnyFunctionIfConfigIsEmpty.

@Test
public void shouldNotLoadAnyFunctionIfConfigIsEmpty() 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(), ""))));
    List<CallableUserAggregationFunction> method = compile(SingleAggregationFunction.class);
    verify(log).warn("The function 'org.neo4j.kernel.impl.proc.collectCool' is not on the whitelist and won't be loaded.");
    assertThat(method.size(), equalTo(0));
}
Also used : CallableUserAggregationFunction(org.neo4j.kernel.api.proc.CallableUserAggregationFunction) Log(org.neo4j.logging.Log) NullLog(org.neo4j.logging.NullLog) Test(org.junit.Test)

Example 12 with CallableUserAggregationFunction

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

the class ReflectiveUserAggregationFunctionTest method shouldAllowOverridingProcedureName.

@Test
public void shouldAllowOverridingProcedureName() throws Throwable {
    // When
    CallableUserAggregationFunction method = compile(FunctionWithOverriddenName.class).get(0);
    // Then
    assertEquals("org.mystuff.thisisActuallyTheName", method.signature().name().toString());
}
Also used : CallableUserAggregationFunction(org.neo4j.kernel.api.proc.CallableUserAggregationFunction) Test(org.junit.Test)

Example 13 with CallableUserAggregationFunction

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

the class ReflectiveUserAggregationFunctionTest method shouldLoadWhiteListedFunction.

@Test
public void shouldLoadWhiteListedFunction() throws Throwable {
    // Given
    procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, new ComponentRegistry(), NullLog.getInstance(), new ProcedureConfig(Config.defaults().with(MapUtil.stringMap(GraphDatabaseSettings.procedure_whitelist.name(), "org.neo4j.kernel.impl.proc.collectCool"))));
    CallableUserAggregationFunction method = compile(SingleAggregationFunction.class).get(0);
    // Expect
    CallableUserAggregationFunction.Aggregator created = method.create(new BasicContext());
    created.update(new Object[] { "Bonnie" });
    assertThat(created.result(), equalTo(Collections.singletonList("Bonnie")));
}
Also used : CallableUserAggregationFunction(org.neo4j.kernel.api.proc.CallableUserAggregationFunction) BasicContext(org.neo4j.kernel.api.proc.BasicContext) Test(org.junit.Test)

Aggregations

CallableUserAggregationFunction (org.neo4j.kernel.api.proc.CallableUserAggregationFunction)13 Test (org.junit.Test)10 BasicContext (org.neo4j.kernel.api.proc.BasicContext)7 Log (org.neo4j.logging.Log)5 NullLog (org.neo4j.logging.NullLog)4 MethodHandle (java.lang.invoke.MethodHandle)2 Method (java.lang.reflect.Method)2 ComponentInjectionException (org.neo4j.kernel.api.exceptions.ComponentInjectionException)2 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)2 CallableProcedure (org.neo4j.kernel.api.proc.CallableProcedure)2 CallableUserFunction (org.neo4j.kernel.api.proc.CallableUserFunction)2 FailedLoadAggregatedFunction (org.neo4j.kernel.api.proc.FailedLoadAggregatedFunction)2 FieldSignature (org.neo4j.kernel.api.proc.FieldSignature)2 UserFunctionSignature (org.neo4j.kernel.api.proc.UserFunctionSignature)2 UserAggregationFunction (org.neo4j.procedure.UserAggregationFunction)2 UserAggregationResult (org.neo4j.procedure.UserAggregationResult)2 UserAggregationUpdate (org.neo4j.procedure.UserAggregationUpdate)2 MethodHandles (java.lang.invoke.MethodHandles)1 Modifier (java.lang.reflect.Modifier)1 ArrayList (java.util.ArrayList)1