org.arquillian.ape.rdbms.flyway.FlywayPopulatorService Maven / Gradle / Ivy
package org.arquillian.ape.rdbms.flyway;
import java.net.URI;
import java.util.List;
import java.util.Map;
import org.arquillian.ape.rdbms.core.RdbmsPopulatorService;
class FlywayPopulatorService implements RdbmsPopulatorService {
private org.flywaydb.core.Flyway flyway = new org.flywaydb.core.Flyway();
@Override
public void connect(URI jdbc, String username, String password, Class> driver, Map customOptions) {
this.flyway.setDataSource(jdbc.toString(),username, password);
final FlywayOptions flywayOptions = new FlywayOptions(customOptions);
flywayOptions.configure(this.flyway);
}
@Override
public void disconnect() {
}
@Override
public void execute(List resources) {
this.flyway.setLocations(resources.toArray(new String[resources.size()]));
this.flyway.migrate();
}
@Override
public void clean(List resources) {
flyway.clean();
}
@Override
public Class getPopulatorAnnotation() {
return Flyway.class;
}
}