|
14 | 14 |
|
15 | 15 | import com.google.common.base.Function; |
16 | 16 | import com.google.common.base.Joiner; |
| 17 | +import com.google.common.base.Predicates; |
17 | 18 | import com.google.common.collect.ArrayListMultimap; |
18 | 19 | import com.google.common.collect.BiMap; |
19 | 20 | import com.google.common.collect.ClassToInstanceMap; |
@@ -90,6 +91,26 @@ public void whenRemoveDuplicatesFromList_thenRemoved() { |
90 | 91 | assertThat(result, contains('h', 'e', 'l', 'o')); |
91 | 92 | } |
92 | 93 |
|
| 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 | + |
93 | 114 | @Test |
94 | 115 | public void whenCalculateUnion_thenCorrect() { |
95 | 116 | final Set<Character> first = ImmutableSet.of('a', 'b', 'c'); |
|
0 commit comments