Search in sources :

Example 1 with DbmsRuntimeRepository

use of org.neo4j.dbms.database.DbmsRuntimeRepository in project neo4j by neo4j.

the class DatabaseUpgradeTransactionHandlerTest method init.

private void init(KernelVersion initialKernelVersion, DbmsRuntimeVersion initialDbmsRuntimeVersion) {
    setKernelVersion(initialKernelVersion);
    setDbmsRuntime(initialDbmsRuntimeVersion);
    StorageEngine storageEngine = mock(StorageEngine.class);
    doAnswer(inv -> {
        KernelVersion toKernelVersion = inv.getArgument(0, KernelVersion.class);
        registeredTransactions.add(new RegisteredTransaction(toKernelVersion, true));
        return List.of(new FakeKernelVersionUpgradeCommand(toKernelVersion));
    }).when(storageEngine).createUpgradeCommands(any(), any());
    DbmsRuntimeRepository dbmsRuntimeRepository = mock(DbmsRuntimeRepository.class);
    doAnswer(inv -> currentDbmsRuntimeVersion).when(dbmsRuntimeRepository).getVersion();
    KernelVersionRepository kernelVersionRepository = this::getKernelVersion;
    DatabaseTransactionEventListeners databaseTransactionEventListeners = mock(DatabaseTransactionEventListeners.class);
    doAnswer(inv -> listener = inv.getArgument(0, InternalTransactionEventListener.class)).when(databaseTransactionEventListeners).registerTransactionEventListener(any());
    doAnswer(inv -> listenerUnregistered = true).when(databaseTransactionEventListeners).unregisterTransactionEventListener(any());
    DatabaseUpgradeTransactionHandler handler = new DatabaseUpgradeTransactionHandler(storageEngine, dbmsRuntimeRepository, kernelVersionRepository, databaseTransactionEventListeners, lock, logProvider);
    handler.registerUpgradeListener(commands -> setKernelVersion(((FakeKernelVersionUpgradeCommand) commands.iterator().next()).version));
}
Also used : KernelVersion(org.neo4j.kernel.KernelVersion) DbmsRuntimeRepository(org.neo4j.dbms.database.DbmsRuntimeRepository) DatabaseTransactionEventListeners(org.neo4j.kernel.internal.event.DatabaseTransactionEventListeners) StorageEngine(org.neo4j.storageengine.api.StorageEngine) KernelVersionRepository(org.neo4j.storageengine.api.KernelVersionRepository)

Aggregations

DbmsRuntimeRepository (org.neo4j.dbms.database.DbmsRuntimeRepository)1 KernelVersion (org.neo4j.kernel.KernelVersion)1 DatabaseTransactionEventListeners (org.neo4j.kernel.internal.event.DatabaseTransactionEventListeners)1 KernelVersionRepository (org.neo4j.storageengine.api.KernelVersionRepository)1 StorageEngine (org.neo4j.storageengine.api.StorageEngine)1