use of org.neo4j.internal.kernel.api.procs.ProcedureSignature 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);
}
use of org.neo4j.internal.kernel.api.procs.ProcedureSignature 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();
}
use of org.neo4j.internal.kernel.api.procs.ProcedureSignature in project neo4j by neo4j.
the class ProcedureJarLoaderTest method shouldLoadProcedureFromJar.
@Test
void shouldLoadProcedureFromJar() throws Throwable {
// Given
URL jar = createJarFor(ClassWithOneProcedure.class);
// When
List<CallableProcedure> procedures = jarloader.loadProceduresFromDir(parentDir(jar)).procedures();
// Then
List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
assertThat(signatures).containsExactly(procedureSignature("org", "neo4j", "procedure", "impl", "myProcedure").out("someNumber", NTInteger).build());
assertThat(asList(procedures.get(0).apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER))).containsExactly(new AnyValue[] { Values.longValue(1337L) });
}
use of org.neo4j.internal.kernel.api.procs.ProcedureSignature in project neo4j by neo4j.
the class ProcedureJarLoaderTest method shouldLoadProcedureFromJarWithSpacesInFilename.
@Test
void shouldLoadProcedureFromJarWithSpacesInFilename() throws Throwable {
// Given
URL jar = new JarBuilder().createJarFor(testDirectory.createFile(new Random().nextInt() + " some spaces in filename.jar"), ClassWithOneProcedure.class);
// When
List<CallableProcedure> procedures = jarloader.loadProceduresFromDir(parentDir(jar)).procedures();
// Then
List<ProcedureSignature> signatures = procedures.stream().map(CallableProcedure::signature).collect(toList());
assertThat(signatures).containsExactly(procedureSignature("org", "neo4j", "procedure", "impl", "myProcedure").out("someNumber", NTInteger).build());
assertThat(asList(procedures.get(0).apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER))).containsExactly(new AnyValue[] { Values.longValue(1337L) });
}
use of org.neo4j.internal.kernel.api.procs.ProcedureSignature in project neo4j by neo4j.
the class ProcedureSignatureTest method toStringForVoidProcedureShouldMatchCypherSyntax.
@Test
void toStringForVoidProcedureShouldMatchCypherSyntax() {
// 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);
}
Aggregations