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));
}
Aggregations