@Test void partialMigrationShouldAbortMigrations() throws InterruptedException { InMemorySchemaDAO schemaVersionDAO = new InMemorySchemaDAO(OLDER_VERSION); Task failingTask = mock(Task.class); when(failingTask.run()).thenThrow(MigrationException.class); Migration migration1 = failingTask::run; Migration migration2 = mock(Migration.class); CassandraSchemaTransitions transitions = new CassandraSchemaTransitions(ImmutableMap.of( FROM_OLDER_TO_CURRENT, migration1, FROM_CURRENT_TO_LATEST, migration2)); testee = new CassandraMigrationService(schemaVersionDAO, transitions, version -> new MigrationTask(schemaVersionDAO, transitions, version), LATEST_VERSION); assertThatThrownBy(() -> testee.upgradeToVersion(LATEST_VERSION).run()) .isInstanceOf(MigrationException.class); verify(failingTask, times(1)).run(); verifyNoMoreInteractions(failingTask); verifyZeroInteractions(migration2); }
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; }