Skip to content

Commit 7cd5845

Browse files
author
eugenp
committed
adding java 8 null removal test
1 parent 226e23b commit 7cd5845

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎core-java-8/src/test/java/com/baeldung/java8/Java8CollectionCleanupUnitTest.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ public void givenListContainsNulls_whenFilteringSerial_thenCorrect() {
3030
assertThat(listWithoutNulls, hasSize(3));
3131
}
3232

33+
@Test
34+
public void givenListContainsNulls_whenRemovingNullsWithRemoveIf_thenCorrect() {
35+
final List<Integer> listWithoutNulls = Lists.newArrayList(null, 1, 2, null, 3, null);
36+
listWithoutNulls.removeIf(p -> p == null);
37+
38+
assertThat(listWithoutNulls, hasSize(3));
39+
}
40+
3341
@Test
3442
public void givenListContainsDuplicates_whenRemovingDuplicatesWithJava8_thenCorrect() {
3543
final List<Integer> listWithDuplicates = Lists.newArrayList(1, 1, 2, 2, 3, 3);

0 commit comments

Comments
 (0)