//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void raftIndexIsRecorded() throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RaftIndexIsRecorded() { // given int txLockSessionId = Org.Neo4j.Kernel.impl.locking.Locks_Client_Fields.NO_LOCK_SESSION_ID; long anyTransactionId = 1234; long lastCommittedIndex = 1357; long updatedCommandIndex = 2468; // and ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(txLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); ReplicatedTransaction replicatedTransaction = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); // and TransactionCommitProcess localCommitProcess = CreateFakeTransactionCommitProcess(anyTransactionId); // when stateMachine.InstallCommitProcess(localCommitProcess, lastCommittedIndex); // then assertEquals(lastCommittedIndex, _commandIndexTracker.AppliedCommandIndex); // when stateMachine.ApplyCommand(replicatedTransaction, updatedCommandIndex, result => { }); stateMachine.EnsuredApplied(); // then assertEquals(updatedCommandIndex, _commandIndexTracker.AppliedCommandIndex); }
/* * Tests that we unfreeze active transactions after commit and after apply of batch if batch length (in time) * is larger than safeZone time. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() { // GIVEN int maxBatchSize = 10; long idReuseSafeZoneTime = 100; Dependencies dependencies = mock(typeof(Dependencies)); TransactionObligationFulfiller fulfiller = mock(typeof(TransactionObligationFulfiller)); when(dependencies.ObligationFulfiller()).thenReturn(fulfiller); when(dependencies.LogService()).thenReturn(NullLogService.Instance); when(dependencies.VersionContextSupplier()).thenReturn(EmptyVersionContextSupplier.EMPTY); KernelTransactions kernelTransactions = mock(typeof(KernelTransactions)); when(dependencies.KernelTransactions()).thenReturn(kernelTransactions); TransactionCommitProcess commitProcess = mock(typeof(TransactionCommitProcess)); when(dependencies.CommitProcess()).thenReturn(commitProcess); TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, maxBatchSize, idReuseSafeZoneTime)); // WHEN int txCount = maxBatchSize; int doesNotMatter = 1; unpacker.UnpackResponse(new DummyTransactionResponse(doesNotMatter, txCount, idReuseSafeZoneTime + 1), NO_OP_TX_HANDLER); // THEN InOrder inOrder = inOrder(commitProcess, kernelTransactions); inOrder.verify(commitProcess, times(1)).commit(any(), any(), any()); inOrder.verify(kernelTransactions, times(1)).unblockNewTransactions(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAcceptTransactionCommittedWithNoLockManager() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAcceptTransactionCommittedWithNoLockManager() { // given int txLockSessionId = Org.Neo4j.Kernel.impl.locking.Locks_Client_Fields.NO_LOCK_SESSION_ID; int currentLockSessionId = 24; long txId = 42L; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); TransactionCommitProcess localCommitProcess = CreateFakeTransactionCommitProcess(txId); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(currentLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); AtomicBoolean called = new AtomicBoolean(); // when stateMachine.ApplyCommand(tx, 0, result => { // then called.set(true); try { assertEquals(txId, ( long )result.consume()); } catch (Exception e) { throw new Exception(e); } }); stateMachine.EnsuredApplied(); assertTrue(called.get()); }
public virtual void InstallCommitProcess(TransactionCommitProcess commitProcess, long lastCommittedIndex) { lock (this) { this._commitProcess = commitProcess; this._lastCommittedIndex = lastCommittedIndex; _log.info(format("(%s) Updated lastCommittedIndex to %d", _tokenRegistry.TokenType, lastCommittedIndex)); } }
internal TransactionBatchCommitter(KernelTransactions kernelTransactions, long idReuseSafeZoneTime, TransactionCommitProcess commitProcess, Log log) { Debug.Assert(log != null); this._kernelTransactions = kernelTransactions; this._idReuseSafeZoneTime = idReuseSafeZoneTime; this._commitProcess = commitProcess; this._log = log; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private synchronized void stopWithRequirement(org.neo4j.kernel.availability.AvailabilityRequirement requirement) throws Throwable private void StopWithRequirement(AvailabilityRequirement requirement) { lock (this) { _log.info("Stopping, reason: " + requirement()); RaiseAvailabilityGuard(requirement); _databaseHealth = null; _localCommit = null; _dataSourceManager.stop(); } }
public virtual void InstallCommitProcess(TransactionCommitProcess localCommit) { Debug.Assert(!_runningBatch); long lastAppliedIndex = _consensusLogIndexRecovery.findLastAppliedIndex(); _replicatedTxStateMachine.installCommitProcess(localCommit, lastAppliedIndex); _labelTokenStateMachine.installCommitProcess(localCommit, lastAppliedIndex); _relationshipTypeTokenStateMachine.installCommitProcess(localCommit, lastAppliedIndex); _propertyKeyTokenStateMachine.installCommitProcess(localCommit, lastAppliedIndex); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static TransactionCommitProcess newRememberingCommitProcess(final org.neo4j.kernel.impl.transaction.TransactionRepresentation[] slot) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException //JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: private static TransactionCommitProcess NewRememberingCommitProcess(TransactionRepresentation[] slot) { TransactionCommitProcess commitProcess = mock(typeof(TransactionCommitProcess)); when(commitProcess.Commit(any(typeof(TransactionToApply)), any(typeof(CommitEvent)), any(typeof(TransactionApplicationMode)))).then(invocation => { slot[0] = (( TransactionToApply )invocation.getArgument(0)).TransactionRepresentation(); return(1L); }); return(commitProcess); }
public virtual void InstallCommitProcess(TransactionCommitProcess commitProcess, long lastCommittedIndex) { lock (this) { this._lastCommittedIndex = lastCommittedIndex; _commandIndexTracker.AppliedCommandIndex = lastCommittedIndex; _log.info(format("Updated lastCommittedIndex to %d", lastCommittedIndex)); this._queue = new TransactionQueue(_maxBatchSize, (first, last) => { commitProcess.Commit(first, CommitEvent.NULL, TransactionApplicationMode.EXTERNAL); _pageCursorTracerSupplier.get().reportEvents(); // Report paging metrics for the commit }); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.kernel.impl.api.TransactionCommitProcess createFakeTransactionCommitProcess(long txId) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException private TransactionCommitProcess CreateFakeTransactionCommitProcess(long txId) { TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess)); when(localCommitProcess.Commit(any(typeof(TransactionToApply)), any(typeof(CommitEvent)), any(typeof(TransactionApplicationMode)))).thenAnswer(invocation => { TransactionToApply txToApply = invocation.getArgument(0); txToApply.commitment(new FakeCommitment(txId, mock(typeof(TransactionIdStore))), txId); txToApply.commitment().publishAsCommitted(); txToApply.commitment().publishAsClosed(); txToApply.close(); return(txId); }); return(localCommitProcess); }
private static void Apply(GraphDatabaseAPI db, IList <TransactionRepresentation> transactions) { TransactionCommitProcess committer = Db.DependencyResolver.resolveDependency(typeof(TransactionCommitProcess)); transactions.ForEach(tx => { try { committer.Commit(new TransactionToApply(tx), CommitEvent.NULL, EXTERNAL); } catch (TransactionFailureException e) { throw new Exception(e); } }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailFutureForTransactionCommittedUnderWrongLockSession() public virtual void ShouldFailFutureForTransactionCommittedUnderWrongLockSession() { // given int txLockSessionId = 23; int currentLockSessionId = 24; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(txLockSessionId)); TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(commandIndexTracker, lockState(currentLockSessionId), batchSize, logProvider, org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.NULL, org.neo4j.io.pagecache.tracing.cursor.context.EmptyVersionContextSupplier.EMPTY); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(currentLockSessionId), _batchSize, _logProvider, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); AtomicBoolean called = new AtomicBoolean(); // when stateMachine.ApplyCommand(tx, 0, result => { // then called.set(true); try { result.consume(); fail("should have thrown"); } catch (TransactionFailureException tfe) { assertEquals(Status.Transaction.LockSessionExpired, tfe.status()); } catch (Exception e) { throw new Exception(e); } }); stateMachine.EnsuredApplied(); assertTrue(called.get()); }
private Future <object> ApplyInT2(GraphDatabaseAPI db, IList <TransactionRepresentation> transactions) { TransactionCommitProcess commitProcess = Db.DependencyResolver.resolveDependency(typeof(TransactionCommitProcess)); return(T2.execute(state => { transactions.ForEach(tx => { try { // It will matter if the transactions are supplied all in the same batch or one by one // since the CountsTracker#apply lock is held and released per transaction commitProcess.Commit(new TransactionToApply(tx), NULL, EXTERNAL); } catch (TransactionFailureException e) { throw new Exception(e); } }); return null; })); }
public KernelTransactions(Config config, StatementLocksFactory statementLocksFactory, ConstraintIndexCreator constraintIndexCreator, StatementOperationParts statementOperations, SchemaWriteGuard schemaWriteGuard, TransactionHeaderInformationFactory txHeaderFactory, TransactionCommitProcess transactionCommitProcess, AuxiliaryTransactionStateManager auxTxStateManager, TransactionHooks hooks, TransactionMonitor transactionMonitor, AvailabilityGuard databaseAvailabilityGuard, Tracers tracers, StorageEngine storageEngine, Procedures procedures, TransactionIdStore transactionIdStore, SystemNanoClock clock, AtomicReference <CpuClock> cpuClockRef, AtomicReference <HeapAllocation> heapAllocationRef, AccessCapability accessCapability, AutoIndexing autoIndexing, ExplicitIndexStore explicitIndexStore, VersionContextSupplier versionContextSupplier, CollectionsFactorySupplier collectionsFactorySupplier, ConstraintSemantics constraintSemantics, SchemaState schemaState, IndexingService indexingService, TokenHolders tokenHolders, string currentDatabaseName, Dependencies dataSourceDependencies) { if (!InstanceFieldsInitialized) { InitializeInstanceFields(); InstanceFieldsInitialized = true; } this._config = config; this._statementLocksFactory = statementLocksFactory; this._constraintIndexCreator = constraintIndexCreator; this._statementOperations = statementOperations; this._schemaWriteGuard = schemaWriteGuard; this._transactionHeaderInformationFactory = txHeaderFactory; this._transactionCommitProcess = transactionCommitProcess; this._auxTxStateManager = auxTxStateManager; this._hooks = hooks; this._transactionMonitor = transactionMonitor; this._databaseAvailabilityGuard = databaseAvailabilityGuard; this._tracers = tracers; this._storageEngine = storageEngine; this._procedures = procedures; this._transactionIdStore = transactionIdStore; this._cpuClockRef = cpuClockRef; this._heapAllocationRef = heapAllocationRef; this._accessCapability = accessCapability; this._autoIndexing = autoIndexing; this._explicitIndexStore = explicitIndexStore; this._indexingService = indexingService; this._tokenHolders = tokenHolders; this._currentDatabaseName = currentDatabaseName; this._dataSourceDependencies = dataSourceDependencies; this._versionContextSupplier = versionContextSupplier; this._clock = clock; DoBlockNewTransactions(); this._collectionsFactorySupplier = collectionsFactorySupplier; this._constraintSemantics = constraintSemantics; this._schemaState = schemaState; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCommitTransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCommitTransaction() { // given int lockSessionId = 23; ReplicatedTransaction tx = ReplicatedTransaction.from(PhysicalTx(lockSessionId)); TransactionCommitProcess localCommitProcess = mock(typeof(TransactionCommitProcess)); PageCursorTracer cursorTracer = mock(typeof(PageCursorTracer)); ReplicatedTransactionStateMachine stateMachine = new ReplicatedTransactionStateMachine(_commandIndexTracker, LockState(lockSessionId), _batchSize, _logProvider, () => cursorTracer, EmptyVersionContextSupplier.EMPTY); stateMachine.InstallCommitProcess(localCommitProcess, -1L); // when stateMachine.ApplyCommand(tx, 0, r => { }); stateMachine.EnsuredApplied(); // then verify(localCommitProcess, times(1)).commit(any(typeof(TransactionToApply)), any(typeof(CommitEvent)), any(typeof(TransactionApplicationMode))); verify(cursorTracer, times(1)).reportEvents(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static KernelTransactions newKernelTransactions(TransactionCommitProcess commitProcess) throws Throwable private static KernelTransactions NewKernelTransactions(TransactionCommitProcess commitProcess) { return(newKernelTransactions(false, commitProcess, mock(typeof(StorageReader)))); }
internal virtual void RefreshFromNewStore() { Debug.Assert(_txQueue == null || _txQueue.Empty); _lastQueuedTxId = _txIdStoreSupplier.get().LastCommittedTransactionId; _commitProcess = _commitProcessSupplier.get(); }
private static KernelTransactions NewKernelTransactions(Locks locks, StorageEngine storageEngine, TransactionCommitProcess commitProcess, bool testKernelTransactions) { LifeSupport life = new LifeSupport(); life.Start(); TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore)); when(transactionIdStore.LastCommittedTransaction).thenReturn(new TransactionId(0, 0, 0)); Tracers tracers = new Tracers("null", NullLog.Instance, new Monitors(), mock(typeof(JobScheduler)), _clock); StatementLocksFactory statementLocksFactory = new SimpleStatementLocksFactory(locks); StatementOperationParts statementOperations = mock(typeof(StatementOperationParts)); KernelTransactions transactions; if (testKernelTransactions) { transactions = CreateTestTransactions(storageEngine, commitProcess, transactionIdStore, tracers, statementLocksFactory, statementOperations, _clock, _databaseAvailabilityGuard); } else { transactions = CreateTransactions(storageEngine, commitProcess, transactionIdStore, tracers, statementLocksFactory, statementOperations, _clock, _databaseAvailabilityGuard); } transactions.Start(); return(transactions); }
/// <summary> /// Called by the DataSourceManager during start. /// </summary> public virtual void RegisterCommitProcessDependencies(TransactionAppender appender, StorageEngine applier) { _localCommit = new TransactionRepresentationCommitProcess(appender, applier); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void indexShouldIncludeNodesCreatedPreviouslyInBatch() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void IndexShouldIncludeNodesCreatedPreviouslyInBatch() { // GIVEN a transaction stream leading up to this issue // perform the transactions from db-level and extract the transactions as commands // so that they can be applied batch-wise they way we'd like to later. // a bunch of nodes (to have the index population later on to decide to use label scan for population) IList <TransactionRepresentation> transactions; GraphDatabaseAPI db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabase(); string nodeN = "our guy"; string otherNode = "just to create the tokens"; try { using (Transaction tx = Db.beginTx()) { Db.createNode(_label).setProperty(PROPERTY_KEY, otherNode); for (int i = 0; i < 10_000; i++) { Db.createNode(); } tx.Success(); } // node N using (Transaction tx = Db.beginTx()) { Db.createNode(_label).setProperty(PROPERTY_KEY, nodeN); tx.Success(); } // uniqueness constraint affecting N using (Transaction tx = Db.beginTx()) { Db.schema().constraintFor(_label).assertPropertyIsUnique(PROPERTY_KEY).create(); tx.Success(); } transactions = ExtractTransactions(db); } finally { Db.shutdown(); } db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabase(); TransactionCommitProcess commitProcess = Db.DependencyResolver.resolveDependency(typeof(TransactionCommitProcess)); try { int cutoffIndex = FindCutoffIndex(transactions); commitProcess.Commit(ToApply(transactions.subList(0, cutoffIndex)), NULL, EXTERNAL); // WHEN applying the two transactions (node N and the constraint) in the same batch commitProcess.Commit(ToApply(transactions.subList(cutoffIndex, transactions.Count)), NULL, EXTERNAL); // THEN node N should've ended up in the index too using (Transaction tx = Db.beginTx()) { assertNotNull("Verification node not found", singleOrNull(Db.findNodes(_label, PROPERTY_KEY, otherNode))); // just to verify assertNotNull("Node N not found", singleOrNull(Db.findNodes(_label, PROPERTY_KEY, nodeN))); tx.Success(); } } finally { Db.shutdown(); } }
internal TestKernelTransactions(StatementLocksFactory statementLocksFactory, ConstraintIndexCreator constraintIndexCreator, StatementOperationParts statementOperations, SchemaWriteGuard schemaWriteGuard, TransactionHeaderInformationFactory txHeaderFactory, TransactionCommitProcess transactionCommitProcess, AuxiliaryTransactionStateManager auxTxStateManager, TransactionHooks hooks, TransactionMonitor transactionMonitor, AvailabilityGuard databaseAvailabilityGuard, Tracers tracers, StorageEngine storageEngine, Procedures procedures, TransactionIdStore transactionIdStore, SystemNanoClock clock, AccessCapability accessCapability, AutoIndexing autoIndexing, VersionContextSupplier versionContextSupplier, TokenHolders tokenHolders, Dependencies dataSourceDependencies) : base(Config.defaults(), statementLocksFactory, constraintIndexCreator, statementOperations, schemaWriteGuard, txHeaderFactory, transactionCommitProcess, auxTxStateManager, hooks, transactionMonitor, databaseAvailabilityGuard, tracers, storageEngine, procedures, transactionIdStore, clock, new AtomicReference <CpuClock>(CpuClock.NOT_AVAILABLE), new AtomicReference <HeapAllocation>(HeapAllocation.NOT_AVAILABLE), accessCapability, autoIndexing, mock(typeof(ExplicitIndexStore)), versionContextSupplier, ON_HEAP, new StandardConstraintSemantics(), mock(typeof(SchemaState)), mock(typeof(IndexingService)), tokenHolders, DEFAULT_DATABASE_NAME, dataSourceDependencies) { }
private static TestKernelTransactions CreateTestTransactions(StorageEngine storageEngine, TransactionCommitProcess commitProcess, TransactionIdStore transactionIdStore, Tracers tracers, StatementLocksFactory statementLocksFactory, StatementOperationParts statementOperations, SystemNanoClock clock, AvailabilityGuard databaseAvailabilityGuard) { return(new TestKernelTransactions(statementLocksFactory, null, statementOperations, null, DEFAULT, commitProcess, mock(typeof(AuxiliaryTransactionStateManager)), new TransactionHooks(), mock(typeof(TransactionMonitor)), databaseAvailabilityGuard, tracers, storageEngine, new Procedures(), transactionIdStore, clock, new CanWrite(), AutoIndexing.UNSUPPORTED, EmptyVersionContextSupplier.EMPTY, mockedTokenHolders(), new Dependencies())); }
private static KernelTransactions CreateTransactions(StorageEngine storageEngine, TransactionCommitProcess commitProcess, TransactionIdStore transactionIdStore, Tracers tracers, StatementLocksFactory statementLocksFactory, StatementOperationParts statementOperations, SystemNanoClock clock, AvailabilityGuard databaseAvailabilityGuard) { return(new KernelTransactions(Config.defaults(), statementLocksFactory, null, statementOperations, null, DEFAULT, commitProcess, mock(typeof(AuxiliaryTransactionStateManager)), new TransactionHooks(), mock(typeof(TransactionMonitor)), databaseAvailabilityGuard, tracers, storageEngine, new Procedures(), transactionIdStore, clock, new AtomicReference <CpuClock>(CpuClock.NOT_AVAILABLE), new AtomicReference <HeapAllocation>(HeapAllocation.NOT_AVAILABLE), new CanWrite(), AutoIndexing.UNSUPPORTED, mock(typeof(ExplicitIndexStore)), EmptyVersionContextSupplier.EMPTY, ON_HEAP, mock(typeof(ConstraintSemantics)), mock(typeof(SchemaState)), mock(typeof(IndexingService)), mockedTokenHolders(), DEFAULT_DATABASE_NAME, new Dependencies())); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static KernelTransactions newKernelTransactions(TransactionCommitProcess commitProcess, org.neo4j.storageengine.api.StorageReader firstReader, org.neo4j.storageengine.api.StorageReader... otherReaders) throws Throwable private static KernelTransactions NewKernelTransactions(TransactionCommitProcess commitProcess, StorageReader firstReader, params StorageReader[] otherReaders) { return(NewKernelTransactions(false, commitProcess, firstReader, otherReaders)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static KernelTransactions newKernelTransactions(boolean testKernelTransactions, TransactionCommitProcess commitProcess, org.neo4j.storageengine.api.StorageReader firstReader, org.neo4j.storageengine.api.StorageReader... otherReaders) throws Throwable private static KernelTransactions NewKernelTransactions(bool testKernelTransactions, TransactionCommitProcess commitProcess, StorageReader firstReader, params StorageReader[] otherReaders) { Locks locks = mock(typeof(Locks)); Org.Neo4j.Kernel.impl.locking.Locks_Client client = mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client)); when(locks.NewClient()).thenReturn(client); StorageEngine storageEngine = mock(typeof(StorageEngine)); when(storageEngine.NewReader()).thenReturn(firstReader, otherReaders); doAnswer(invocation => { ICollection <StorageCommand> argument = invocation.getArgument(0); argument.add(mock(typeof(StorageCommand))); return(null); }).when(storageEngine).createCommands(anyCollection(), any(typeof(ReadableTransactionState)), any(typeof(StorageReader)), any(typeof(ResourceLocker)), anyLong(), any(typeof(TxStateVisitor.Decorator))); return(NewKernelTransactions(locks, storageEngine, commitProcess, testKernelTransactions)); }