public virtual NeoStoreDataSource GetDataSource(DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, DependencyResolver otherCustomOverriddenDependencies) { ShutdownAnyRunning(); StatementLocksFactory locksFactory = mock(typeof(StatementLocksFactory)); StatementLocks statementLocks = mock(typeof(StatementLocks)); Org.Neo4j.Kernel.impl.locking.Locks_Client locks = mock(typeof(Org.Neo4j.Kernel.impl.locking.Locks_Client)); when(statementLocks.Optimistic()).thenReturn(locks); when(statementLocks.Pessimistic()).thenReturn(locks); when(locksFactory.NewInstance()).thenReturn(statementLocks); JobScheduler jobScheduler = mock(typeof(JobScheduler), RETURNS_MOCKS); Monitors monitors = new Monitors(); Dependencies mutableDependencies = new Dependencies(otherCustomOverriddenDependencies); // Satisfy non-satisfied dependencies Config config = Dependency(mutableDependencies, typeof(Config), deps => Config.defaults()); config.augment(default_schema_provider, EMPTY.ProviderDescriptor.name()); LogService logService = Dependency(mutableDependencies, typeof(LogService), deps => new SimpleLogService(NullLogProvider.Instance)); IdGeneratorFactory idGeneratorFactory = Dependency(mutableDependencies, typeof(IdGeneratorFactory), deps => new DefaultIdGeneratorFactory(fs)); IdTypeConfigurationProvider idConfigurationProvider = Dependency(mutableDependencies, typeof(IdTypeConfigurationProvider), deps => new CommunityIdTypeConfigurationProvider()); DatabaseHealth databaseHealth = Dependency(mutableDependencies, typeof(DatabaseHealth), deps => new DatabaseHealth(mock(typeof(DatabasePanicEventGenerator)), NullLog.Instance)); SystemNanoClock clock = Dependency(mutableDependencies, typeof(SystemNanoClock), deps => Clocks.nanoClock()); TransactionMonitor transactionMonitor = Dependency(mutableDependencies, typeof(TransactionMonitor), deps => new DatabaseTransactionStats()); DatabaseAvailabilityGuard databaseAvailabilityGuard = Dependency(mutableDependencies, typeof(DatabaseAvailabilityGuard), deps => new DatabaseAvailabilityGuard(DEFAULT_DATABASE_NAME, deps.resolveDependency(typeof(SystemNanoClock)), NullLog.Instance)); Dependency(mutableDependencies, typeof(DiagnosticsManager), deps => new DiagnosticsManager(NullLog.Instance)); Dependency(mutableDependencies, typeof(IndexProvider), deps => EMPTY); _dataSource = new NeoStoreDataSource(new TestDatabaseCreationContext(DEFAULT_DATABASE_NAME, databaseLayout, config, idGeneratorFactory, logService, mock(typeof(JobScheduler), RETURNS_MOCKS), mock(typeof(TokenNameLookup)), mutableDependencies, mockedTokenHolders(), locksFactory, mock(typeof(SchemaWriteGuard)), mock(typeof(TransactionEventHandlers)), IndexingService.NO_MONITOR, fs, transactionMonitor, databaseHealth, mock(typeof(LogFileCreationMonitor)), TransactionHeaderInformationFactory.DEFAULT, new CommunityCommitProcessFactory(), mock(typeof(InternalAutoIndexing)), mock(typeof(IndexConfigStore)), mock(typeof(ExplicitIndexProvider)), pageCache, new StandardConstraintSemantics(), monitors, new Tracers("null", NullLog.Instance, monitors, jobScheduler, clock), mock(typeof(Procedures)), Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited, databaseAvailabilityGuard, clock, new CanWrite(), new StoreCopyCheckPointMutex(), RecoveryCleanupWorkCollector.immediate(), new BufferedIdController(new BufferingIdGeneratorFactory(idGeneratorFactory, Org.Neo4j.Kernel.impl.store.id.IdReuseEligibility_Fields.Always, idConfigurationProvider), jobScheduler), DatabaseInfo.COMMUNITY, new TransactionVersionContextSupplier(), ON_HEAP, Collections.emptyList(), file => EMPTY_WATCHER, new GraphDatabaseFacade(), Iterables.empty())); return(_dataSource); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void loadSimpleStatementLocksFactoryWhenNoServices() public virtual void LoadSimpleStatementLocksFactoryWhenNoServices() { Locks locks = mock(typeof(Locks)); Locks_Client locksClient = mock(typeof(Locks_Client)); when(locks.NewClient()).thenReturn(locksClient); StatementLocksFactorySelector loader = NewLoader(locks); StatementLocksFactory factory = loader.Select(); StatementLocks statementLocks = factory.NewInstance(); assertThat(factory, instanceOf(typeof(SimpleStatementLocksFactory))); assertThat(statementLocks, instanceOf(typeof(SimpleStatementLocks))); assertSame(locksClient, statementLocks.Optimistic()); assertSame(locksClient, statementLocks.Pessimistic()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void newInstanceCreatesDeferredLocksWhenConfigSet() public virtual void NewInstanceCreatesDeferredLocksWhenConfigSet() { Locks locks = mock(typeof(Locks)); Locks_Client client = mock(typeof(Locks_Client)); when(locks.NewClient()).thenReturn(client); Config config = Config.defaults(deferred_locks_enabled, Settings.TRUE); DeferringStatementLocksFactory factory = new DeferringStatementLocksFactory(); factory.Initialize(locks, config); StatementLocks statementLocks = factory.NewInstance(); assertThat(statementLocks, instanceOf(typeof(DeferringStatementLocks))); assertThat(statementLocks.Optimistic(), instanceOf(typeof(DeferringLockClient))); assertSame(client, statementLocks.Pessimistic()); }