diff --git a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java index 85f5d3f009..537262607a 100644 --- a/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java +++ b/core-java/src/test/java/org/baeldung/java/collections/JavaCollectionCleanupUnitTest.java @@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertThat; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -29,6 +30,14 @@ public class JavaCollectionCleanupUnitTest { assertThat(list, hasSize(1)); } + @Test + public final void givenListContainsNulls_whenRemovingNullsWithPlainJavaAlternative_thenCorrect() { + final List list = Lists.newArrayList(null, 1, null); + list.removeAll(Collections.singleton(null)); + + assertThat(list, hasSize(1)); + } + @Test public final void givenListContainsNulls_whenRemovingNullsWithGuavaV1_thenCorrect() { final List list = Lists.newArrayList(null, 1, null);