diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ArrayUtilTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ArrayUtilTest.java index 358dfd9f..3a314c4d 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ArrayUtilTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/ArrayUtilTest.java @@ -19,11 +19,8 @@ package cn.hippo4j.common.toolkit; import cn.hippo4j.common.function.Matcher; import com.google.common.base.Strings; -import org.checkerframework.checker.units.qual.A; import org.junit.Test; -import java.lang.reflect.Array; - public class ArrayUtilTest { @Test @@ -41,13 +38,10 @@ public class ArrayUtilTest { @Test public void assertFirstMatch() { Matcher matcher = (str) -> "1".equalsIgnoreCase(str); - String[] array = new String[0]; Assert.isTrue(Strings.isNullOrEmpty(ArrayUtil.firstMatch(matcher, array))); - array = new String[]{"0"}; Assert.isTrue(Strings.isNullOrEmpty(ArrayUtil.firstMatch(matcher, array))); - array = new String[]{"1"}; Assert.isTrue(!Strings.isNullOrEmpty(ArrayUtil.firstMatch(matcher, array))); } @@ -57,14 +51,12 @@ public class ArrayUtilTest { String[] array = new String[]{"1"}; Assert.isTrue(ArrayUtil.addAll(array, null).length == 1); Assert.isTrue(ArrayUtil.addAll(null, array).length == 1); - Assert.isTrue(ArrayUtil.addAll(array, new String[]{"1"}).length == 2); } @Test public void assertClone() { Assert.isNull(ArrayUtil.clone(null)); - String[] array = new String[0]; Assert.isTrue(array != ArrayUtil.clone(array)); Assert.isTrue(array.length == ArrayUtil.clone(array).length); diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/CollectionUtilTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/CollectionUtilTest.java index b0be6add..78715122 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/CollectionUtilTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/CollectionUtilTest.java @@ -30,7 +30,6 @@ public class CollectionUtilTest { @Test public void assertGetFirst() { Assert.isNull(CollectionUtil.getFirst(null)); - String first = CollectionUtil.getFirst(Lists.newArrayList("1", "2")); Assert.notEmpty(first); } @@ -39,28 +38,20 @@ public class CollectionUtilTest { public void assertIsEmpty() { List list = null; Assert.isTrue(CollectionUtil.isEmpty(list)); - list = Lists.newArrayList(); Assert.isTrue(CollectionUtil.isEmpty(list)); - list = Lists.newArrayList("1"); Assert.isTrue(!CollectionUtil.isEmpty(list)); - Map map = null; Assert.isTrue(CollectionUtil.isEmpty(map)); - map = Maps.newHashMap(); Assert.isTrue(CollectionUtil.isEmpty(map)); - map.put("key", "value"); Assert.isTrue(!CollectionUtil.isEmpty(map)); - Iterator iterator = null; Assert.isTrue(CollectionUtil.isEmpty(iterator)); - iterator = Lists.emptyList().iterator(); Assert.isTrue(CollectionUtil.isEmpty(iterator)); - iterator = Lists.newArrayList("1").iterator(); Assert.isTrue(!CollectionUtil.isEmpty(iterator)); } @@ -69,28 +60,20 @@ public class CollectionUtilTest { public void assertIsNotEmpty() { List list = null; Assert.isTrue(!CollectionUtil.isNotEmpty(list)); - list = Lists.newArrayList(); Assert.isTrue(!CollectionUtil.isNotEmpty(list)); - list = Lists.newArrayList("1"); Assert.isTrue(CollectionUtil.isNotEmpty(list)); - Map map = null; Assert.isTrue(!CollectionUtil.isNotEmpty(map)); - map = Maps.newHashMap(); Assert.isTrue(!CollectionUtil.isNotEmpty(map)); - map.put("key", "value"); Assert.isTrue(CollectionUtil.isNotEmpty(map)); - Iterator iterator = null; Assert.isTrue(!CollectionUtil.isNotEmpty(iterator)); - iterator = Lists.emptyList().iterator(); Assert.isTrue(!CollectionUtil.isNotEmpty(iterator)); - iterator = Lists.newArrayList("1").iterator(); Assert.isTrue(CollectionUtil.isNotEmpty(iterator)); } diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java index d52a684f..1bb988d0 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/JSONUtilTest.java @@ -31,8 +31,11 @@ import java.util.List; public class JSONUtilTest { private static final Foo EXPECTED_FOO = new Foo(1, "foo1", new Foo(2, "foo2", null)); + private static final List EXPECTED_FOO_ARRAY = Arrays.asList(EXPECTED_FOO, EXPECTED_FOO); + private static final String EXPECTED_FOO_JSON = "{\"id\":1,\"name\":\"foo1\",\"foo\":{\"id\":2,\"name\":\"foo2\"}}"; + private static final String EXPECTED_FOO_JSON_ARRAY = "[" + EXPECTED_FOO_JSON + "," + EXPECTED_FOO_JSON + "]"; @Test @@ -76,8 +79,9 @@ public class JSONUtilTest { private static class Foo { private Integer id; + private String name; + private Foo foo; } - }