use of org.neo4j.bolt.dbapi.BoltTransaction in project neo4j by neo4j.
the class TransactionStateMachineTest method shouldOpenImplicitTransactionForPeriodicCommitQuery.
@Test
void shouldOpenImplicitTransactionForPeriodicCommitQuery() throws Exception {
BoltTransaction transaction = newTransaction();
TransactionStateMachineSPI stateMachineSPI = newTransactionStateMachineSPI(transaction);
when(stateMachineSPI.isPeriodicCommit(PERIODIC_COMMIT_QUERY)).thenReturn(true);
final BoltTransaction periodicTransaction = mock(BoltTransaction.class);
when(stateMachineSPI.beginPeriodicCommitTransaction(any(), any(), any(), any(), any(), any())).thenReturn(periodicTransaction);
TransactionStateMachine stateMachine = newTransactionStateMachine(stateMachineSPI);
stateMachine.run(PERIODIC_COMMIT_QUERY, EMPTY_MAP);
// transaction was created only to stream back result of the periodic commit query
assertEquals(periodicTransaction, stateMachine.ctx.currentTransaction);
InOrder inOrder = inOrder(stateMachineSPI);
inOrder.verify(stateMachineSPI).isPeriodicCommit(PERIODIC_COMMIT_QUERY);
// implicit transaction was started for periodic query execution
inOrder.verify(stateMachineSPI).beginPeriodicCommitTransaction(any(LoginContext.class), any(), any(), any(), any(), any());
// periodic commit query was executed after specific transaction started
inOrder.verify(stateMachineSPI).executeQuery(any(BoltQueryExecutor.class), eq(PERIODIC_COMMIT_QUERY), eq(EMPTY_MAP));
}
Aggregations