Merge pull request '更新项目依赖和文章 Java 从一个 List 中删除 null 元素' (#14) from code_bank into master
Reviewed-on: https://src.ossez.com/cwiki-us-docs/java-tutorials/pulls/14
This commit is contained in:
commit
7bb2e0e930
@ -11,7 +11,7 @@
|
||||
<groupId>com.ossez.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.2-SNAPSHOT</version>
|
||||
<relativePath></relativePath>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.ossez.collections;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.containsInRelativeOrder;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -13,22 +13,28 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.PredicateUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
/**
|
||||
* Test for list Clean up
|
||||
*
|
||||
* <p><a href="https://www.ossez.com/t/java-list-null/13940">https://www.ossez.com/t/java-list-null/13940</a></p>
|
||||
*
|
||||
* @author YuCheng
|
||||
*/
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class JavaCollectionCleanupUnitTest {
|
||||
|
||||
// tests - removing nulls
|
||||
|
||||
@Test
|
||||
public void givenListContainsNulls_whenRemovingNullsWithPlainJava_thenCorrect() {
|
||||
final List<Integer> list = Lists.newArrayList(null, 1, null);
|
||||
while (list.remove(null))
|
||||
;
|
||||
while (list.remove(null));
|
||||
|
||||
assertThat(list, hasSize(1));
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
<modules>
|
||||
<module>core-java-8</module>
|
||||
<!-- <module>core-java-annotations</module>-->
|
||||
<module>core-java-annotations</module>
|
||||
<module>core-java-collections-list</module>
|
||||
<!-- <module>core-java-datetime-conversion</module>-->
|
||||
<!-- <module>core-java-io</module>-->
|
||||
|
Loading…
x
Reference in New Issue
Block a user