Search in sources :

Example 96 with ValidationErrors

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

the class AddForeignKeyConstraintGenerator method validate.

@Override
public ValidationErrors validate(AddForeignKeyConstraintStatement addForeignKeyConstraintStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = new ValidationErrors();
    if ((addForeignKeyConstraintStatement.isInitiallyDeferred() || addForeignKeyConstraintStatement.isDeferrable()) && !database.supportsInitiallyDeferrableColumns()) {
        validationErrors.checkDisallowedField("initiallyDeferred", addForeignKeyConstraintStatement.isInitiallyDeferred(), database);
        validationErrors.checkDisallowedField("deferrable", addForeignKeyConstraintStatement.isDeferrable(), database);
    }
    validationErrors.checkRequiredField("baseColumnNames", addForeignKeyConstraintStatement.getBaseColumnNames());
    validationErrors.checkRequiredField("baseTableNames", addForeignKeyConstraintStatement.getBaseTableName());
    validationErrors.checkRequiredField("referencedColumnNames", addForeignKeyConstraintStatement.getReferencedColumnNames());
    validationErrors.checkRequiredField("referencedTableName", addForeignKeyConstraintStatement.getReferencedTableName());
    validationErrors.checkRequiredField("constraintName", addForeignKeyConstraintStatement.getConstraintName());
    validationErrors.checkDisallowedField("onDelete", addForeignKeyConstraintStatement.getOnDelete(), database, SybaseDatabase.class);
    return validationErrors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 97 with ValidationErrors

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

the class CopyRowsGenerator method validate.

@Override
public ValidationErrors validate(CopyRowsStatement copyRowsStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = new ValidationErrors();
    validationErrors.checkRequiredField("targetTable", copyRowsStatement.getTargetTable());
    validationErrors.checkRequiredField("sourceTable", copyRowsStatement.getSourceTable());
    validationErrors.checkRequiredField("copyColumns", copyRowsStatement.getCopyColumns());
    return validationErrors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 98 with ValidationErrors

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

the class AddAutoIncrementGeneratorDB2 method validate.

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

Example 99 with ValidationErrors

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

the class AddAutoIncrementGeneratorInformix method validate.

@Override
public ValidationErrors validate(AddAutoIncrementStatement addAutoIncrementStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = super.validate(addAutoIncrementStatement, database, sqlGeneratorChain);
    validationErrors.checkRequiredField("columnDataType", addAutoIncrementStatement.getColumnDataType());
    return validationErrors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 100 with ValidationErrors

use of liquibase.exception.ValidationErrors 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.database.core.MockDatabase) Test(org.junit.Test)

Aggregations

ValidationErrors (liquibase.exception.ValidationErrors)105 Test (org.junit.Test)14 MockDatabase (liquibase.database.core.MockDatabase)11 Database (liquibase.database.Database)7 MockSqlStatement (liquibase.statement.core.MockSqlStatement)6 TreeSet (java.util.TreeSet)5 SqlStatement (liquibase.statement.SqlStatement)5 Change (liquibase.change.Change)4 ChangeFactory (liquibase.change.ChangeFactory)4 ChangeParameterMetaData (liquibase.change.ChangeParameterMetaData)4 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)4 ChangeMetaData (liquibase.change.ChangeMetaData)3 MockSqlGeneratorChain (liquibase.sqlgenerator.MockSqlGeneratorChain)3 AbstractVerifyTest (liquibase.verify.AbstractVerifyTest)3 ArrayList (java.util.ArrayList)2 CreateTableChange (liquibase.change.core.CreateTableChange)2 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)2 RanChangeSet (liquibase.changelog.RanChangeSet)2 DatabaseConnection (liquibase.database.DatabaseConnection)2 Db2zDatabase (liquibase.database.core.Db2zDatabase)2