adding alternative to remove nulls for list
This commit is contained in:
parent
b089214ba6
commit
f4758569a7
|
@ -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<Integer> list = Lists.newArrayList(null, 1, null);
|
||||
list.removeAll(Collections.singleton(null));
|
||||
|
||||
assertThat(list, hasSize(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void givenListContainsNulls_whenRemovingNullsWithGuavaV1_thenCorrect() {
|
||||
final List<Integer> list = Lists.newArrayList(null, 1, null);
|
||||
|
|
Loading…
Reference in New Issue