Search in sources :

Example 41 with ChangeSet

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

the class ContextChangeSetFilterTest method visitorContextFilterLowerUpper.

@Test
public void visitorContextFilterLowerUpper() {
    ContextChangeSetFilter filter = new ContextChangeSetFilter(new Contexts("test1"));
    ChangeSet changeSet = new ChangeSet(null, null, false, false, null, null, null, null);
    changeSet.addSqlVisitor(new TestSqlVisitor("TEST1"));
    assertTrue(filter.accepts(changeSet).isAccepted());
    assertEquals(1, changeSet.getSqlVisitors().size());
}
Also used : Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 42 with ChangeSet

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

the class ContextChangeSetFilterTest method visitorContextFilterUpperLower.

@Test
public void visitorContextFilterUpperLower() {
    ContextChangeSetFilter filter = new ContextChangeSetFilter(new Contexts("TEST1"));
    ChangeSet changeSet = new ChangeSet(null, null, false, false, null, null, null, null);
    changeSet.addSqlVisitor(new TestSqlVisitor("test1"));
    assertTrue(filter.accepts(changeSet).isAccepted());
    assertEquals(1, changeSet.getSqlVisitors().size());
}
Also used : Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 43 with ChangeSet

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

the class ContextChangeSetFilterTest method multiContexts.

@Test
public void multiContexts() {
    ContextChangeSetFilter filter = new ContextChangeSetFilter(new Contexts("test1", "test2"));
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test1", null, null)).isAccepted());
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test2", null, null)).isAccepted());
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test1, test2", null, null)).isAccepted());
    assertFalse(filter.accepts(new ChangeSet(null, null, false, false, null, "test3", null, null)).isAccepted());
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test3, test1", null, null)).isAccepted());
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, "test3, TEST1", null, null)).isAccepted());
    assertTrue(filter.accepts(new ChangeSet(null, null, false, false, null, null, null, null)).isAccepted());
}
Also used : Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 44 with ChangeSet

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

the class XMLChangeLogSAXParserTest method testIgnoreDuplicateChangeSets.

@Test
public void testIgnoreDuplicateChangeSets() throws ChangeLogParseException, Exception {
    XMLChangeLogSAXParser xmlParser = new XMLChangeLogSAXParser();
    DatabaseChangeLog changeLog = xmlParser.parse("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/master.changelog.xml", new ChangeLogParameters(), new JUnitResourceAccessor());
    final List<ChangeSet> changeSets = new ArrayList<ChangeSet>();
    new ChangeLogIterator(changeLog).run(new ChangeSetVisitor() {

        @Override
        public Direction getDirection() {
            return Direction.FORWARD;
        }

        @Override
        public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database, Set<ChangeSetFilterResult> filterResults) throws LiquibaseException {
            changeSets.add(changeSet);
        }
    }, new RuntimeEnvironment(new MockDatabase(), new Contexts(), new LabelExpression()));
    Assert.assertEquals(8, changeSets.size());
    Assert.assertEquals("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser", changeSets.get(0).toString());
    Assert.assertEquals("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser", changeSets.get(1).toString());
    Assert.assertEquals(1, changeSets.get(1).getContexts().getContexts().size());
    Assert.assertEquals("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser", changeSets.get(2).toString());
    Assert.assertEquals(1, changeSets.get(2).getLabels().getLabels().size());
    Assert.assertEquals("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser", changeSets.get(3).toString());
    Assert.assertEquals(2, changeSets.get(3).getLabels().getLabels().size());
    Assert.assertEquals("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog4.xml::1::testuser", changeSets.get(4).toString());
    Assert.assertEquals(1, changeSets.get(4).getDbmsSet().size());
    Assert.assertEquals("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog1.xml::1::testuser", changeSets.get(5).toString());
    Assert.assertEquals("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog3.xml::1::testuser", changeSets.get(6).toString());
    Assert.assertEquals("liquibase/parser/core/xml/ignoreDuplicatedChangeLogs/included.changelog2.xml::1::testuser", changeSets.get(7).toString());
}
Also used : ChangeSetVisitor(liquibase.changelog.visitor.ChangeSetVisitor) RuntimeEnvironment(liquibase.RuntimeEnvironment) JUnitResourceAccessor(liquibase.test.JUnitResourceAccessor) ArrayList(java.util.ArrayList) Contexts(liquibase.Contexts) DatabaseChangeLog(liquibase.changelog.DatabaseChangeLog) ChangeLogIterator(liquibase.changelog.ChangeLogIterator) ChangeLogParameters(liquibase.changelog.ChangeLogParameters) MockDatabase(liquibase.sdk.database.MockDatabase) Database(liquibase.database.Database) LabelExpression(liquibase.LabelExpression) MockDatabase(liquibase.sdk.database.MockDatabase) LiquibaseException(liquibase.exception.LiquibaseException) ChangeSetFilterResult(liquibase.changelog.filter.ChangeSetFilterResult) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Example 45 with ChangeSet

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

the class AbstractIntegrationTest method testUnrunChangeSetsEmptyDatabase.

@Test
public void testUnrunChangeSetsEmptyDatabase() throws Exception {
    if (database == null) {
        return;
    }
    Liquibase liquibase = createLiquibase(completeChangeLog);
    clearDatabase(liquibase);
    liquibase = createLiquibase(completeChangeLog);
    List<ChangeSet> list = liquibase.listUnrunChangeSets(new Contexts(this.contexts), new LabelExpression());
    assertTrue(list.size() > 0);
}
Also used : Liquibase(liquibase.Liquibase) LabelExpression(liquibase.LabelExpression) Contexts(liquibase.Contexts) ChangeSet(liquibase.changelog.ChangeSet) Test(org.junit.Test)

Aggregations

ChangeSet (liquibase.changelog.ChangeSet)72 Test (org.junit.Test)41 Contexts (liquibase.Contexts)12 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)11 RanChangeSet (liquibase.changelog.RanChangeSet)10 Liquibase (liquibase.Liquibase)9 Change (liquibase.change.Change)9 Database (liquibase.database.Database)9 LiquibaseException (liquibase.exception.LiquibaseException)8 ArrayList (java.util.ArrayList)7 DiffOutputControl (liquibase.diff.output.DiffOutputControl)7 DiffToChangeLog (liquibase.diff.output.changelog.DiffToChangeLog)7 ObjectQuotingStrategy (liquibase.database.ObjectQuotingStrategy)6 DiffResult (liquibase.diff.DiffResult)6 CompareControl (liquibase.diff.compare.CompareControl)6 IOException (java.io.IOException)5 Sql (liquibase.sql.Sql)5 MarkChangeSetRanStatement (liquibase.statement.core.MarkChangeSetRanStatement)5 Date (java.util.Date)4 Labels (liquibase.Labels)4