### Question:
DbMigrationService { public void migrateDatabase() { String databaseUrl = database.getUrl(); String databaseSchema = database.getProperties().getOrDefault("currentSchema", "public"); LOG.info( "Starting database migration for schema {} using database {}", databaseSchema, databaseUrl); Configuration configuration = new FluentConfiguration() .dataSource(databaseUrl, database.getUser(), database.getPassword()) .schemas(databaseSchema); Flyway flyway = new Flyway(configuration); flyway.migrate(); LOG.info("Database migration successful."); } DbMigrationService(DataSourceFactory database); void migrateDatabase(); static final String DEFAULT_COMMAND_NAME; static final String DEFAULT_COMMAND_DOC; }### Answer:
@Test public void testDBMigration() throws Exception { DataSourceFactory dataSourceFactory = new DataSourceFactory(); dataSourceFactory.setUrl(DB_URL); dataSourceFactory.setUser("sa"); dataSourceFactory.setPassword("sa"); new DbMigrationService(dataSourceFactory).migrateDatabase(); Connection connection = ((SessionImpl) daoTestRule.getSessionFactory().getCurrentSession()).connection(); ResultSet tables = connection.getMetaData().getTables("", "public", "flyway_schema_history", null); assertTrue("Expect a result for schema_version", tables.first()); }