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());
}
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());
}
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);
}
}
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);
}
}
}
}
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());
}
Aggregations