BAEL-35: Added test methods using Apache Commons Collections4
This commit is contained in:
parent
45ab03cc51
commit
a1fe0749c0
|
@ -2,6 +2,9 @@ package org.baeldung.java.collections;
|
|||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.IterableUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -107,4 +110,26 @@ public class CollectionsConcatenateUnitTest {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUsingApacheCommons_whenConcatenatingUsingUnion_thenCorrect() {
|
||||
Collection<String> collectionA = asList("S", "T");
|
||||
Collection<String> collectionB = asList("U", "V");
|
||||
|
||||
Iterable<String> combinedIterables = CollectionUtils.union(collectionA, collectionB);
|
||||
Collection<String> collectionCombined = Lists.newArrayList(combinedIterables);
|
||||
|
||||
Assert.assertEquals(asList("S", "T", "U", "V"), collectionCombined);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUsingApacheCommons_whenConcatenatingUsingChainedIterable_thenCorrect() {
|
||||
Collection<String> collectionA = asList("S", "T");
|
||||
Collection<String> collectionB = asList("U", "V");
|
||||
|
||||
Iterable<String> combinedIterables = IterableUtils.chainedIterable(collectionA, collectionB);
|
||||
Collection<String> collectionCombined = Lists.newArrayList(combinedIterables);
|
||||
|
||||
Assert.assertEquals(asList("S", "T", "U", "V"), collectionCombined);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue