use of org.neo4j.internal.kernel.api.procs.ProcedureSignature in project neo4j by neo4j.
the class ProcedureCompilationTest method shouldExposeProcedureSignature.
@Test
void shouldExposeProcedureSignature() throws ProcedureException {
// Given
ProcedureSignature signature = ProcedureSignature.procedureSignature("test", "foo").in("in", NTInteger).out(singletonList(inputField("name", NTInteger))).build();
// When
CallableProcedure longStream = compileProcedure(signature, emptyList(), method("longStream", long.class));
// Then
assertEquals(signature, longStream.signature());
}
use of org.neo4j.internal.kernel.api.procs.ProcedureSignature in project neo4j by neo4j.
the class ProcedureCompilationTest method procedureShouldAccessContext.
@Test
void procedureShouldAccessContext() throws ProcedureException, NoSuchFieldException {
// Given
ProcedureSignature signature = ProcedureSignature.procedureSignature("test", "foo").in("in", NTString).out(singletonList(inputField("name", NTString))).build();
FieldSetter setter1 = createSetter(InnerClass.class, "transaction", Context::internalTransaction);
FieldSetter setter2 = createSetter(InnerClass.class, "thread", Context::thread);
Method stringStream = method(InnerClass.class, "stringStream");
// Then
String threadName = Thread.currentThread().getName();
assertEquals(stringValue("NULL AND NULL"), compileProcedure(signature, emptyList(), stringStream).apply(ctx, EMPTY, RESOURCE_TRACKER).next()[0]);
assertEquals(stringValue("I'm transaction AND NULL"), compileProcedure(signature, singletonList(setter1), stringStream).apply(ctx, EMPTY, RESOURCE_TRACKER).next()[0]);
assertEquals(stringValue("NULL AND " + threadName), compileProcedure(signature, singletonList(setter2), stringStream).apply(ctx, EMPTY, RESOURCE_TRACKER).next()[0]);
assertEquals(stringValue("I'm transaction AND " + threadName), compileProcedure(signature, asList(setter1, setter2), stringStream).apply(ctx, EMPTY, RESOURCE_TRACKER).next()[0]);
}
use of org.neo4j.internal.kernel.api.procs.ProcedureSignature in project neo4j by neo4j.
the class ProcedureCompilationTest method shouldCallVoidProcedure.
@Test
void shouldCallVoidProcedure() throws ProcedureException, NoSuchFieldException {
// Given
ProcedureSignature signature = ProcedureSignature.procedureSignature("test", "foo").build();
// When
FieldSetter setter = createSetter(InnerClass.class, "transaction", Context::internalTransaction);
CallableProcedure voidMethod = compileProcedure(signature, singletonList(setter), method(InnerClass.class, "voidMethod"));
// Then
RawIterator<AnyValue[], ProcedureException> iterator = voidMethod.apply(ctx, EMPTY, RESOURCE_TRACKER);
assertFalse(iterator.hasNext());
verify(TRANSACTION).traversalDescription();
}
Aggregations