Search in sources :

Example 1 with AppendSqlVisitor

use of liquibase.sql.visitor.AppendSqlVisitor in project liquibase by liquibase.

the class AbstractJdbcDatabaseTest method executeRollbackStatements_WithChangeOverload_ShouldNotIncludeAppendTextFromApplyToRollbackFalseVisitor.

@Test
public void executeRollbackStatements_WithChangeOverload_ShouldNotIncludeAppendTextFromApplyToRollbackFalseVisitor() throws Exception {
    Database database = getDatabase();
    final MockExecutor mockExecutor = new MockExecutor();
    Scope.getCurrentScope().getSingleton(ExecutorService.class).setExecutor("jdbc", database, mockExecutor);
    final List<SqlVisitor> sqlVisitors = new ArrayList<SqlVisitor>();
    final CreateTableChange change = new CreateTableChange();
    change.setTableName("test_table");
    final AppendSqlVisitor appendSqlVisitor = new AppendSqlVisitor();
    appendSqlVisitor.setApplyToRollback(false);
    appendSqlVisitor.setValue(" SHOULD NOT BE APPENDED");
    sqlVisitors.add(appendSqlVisitor);
    database.executeRollbackStatements(change, sqlVisitors);
    assertEquals("DROP TABLE test_table;", mockExecutor.getRanSql().trim());
}
Also used : AppendSqlVisitor(liquibase.sql.visitor.AppendSqlVisitor) MockExecutor(liquibase.sdk.executor.MockExecutor) ExecutorService(liquibase.executor.ExecutorService) ArrayList(java.util.ArrayList) CreateTableChange(liquibase.change.core.CreateTableChange) SqlVisitor(liquibase.sql.visitor.SqlVisitor) AppendSqlVisitor(liquibase.sql.visitor.AppendSqlVisitor) Test(org.junit.Test)

Example 2 with AppendSqlVisitor

use of liquibase.sql.visitor.AppendSqlVisitor in project liquibase by liquibase.

the class AbstractJdbcDatabaseTest method executeRollbackStatements_WithStatementsOverload_ShouldIncludeAppendTextFromApplyToRollbackTrueVisitor.

@Test
public void executeRollbackStatements_WithStatementsOverload_ShouldIncludeAppendTextFromApplyToRollbackTrueVisitor() throws Exception {
    Database database = getDatabase();
    final MockExecutor mockExecutor = new MockExecutor();
    Scope.getCurrentScope().getSingleton(ExecutorService.class).setExecutor("jdbc", database, mockExecutor);
    final List<SqlVisitor> sqlVisitors = new ArrayList<SqlVisitor>();
    final SqlStatement dropTableStatement = new DropTableStatement(null, null, "test_table", false);
    final AppendSqlVisitor appendSqlVisitor = new AppendSqlVisitor();
    appendSqlVisitor.setApplyToRollback(true);
    appendSqlVisitor.setValue(" SHOULD BE APPENDED");
    sqlVisitors.add(appendSqlVisitor);
    database.executeRollbackStatements(new SqlStatement[] { dropTableStatement }, sqlVisitors);
    assertEquals("DROP TABLE test_table SHOULD BE APPENDED;", mockExecutor.getRanSql().trim());
}
Also used : AppendSqlVisitor(liquibase.sql.visitor.AppendSqlVisitor) SqlStatement(liquibase.statement.SqlStatement) MockExecutor(liquibase.sdk.executor.MockExecutor) ExecutorService(liquibase.executor.ExecutorService) ArrayList(java.util.ArrayList) DropTableStatement(liquibase.statement.core.DropTableStatement) SqlVisitor(liquibase.sql.visitor.SqlVisitor) AppendSqlVisitor(liquibase.sql.visitor.AppendSqlVisitor) Test(org.junit.Test)

Example 3 with AppendSqlVisitor

use of liquibase.sql.visitor.AppendSqlVisitor in project liquibase by liquibase.

the class AbstractJdbcDatabaseTest method executeRollbackStatements_WithChangeOverload_ShouldIncludeAppendTextFromApplyToRollbackTrueVisitor.

