Search in sources :

Example 21 with QualifiedName

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

the class ProcedureHolderTest method shouldGetCaseInsensitiveFromHolder.

@Test
void shouldGetCaseInsensitiveFromHolder() {
    // given
    ProcedureHolder<String> procHolder = new ProcedureHolder<>();
    QualifiedName qualifiedName = new QualifiedName(new String[0], "CaseInSensitive");
    String item = "CaseInSensitiveItem";
    procHolder.put(qualifiedName, item, true);
    // then
    QualifiedName lowerCaseName = new QualifiedName(new String[0], "caseinsensitive");
    assertThat(procHolder.get(lowerCaseName)).isEqualTo(item);
    assertThat(procHolder.idOf(lowerCaseName)).isEqualTo(0);
}
Also used : QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) Test(org.junit.jupiter.api.Test)

Example 22 with QualifiedName

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

the class SingleInstanceGetRoutingTableProcedureTest method shouldHaveCorrectNamespace.

@RoutingConfigsTest
void shouldHaveCorrectNamespace(Config config, String clientAddress) {
    var portRegister = mock(ConnectorPortRegister.class);
    var proc = newProcedure(portRegister, config);
    var name = proc.signature().name();
    assertEquals(new QualifiedName(new String[] { "dbms", "routing" }, "getRoutingTable"), name);
}
Also used : QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) NTString(org.neo4j.internal.kernel.api.procs.Neo4jTypes.NTString)

Example 23 with QualifiedName

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

the class ProcedureRegistry method register.

/**
 * Register a new function.
 *
 * @param function the function.
 */
public void register(CallableUserFunction function, boolean overrideCurrentImplementation, boolean builtIn) throws ProcedureException {
    UserFunctionSignature signature = function.signature();
    QualifiedName name = signature.name();
    if (aggregationFunctions.get(name) != null) {
        throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, "Unable to register function, because the name `%s` is already in use as an aggregation function.", name);
    }
    CallableUserFunction oldImplementation = functions.get(name);
    if (oldImplementation == null) {
        functions.put(name, function, signature.caseInsensitive());
    } else {
        if (overrideCurrentImplementation) {
            functions.put(name, function, signature.caseInsensitive());
        } else {
            throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, "Unable to register function, because the name `%s` is already in use.", name);
        }
    }
    if (builtIn) {
        builtInFunctionIds.add(functions.idOf(name));
    }
}
Also used : CallableUserFunction(org.neo4j.kernel.api.procedure.CallableUserFunction) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) UserFunctionSignature(org.neo4j.internal.kernel.api.procs.UserFunctionSignature)

Aggregations

QualifiedName (org.neo4j.internal.kernel.api.procs.QualifiedName)23 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)14 Test (org.junit.jupiter.api.Test)13 Arrays (java.util.Arrays)7 List (java.util.List)7 Collectors (java.util.stream.Collectors)7 KernelException (org.neo4j.exceptions.KernelException)7 ProcedureSignature (org.neo4j.internal.kernel.api.procs.ProcedureSignature)6 Config (org.neo4j.configuration.Config)5 ArrayUtils.toArray (org.apache.commons.lang3.ArrayUtils.toArray)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 UserFunctionSignature (org.neo4j.internal.kernel.api.procs.UserFunctionSignature)4 CallableProcedure (org.neo4j.kernel.api.procedure.CallableProcedure)4 CallableUserAggregationFunction (org.neo4j.kernel.api.procedure.CallableUserAggregationFunction)4 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)4 Constructor (java.lang.reflect.Constructor)3 Method (java.lang.reflect.Method)3 Modifier.isPublic (java.lang.reflect.Modifier.isPublic)3 ArrayList (java.util.ArrayList)3 Collections.emptyList (java.util.Collections.emptyList)3