Merge pull request #66 from Doha2012/master

Modify Class GuavaCollectionTypesTest
This commit is contained in:
Eugen 2014-11-02 11:16:32 +02:00
commit 5477d52e11
1 changed files with 21 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import org.junit.Test;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Predicates;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.BiMap;
import com.google.common.collect.ClassToInstanceMap;
@ -90,6 +91,26 @@ public class GuavaCollectionTypesTest {
assertThat(result, contains('h', 'e', 'l', 'o'));
}
@Test
public void whenRemoveNullFromList_thenRemoved() {
final List<String> names = Lists.newArrayList("John", null, "Adam", null, "Jane");
Iterables.removeIf(names, Predicates.isNull());
assertEquals(3, names.size());
assertThat(names, contains("John", "Adam", "Jane"));
}
@Test
public void whenCreateImmutableList_thenCreated() {
final List<String> names = Lists.newArrayList("John", "Adam", "Jane");
names.add("Tom");
assertEquals(4, names.size());
final ImmutableList<String> immutable = ImmutableList.copyOf(names);
assertThat(immutable, contains("John", "Adam", "Jane", "Tom"));
}
@Test
public void whenCalculateUnion_thenCorrect() {
final Set<Character> first = ImmutableSet.of('a', 'b', 'c');