Search in sources :

Example 1 with UserFunctionHandle

use of org.neo4j.internal.kernel.api.procs.UserFunctionHandle in project neo4j by neo4j.

the class TokenHoldersIdLookupTest method setup.

@BeforeAll
static void setup() throws KernelException {
    GlobalProcedures procs = new GlobalProceduresRegistry();
    procs.registerProcedure(TestProcedures.class);
    procs.registerFunction(TestProcedures.class);
    procs.registerAggregationFunction(TestProcedures.class);
    procName2id = new HashMap<>();
    for (ProcedureSignature signature : procs.getAllProcedures()) {
        QualifiedName name = signature.name();
        ProcedureHandle procedure = procs.procedure(name);
        procName2id.put(name.toString(), procedure.id());
    }
    funcName2id = new HashMap<>();
    procs.getAllNonAggregatingFunctions().forEach(signature -> {
        QualifiedName name = signature.name();
        UserFunctionHandle function = procs.function(name);
        funcName2id.put(name.toString(), function.id());
    });
    procs.getAllAggregatingFunctions().forEach(signature -> {
        QualifiedName name = signature.name();
        UserFunctionHandle function = procs.aggregationFunction(name);
        funcName2id.put(name.toString(), function.id());
    });
    idLookup = new TokenHoldersIdLookup(mockedTokenHolders(), procs);
}
Also used : ProcedureSignature(org.neo4j.internal.kernel.api.procs.ProcedureSignature) ProcedureHandle(org.neo4j.internal.kernel.api.procs.ProcedureHandle) GlobalProceduresRegistry(org.neo4j.procedure.impl.GlobalProceduresRegistry) UserFunctionHandle(org.neo4j.internal.kernel.api.procs.UserFunctionHandle) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) GlobalProcedures(org.neo4j.kernel.api.procedure.GlobalProcedures) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with UserFunctionHandle

use of org.neo4j.internal.kernel.api.procs.UserFunctionHandle in project neo4j by neo4j.

the class UserFunctionsTest method shouldNotAllowCallingNonExistingFunction.

@Test
void shouldNotAllowCallingNonExistingFunction() {
    UserFunctionHandle functionHandle = procs.function(signature.name());
    ProcedureException exception = assertThrows(ProcedureException.class, () -> procs.callFunction(prepareContext(), functionHandle != null ? functionHandle.id() : -1, new AnyValue[] { numberValue(1337) }));
    assertThat(exception.getMessage()).isEqualTo("There is no function with the internal id `-1` registered for this database instance.");
}
Also used : UserFunctionHandle(org.neo4j.internal.kernel.api.procs.UserFunctionHandle) AnyValue(org.neo4j.values.AnyValue) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test)

Aggregations

UserFunctionHandle (org.neo4j.internal.kernel.api.procs.UserFunctionHandle)2 BeforeAll (org.junit.jupiter.api.BeforeAll)1 Test (org.junit.jupiter.api.Test)1 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)1 ProcedureHandle (org.neo4j.internal.kernel.api.procs.ProcedureHandle)1 ProcedureSignature (org.neo4j.internal.kernel.api.procs.ProcedureSignature)1 QualifiedName (org.neo4j.internal.kernel.api.procs.QualifiedName)1 GlobalProcedures (org.neo4j.kernel.api.procedure.GlobalProcedures)1 GlobalProceduresRegistry (org.neo4j.procedure.impl.GlobalProceduresRegistry)1 AnyValue (org.neo4j.values.AnyValue)1