MongoMigrationHistoryService implements MigrationHistoryService { @Override public Iterable<MigrationEntry> getAllMigrationsApplied() { return getMigramongoCollection().find().sort(new Document("createdAt", 1)).map(d -> mapMigrationEntry(d)); } MongoMigrationHistoryService(MongoDatabase database); @Override MigrationEntry insertMigrationStatusInProgress(MigrationInfo migrationInfo); @Override MigrationEntry insertMigrationStatusSkipped(MigrationInfo migrationInfo); @Override MigrationEntry setMigrationStatusToFailed(MigrationEntry migrationEntry, Exception e); @Override MigrationEntry setMigrationStatusToFinished(MigrationEntry migrationEntry); @Override MigrationEntry setMigrationStatusToManuallyRepaired(MigrationEntry migrationEntry); @Override MigrationEntry getLastMigrationApplied(); @Override Iterable<MigrationEntry> getAllMigrationsApplied(); @Override MigrationEntry findMigration(String fromVersion, String toVersion); @Override Iterable<MigrationEntry> findMigrations(String fromVersion); @Override MigrationEntry addRunToMigrationEntry(MigrationEntry migEntry, MigrationRun migRun); static final String MIGRAMONGO_COLLECTION; }
@Test public void shouldFindAllMigrationEntries() throws Exception { addMigration(new InitialMigrationInfo("1")); addMigration(new MigrationInfo("1", "2")); final List<MigrationEntry> allMigrationsApplied = toList(migrationHistoryService.getAllMigrationsApplied()); assertThat(allMigrationsApplied, hasSize(2)); }
@Test public void shouldNotFindMigrationEntriesIfNoneExist() throws Exception { final List<MigrationEntry> allMigrationsApplied = toList(migrationHistoryService.getAllMigrationsApplied()); assertThat(allMigrationsApplied, hasSize(0)); }