### Question:
ChangeLogIterator { public void run(ChangeSetVisitor visitor, Database database) throws LiquibaseException { List<ChangeSet> changeSetList = databaseChangeLog.getChangeSets(); if (visitor.getDirection().equals(ChangeSetVisitor.Direction.REVERSE)) { Collections.reverse(changeSetList); } for (ChangeSet changeSet : changeSetList) { boolean shouldVisit = true; if (changeSetFilters != null) { for (ChangeSetFilter filter : changeSetFilters) { if (!filter.accepts(changeSet)) { shouldVisit = false; break; } } } if (shouldVisit) { visitor.visit(changeSet, databaseChangeLog, database); } } } ChangeLogIterator(DatabaseChangeLog databaseChangeLog, ChangeSetFilter... changeSetFilters);  ChangeLogIterator(List<RanChangeSet> changeSetList, DatabaseChangeLog changeLog, ChangeSetFilter... changeSetFilters); void run(ChangeSetVisitor visitor, Database database);  }### Answer:
@Test public void runChangeSet_emptyFiltersIterator() throws Exception { TestChangeSetVisitor testChangeLogVisitor = new TestChangeSetVisitor(); ChangeLogIterator iterator = new ChangeLogIterator(changeLog); iterator.run(testChangeLogVisitor, null); assertEquals(6, testChangeLogVisitor.visitedChangeSets.size()); }
@Test public void runChangeSet_singleFilterIterator() throws Exception { TestChangeSetVisitor testChangeLogVisitor = new TestChangeSetVisitor(); ChangeLogIterator iterator = new ChangeLogIterator(changeLog, new ContextChangeSetFilter("test1")); iterator.run(testChangeLogVisitor, null); assertEquals(4, testChangeLogVisitor.visitedChangeSets.size()); }
@Test public void runChangeSet_doubleFilterIterator() throws Exception { TestChangeSetVisitor testChangeLogVisitor = new TestChangeSetVisitor(); ChangeLogIterator iterator = new ChangeLogIterator(changeLog, new ContextChangeSetFilter("test1"), new DbmsChangeSetFilter(new MySQLDatabase())); iterator.run(testChangeLogVisitor, 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()); }
@Test public void runChangeSet_reverseVisitor() throws Exception { TestChangeSetVisitor testChangeLogVisitor = new ReverseChangeSetVisitor(); ChangeLogIterator iterator = new ChangeLogIterator(changeLog, new ContextChangeSetFilter("test1"), new DbmsChangeSetFilter(new MySQLDatabase())); iterator.run(testChangeLogVisitor, 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()); }