Search in sources :

Example 21 with QueryExecutionEngine

use of org.neo4j.kernel.impl.query.QueryExecutionEngine 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);
}
Also used : InOrder(org.mockito.InOrder) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) Notification(org.neo4j.graphdb.Notification) Result(org.neo4j.graphdb.Result) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) HttpServletRequest(javax.servlet.http.HttpServletRequest) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext) Test(org.junit.Test)

Aggregations

QueryExecutionEngine (org.neo4j.kernel.impl.query.QueryExecutionEngine)21 Test (org.junit.Test)16 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 TransactionalContext (org.neo4j.kernel.impl.query.TransactionalContext)12 InOrder (org.mockito.InOrder)10 Result (org.neo4j.graphdb.Result)8 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)8 Notification (org.neo4j.graphdb.Notification)7 DependencyResolver (org.neo4j.graphdb.DependencyResolver)3 LogProvider (org.neo4j.logging.LogProvider)3 SyntaxException (org.neo4j.cypher.SyntaxException)2 CommunityCompatibilityFactory (org.neo4j.cypher.internal.CommunityCompatibilityFactory)2 GraphDatabaseCypherService (org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService)2 DeadlockDetectedException (org.neo4j.kernel.DeadlockDetectedException)2 KernelAPI (org.neo4j.kernel.api.KernelAPI)2 Type (org.neo4j.kernel.api.KernelTransaction.Type)2 SecurityContext (org.neo4j.kernel.api.security.SecurityContext)2 LogService (org.neo4j.kernel.impl.logging.LogService)2 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)2 Monitors (org.neo4j.kernel.monitoring.Monitors)2