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

liquibase.harness.util.FileUtils.groovy Maven / Gradle / Ivy

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


import liquibase.harness.config.TestConfig
import liquibase.util.StreamUtil

class FileUtils {

    static String getFileContent(String changeObject, String databaseName, String version , String expectedFolder,
                                 String fileExtension) {
        def resourceAccessor = TestConfig.instance.resourceAccessor

        def content = resourceAccessor.openStream(null, expectedFolder + "/" + databaseName + "/" + version + "/" + changeObject + fileExtension)
        if (content != null) {
            return StreamUtil.readStreamAsString(content)
        }

        content = resourceAccessor.openStream(null, expectedFolder + "/" + databaseName + "/" + changeObject + fileExtension)
        if (content != null) {
            return StreamUtil.readStreamAsString(content)
        }

        content = resourceAccessor.openStream(null, expectedFolder + "/" + changeObject + fileExtension)
        if (content != null) {
            return StreamUtil.readStreamAsString(content)
        }

        return null
    }

    static String getExpectedSqlFileContent(String changeObject, String databaseName, String version) {
        return getFileContent(changeObject, databaseName, version, "liquibase/harness/change/expectedSql", ".sql")
    }

    static String getExpectedSnapshotFileContent(String changeObject, String databaseName, String version) {
        return getFileContent(changeObject, databaseName, version, "liquibase/harness/change/expectedSnapshot", ".json")
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy