From 8c5ab530f0f6169744ff278ffff5669cd174bc4a Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Sat, 30 Apr 2022 18:16:31 -0400 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E4=BD=95=E4=BB=8E=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=20List=20=E4=B8=AD=E5=88=A0=E9=99=A4=20null=20=E5=85=83?= =?UTF-8?q?=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JavaCollectionCleanupUnitTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core-java-modules/core-java-collections-list/src/test/java/com/ossez/collections/JavaCollectionCleanupUnitTest.java b/core-java-modules/core-java-collections-list/src/test/java/com/ossez/collections/JavaCollectionCleanupUnitTest.java index 40aa276080..f5f85ee57d 100644 --- a/core-java-modules/core-java-collections-list/src/test/java/com/ossez/collections/JavaCollectionCleanupUnitTest.java +++ b/core-java-modules/core-java-collections-list/src/test/java/com/ossez/collections/JavaCollectionCleanupUnitTest.java @@ -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 + * + *

https://www.ossez.com/t/java-list-null/13940

+ * + * @author YuCheng + */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class JavaCollectionCleanupUnitTest { - // tests - removing nulls - @Test public void givenListContainsNulls_whenRemovingNullsWithPlainJava_thenCorrect() { final List list = Lists.newArrayList(null, 1, null); - while (list.remove(null)) - ; + while (list.remove(null)); assertThat(list, hasSize(1)); }