@Test
public void executeRollbackStatements_WithChangeOverload_ShouldIncludeAppendTextFromApplyToRollbackTrueVisitor() throws Exception {
    Database database = getDatabase();
    final MockExecutor mockExecutor = new MockExecutor();
    Scope.getCurrentScope().getSingleton(ExecutorService.class).setExecutor("jdbc", database, mockExecutor);
    final List<SqlVisitor> sqlVisitors = new ArrayList<SqlVisitor>();
    final CreateTableChange change = new CreateTableChange();
    change.setTableName("test_table");
    final AppendSqlVisitor appendSqlVisitor = new AppendSqlVisitor();
    appendSqlVisitor.setApplyToRollback(true);
    appendSqlVisitor.setValue(" SHOULD BE APPENDED");
    sqlVisitors.add(appendSqlVisitor);
    database.executeRollbackStatements(change, sqlVisitors);
    assertEquals("DROP TABLE test_table SHOULD BE APPENDED;", mockExecutor.getRanSql().trim());
}
Also used : AppendSqlVisitor(liquibase.sql.visitor.AppendSqlVisitor) MockExecutor(liquibase.sdk.executor.MockExecutor) ExecutorService(liquibase.executor.ExecutorService) ArrayList(java.util.ArrayList) CreateTableChange(liquibase.change.core.CreateTableChange) SqlVisitor(liquibase.sql.visitor.SqlVisitor) AppendSqlVisitor(liquibase.sql.visitor.AppendSqlVisitor) Test(org.junit.Test)

Example 4 with AppendSqlVisitor

use of liquibase.sql.visitor.AppendSqlVisitor in project liquibase by liquibase.

the class AbstractJdbcDatabaseTest method executeRollbackStatements_WithStatementsOverload_ShouldNotIncludeAppendTextFromApplyToRollbackFalseVisitor.

@Test
public void executeRollbackStatements_WithStatementsOverload_ShouldNotIncludeAppendTextFromApplyToRollbackFalseVisitor() throws Exception {
    Database database = getDatabase();
    final MockExecutor mockExecutor = new MockExecutor();
    Scope.getCurrentScope().getSingleton(ExecutorService.class).setExecutor("jdbc", database, mockExecutor);
    final List<SqlVisitor> sqlVisitors = new ArrayList<SqlVisitor>();
    final SqlStatement dropTableStatement = new DropTableStatement(null, null, "test_table", false);
    final AppendSqlVisitor appendSqlVisitor = new AppendSqlVisitor();
    appendSqlVisitor.setApplyToRollback(false);
    appendSqlVisitor.setValue(" SHOULD NOT BE APPENDED");
    sqlVisitors.add(appendSqlVisitor);
    database.executeRollbackStatements(new SqlStatement[] { dropTableStatement }, sqlVisitors);
    assertEquals("DROP TABLE test_table;", mockExecutor.getRanSql().trim());
}
Also used : AppendSqlVisitor(liquibase.sql.visitor.AppendSqlVisitor) SqlStatement(liquibase.statement.SqlStatement) MockExecutor(liquibase.sdk.executor.MockExecutor) ExecutorService(liquibase.executor.ExecutorService) ArrayList(java.util.ArrayList) DropTableStatement(liquibase.statement.core.DropTableStatement) SqlVisitor(liquibase.sql.visitor.SqlVisitor) AppendSqlVisitor(liquibase.sql.visitor.AppendSqlVisitor) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)4 ExecutorService (liquibase.executor.ExecutorService)4 MockExecutor (liquibase.sdk.executor.MockExecutor)4 AppendSqlVisitor (liquibase.sql.visitor.AppendSqlVisitor)4 SqlVisitor (liquibase.sql.visitor.SqlVisitor)4 Test (org.junit.Test)4 CreateTableChange (liquibase.change.core.CreateTableChange)2 SqlStatement (liquibase.statement.SqlStatement)2 DropTableStatement (liquibase.statement.core.DropTableStatement)2