Search in sources :

Example 31 with ValidationErrors

use of liquibase.exception.ValidationErrors in project liquibase by liquibase.

the class RenameViewGenerator method validate.

@Override
public ValidationErrors validate(RenameViewStatement renameViewStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = new ValidationErrors();
    validationErrors.checkRequiredField("oldViewName", renameViewStatement.getOldViewName());
    validationErrors.checkRequiredField("newViewName", renameViewStatement.getNewViewName());
    validationErrors.checkDisallowedField("schemaName", renameViewStatement.getSchemaName(), database, OracleDatabase.class);
    return validationErrors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 32 with ValidationErrors

use of liquibase.exception.ValidationErrors in project liquibase by liquibase.

the class SetColumnRemarksGenerator method validate.

@Override
public ValidationErrors validate(SetColumnRemarksStatement setColumnRemarksStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = new ValidationErrors();
    validationErrors.checkRequiredField("tableName", setColumnRemarksStatement.getTableName());
    validationErrors.checkRequiredField("columnName", setColumnRemarksStatement.getColumnName());
    return validationErrors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 33 with ValidationErrors

use of liquibase.exception.ValidationErrors in project liquibase by liquibase.

the class ValidatingVisitorTest method visit_torunOnly.

@Test
public void visit_torunOnly() throws Exception {
    changeSet1.addChange(new CreateTableChange() {

        @Override
        public ValidationErrors validate(Database database) {
            ValidationErrors changeValidationErrors = new ValidationErrors();
            changeValidationErrors.addError("Test message");
            return changeValidationErrors;
        }
    });
    List<RanChangeSet> ran = new ArrayList<RanChangeSet>();
    ran.add(new RanChangeSet(changeSet1));
    ValidatingVisitor handler = new ValidatingVisitor(ran);
    handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
    assertEquals(0, handler.getSetupExceptions().size());
    assertTrue(handler.validationPassed());
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors) CreateTableChange(liquibase.change.core.CreateTableChange) MockDatabase(liquibase.sdk.database.MockDatabase) Database(liquibase.database.Database) ArrayList(java.util.ArrayList) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) RanChangeSet(liquibase.changelog.RanChangeSet) Test(org.junit.Test)

Example 34 with ValidationErrors

use of liquibase.exception.ValidationErrors in project liquibase by liquibase.

the class MockSqlGenerator method validate.

@Override
public ValidationErrors validate(SqlStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = sqlGeneratorChain.validate(statement, database);
    validationErrors.addAll(errors);
    return validationErrors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 35 with ValidationErrors

use of liquibase.exception.ValidationErrors 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)

Aggregations

ValidationErrors (liquibase.exception.ValidationErrors)89 Test (org.junit.Test)11 MockDatabase (liquibase.sdk.database.MockDatabase)9 Database (liquibase.database.Database)6 MockSqlStatement (liquibase.statement.core.MockSqlStatement)6 TreeSet (java.util.TreeSet)5 ArrayList (java.util.ArrayList)2 Change (liquibase.change.Change)2 ChangeFactory (liquibase.change.ChangeFactory)2 ChangeMetaData (liquibase.change.ChangeMetaData)2 ChangeParameterMetaData (liquibase.change.ChangeParameterMetaData)2 CreateTableChange (liquibase.change.core.CreateTableChange)2 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)2 RanChangeSet (liquibase.changelog.RanChangeSet)2 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)2 SqlStatement (liquibase.statement.SqlStatement)2 AddColumnStatement (liquibase.statement.core.AddColumnStatement)2 JUnitResourceAccessor (liquibase.test.JUnitResourceAccessor)2 AbstractVerifyTest (liquibase.verify.AbstractVerifyTest)2 Ignore (org.junit.Ignore)2