use of org.neo4j.kernel.GraphDatabaseQueryService in project neo4j by neo4j.
the class TransactionHandleTest method shouldRollbackTransactionAndTellRegistryToForgetItsHandle.
@Test
public void shouldRollbackTransactionAndTellRegistryToForgetItsHandle() throws Exception {
// given
TransitionalPeriodTransactionMessContainer kernel = mockKernel();
TransitionalTxManagementKernelTransaction transactionContext = kernel.newTransaction(explicit, AUTH_DISABLED, -1);
TransactionRegistry registry = mock(TransactionRegistry.class);
when(registry.begin(any(TransactionHandle.class))).thenReturn(1337L);
GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
TransactionHandle handle = new TransactionHandle(kernel, mock(QueryExecutionEngine.class), queryService, registry, uriScheme, true, AUTH_DISABLED, anyLong(), NullLogProvider.getInstance());
ExecutionResultSerializer output = mock(ExecutionResultSerializer.class);
// when
handle.rollback(output);
// then
InOrder transactionOrder = inOrder(transactionContext, registry);
transactionOrder.verify(transactionContext).rollback();
transactionOrder.verify(registry).forget(1337L);
InOrder outputOrder = inOrder(output);
outputOrder.verify(output).errors(argThat(hasNoErrors()));
outputOrder.verify(output).finish();
verifyNoMoreInteractions(output);
}
use of org.neo4j.kernel.GraphDatabaseQueryService in project neo4j by neo4j.
the class TransactionHandleTest method shouldCommitTransactionAndTellRegistryToForgetItsHandle.
@Test
public void shouldCommitTransactionAndTellRegistryToForgetItsHandle() throws Exception {
// given
TransitionalPeriodTransactionMessContainer kernel = mockKernel();
TransitionalTxManagementKernelTransaction transactionContext = kernel.newTransaction(explicit, AUTH_DISABLED, -1);
TransactionRegistry registry = mock(TransactionRegistry.class);
QueryExecutionEngine engine = mock(QueryExecutionEngine.class);
TransactionalContext transactionalContext = prepareKernelWithQuerySession(kernel);
Result result = mock(Result.class);
when(engine.executeQuery("query", map(), transactionalContext)).thenReturn(result);
when(registry.begin(any(TransactionHandle.class))).thenReturn(1337L);
GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
TransactionHandle handle = new TransactionHandle(kernel, engine, queryService, registry, uriScheme, false, AUTH_DISABLED, anyLong(), NullLogProvider.getInstance());
ExecutionResultSerializer output = mock(ExecutionResultSerializer.class);
// when
Statement statement = new Statement("query", map(), false, (ResultDataContent[]) null);
handle.commit(statements(statement), output, mock(HttpServletRequest.class));
// then
InOrder transactionOrder = inOrder(transactionContext, registry);
transactionOrder.verify(transactionContext).commit();
transactionOrder.verify(registry).forget(1337L);
InOrder outputOrder = inOrder(output);
outputOrder.verify(output).statementResult(result, false, (ResultDataContent[]) null);
outputOrder.verify(output).notifications(anyCollectionOf(Notification.class));
outputOrder.verify(output).errors(argThat(hasNoErrors()));
outputOrder.verify(output).finish();
verifyNoMoreInteractions(output);
}
use of org.neo4j.kernel.GraphDatabaseQueryService in project neo4j by neo4j.
the class TransactionStateMachineSPIProviderV4Test method managementService.
private DatabaseManagementService managementService(String databaseName) {
DatabaseManagementService managementService = mock(DatabaseManagementService.class);
GraphDatabaseFacade databaseFacade = mock(GraphDatabaseFacade.class);
final DependencyResolver dependencyResolver = mock(DependencyResolver.class);
GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
when(databaseFacade.isAvailable(anyLong())).thenReturn(true);
when(managementService.database(databaseName)).thenReturn(databaseFacade);
when(databaseFacade.getDependencyResolver()).thenReturn(dependencyResolver);
when(dependencyResolver.resolveDependency(GraphDatabaseQueryService.class)).thenReturn(queryService);
when(dependencyResolver.resolveDependency(Database.class)).thenReturn(mock(Database.class));
when(queryService.getDependencyResolver()).thenReturn(dependencyResolver);
return managementService;
}
Aggregations