adding java 8 null removal test

This commit is contained in:
eugenp 2016-01-21 14:47:30 +02:00
parent 226e23b603
commit 7cd58457ec
1 changed files with 8 additions and 0 deletions

View File

@ -30,6 +30,14 @@ public class Java8CollectionCleanupUnitTest {
assertThat(listWithoutNulls, hasSize(3));
}
@Test
public void givenListContainsNulls_whenRemovingNullsWithRemoveIf_thenCorrect() {
final List<Integer> listWithoutNulls = Lists.newArrayList(null, 1, 2, null, 3, null);
listWithoutNulls.removeIf(p -> p == null);
assertThat(listWithoutNulls, hasSize(3));
}
@Test
public void givenListContainsDuplicates_whenRemovingDuplicatesWithJava8_thenCorrect() {
final List<Integer> listWithDuplicates = Lists.newArrayList(1, 1, 2, 2, 3, 3);