use of liquibase.sdk.executor.MockExecutor 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();
ExecutorService.getInstance().setExecutor(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());
}
use of liquibase.sdk.executor.MockExecutor 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();
ExecutorService.getInstance().setExecutor(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());
}
use of liquibase.sdk.executor.MockExecutor 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();
ExecutorService.getInstance().setExecutor(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());
}
use of liquibase.sdk.executor.MockExecutor 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();
ExecutorService.getInstance().setExecutor(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());
}
Aggregations