use of org.neo4j.kernel.api.procedure.CallableProcedure in project neo4j by neo4j.
the class ProcedureTest method shouldRunClassWithMultipleProceduresDeclared.
@Test
void shouldRunClassWithMultipleProceduresDeclared() throws Throwable {
// Given
List<CallableProcedure> compiled = compile(MultiProcedureProcedure.class);
CallableProcedure bananaPeople = compiled.get(0);
CallableProcedure coolPeople = compiled.get(1);
// When
RawIterator<AnyValue[], ProcedureException> coolOut = coolPeople.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
RawIterator<AnyValue[], ProcedureException> bananaOut = bananaPeople.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
assertThat(asList(coolOut)).containsExactly(new AnyValue[] { stringValue("Bonnie") }, new AnyValue[] { stringValue("Clyde") });
assertThat(asList(bananaOut)).containsExactly(new AnyValue[] { stringValue("Jake"), longValue(18L) }, new AnyValue[] { stringValue("Pontus"), longValue(2L) });
}
use of org.neo4j.kernel.api.procedure.CallableProcedure in project neo4j by neo4j.
the class ProcedureTest method shouldAllowVoidOutput.
@Test
void shouldAllowVoidOutput() throws Throwable {
// When
CallableProcedure proc = compile(ProcedureWithVoidOutput.class).get(0);
// Then
assertEquals(0, proc.signature().outputSignature().size());
assertFalse(proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER).hasNext());
}
use of org.neo4j.kernel.api.procedure.CallableProcedure in project neo4j by neo4j.
the class ProcedureTest method shouldRunProcedureWithInternalTypes.
@Test
void shouldRunProcedureWithInternalTypes() throws Throwable {
// Given
CallableProcedure proc = compile(InternalTypes.class).get(0);
// When
RawIterator<AnyValue[], ProcedureException> out = proc.apply(prepareContext(), new AnyValue[] { longValue(42), stringValue("hello"), Values.TRUE }, EMPTY_RESOURCE_TRACKER);
// Then
assertThat(out.next()).isEqualTo(new AnyValue[] { longValue(42), stringValue("hello"), Values.TRUE });
assertFalse(out.hasNext());
}
use of org.neo4j.kernel.api.procedure.CallableProcedure in project neo4j by neo4j.
the class ProcedureTest method shouldInjectLogging.
@Test
void shouldInjectLogging() throws KernelException {
// Given
Log log = spy(Log.class);
components.register(Log.class, ctx -> log);
CallableProcedure procedure = procedureCompiler.compileProcedure(LoggingProcedure.class, null, true).get(0);
// When
procedure.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
verify(log).debug("1");
verify(log).info("2");
verify(log).warn("3");
verify(log).error("4");
}
use of org.neo4j.kernel.api.procedure.CallableProcedure in project neo4j by neo4j.
the class ProcedureTest method shouldRunSimpleReadOnlyProcedure.
@Test
void shouldRunSimpleReadOnlyProcedure() throws Throwable {
// Given
CallableProcedure proc = compile(SingleReadOnlyProcedure.class).get(0);
// When
RawIterator<AnyValue[], ProcedureException> out = proc.apply(prepareContext(), new AnyValue[0], EMPTY_RESOURCE_TRACKER);
// Then
assertThat(asList(out)).containsExactly(new AnyValue[] { stringValue("Bonnie") }, new AnyValue[] { stringValue("Clyde") });
}
Aggregations