use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldLoadWhiteListedProcedure.
@Test
public void shouldLoadWhiteListedProcedure() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults().with(genericMap(procedure_whitelist.name(), "org.neo4j.kernel.impl.proc.listCoolPeople")));
Log log = mock(Log.class);
ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, components, log, config);
// When
CallableProcedure proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, Optional.empty(), false).get(0);
// When
RawIterator<Object[], ProcedureException> result = proc.apply(new BasicContext(), new Object[0]);
// Then
assertEquals(result.next()[0], "Bonnie");
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ReflectiveProcedureWithArgumentsTest method shouldRunSimpleProcedure.
@Test
public void shouldRunSimpleProcedure() throws Throwable {
// Given
CallableProcedure procedure = compile(ClassWithProcedureWithSimpleArgs.class).get(0);
// When
RawIterator<Object[], ProcedureException> out = procedure.apply(new BasicContext(), new Object[] { "Pontus", 35L });
// Then
List<Object[]> collect = asList(out);
assertThat(collect.get(0)[0], equalTo("Pontus is 35 years old."));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProceduresTest method shouldCallRegisteredProcedure.
@Test
public void shouldCallRegisteredProcedure() throws Throwable {
// Given
procs.register(procedure);
// When
RawIterator<Object[], ProcedureException> result = procs.callProcedure(new BasicContext(), signature.name(), new Object[] { 1337 });
// Then
assertThat(asList(result), contains(equalTo(new Object[] { 1337 })));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProceduresTest method shouldMakeContextAvailable.
@Test
public void shouldMakeContextAvailable() throws Throwable {
// Given
Key<String> someKey = key("someKey", String.class);
procs.register(new CallableProcedure.BasicProcedure(signature) {
@Override
public RawIterator<Object[], ProcedureException> apply(Context ctx, Object[] input) throws ProcedureException {
return RawIterator.<Object[], ProcedureException>of(new Object[] { ctx.get(someKey) });
}
});
BasicContext ctx = new BasicContext();
ctx.put(someKey, "hello, world");
// When
RawIterator<Object[], ProcedureException> result = procs.callProcedure(ctx, signature.name(), new Object[0]);
// Then
assertThat(asList(result), contains(equalTo(new Object[] { "hello, world" })));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldIgnoreWhiteListingIfFullAccess.
@Test
public void shouldIgnoreWhiteListingIfFullAccess() throws Throwable {
// Given
ProcedureConfig config = new ProcedureConfig(Config.defaults().with(genericMap(procedure_whitelist.name(), "empty")));
Log log = mock(Log.class);
ReflectiveProcedureCompiler procedureCompiler = new ReflectiveProcedureCompiler(new TypeMappers(), components, components, log, config);
// When
CallableProcedure proc = procedureCompiler.compileProcedure(SingleReadOnlyProcedure.class, Optional.empty(), true).get(0);
// Then
RawIterator<Object[], ProcedureException> result = proc.apply(new BasicContext(), new Object[0]);
assertEquals(result.next()[0], "Bonnie");
}
Aggregations