use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ResampleIndexProcedureTest method shouldThrowAnExceptionIfTheIndexDoesNotExist.
@Test
public void shouldThrowAnExceptionIfTheIndexDoesNotExist() throws SchemaRuleNotFoundException, IndexNotFoundKernelException {
when(operations.labelGetForName(anyString())).thenReturn(0);
when(operations.propertyKeyGetForName(anyString())).thenReturn(0);
when(operations.indexGetForLabelAndPropertyKey(any())).thenThrow(new SchemaRuleNotFoundException(INDEX_RULE, SchemaDescriptorFactory.forLabel(0, 0)));
try {
procedure.resampleIndex(":Person(name)");
fail("Expected an exception");
} catch (ProcedureException e) {
assertThat(e.status(), is(Status.Schema.IndexNotFound));
}
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInProceduresIT method listAllIndexes.
@Test
public void listAllIndexes() throws Throwable {
// Given
Statement statement = statementInNewTransaction(SecurityContext.AUTH_DISABLED);
int labelId1 = statement.tokenWriteOperations().labelGetOrCreateForName("Person");
int labelId2 = statement.tokenWriteOperations().labelGetOrCreateForName("Age");
int propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName("foo");
//TODO: Add test support for composite indexes
statement.schemaWriteOperations().indexCreate(SchemaDescriptorFactory.forLabel(labelId1, propertyKeyId));
statement.schemaWriteOperations().uniquePropertyConstraintCreate(forLabel(labelId2, propertyKeyId));
commit();
//let indexes come online
try (Transaction tx = db.beginTx()) {
db.schema().awaitIndexOnline(db.schema().getIndexes().iterator().next(), 20, SECONDS);
tx.success();
}
// When
RawIterator<Object[], ProcedureException> stream = procedureCallOpsInNewTx().procedureCallRead(procedureName("db", "indexes"), new Object[0]);
Set<Object[]> result = new HashSet<>();
while (stream.hasNext()) {
result.add(stream.next());
}
// Then
assertThat(result, containsInAnyOrder(new Object[] { "INDEX ON :Age(foo)", "ONLINE", "node_unique_property" }, new Object[] { "INDEX ON :Person(foo)", "ONLINE", "node_label_property" }));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class BuiltInProceduresIT method listPropertyKeys.
@Test
public void listPropertyKeys() throws Throwable {
// Given
TokenWriteOperations ops = tokenWriteOperationsInNewTransaction();
ops.propertyKeyGetOrCreateForName("MyProp");
commit();
// When
RawIterator<Object[], ProcedureException> stream = procedureCallOpsInNewTx().procedureCallRead(procedureName("db", "propertyKeys"), new Object[0]);
// Then
assertThat(asList(stream), contains(equalTo(new Object[] { "MyProp" })));
}
use of org.neo4j.kernel.api.exceptions.ProcedureException in project neo4j by neo4j.
the class ReflectiveProcedureWithArgumentsTest method shouldRunGenericProcedure.
@Test
public void shouldRunGenericProcedure() throws Throwable {
// Given
CallableProcedure procedure = compile(ClassWithProcedureWithGenericArgs.class).get(0);
// When
RawIterator<Object[], ProcedureException> out = procedure.apply(new BasicContext(), new Object[] { Arrays.asList("Roland", "Eddie", "Susan", "Jake"), Arrays.asList(1000L, 23L, 29L, 12L) });
// Then
List<Object[]> collect = asList(out);
assertThat(collect.get(0)[0], equalTo("Roland is 1000 years old."));
assertThat(collect.get(1)[0], equalTo("Eddie is 23 years old."));
assertThat(collect.get(2)[0], equalTo("Susan is 29 years old."));
assertThat(collect.get(3)[0], equalTo("Jake is 12 years old."));
}
Aggregations