Search in sources :

Example 11 with ProcedureSignature

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

the class GetServersProcedureV2Test method shouldHaveCorrectSignature.

@Test
public void shouldHaveCorrectSignature() throws Exception {
    // given
    GetServersProcedureForMultiDC proc = new GetServersProcedureForMultiDC(null);
    // when
    ProcedureSignature signature = proc.signature();
    // then
    assertThat(signature.inputSignature(), containsInAnyOrder(new FieldSignature("context", NTMap)));
    assertThat(signature.outputSignature(), containsInAnyOrder(new FieldSignature("ttl", NTInteger), new FieldSignature("servers", NTMap)));
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) FieldSignature(org.neo4j.kernel.api.proc.FieldSignature) Test(org.junit.Test)

Example 12 with ProcedureSignature

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

the class ProceduresKernelIT method shouldGetProcedureByName.

@Test
public void shouldGetProcedureByName() throws Throwable {
    // Given
    kernel.registerProcedure(procedure);
    // When
    ProcedureSignature found = readOperationsInNewTransaction().procedureGet(new QualifiedName(new String[] { "example" }, "exampleProc"));
    // Then
    assertThat(found, equalTo(signature));
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) QualifiedName(org.neo4j.kernel.api.proc.QualifiedName) NTString(org.neo4j.kernel.api.proc.Neo4jTypes.NTString) Test(org.junit.Test)

Example 13 with ProcedureSignature

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

the class ProcedureSignatureTest method toStringForVoidProcedureShouldMatchCypherSyntax.

@Test
public void toStringForVoidProcedureShouldMatchCypherSyntax() throws Throwable {
    // Given
    ProcedureSignature proc = procedureSignature("org", "myProcedure").in("inputArg", Neo4jTypes.NTList(Neo4jTypes.NTString)).out(ProcedureSignature.VOID).build();
    // When
    String toStr = proc.toString();
    // Then
    assertEquals("org.myProcedure(inputArg :: LIST? OF STRING?) :: VOID", toStr);
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) Test(org.junit.Test)

Example 14 with ProcedureSignature

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

the class ProcedureJarLoaderTest method shouldLoadProcedureFromJar.

@Test
public void shouldLoadProcedureFromJar() throws Throwable {
    // Given
    URL jar = createJarFor(ClassWithOneProcedure.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").out("someNumber", NTInteger).build()));
    assertThat(asList(procedures.get(0).apply(new BasicContext(), new Object[0])), contains(IsEqual.equalTo(new Object[] { 1337L })));
}
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 15 with ProcedureSignature

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

the class ProcedureJarLoaderTest method shouldLoadProcedureFromJarWithMultipleProcedureClasses.

@Test
public void shouldLoadProcedureFromJarWithMultipleProcedureClasses() throws Throwable {
    // Given
    URL jar = createJarFor(ClassWithOneProcedure.class, ClassWithAnotherProcedure.class, ClassWithNoProcedureAtAll.class);
    // When
    List<CallableProcedure> procedures = jarloader.loadProcedures(jar).procedures();
    // Then
    List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
    assertThat(signatures, containsInAnyOrder(procedureSignature("org", "neo4j", "kernel", "impl", "proc", "myOtherProcedure").out("someNumber", NTInteger).build(), procedureSignature("org", "neo4j", "kernel", "impl", "proc", "myProcedure").out("someNumber", NTInteger).build()));
}
Also used : ProcedureSignature(org.neo4j.kernel.api.proc.ProcedureSignature) CallableProcedure(org.neo4j.kernel.api.proc.CallableProcedure) URL(java.net.URL) 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