Skip to content

Commit a1fe074

Browse files
committed
BAEL-35: Added test methods using Apache Commons Collections4
1 parent 45ab03c commit a1fe074

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎core-java/src/test/java/org/baeldung/java/collections/CollectionsConcatenateUnitTest.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import com.google.common.collect.Iterables;
44
import com.google.common.collect.Lists;
5+
6+
import org.apache.commons.collections4.CollectionUtils;
7+
import org.apache.commons.collections4.IterableUtils;
58
import org.junit.Assert;
69
import org.junit.Test;
710

@@ -107,4 +110,26 @@ public static <E> List<E> makeListFromIterable(Iterable<E> iter) {
107110
}
108111
return list;
109112
}
113+
114+
@Test
115+
public void givenUsingApacheCommons_whenConcatenatingUsingUnion_thenCorrect() {
116+
Collection<String> collectionA = asList("S", "T");
117+
Collection<String> collectionB = asList("U", "V");
118+
119+
Iterable<String> combinedIterables = CollectionUtils.union(collectionA, collectionB);
120+
Collection<String> collectionCombined = Lists.newArrayList(combinedIterables);
121+
122+
Assert.assertEquals(asList("S", "T", "U", "V"), collectionCombined);
123+
}
124+
125+
@Test
126+
public void givenUsingApacheCommons_whenConcatenatingUsingChainedIterable_thenCorrect() {
127+
Collection<String> collectionA = asList("S", "T");
128+
Collection<String> collectionB = asList("U", "V");
129+
130+
Iterable<String> combinedIterables = IterableUtils.chainedIterable(collectionA, collectionB);
131+
Collection<String> collectionCombined = Lists.newArrayList(combinedIterables);
132+
133+
Assert.assertEquals(asList("S", "T", "U", "V"), collectionCombined);
134+
}
110135
}

0 commit comments

Comments
 (0)