@Before public void before() throws Exception { collectionsFactory = Mockito.spy( new TestCollectionsFactory() ); when( headerInformation.getAdditionalHeader() ).thenReturn( new byte[0] ); when( headerInformationFactory.create() ).thenReturn( headerInformation ); when( neoStores.getMetaDataStore() ).thenReturn( metaDataStore ); when( storageEngine.newReader() ).thenReturn( readLayer ); doAnswer( invocation -> ((Collection<StorageCommand>) invocation.getArgument(0) ).add( new Command .RelationshipCountsCommand( 1, 2,3, 4L ) ) ) .when( storageEngine ).createCommands( anyCollection(), any( ReadableTransactionState.class ), any( StorageReader.class ), any( ResourceLocker.class ), anyLong(), any( TxStateVisitor.Decorator.class ) ); }
private static KernelTransactions newKernelTransactions( boolean testKernelTransactions, TransactionCommitProcess commitProcess, StorageReader firstReader, StorageReader... otherReaders ) throws Throwable { Locks locks = mock( Locks.class ); Locks.Client client = mock( Locks.Client.class ); when( locks.newClient() ).thenReturn( client ); StorageEngine storageEngine = mock( StorageEngine.class ); when( storageEngine.newReader() ).thenReturn( firstReader, otherReaders ); doAnswer( invocation -> { Collection<StorageCommand> argument = invocation.getArgument( 0 ); argument.add( mock( StorageCommand.class ) ); return null; } ).when( storageEngine ).createCommands( anyCollection(), any( ReadableTransactionState.class ), any( StorageReader.class ), any( ResourceLocker.class ), anyLong(), any( TxStateVisitor.Decorator.class ) ); return newKernelTransactions( locks, storageEngine, commitProcess, testKernelTransactions ); }
StorageEngine storageEngine = mock( StorageEngine.class ); StorageReader storageReader = mock( StorageReader.class ); when( storageEngine.newReader() ).thenReturn( storageReader );
when( storageReader.constraintsGetForLabel( anyInt() )).thenReturn( Collections.emptyIterator() ); when( storageReader.constraintsGetAll() ).thenReturn( Collections.emptyIterator() ); when( engine.newReader() ).thenReturn( storageReader ); allStoreHolder = new AllStoreHolder( storageReader, transaction, cursors, mock( ExplicitIndexStore.class ), mock( Procedures.class ), mock( SchemaState.class ), new Dependencies() );
static Instances kernelTransactionWithInternals( LoginContext loginContext ) { TransactionHeaderInformation headerInformation = new TransactionHeaderInformation( -1, -1, new byte[0] ); TransactionHeaderInformationFactory headerInformationFactory = mock( TransactionHeaderInformationFactory.class ); when( headerInformationFactory.create() ).thenReturn( headerInformation ); StorageEngine storageEngine = mock( StorageEngine.class ); StorageReader storageReader = mock( StorageReader.class ); when( storageEngine.newReader() ).thenReturn( storageReader ); KernelTransactionImplementation transaction = new KernelTransactionImplementation( Config.defaults(), mock( StatementOperationParts.class ), mock( SchemaWriteGuard.class ), new TransactionHooks(), mock( ConstraintIndexCreator.class ), new Procedures(), headerInformationFactory, mock( TransactionRepresentationCommitProcess.class ), mock( TransactionMonitor.class ), mock( AuxiliaryTransactionStateManager.class ), mock( Pool.class ), Clocks.systemClock(), new AtomicReference<>( CpuClock.NOT_AVAILABLE ), new AtomicReference<>( HeapAllocation.NOT_AVAILABLE ), NULL, LockTracer.NONE, PageCursorTracerSupplier.NULL, storageEngine, new CanWrite(), AutoIndexing.UNSUPPORTED, mock( ExplicitIndexStore.class ), EmptyVersionContextSupplier.EMPTY, ON_HEAP, new StandardConstraintSemantics(), mock( SchemaState.class ), mock( IndexingService.class ), mockedTokenHolders(), new Dependencies() ); StatementLocks statementLocks = new SimpleStatementLocks( new NoOpClient() ); transaction.initialize( 0, 0, statementLocks, KernelTransaction.Type.implicit, loginContext.authorize( s -> -1, GraphDatabaseSettings.DEFAULT_DATABASE_NAME ), 0L, 1L ); return new Instances( transaction ); }
@SuppressWarnings( "deprecation" ) @Before public void before() { db = (GraphDatabaseAPI) createGraphDatabase(); DependencyResolver resolver = db.getDependencyResolver(); this.storageReader = resolver.resolveDependency( StorageEngine.class ).newReader(); this.state = new KernelStatement( null, null, storageReader, LockTracer.NONE, null, new ClockContext(), EmptyVersionContextSupplier.EMPTY ); }
private void initializeStores( DatabaseLayout databaseLayout, Map<String,String> additionalConfig ) throws IOException { Dependencies dependencies = new Dependencies(); dependencies.satisfyDependency( Config.defaults( additionalConfig ) ); ds = dsRule.getDataSource( databaseLayout, fs.get(), pageCache, dependencies ); ds.start(); NeoStores neoStores = ds.getDependencyResolver() .resolveDependency( RecordStorageEngine.class ).testAccessNeoStores(); pStore = neoStores.getPropertyStore(); rtStore = neoStores.getRelationshipTypeTokenStore(); relStore = neoStores.getRelationshipStore(); nodeStore = neoStores.getNodeStore(); storageReader = ds.getDependencyResolver().resolveDependency( StorageEngine.class ).newReader(); }