Search in sources :

Example 16 with QualifiedName

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

the class BuiltInDbmsProceduresIT method listClientConfig.

@Test
void listClientConfig() throws Exception {
    QualifiedName procedureName = procedureName("dbms", "clientConfig");
    int procedureId = procs().procedureGet(procedureName).id();
    RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
    List<AnyValue[]> config = asList(callResult);
    assertEquals(4, config.size());
    assertEquals(config.get(0)[0], stringValue("browser.post_connect_cmd"));
    assertEquals(config.get(1)[0], stringValue("browser.remote_content_hostname_whitelist"));
    assertEquals(config.get(2)[0], stringValue("dbms.default_database"));
    assertEquals(config.get(3)[0], stringValue("dbms.security.auth_enabled"));
}
Also used : QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 17 with QualifiedName

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

the class BuiltInDbmsProceduresIT method listCapabilitiesShouldNotReturnBlocked.

@Test
void listCapabilitiesShouldNotReturnBlocked() throws KernelException {
    // set blocked capabilities
    Config config = dependencyResolver.resolveDependency(Config.class);
    config.set(CapabilitiesSettings.dbms_capabilities_blocked, List.of("my.**"));
    QualifiedName procedureName = procedureName("dbms", "listCapabilities");
    int procedureId = procs().procedureGet(procedureName).id();
    RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
    List<AnyValue[]> capabilities = asList(callResult);
    List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
    assertThat(capabilityNames).doesNotContain(TestCapabilities.my_custom_capability.name().fullName());
}
Also used : AnyValue(org.neo4j.values.AnyValue) Arrays(java.util.Arrays) Label(org.neo4j.graphdb.Label) RawIterator(org.neo4j.collection.RawIterator) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) Iterators.asList(org.neo4j.internal.helpers.collection.Iterators.asList) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Config(org.neo4j.configuration.Config) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) ProcedureSignature.procedureName(org.neo4j.internal.kernel.api.procs.ProcedureSignature.procedureName) Public(org.neo4j.annotations.Public) Values(org.neo4j.values.storable.Values) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) CapabilitiesRegistry(org.neo4j.capabilities.CapabilitiesRegistry) Capability(org.neo4j.capabilities.Capability) CapabilitiesSettings(org.neo4j.capabilities.CapabilitiesSettings) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FALSE(org.neo4j.configuration.SettingValueParsers.FALSE) CapabilityProviderContext(org.neo4j.capabilities.CapabilityProviderContext) INTEGER(org.neo4j.capabilities.Type.INTEGER) DOUBLE(org.neo4j.capabilities.Type.DOUBLE) CapabilityProvider(org.neo4j.capabilities.CapabilityProvider) Name(org.neo4j.capabilities.Name) DBMSCapabilities(org.neo4j.capabilities.DBMSCapabilities) BooleanValue(org.neo4j.values.storable.BooleanValue) BOOLEAN(org.neo4j.capabilities.Type.BOOLEAN) TextValue(org.neo4j.values.storable.TextValue) Label.label(org.neo4j.graphdb.Label.label) Values.stringValue(org.neo4j.values.storable.Values.stringValue) Collectors(java.util.stream.Collectors) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) Test(org.junit.jupiter.api.Test) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) List(java.util.List) ProcedureCallContext(org.neo4j.internal.kernel.api.procs.ProcedureCallContext) ArrayUtils.toArray(org.apache.commons.lang3.ArrayUtils.toArray) Description(org.neo4j.configuration.Description) KernelException(org.neo4j.exceptions.KernelException) Matchers.contains(org.hamcrest.Matchers.contains) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CapabilityDeclaration(org.neo4j.capabilities.CapabilityDeclaration) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest) Config(org.neo4j.configuration.Config) TextValue(org.neo4j.values.storable.TextValue) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 18 with QualifiedName

use of org.neo4j.internal.kernel.api.procs.QualifiedName 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 19 with QualifiedName

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

the class ProceduresKernelIT method shouldGetProcedureByName.

@Test
void shouldGetProcedureByName() throws Throwable {
    // Given
    internalKernel().registerProcedure(procedure);
    // When
    ProcedureSignature found = procs().procedureGet(new QualifiedName(new String[] { "example" }, "exampleProc")).signature();
    // Then
    assertThat(found).isEqualTo(signature);
    commit();
}
Also used : ProcedureSignature(org.neo4j.internal.kernel.api.procs.ProcedureSignature) QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) Test(org.junit.jupiter.api.Test)

Example 20 with QualifiedName

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

the class ProcedureHolderTest method canOverwriteFunctionAndChangeCaseSensitivity.

@Test
void canOverwriteFunctionAndChangeCaseSensitivity() {
    // 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);
    // and then
    procHolder.put(qualifiedName, item, false);
    assertNull(procHolder.get(lowerCaseName));
    assertThrows(NoSuchElementException.class, () -> procHolder.idOf(lowerCaseName));
}
Also used : QualifiedName(org.neo4j.internal.kernel.api.procs.QualifiedName) Test(org.junit.jupiter.api.Test)

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