Search in sources :

Example 1 with ContextChangeSetFilter

use of liquibase.changelog.filter.ContextChangeSetFilter in project liquibase by liquibase.

the class ChangeLogIteratorTest method runChangeSet_singleFilterIterator.

@Test
public void runChangeSet_singleFilterIterator() throws Exception {
    TestChangeSetVisitor testChangeLogVisitor = new TestChangeSetVisitor();
    ChangeLogIterator iterator = new ChangeLogIterator(changeLog, new ContextChangeSetFilter(new Contexts("test1")));
    iterator.run(testChangeLogVisitor, new RuntimeEnvironment(null, null, null));
    assertEquals(4, testChangeLogVisitor.visitedChangeSets.size());
}
Also used : RuntimeEnvironment(liquibase.RuntimeEnvironment) ContextChangeSetFilter(liquibase.changelog.filter.ContextChangeSetFilter) Contexts(liquibase.Contexts) Test(org.junit.Test)

Example 2 with ContextChangeSetFilter

use of liquibase.changelog.filter.ContextChangeSetFilter in project liquibase by liquibase.

the class ChangeLogIteratorTest method runChangeSet_reverseVisitor.

@Test
public void runChangeSet_reverseVisitor() throws Exception {
    TestChangeSetVisitor testChangeLogVisitor = new ReverseChangeSetVisitor();
    ChangeLogIterator iterator = new ChangeLogIterator(changeLog, new ContextChangeSetFilter(new Contexts("test1")), new DbmsChangeSetFilter(new MySQLDatabase()));
    iterator.run(testChangeLogVisitor, new RuntimeEnvironment(null, null, null));
    assertEquals(3, testChangeLogVisitor.visitedChangeSets.size());
    assertEquals("5", testChangeLogVisitor.visitedChangeSets.get(0).getId());
    assertEquals("4", testChangeLogVisitor.visitedChangeSets.get(1).getId());
    assertEquals("1", testChangeLogVisitor.visitedChangeSets.get(2).getId());
}
Also used : RuntimeEnvironment(liquibase.RuntimeEnvironment) ContextChangeSetFilter(liquibase.changelog.filter.ContextChangeSetFilter) MySQLDatabase(liquibase.database.core.MySQLDatabase) DbmsChangeSetFilter(liquibase.changelog.filter.DbmsChangeSetFilter) Contexts(liquibase.Contexts) Test(org.junit.Test)

Example 3 with ContextChangeSetFilter

use of liquibase.changelog.filter.ContextChangeSetFilter in project liquibase by liquibase.

the class DatabaseChangeLog method validate.

public void validate(Database database, Contexts contexts, LabelExpression labelExpression) throws LiquibaseException {
    ChangeLogIterator logIterator = new ChangeLogIterator(this, new DbmsChangeSetFilter(database), new ContextChangeSetFilter(contexts), new LabelChangeSetFilter(labelExpression));
    ValidatingVisitor validatingVisitor = new ValidatingVisitor(database.getRanChangeSetList());
    validatingVisitor.validate(database, this);
    logIterator.run(validatingVisitor, new RuntimeEnvironment(database, contexts, labelExpression));
    for (String message : validatingVisitor.getWarnings().getMessages()) {
        LogFactory.getLogger().warning(message);
    }
    if (!validatingVisitor.validationPassed()) {
        throw new ValidationFailedException(validatingVisitor);
    }
}
Also used : LabelChangeSetFilter(liquibase.changelog.filter.LabelChangeSetFilter) ValidatingVisitor(liquibase.changelog.visitor.ValidatingVisitor) RuntimeEnvironment(liquibase.RuntimeEnvironment) ValidationFailedException(liquibase.exception.ValidationFailedException) ContextChangeSetFilter(liquibase.changelog.filter.ContextChangeSetFilter) DbmsChangeSetFilter(liquibase.changelog.filter.DbmsChangeSetFilter)

Example 4 with ContextChangeSetFilter

use of liquibase.changelog.filter.ContextChangeSetFilter in project liquibase by liquibase.

the class AbstractChangeLogHistoryService method upgradeChecksums.

public void upgradeChecksums(final DatabaseChangeLog databaseChangeLog, final Contexts contexts, LabelExpression labels) throws DatabaseException {
    for (RanChangeSet ranChangeSet : this.getRanChangeSets()) {
        if (ranChangeSet.getLastCheckSum() == null) {
            ChangeSet changeSet = databaseChangeLog.getChangeSet(ranChangeSet);
            if (changeSet != null && new ContextChangeSetFilter(contexts).accepts(changeSet).isAccepted() && new DbmsChangeSetFilter(getDatabase()).accepts(changeSet).isAccepted()) {
                LogFactory.getLogger().debug("Updating null or out of date checksum on changeSet " + changeSet + " to correct value");
                replaceChecksum(changeSet);
            }
        }
    }
}
Also used : ContextChangeSetFilter(liquibase.changelog.filter.ContextChangeSetFilter) DbmsChangeSetFilter(liquibase.changelog.filter.DbmsChangeSetFilter)

Example 5 with ContextChangeSetFilter

use of liquibase.changelog.filter.ContextChangeSetFilter in project liquibase by liquibase.

the class ChangeLogIteratorTest method runChangeSet_doubleFilterIterator.

@Test
public void runChangeSet_doubleFilterIterator() throws Exception {
    TestChangeSetVisitor testChangeLogVisitor = new TestChangeSetVisitor();
    ChangeLogIterator iterator = new ChangeLogIterator(changeLog, new ContextChangeSetFilter(new Contexts("test1")), new DbmsChangeSetFilter(new MySQLDatabase()));
    iterator.run(testChangeLogVisitor, new RuntimeEnvironment(null, null, null));
    assertEquals(3, testChangeLogVisitor.visitedChangeSets.size());
    assertEquals("1", testChangeLogVisitor.visitedChangeSets.get(0).getId());
    assertEquals("4", testChangeLogVisitor.visitedChangeSets.get(1).getId());
    assertEquals("5", testChangeLogVisitor.visitedChangeSets.get(2).getId());
}
Also used : RuntimeEnvironment(liquibase.RuntimeEnvironment) ContextChangeSetFilter(liquibase.changelog.filter.ContextChangeSetFilter) MySQLDatabase(liquibase.database.core.MySQLDatabase) DbmsChangeSetFilter(liquibase.changelog.filter.DbmsChangeSetFilter) Contexts(liquibase.Contexts) Test(org.junit.Test)

Aggregations

ContextChangeSetFilter (liquibase.changelog.filter.ContextChangeSetFilter)5 RuntimeEnvironment (liquibase.RuntimeEnvironment)4 DbmsChangeSetFilter (liquibase.changelog.filter.DbmsChangeSetFilter)4 Contexts (liquibase.Contexts)3 Test (org.junit.Test)3 MySQLDatabase (liquibase.database.core.MySQLDatabase)2 LabelChangeSetFilter (liquibase.changelog.filter.LabelChangeSetFilter)1 ValidatingVisitor (liquibase.changelog.visitor.ValidatingVisitor)1 ValidationFailedException (liquibase.exception.ValidationFailedException)1