BAEL-35: Added test methods using Apache Commons Collections4

This commit is contained in:
Kevin Gilmore 2016-12-17 08:12:32 -06:00
parent 45ab03cc51
commit a1fe0749c0
1 changed files with 25 additions and 0 deletions

View File

@ -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);
}
}