use of org.flywaydb.core.api.resolver.MigrationResolver in project flyway by flyway.
the class CompositeMigrationResolverSmallTest method resolveMigrationsMultipleLocations.
@Test
public void resolveMigrationsMultipleLocations() {
FlywayConfigurationForTests config = FlywayConfigurationForTests.create();
PlaceholderReplacer placeholderReplacer = new PlaceholderReplacer(new HashMap<String, String>(), "${", "}");
MigrationResolver migrationResolver = new CompositeMigrationResolver(null, new Scanner(Thread.currentThread().getContextClassLoader()), config, new Locations("migration/subdir/dir2", "migration.outoforder", "migration/subdir/dir1"), placeholderReplacer, new MyCustomMigrationResolver());
Collection<ResolvedMigration> migrations = migrationResolver.resolveMigrations();
List<ResolvedMigration> migrationList = new ArrayList<ResolvedMigration>(migrations);
assertEquals(4, migrations.size());
assertEquals("First", migrationList.get(0).getDescription());
assertEquals("Late arrivals", migrationList.get(1).getDescription());
assertEquals("Virtual Migration", migrationList.get(2).getDescription());
assertEquals("Add foreign key", migrationList.get(3).getDescription());
}
use of org.flywaydb.core.api.resolver.MigrationResolver in project flyway by flyway.
the class CompositeMigrationResolverSmallTest method collectMigrationsExactDuplicatesInDifferentLocations.
/**
* Checks that migrations are properly collected, eliminating all exact duplicates.
*/
@Test
public void collectMigrationsExactDuplicatesInDifferentLocations() {
MigrationResolver migrationResolver = new MigrationResolver() {
public List<ResolvedMigration> resolveMigrations() {
ResolvedMigrationImpl testMigration = createTestMigration(MigrationType.SQL, "2", "Description2", "Migration2", 1234);
testMigration.setPhysicalLocation("abc");
ResolvedMigrationImpl testMigration2 = createTestMigration(MigrationType.SQL, "2", "Description2", "Migration2", 1234);
testMigration2.setPhysicalLocation("xyz");
List<ResolvedMigration> migrations = new ArrayList<ResolvedMigration>();
migrations.add(testMigration);
migrations.add(testMigration2);
return migrations;
}
};
MigrationResolver migrationResolver2 = new MigrationResolver() {
public List<ResolvedMigration> resolveMigrations() {
List<ResolvedMigration> migrations = new ArrayList<ResolvedMigration>();
ResolvedMigrationImpl testMigration = createTestMigration(MigrationType.SQL, "2", "Description2", "Migration2", 1234);
testMigration.setPhysicalLocation("def");
migrations.add(testMigration);
return migrations;
}
};
Collection<MigrationResolver> migrationResolvers = Arrays.asList(migrationResolver, migrationResolver2);
Collection<ResolvedMigration> migrations = CompositeMigrationResolver.collectMigrations(migrationResolvers);
assertEquals(1, migrations.size());
}
Aggregations