/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.opentable.db.postgres.embedded;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.flywaydb.core.Flyway;

public class FlywayPreparer implements DatabasePreparer {

    private final Flyway flyway;

    public static FlywayPreparer forClasspathLocation(String... locations) {
        Flyway f = new Flyway();
        f.setLocations(locations);
        return new FlywayPreparer(f);
    }

    private FlywayPreparer(Flyway flyway) {
        this.flyway = flyway;
    }

    @Override
    public void prepare(DataSource ds) throws SQLException {
        flyway.setDataSource(ds);
        flyway.migrate();
    }
}

@@ -625,16 +625,90 @@
 ception;
+%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Objects;
 %0A%0Aimport
@@ -856,16 +856,58 @@
  flyway;
+%0A    private final List%3CString%3E locations;
 %0A%0A    pu
@@ -1080,16 +1080,42 @@
 eparer(f
+, Arrays.asList(locations)
 );%0A    %7D
@@ -1156,16 +1156,40 @@
 y flyway
+, List%3CString%3E locations
 ) %7B%0A    
@@ -1210,24 +1210,60 @@
 y = flyway;%0A
+        this.locations = locations;%0A
     %7D%0A%0A    @
@@ -1397,11 +1397,326 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (! (obj instanceof FlywayPreparer)) %7B%0A            return false;%0A        %7D%0A        return Objects.equals(locations, ((FlywayPreparer) obj).locations);%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return Objects.hashCode(locations);%0A    %7D
 %0A%7D%0A

Implement equals and hashCode for FlywayPreparer