@Test void upgradeToVersionShouldUpdateIntermediarySuccessfulMigrationsInCaseOfError() throws InterruptedException { try { CassandraSchemaTransitions transitions = new CassandraSchemaTransitions(ImmutableMap.of( FROM_OLDER_TO_CURRENT, successfulMigration, FROM_CURRENT_TO_LATEST, () -> { throw new RuntimeException(); })); testee = new CassandraMigrationService(schemaVersionDAO, transitions, version -> new MigrationTask(schemaVersionDAO, transitions, version), LATEST_VERSION); when(schemaVersionDAO.getCurrentSchemaVersion()).thenReturn(Mono.just(Optional.of(OLDER_VERSION))); assertThatThrownBy(() -> testee.upgradeToVersion(LATEST_VERSION).run()) .isInstanceOf(RuntimeException.class); } finally { verify(schemaVersionDAO).updateVersion(CURRENT_VERSION); } }
public Task upgradeToVersion(SchemaVersion target) { checkTarget(target); return taskFactory.create(target); }
CassandraMigrationService { public Task upgradeToVersion(SchemaVersion target) { checkTarget(target); return taskFactory.create(target); } }
CassandraMigrationService { public Task upgradeToVersion(SchemaVersion target) { checkTarget(target); return taskFactory.create(target); } @Inject  CassandraMigrationService(CassandraSchemaVersionDAO schemaVersionDAO, CassandraSchemaTransitions transitions,
                                     MigrationTask.Factory factory, @Named(LATEST_VERSION) SchemaVersion latestVersion); }
CassandraMigrationService { public Task upgradeToVersion(SchemaVersion target) { checkTarget(target); return taskFactory.create(target); } @Inject  CassandraMigrationService(CassandraSchemaVersionDAO schemaVersionDAO, CassandraSchemaTransitions transitions,
                                     MigrationTask.Factory factory, @Named(LATEST_VERSION) SchemaVersion latestVersion); Optional<SchemaVersion> getCurrentVersion(); Optional<SchemaVersion> getLatestVersion(); Task upgradeToVersion(SchemaVersion target); Task upgradeToLastVersion(); }
CassandraMigrationService { public Task upgradeToVersion(SchemaVersion target) { checkTarget(target); return taskFactory.create(target); } @Inject  CassandraMigrationService(CassandraSchemaVersionDAO schemaVersionDAO, CassandraSchemaTransitions transitions,
                                     MigrationTask.Factory factory, @Named(LATEST_VERSION) SchemaVersion latestVersion); Optional<SchemaVersion> getCurrentVersion(); Optional<SchemaVersion> getLatestVersion(); Task upgradeToVersion(SchemaVersion target); Task upgradeToLastVersion(); static final String LATEST_VERSION; }