use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldRunClassWithMultipleProceduresDeclared.
@Test
public void shouldRunClassWithMultipleProceduresDeclared() throws Throwable {
// Given
List<CallableProcedure> compiled = compile(MultiProcedureProcedure.class);
CallableProcedure bananaPeople = compiled.get(0);
CallableProcedure coolPeople = compiled.get(1);
// When
RawIterator<Object[], ProcedureException> coolOut = coolPeople.apply(new BasicContext(), new Object[0]);
RawIterator<Object[], ProcedureException> bananaOut = bananaPeople.apply(new BasicContext(), new Object[0]);
// Then
assertThat(asList(coolOut), contains(new Object[] { "Bonnie" }, new Object[] { "Clyde" }));
assertThat(asList(bananaOut), contains(new Object[] { "Jake", 18L }, new Object[] { "Pontus", 2L }));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ReflectiveProcedureTest method shouldRunSimpleReadOnlyProcedure.
@Test
public void shouldRunSimpleReadOnlyProcedure() throws Throwable {
// Given
CallableProcedure proc = compile(SingleReadOnlyProcedure.class).get(0);
// When
RawIterator<Object[], ProcedureException> out = proc.apply(new BasicContext(), new Object[0]);
// Then
assertThat(asList(out), contains(new Object[] { "Bonnie" }, new Object[] { "Clyde" }));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInProceduresIT method listRelationshipTypes.
@Test
public void listRelationshipTypes() throws Throwable {
// Given
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
int relType = statement.tokenWriteOperations().relationshipTypeGetOrCreateForName("MyRelType");
long startNodeId = statement.dataWriteOperations().nodeCreate();
long endNodeId = statement.dataWriteOperations().nodeCreate();
statement.dataWriteOperations().relationshipCreate(relType, startNodeId, endNodeId);
commit();
// When
RawIterator<Object[], ProcedureException> stream = procedureCallOpsInNewTx().procedureCallRead(procedureName("db", "relationshipTypes"), new Object[0]);
// Then
assertThat(asList(stream), contains(equalTo(new Object[] { "MyRelType" })));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInProceduresIT method listAllLabels.
@Test
public void listAllLabels() throws Throwable {
// Given
Statement statement = statementInNewTransaction(AnonymousContext.writeToken());
long nodeId = statement.dataWriteOperations().nodeCreate();
int labelId = statement.tokenWriteOperations().labelGetOrCreateForName("MyLabel");
statement.dataWriteOperations().nodeAddLabel(nodeId, labelId);
commit();
// When
RawIterator<Object[], ProcedureException> stream = procedureCallOpsInNewTx().procedureCallRead(procedureName("db", "labels"), new Object[0]);
// Then
assertThat(asList(stream), contains(equalTo(new Object[] { "MyLabel" })));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ProceduresKernelIT method shouldCallReadOnlyProcedure.
@Test
public void shouldCallReadOnlyProcedure() throws Throwable {
// Given
kernel.registerProcedure(procedure);
// When
RawIterator<Object[], ProcedureException> found = procedureCallOpsInNewTx().procedureCallRead(new QualifiedName(new String[] { "example" }, "exampleProc"), new Object[] { 1337 });
// Then
assertThat(asList(found), contains(equalTo(new Object[] { 1337 })));
}
Aggregations