Search in sources :

Example 1 with SQLDispatcher

use of com.alessiodp.core.common.storage.dispatchers.SQLDispatcher in project ADP-Core by AlessioDP.

the class MigratorTest method prepareMigrator.

private Migrator prepareMigrator(ConnectionFactory cf, StorageType storageType) {
    if (cf == null)
        return null;
    TreeSet<String> scripts = new TreeSet<>();
    switch(storageType) {
        case MARIADB:
        case MYSQL:
        case POSTGRESQL:
        case SQLITE:
        case H2:
            scripts.add("1__Test_queries.sql");
            scripts.add("2__Second_test.sql");
            break;
        default:
            return null;
    }
    return Migrator.configure().setLocation("db/migrations/" + CommonUtils.toLowerCase(storageType.name()) + "/").setScripts(scripts).setConnectionFactory(cf).setStorageType(storageType).load(mockPlugin, new SQLDispatcher(mockPlugin, storageType) {

        @Override
        protected ConnectionFactory initConnectionFactory() {
            return null;
        }
    });
}
Also used : MySQLConnectionFactory(com.alessiodp.core.common.storage.sql.connection.MySQLConnectionFactory) PostgreSQLConnectionFactory(com.alessiodp.core.common.storage.sql.connection.PostgreSQLConnectionFactory) H2ConnectionFactory(com.alessiodp.core.common.storage.sql.connection.H2ConnectionFactory) ConnectionFactory(com.alessiodp.core.common.storage.sql.connection.ConnectionFactory) MariaDBConnectionFactory(com.alessiodp.core.common.storage.sql.connection.MariaDBConnectionFactory) SQLiteConnectionFactory(com.alessiodp.core.common.storage.sql.connection.SQLiteConnectionFactory) SQLDispatcher(com.alessiodp.core.common.storage.dispatchers.SQLDispatcher) TreeSet(java.util.TreeSet) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Aggregations

SQLDispatcher (com.alessiodp.core.common.storage.dispatchers.SQLDispatcher)1 ConnectionFactory (com.alessiodp.core.common.storage.sql.connection.ConnectionFactory)1 H2ConnectionFactory (com.alessiodp.core.common.storage.sql.connection.H2ConnectionFactory)1 MariaDBConnectionFactory (com.alessiodp.core.common.storage.sql.connection.MariaDBConnectionFactory)1 MySQLConnectionFactory (com.alessiodp.core.common.storage.sql.connection.MySQLConnectionFactory)1 PostgreSQLConnectionFactory (com.alessiodp.core.common.storage.sql.connection.PostgreSQLConnectionFactory)1 SQLiteConnectionFactory (com.alessiodp.core.common.storage.sql.connection.SQLiteConnectionFactory)1 TreeSet (java.util.TreeSet)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1