private KernelTransactionImplementation CreateTransaction() { KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation)); try { TransactionHeaderInformation headerInformation = new TransactionHeaderInformation(-1, -1, new sbyte[0]); TransactionHeaderInformationFactory headerInformationFactory = mock(typeof(TransactionHeaderInformationFactory)); when(headerInformationFactory.Create()).thenReturn(headerInformation); StorageEngine storageEngine = mock(typeof(StorageEngine)); StorageReader storageReader = mock(typeof(StorageReader)); when(storageEngine.NewReader()).thenReturn(storageReader); SimpleStatementLocks locks = new SimpleStatementLocks(mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client))); when(transaction.StatementLocks()).thenReturn(locks); when(transaction.TokenRead()).thenReturn(_tokenRead); when(transaction.SchemaRead()).thenReturn(_schemaRead); when(transaction.SchemaWrite()).thenReturn(_schemaWrite); TransactionState transactionState = mock(typeof(TransactionState)); when(transaction.TxState()).thenReturn(transactionState); when(transaction.IndexUniqueCreate(any(typeof(SchemaDescriptor)), any(typeof(string)))).thenAnswer(i => IndexDescriptorFactory.uniqueForSchema(i.getArgument(0))); } catch (InvalidTransactionTypeKernelException) { fail("Expected write transaction"); } catch (SchemaKernelException e) { throw new Exception(e); } return(transaction); }
internal virtual TransactionToApply NextTransaction(long txId) { PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(CreateRandomCommands()); TransactionHeaderInformation headerInfo = DEFAULT.create(); representation.SetHeader(headerInfo.AdditionalHeader, headerInfo.MasterId, headerInfo.AuthorId, headerInfo.AuthorId, txId, currentTimeMillis(), 42); return(new TransactionToApply(representation)); }