Search in sources :

Example 76 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class ReadTracingIT method tracePageCacheAccessOnNodeCountByLabel.

@Test
void tracePageCacheAccessOnNodeCountByLabel() {
    try (InternalTransaction transaction = (InternalTransaction) database.beginTx()) {
        var kernelTransaction = transaction.kernelTransaction();
        var cursorContext = kernelTransaction.cursorContext();
        var dataRead = kernelTransaction.dataRead();
        assertZeroCursor(cursorContext);
        dataRead.countsForNode(0);
        assertOneCursor(cursorContext);
    }
}
Also used : InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Test(org.junit.jupiter.api.Test)

Example 77 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class ReadTracingIT method tracePageCacheAccessOnRelationshipWithoutTxStateCount.

@Test
void tracePageCacheAccessOnRelationshipWithoutTxStateCount() {
    try (InternalTransaction transaction = (InternalTransaction) database.beginTx()) {
        var kernelTransaction = transaction.kernelTransaction();
        var cursorContext = kernelTransaction.cursorContext();
        var dataRead = kernelTransaction.dataRead();
        assertZeroCursor(cursorContext);
        dataRead.countsForRelationshipWithoutTxState(ANY_LABEL, ANY_RELATIONSHIP_TYPE, ANY_LABEL);
        assertOneCursor(cursorContext);
    }
}
Also used : InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Test(org.junit.jupiter.api.Test)

Example 78 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class Neo4jTransactionalContextTest method shouldBePossibleToCloseAfterTermination.

@Test
void shouldBePossibleToCloseAfterTermination() {
    InternalTransaction tx = mock(InternalTransaction.class);
    when(tx.transactionType()).thenReturn(KernelTransaction.Type.IMPLICIT);
    Neo4jTransactionalContext context = newContext(tx);
    context.terminate();
    verify(tx).terminate();
    verify(tx, never()).close();
    context.close();
}
Also used : InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Test(org.junit.jupiter.api.Test)

Example 79 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class Neo4jTransactionalContextTest method setUpMocks.

private void setUpMocks() {
    queryService = mock(GraphDatabaseQueryService.class);
    DependencyResolver resolver = mock(DependencyResolver.class);
    statement = mock(KernelStatement.class);
    statistics = new ConfiguredExecutionStatistics();
    QueryRegistry queryRegistry = mock(QueryRegistry.class);
    InternalTransaction internalTransaction = mock(InternalTransaction.class);
    when(internalTransaction.terminationReason()).thenReturn(Optional.empty());
    when(statement.queryRegistration()).thenReturn(queryRegistry);
    when(queryService.getDependencyResolver()).thenReturn(resolver);
    when(queryService.beginTransaction(any(), any(), any())).thenReturn(internalTransaction);
    KernelTransaction mockTransaction = mockTransaction(statement);
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) QueryRegistry(org.neo4j.kernel.api.QueryRegistry) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) DependencyResolver(org.neo4j.common.DependencyResolver)

Example 80 with InternalTransaction

use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.

the class Neo4jTransactionalContextTest method shouldNotCloseTransactionDuringTermination.

@Test
void shouldNotCloseTransactionDuringTermination() {
    InternalTransaction tx = mock(InternalTransaction.class);
    when(tx.transactionType()).thenReturn(KernelTransaction.Type.IMPLICIT);
    Neo4jTransactionalContext context = newContext(tx);
    context.terminate();
    verify(tx).terminate();
    verify(tx, never()).close();
}
Also used : InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Test(org.junit.jupiter.api.Test)

Aggregations

InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)126 Transaction (org.neo4j.graphdb.Transaction)58 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)53 Test (org.junit.jupiter.api.Test)46 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 MethodSource (org.junit.jupiter.params.provider.MethodSource)18 Node (org.neo4j.graphdb.Node)16 NodeValueIndexCursor (org.neo4j.internal.kernel.api.NodeValueIndexCursor)15 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)12 Result (org.neo4j.graphdb.Result)12 TokenRead (org.neo4j.internal.kernel.api.TokenRead)11 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)10 IndexReadSession (org.neo4j.internal.kernel.api.IndexReadSession)8 ExecutingQuery (org.neo4j.kernel.api.query.ExecutingQuery)7 Relationship (org.neo4j.graphdb.Relationship)6 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)6 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)6 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)6 ReturnsDeepStubs (org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs)5