Skip to content

Commit 37aa271

Browse files
author
eugenp
committed
Merge branch 'master' of https://github.com/eugenp/tutorials
2 parents ba38b2a + 5477d52 commit 37aa271

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

guava/src/test/java/org/baeldung/guava/GuavaCollectionTypesTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import com.google.common.base.Function;
1616
import com.google.common.base.Joiner;
17+
import com.google.common.base.Predicates;
1718
import com.google.common.collect.ArrayListMultimap;
1819
import com.google.common.collect.BiMap;
1920
import com.google.common.collect.ClassToInstanceMap;
@@ -90,6 +91,26 @@ public void whenRemoveDuplicatesFromList_thenRemoved() {
9091
assertThat(result, contains('h', 'e', 'l', 'o'));
9192
}
9293

94+
@Test
95+
public void whenRemoveNullFromList_thenRemoved() {
96+
final List<String> names = Lists.newArrayList("John", null, "Adam", null, "Jane");
97+
Iterables.removeIf(names, Predicates.isNull());
98+
99+
assertEquals(3, names.size());
100+
assertThat(names, contains("John", "Adam", "Jane"));
101+
}
102+
103+
@Test
104+
public void whenCreateImmutableList_thenCreated() {
105+
final List<String> names = Lists.newArrayList("John", "Adam", "Jane");
106+
107+
names.add("Tom");
108+
assertEquals(4, names.size());
109+
110+
final ImmutableList<String> immutable = ImmutableList.copyOf(names);
111+
assertThat(immutable, contains("John", "Adam", "Jane", "Tom"));
112+
}
113+
93114
@Test
94115
public void whenCalculateUnion_thenCorrect() {
95116
final Set<Character> first = ImmutableSet.of('a', 'b', 'c');

0 commit comments

Comments
 (0)