Skip to content

Commit

Permalink
Add missing test
Browse files Browse the repository at this point in the history
Rename existing test
  • Loading branch information
garydgregory committed Oct 19, 2024
1 parent 649a39b commit 2d8ad42
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.commons.collections4.iterators.EmptyOrderedIterator;
import org.apache.commons.collections4.iterators.EmptyOrderedMapIterator;
import org.apache.commons.collections4.iterators.EnumerationIterator;
import org.apache.commons.collections4.iterators.IteratorChainTest;
import org.apache.commons.collections4.iterators.NodeListIterator;
import org.apache.commons.collections4.iterators.ObjectArrayIterator;
import org.apache.commons.collections4.iterators.ZippingIterator;
Expand Down Expand Up @@ -435,14 +436,34 @@ public void testAsMultipleIterableNull() {
}

@Test
public void testChainedIterator() {
public void testChainedIteratorRawGenerics() {
final ArrayList arrayList = new ArrayList();
final Iterator iterator = arrayList.iterator();
assertTrue(IteratorUtils.chainedIterator(iterator) instanceof Iterator, "create instance fail");
final Collection<Iterator<?>> coll = new ArrayList();
assertTrue(IteratorUtils.chainedIterator(coll) instanceof Iterator, "create instance fail");
}

@Test
public void testChainedIteratorString() {
// String
final IteratorChainTest iteratorChainTest = new IteratorChainTest();
iteratorChainTest.setUp();
// @formateter:off
final Iterator<String> iterator = IteratorUtils.chainedIterator(
iteratorChainTest.getList1().iterator(),
iteratorChainTest.getList2().iterator(),
iteratorChainTest.getList3().iterator());
// @formateter:on
assertEquals("One", iterator.next());
assertEquals("Two", iterator.next());
assertEquals("Three", iterator.next());
assertEquals("Four", iterator.next());
assertEquals("Five", iterator.next());
assertEquals("Six", iterator.next());
assertFalse(iterator.hasNext());
}

/**
* Tests methods collatedIterator(...)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ public IteratorChainTest() {
super(IteratorChainTest.class.getSimpleName());
}

public List<String> getList1() {
return list1;
}

public List<String> getList2() {
return list2;
}

public List<String> getList3() {
return list3;
}

public String[] getTestArray() {
return testArray;
}

@Override
public IteratorChain<String> makeEmptyIterator() {
final ArrayList<String> list = new ArrayList<>();
Expand Down

0 comments on commit 2d8ad42

Please sign in to comment.