Search in sources :

Example 16 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class ExtensionContextTest method shouldConsultUnsatisfiedDependencyHandlerOnMissingDependencies.

@Test
void shouldConsultUnsatisfiedDependencyHandlerOnMissingDependencies() {
    GlobalExtensionContext context = mock(GlobalExtensionContext.class);
    ExtensionFailureStrategy handler = mock(ExtensionFailureStrategy.class);
    // that hasn't got anything.
    Dependencies dependencies = new Dependencies();
    TestingExtensionFactory extensionFactory = new TestingExtensionFactory();
    GlobalExtensions extensions = new GlobalExtensions(context, iterable(extensionFactory), dependencies, handler);
    try (Lifespan ignored = new Lifespan(extensions)) {
        verify(handler).handle(eq(extensionFactory), any(UnsatisfiedDependencyException.class));
    }
}
Also used : UnsatisfiedDependencyException(org.neo4j.exceptions.UnsatisfiedDependencyException) Dependencies(org.neo4j.collection.Dependencies) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) GlobalExtensionContext(org.neo4j.kernel.extension.context.GlobalExtensionContext) Test(org.junit.jupiter.api.Test)

Example 17 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class ExtensionContextTest method globalContextRootDirectoryEqualToStoreDirectory.

@Test
void globalContextRootDirectoryEqualToStoreDirectory() {
    GlobalExtensionContext context = new GlobalExtensionContext(neo4jLayout, DbmsInfo.TOOL, new Dependencies());
    assertSame(neo4jLayout.databasesDirectory(), context.directory());
}
Also used : Dependencies(org.neo4j.collection.Dependencies) GlobalExtensionContext(org.neo4j.kernel.extension.context.GlobalExtensionContext) Test(org.junit.jupiter.api.Test)

Example 18 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class ExtensionContextTest method shouldFindDependenciesFromHierarchyBottomUp.

@Test
void shouldFindDependenciesFromHierarchyBottomUp() {
    GlobalExtensionContext context = mock(GlobalExtensionContext.class);
    ExtensionFailureStrategy handler = mock(ExtensionFailureStrategy.class);
    Dependencies dependencies = new Dependencies();
    JobScheduler jobScheduler = mock(JobScheduler.class);
    dependencies.satisfyDependencies(jobScheduler);
    SubTestingExtensionFactory extensionFactory = new SubTestingExtensionFactory();
    GlobalExtensions extensions = new GlobalExtensions(context, iterable(extensionFactory), dependencies, handler);
    try (Lifespan ignored = new Lifespan(extensions)) {
        assertNotNull(dependencies.resolveDependency(TestingExtension.class));
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) Dependencies(org.neo4j.collection.Dependencies) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) GlobalExtensionContext(org.neo4j.kernel.extension.context.GlobalExtensionContext) Test(org.junit.jupiter.api.Test)

Example 19 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class NonUniqueIndexTest method newEmbeddedGraphDatabaseWithSlowJobScheduler.

