Search in sources :

Example 1 with ProcedureSignature

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

the class ProcedureJarLoaderTest method shouldLoadUnsafeAllowedProcedureFromJar.

@Test
public void shouldLoadUnsafeAllowedProcedureFromJar() throws Throwable {
    // Given
    URL jar = createJarFor(ClassWithUnsafeConfiguredComponent.class);
    // When
    ProcedureJarLoader.Callables callables = jarloader.loadProcedures(jar);
    List<CallableUserFunction> functions = callables.functions();
    List<CallableProcedure> procedures = callables.procedures();
    // Then
    List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
    assertThat(signatures, contains(procedureSignature("org", "neo4j", "kernel", "impl", "proc", "unsafeFullAccessProcedure").out("someNumber", NTInteger).build()));
    assertThat(asList(procedures.get(0).apply(new BasicContext(), new Object[0])), contains(IsEqual.equalTo(new Object[] { 7331L })));
    List<UserFunctionSignature> functionsSignatures = functions.stream().map(CallableUserFunction::signature).collect(toList());
    assertThat(functionsSignatures, contains(functionSignature("org", "neo4j", "kernel", "impl", "proc", "unsafeFullAccessFunction").out(NTInteger).build()));
    assertThat(functions.get(0).apply(new BasicContext(), new Object[0]), equalTo(7331L));
}
Also used : CallableUserFunction(org.neo4j.kernel.api.proc.CallableUserFunction) BasicContext(org.neo4j.kernel.api.proc.BasicContext) UserFunctionSignature(org.neo4j.kernel.api.proc.UserFunctionSignature) URL(java.net.URL) ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) CallableProcedure(org.neo4j.kernel.api.proc.CallableProcedure) Test(org.junit.Test)

Example 2 with ProcedureSignature

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

the class ProcedureJarLoaderTest method shouldLoadProcedureWithArgumentFromJar.

@Test
public void shouldLoadProcedureWithArgumentFromJar() throws Throwable {
    // Given
    URL jar = createJarFor(ClassWithProcedureWithArgument.class);
    // When
    List<CallableProcedure> procedures = jarloader.loadProcedures(jar).procedures();
    // Then
    List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
    assertThat(signatures, contains(procedureSignature("org", "neo4j", "kernel", "impl", "proc", "myProcedure").in("value", NTInteger).out("someNumber", NTInteger).build()));
    assertThat(asList(procedures.get(0).apply(new BasicContext(), new Object[] { 42L })), contains(IsEqual.equalTo(new Object[] { 42L })));
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) BasicContext(org.neo4j.kernel.api.proc.BasicContext) CallableProcedure(org.neo4j.kernel.api.proc.CallableProcedure) URL(java.net.URL) Test(org.junit.Test)

Example 3 with ProcedureSignature

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

the class ProcedureSignatureTest method shouldHonorVoidInEquals.

@Test
public void shouldHonorVoidInEquals() {
    ProcedureSignature sig1 = procedureSignature("foo").in("a", Neo4jTypes.NTAny).build();
    ProcedureSignature sig2 = procedureSignature("foo").in("a", Neo4jTypes.NTAny).out(ProcedureSignature.VOID).build();
    ProcedureSignature sig2clone = procedureSignature("foo").in("a", Neo4jTypes.NTAny).out(ProcedureSignature.VOID).build();
    assertEquals(sig2, sig2clone);
    assertNotEquals(sig1, sig2);
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) Test(org.junit.Test)

Example 4 with ProcedureSignature

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

the class ProceduresKernelIT method shouldGetBuiltInProcedureByName.

@Test
public void shouldGetBuiltInProcedureByName() throws Throwable {
    // When
    ProcedureSignature found = readOperationsInNewTransaction().procedureGet(procedureName("db", "labels"));
    // Then
    assertThat(found, equalTo(procedureSignature(procedureName("db", "labels")).out("label", NTString).build()));
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) Test(org.junit.Test)

Example 5 with ProcedureSignature

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

the class ConfiguredProceduresTestBase method shouldSetAllowedToConfigSetting.

@Test
public void shouldSetAllowedToConfigSetting() throws Throwable {
    configuredSetup(stringMap(SecuritySettings.default_allowed.name(), "nonEmpty"));
    Procedures procedures = neo.getLocalGraph().getDependencyResolver().resolveDependency(Procedures.class);
    ProcedureSignature numNodes = procedures.procedure(new QualifiedName(new String[] { "test" }, "numNodes"));
    assertThat(Arrays.asList(numNodes.allowed()), containsInAnyOrder("nonEmpty"));
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) QualifiedName(org.neo4j.kernel.api.proc.QualifiedName) Procedures(org.neo4j.kernel.impl.proc.Procedures) Test(org.junit.Test)

Aggregations

ProcedureSignature (org.neo4j.kernel.api.proc.ProcedureSignature)15 Test (org.junit.Test)13 CallableProcedure (org.neo4j.kernel.api.proc.CallableProcedure)6 QualifiedName (org.neo4j.kernel.api.proc.QualifiedName)5 URL (java.net.URL)4 BasicContext (org.neo4j.kernel.api.proc.BasicContext)3 FieldSignature (org.neo4j.kernel.api.proc.FieldSignature)3 Procedures (org.neo4j.kernel.impl.proc.Procedures)3 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)2 MethodHandle (java.lang.invoke.MethodHandle)1 ComponentInjectionException (org.neo4j.kernel.api.exceptions.ComponentInjectionException)1 CallableUserFunction (org.neo4j.kernel.api.proc.CallableUserFunction)1 FailedLoadProcedure (org.neo4j.kernel.api.proc.FailedLoadProcedure)1 NTString (org.neo4j.kernel.api.proc.Neo4jTypes.NTString)1 UserFunctionSignature (org.neo4j.kernel.api.proc.UserFunctionSignature)1 OutputMapper (org.neo4j.kernel.impl.proc.OutputMappers.OutputMapper)1 Mode (org.neo4j.procedure.Mode)1 Procedure (org.neo4j.procedure.Procedure)1