Search in sources :

Example 1 with MockSqlStatement

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

the class SqlGeneratorChainTest method validate_twoGenerators_noErrors.

@Test
public void validate_twoGenerators_noErrors() {
    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);
    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 2 with MockSqlStatement

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

the class SqlGeneratorChainTest method validate_twoGenerators_firstHasErrors.

@Test
public void validate_twoGenerators_firstHasErrors() {
    SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator());
    generators.add(new MockSqlGenerator(2, "B1", "B2").addValidationError("E1"));
    generators.add(new MockSqlGenerator(1, "A1", "A2"));
    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 3 with MockSqlStatement

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

the class SqlGeneratorChainTest method generateSql_threeGenerators.

@Test
public void generateSql_threeGenerators() {
    SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator());
    generators.add(new MockSqlGenerator(2, "B1", "B2"));
    generators.add(new MockSqlGenerator(1, "A1", "A2"));
    generators.add(new MockSqlGenerator(3, "C1", "C2"));
    SqlGeneratorChain chain = new SqlGeneratorChain(generators);
    Sql[] sql = chain.generateSql(new MockSqlStatement(), new MockDatabase());
    assertEquals(6, sql.length);
    assertEquals("C1", sql[0].toSql());
    assertEquals("C2", sql[1].toSql());
    assertEquals("B1", sql[2].toSql());
    assertEquals("B2", sql[3].toSql());
    assertEquals("A1", sql[4].toSql());
    assertEquals("A2", sql[5].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 4 with MockSqlStatement

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

the class SqlGeneratorChainTest method validate_oneGenerators_hasErrors.

@Test
public void validate_oneGenerators_hasErrors() {
    SortedSet<SqlGenerator> generators = new TreeSet<SqlGenerator>(new SqlGeneratorComparator());
    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 5 with MockSqlStatement

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

the class SqlGeneratorChainTest method validate_nullGenerators.

@Test
public void validate_nullGenerators() {
    SqlGeneratorChain chain = new SqlGeneratorChain(null);
    ValidationErrors validationErrors = chain.validate(new MockSqlStatement(), new MockDatabase());
    assertFalse(validationErrors.hasErrors());
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors) MockSqlStatement(liquibase.statement.core.MockSqlStatement) MockDatabase(liquibase.sdk.database.MockDatabase) 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