use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class BuiltInProceduresTest method call.
private List<Object[]> call(String name, Object... args) throws ProcedureException {
BasicContext ctx = new BasicContext();
ctx.put(KERNEL_TRANSACTION, tx);
ctx.put(DEPENDENCY_RESOLVER, resolver);
ctx.put(GRAPHDATABASEAPI, graphDatabaseAPI);
when(graphDatabaseAPI.getDependencyResolver()).thenReturn(resolver);
when(resolver.resolveDependency(Procedures.class)).thenReturn(procs);
return Iterators.asList(procs.callProcedure(ctx, ProcedureSignature.procedureName(name.split("\\.")), args));
}
use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldGiveHelpfulErrorOnNullMessageException.
@Test
public void shouldGiveHelpfulErrorOnNullMessageException() throws Throwable {
// Given
CallableProcedure proc = compile(ProcedureThatThrowsNullMsgExceptionAtInvocation.class).get(0);
// Expect
exception.expect(ProcedureException.class);
exception.expectMessage("Failed to invoke procedure `org.neo4j.kernel.impl.proc.throwsAtInvocation`: " + "Caused by: java.lang.IndexOutOfBoundsException");
// When
proc.apply(new BasicContext(), new Object[0]);
}
use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldInjectLogging.
@Test
public void shouldInjectLogging() throws KernelException {
// Given
Log log = spy(Log.class);
components.register(Log.class, (ctx) -> log);
CallableProcedure procedure = procedureCompiler.compileProcedure(LoggingProcedure.class, Optional.empty(), true).get(0);
// When
procedure.apply(new BasicContext(), new Object[0]);
// Then
verify(log).debug("1");
verify(log).info("2");
verify(log).warn("3");
verify(log).error("4");
}
use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class ReflectiveUserFunctionTest method shouldGiveHelpfulErrorOnNullMessageException.
@Test
public void shouldGiveHelpfulErrorOnNullMessageException() throws Throwable {
// Given
CallableUserFunction proc = compile(FunctionThatThrowsNullMsgExceptionAtInvocation.class).get(0);
// Expect
exception.expect(ProcedureException.class);
exception.expectMessage("Failed to invoke function `org.neo4j.kernel.impl.proc.throwsAtInvocation`: " + "Caused by: java.lang.IndexOutOfBoundsException");
// When
proc.apply(new BasicContext(), new Object[0]);
}
use of org.neo4j.kernel.api.proc.BasicContext in project neo4j by neo4j.
the class ResourceInjectionTest method shouldCompileAndRunUserFunctions.
@Test
public void shouldCompileAndRunUserFunctions() throws Throwable {
// Given
CallableUserFunction proc = compiler.compileFunction(FunctionWithInjectedAPI.class).get(0);
// When
Object out = proc.apply(new BasicContext(), new Object[0]);
// Then
assertThat(out, equalTo("[Bonnie, Clyde]"));
}
Aggregations