private GraphDatabaseService newEmbeddedGraphDatabaseWithSlowJobScheduler() {
    // Inject JobScheduler
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependencies(createJobScheduler());
    managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setExternalDependencies(dependencies).build();
    return managementService.database(GraphDatabaseSettings.DEFAULT_DATABASE_NAME);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Dependencies(org.neo4j.collection.Dependencies)

Example 20 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class OperationsTest method setUp.

@BeforeEach
void setUp() throws Exception {
    TxState realTxState = new TxState();
    txState = Mockito.spy(realTxState);
    when(transaction.getReasonIfTerminated()).thenReturn(Optional.empty());
    when(transaction.lockClient()).thenReturn(locks);
    when(transaction.dataWrite()).thenReturn(write);
    when(transaction.isOpen()).thenReturn(true);
    when(transaction.lockTracer()).thenReturn(LockTracer.NONE);
    when(transaction.txState()).thenReturn(txState);
    when(transaction.securityContext()).thenReturn(SecurityContext.authDisabled(AccessMode.Static.FULL, EMBEDDED_CONNECTION, DB_NAME));
    logHelper = new SecurityLogHelper(getFormat());
    securityLog = new CommunitySecurityLog((LogExtended) logHelper.getLogProvider().getLog(this.getClass()));
    when(transaction.securityAuthorizationHandler()).thenReturn(new SecurityAuthorizationHandler(securityLog));
    DefaultPooledCursors cursors = mock(DefaultPooledCursors.class);
    nodeCursor = mock(FullAccessNodeCursor.class);
    propertyCursor = mock(FullAccessPropertyCursor.class);
    relationshipCursor = mock(DefaultRelationshipScanCursor.class);
    when(cursors.allocateFullAccessNodeCursor(NULL)).thenReturn(nodeCursor);
    when(cursors.allocateFullAccessPropertyCursor(NULL, INSTANCE)).thenReturn(propertyCursor);
    when(cursors.allocateRelationshipScanCursor(NULL)).thenReturn(relationshipCursor);
    StorageEngine engine = mock(StorageEngine.class);
    storageReader = mock(StorageReader.class);
    storageReaderSnapshot = mock(StorageSchemaReader.class);
    when(storageReader.nodeExists(anyLong(), any())).thenReturn(true);
    when(storageReader.constraintsGetForLabel(anyInt())).thenReturn(Collections.emptyIterator());
    when(storageReader.constraintsGetAll()).thenReturn(Collections.emptyIterator());
    when(storageReader.schemaSnapshot()).thenReturn(storageReaderSnapshot);
    when(engine.newReader()).thenReturn(storageReader);
    indexingService = mock(IndexingService.class);
    Dependencies dependencies = new Dependencies();
    var facade = mock(GraphDatabaseFacade.class);
    dependencies.satisfyDependency(facade);
    allStoreHolder = new AllStoreHolder(storageReader, transaction, cursors, mock(GlobalProcedures.class), mock(SchemaState.class), indexingService, mock(IndexStatisticsStore.class), dependencies, Config.defaults(), INSTANCE);
    constraintIndexCreator = mock(ConstraintIndexCreator.class);
    tokenHolders = mockedTokenHolders();
    creationContext = mock(CommandCreationContext.class);
    IndexingProvidersService indexingProvidersService = mock(IndexingProvidersService.class);
    when(indexingProvidersService.indexProviderByName("native-btree-1.0")).thenReturn(GenericNativeIndexProvider.DESCRIPTOR);
    when(indexingProvidersService.getDefaultProvider()).thenReturn(GenericNativeIndexProvider.DESCRIPTOR);
    when(indexingProvidersService.indexProviderByName("fulltext-1.0")).thenReturn(FulltextIndexProviderFactory.DESCRIPTOR);
    when(indexingProvidersService.getFulltextProvider()).thenReturn(FulltextIndexProviderFactory.DESCRIPTOR);
    when(indexingProvidersService.indexProviderByName("provider-1.0")).thenReturn(new IndexProviderDescriptor("provider", "1.0"));
    when(indexingProvidersService.completeConfiguration(any())).thenAnswer(inv -> inv.getArgument(0));
    operations = new Operations(allStoreHolder, storageReader, mock(IndexTxStateUpdater.class), creationContext, transaction, new KernelToken(storageReader, creationContext, transaction, tokenHolders), cursors, constraintIndexCreator, mock(ConstraintSemantics.class), indexingProvidersService, Config.defaults(), INSTANCE, () -> KernelVersion.LATEST, mock(DbmsRuntimeRepository.class));
    operations.initialize(NULL);
    this.order = inOrder(locks, txState, storageReader, storageReaderSnapshot, creationContext);
}
Also used : StorageReader(org.neo4j.storageengine.api.StorageReader) CommunitySecurityLog(org.neo4j.internal.kernel.api.security.CommunitySecurityLog) IndexingProvidersService(org.neo4j.kernel.impl.api.index.IndexingProvidersService) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) SecurityLogHelper(org.neo4j.logging.SecurityLogHelper) LogExtended(org.neo4j.logging.log4j.LogExtended) StorageEngine(org.neo4j.storageengine.api.StorageEngine) SecurityAuthorizationHandler(org.neo4j.internal.kernel.api.security.SecurityAuthorizationHandler) CommandCreationContext(org.neo4j.storageengine.api.CommandCreationContext) ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) TxState(org.neo4j.kernel.impl.api.state.TxState) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) Dependencies(org.neo4j.collection.Dependencies) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Dependencies (org.neo4j.collection.Dependencies)40 Test (org.junit.jupiter.api.Test)13 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)7 Config (org.neo4j.configuration.Config)6 Monitors (org.neo4j.monitoring.Monitors)6 PageCache (org.neo4j.io.pagecache.PageCache)5 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)5 DatabaseHealth (org.neo4j.monitoring.DatabaseHealth)5 StorageEngine (org.neo4j.storageengine.api.StorageEngine)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)4 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)4 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)4 Database (org.neo4j.kernel.database.Database)4 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)4 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)4 IOException (java.io.IOException)3 RecoveryCleanupWorkCollector (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)3 GlobalExtensionContext (org.neo4j.kernel.extension.context.GlobalExtensionContext)3 IndexStatisticsStore (org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore)3