Search in sources :

Example 6 with MockSqlStatement

use of liquibase.statement.core.MockSqlStatement in project liquibase by liquibase.

the class SqlGeneratorChainTest method validate_twoGenerators_secondHasErrors.

@Test
public void validate_twoGenerators_secondHasErrors() {
    SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator());
    generators.add(new MockSqlGenerator(2, "B1", "B2"));
    generators.add(new MockSqlGenerator(1, "A1", "A2").addValidationError("E1"));
    SqlGeneratorChain chain = new SqlGeneratorChain(generators);
    ValidationErrors validationErrors = chain.validate(new MockSqlStatement(), new MockDatabase());
    assertTrue(validationErrors.hasErrors());
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors) TreeSet(java.util.TreeSet) MockSqlStatement(liquibase.statement.core.MockSqlStatement) MockDatabase(liquibase.sdk.database.MockDatabase) Test(org.junit.Test)

Example 7 with MockSqlStatement

use of liquibase.statement.core.MockSqlStatement in project liquibase by liquibase.

the class SqlGeneratorChainTest method validate_oneGenerators_noErrors.

@Test
public void validate_oneGenerators_noErrors() {
    SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator());
    generators.add(new MockSqlGenerator(1, "A1", "A2"));
    SqlGeneratorChain chain = new SqlGeneratorChain(generators);
    ValidationErrors validationErrors = chain.validate(new MockSqlStatement(), new MockDatabase());
    assertFalse(validationErrors.hasErrors());
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors) TreeSet(java.util.TreeSet) MockSqlStatement(liquibase.statement.core.MockSqlStatement) MockDatabase(liquibase.sdk.database.MockDatabase) Test(org.junit.Test)

Example 8 with MockSqlStatement

use of liquibase.statement.core.MockSqlStatement in project liquibase by liquibase.

the class SqlGeneratorChainTest method generateSql_oneGenerators.

@Test
public void generateSql_oneGenerators() {
    SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator());
    generators.add(new MockSqlGenerator(1, "A1", "A2"));
    SqlGeneratorChain chain = new SqlGeneratorChain(generators);
    Sql[] sql = chain.generateSql(new MockSqlStatement(), new MockDatabase());
    assertEquals(2, sql.length);
    assertEquals("A1", sql[0].toSql());
    assertEquals("A2", sql[1].toSql());
}
Also used : TreeSet(java.util.TreeSet) MockSqlStatement(liquibase.statement.core.MockSqlStatement) MockDatabase(liquibase.sdk.database.MockDatabase) Sql(liquibase.sql.Sql) Test(org.junit.Test)

Example 9 with MockSqlStatement

use of liquibase.statement.core.MockSqlStatement in project liquibase by liquibase.

the class SqlGeneratorChainTest method generateSql_noGenerators.

@Test
public void generateSql_noGenerators() {
    SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator());
    SqlGeneratorChain chain = new SqlGeneratorChain(generators);
    assertEquals(0, chain.generateSql(new MockSqlStatement(), new MockDatabase()).length);
}
Also used : TreeSet(java.util.TreeSet) MockSqlStatement(liquibase.statement.core.MockSqlStatement) MockDatabase(liquibase.sdk.database.MockDatabase) Test(org.junit.Test)

Example 10 with MockSqlStatement

use of liquibase.statement.core.MockSqlStatement in project liquibase by liquibase.

the class SqlGeneratorChainTest method generateSql_twoGenerators.

@Test
public void generateSql_twoGenerators() {
    SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator());
    generators.add(new MockSqlGenerator(2, "B1", "B2"));
    generators.add(new MockSqlGenerator(1, "A1", "A2"));
    SqlGeneratorChain chain = new SqlGeneratorChain(generators);
    Sql[] sql = chain.generateSql(new MockSqlStatement(), new MockDatabase());
    assertEquals(4, sql.length);
    assertEquals("B1", sql[0].toSql());
    assertEquals("B2", sql[1].toSql());
    assertEquals("A1", sql[2].toSql());
    assertEquals("A2", sql[3].toSql());
}
Also used : TreeSet(java.util.TreeSet) MockSqlStatement(liquibase.statement.core.MockSqlStatement) MockDatabase(liquibase.sdk.database.MockDatabase) Sql(liquibase.sql.Sql) Test(org.junit.Test)

Aggregations

MockDatabase (liquibase.sdk.database.MockDatabase)10 MockSqlStatement (liquibase.statement.core.MockSqlStatement)10 Test (org.junit.Test)10 TreeSet (java.util.TreeSet)9 ValidationErrors (liquibase.exception.ValidationErrors)6 Sql (liquibase.sql.Sql)3