Search in sources :

Example 11 with DatabaseChangeLog

use of liquibase.changelog.DatabaseChangeLog in project liquibase by liquibase.

the class ValidatingVisitorPreConditionsTest method setUp.

/**
 * Create a DatabaseChangelog, one changeset, and a create sequence change
 */
@Before
public void setUp() {
    changeLog = new DatabaseChangeLog();
    changeSet1 = new ChangeSet("1", "testAuthor", false, false, "path/changelog", null, null, null);
    changeLog.addChangeSet(changeSet1);
    CreateTableChange change1 = new CreateTableChange();
    change1.setTableName("valid_test");
    change1.addColumn(new ColumnConfig().setName("id").setType("int"));
    changeSet1.addChange(change1);
}
Also used : ColumnConfig(liquibase.change.ColumnConfig) CreateTableChange(liquibase.change.core.CreateTableChange) RanChangeSet(liquibase.changelog.RanChangeSet) ChangeSet(liquibase.changelog.ChangeSet) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) Before(org.junit.Before)

Example 12 with DatabaseChangeLog

use of liquibase.changelog.DatabaseChangeLog in project liquibase by liquibase.

the class ChangeLogSyncVisitorTest method setUp.

@Before
public void setUp() {
    changeSet = new ChangeSet("1", "testAuthor", false, false, "path/changelog", null, null, null);
    databaseChangeLog = new DatabaseChangeLog();
}
Also used : ChangeSet(liquibase.changelog.ChangeSet) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) Before(org.junit.Before)

Example 13 with DatabaseChangeLog

use of liquibase.changelog.DatabaseChangeLog in project liquibase by liquibase.

the class ValidatingVisitorTest method visit_setupException.

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

        @Override
        public void finishInitialization() throws SetupException {
            throw new SetupException("Test message");
        }
    });
    ValidatingVisitor handler = new ValidatingVisitor(new ArrayList<RanChangeSet>());
    handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
    assertEquals(1, handler.getSetupExceptions().size());
    assertEquals("Test message", handler.getSetupExceptions().get(0).getMessage());
    assertFalse(handler.validationPassed());
}
Also used : SetupException(liquibase.exception.SetupException) CreateTableChange(liquibase.change.core.CreateTableChange) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) RanChangeSet(liquibase.changelog.RanChangeSet) Test(org.junit.Test)

Example 14 with DatabaseChangeLog

use of liquibase.changelog.DatabaseChangeLog in project liquibase by liquibase.

the class ValidatingVisitorTest method visit_duplicate.

@Test
public void visit_duplicate() throws Exception {
    ValidatingVisitor handler = new ValidatingVisitor(new ArrayList<RanChangeSet>());
    handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
    handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
    assertEquals(1, handler.getDuplicateChangeSets().size());
    assertFalse(handler.validationPassed());
}
Also used : DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) RanChangeSet(liquibase.changelog.RanChangeSet) Test(org.junit.Test)

Example 15 with DatabaseChangeLog

use of liquibase.changelog.DatabaseChangeLog 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) Database(liquibase.database.Database) MockDatabase(liquibase.database.core.MockDatabase) ArrayList(java.util.ArrayList) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) RanChangeSet(liquibase.changelog.RanChangeSet) Test(org.junit.Test)

Aggregations

DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)23 ChangeSet (liquibase.changelog.ChangeSet)11 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 RanChangeSet (liquibase.changelog.RanChangeSet)6 LiquibaseException (liquibase.exception.LiquibaseException)6 IOException (java.io.IOException)5 CreateTableChange (liquibase.change.core.CreateTableChange)5 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)5 Database (liquibase.database.Database)5 MockDatabase (liquibase.database.core.MockDatabase)5 ChangeLogParseException (liquibase.exception.ChangeLogParseException)4 ContextExpression (liquibase.ContextExpression)3 Labels (liquibase.Labels)3 Liquibase (liquibase.Liquibase)3 ColumnConfig (liquibase.change.ColumnConfig)3 CommandExecutionException (liquibase.exception.CommandExecutionException)3 CompositeResourceAccessor (liquibase.resource.CompositeResourceAccessor)3 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)3 ResourceAccessor (liquibase.resource.ResourceAccessor)3