use of org.neo4j.exceptions.SyntaxException in project neo4j by neo4j.
the class InvocationTest method shouldHandleCypherSyntaxError.
@Test
void shouldHandleCypherSyntaxError() {
// given
String queryText = "matsch (n) return n";
when(internalTransaction.execute(queryText, emptyMap())).thenThrow(new RuntimeException(new SyntaxException("did you mean MATCH?")));
when(registry.begin(any(TransactionHandle.class))).thenReturn(1337L);
TransactionHandle handle = getTransactionHandle(executionEngine, registry);
InputEventStream inputEventStream = mock(InputEventStream.class);
Statement statement = new Statement(queryText, map());
when(inputEventStream.read()).thenReturn(statement, NULL_STATEMENT);
Invocation invocation = new Invocation(log, handle, uriScheme.txCommitUri(1337L), mock(MemoryPool.class, RETURNS_MOCKS), inputEventStream, true);
// when
invocation.execute(outputEventStream);
// then
verify(internalTransaction).rollback();
verify(registry).forget(1337L);
InOrder outputOrder = inOrder(outputEventStream);
outputOrder.verify(outputEventStream).writeFailure(Status.Statement.SyntaxError, "did you mean MATCH?");
outputOrder.verify(outputEventStream).writeTransactionInfo(TransactionNotificationState.ROLLED_BACK, uriScheme.txCommitUri(1337L), -1);
verifyNoMoreInteractions(outputEventStream);
}
Aggregations