All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liquibase.harness.snapshot.SnapshotObjectTestHelper.groovy Maven / Gradle / Ivy

There is a newer version: 1.0.10
Show newest version
package liquibase.harness.snapshot

import liquibase.harness.config.DatabaseUnderTest
import liquibase.harness.config.TestConfig
import liquibase.harness.util.DatabaseConnectionUtil
import liquibase.harness.util.TestUtils

class SnapshotObjectTestHelper {
    final static String baseSnapshotPath = "liquibase/harness/snapshot"

    static List buildTestInput() {
        def loader = new GroovyClassLoader()
        def returnList = new ArrayList()
        DatabaseConnectionUtil databaseConnectionUtil = new DatabaseConnectionUtil()

        for (def databaseUnderTest : databaseConnectionUtil.initializeDatabasesConnection(TestConfig.instance.databasesUnderTest)) {
            Map nameToPathMap = TestUtils.resolveInputFilePaths(databaseUnderTest, baseSnapshotPath, "groovy")
            for (def file : nameToPathMap.values()) {

                def testClass = loader.parseClass(new InputStreamReader(TestConfig.getInstance().resourceAccessor.openStream(null, file)), file)
                for (def testConfig : (Collection) ((Script) testClass.newInstance()).run()) {
                    returnList.add(new TestInput(
                            database: databaseUnderTest,
                            permutation: testConfig,
                            testName: testClass.getName()
                    ))
                }
            }
        }
        return returnList
    }

    static class TestInput {
        DatabaseUnderTest database
        SnapshotTest.TestConfig permutation
        String testName
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy