Search in sources :

Example 36 with ValidationErrors

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

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

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

the class SetSequenceGenerator method validate.

@Override
public ValidationErrors validate(final SetSequenceStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = new ValidationErrors();
    validationErrors.checkRequiredField("sequenceName", statement.getSequenceName());
    if (statement.getValue() == null) {
        validationErrors.checkRequiredField("tables", statement.getTables());
    } else {
        if (statement.getTables().size() > 0) {
            LogFactory.getLogger().warning("You have set the sequence to a specific value, but have also provided tables to use for inferring the value.  Using the specific value.");
        }
    }
    return validationErrors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 39 with ValidationErrors

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

the class CreateTypeGenerator method validate.

@Override
public ValidationErrors validate(final CreateTypeStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors errors = new ValidationErrors();
    errors.checkRequiredField("name", statement);
    errors.checkRequiredField("columns", statement);
    return errors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors)

Example 40 with ValidationErrors

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

the class OracleDatabase method validate.

@Override
public ValidationErrors validate() {
    ValidationErrors errors = super.validate();
    DatabaseConnection connection = getConnection();
    if (connection == null || connection instanceof OfflineConnection) {
        LogFactory.getInstance().getLog().info("Cannot validate offline database");
        return errors;
    }
    if (!canAccessDbaRecycleBin()) {
        errors.addWarning(getDbaRecycleBinWarning());
    }
    return errors;
}
Also used : ValidationErrors(liquibase.exception.ValidationErrors) DatabaseConnection(liquibase.database.DatabaseConnection) OfflineConnection(liquibase.database.OfflineConnection)

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