From a59227abc42cc635c3629e86397ea2ac61746dd2 Mon Sep 17 00:00:00 2001 From: weihubeats Date: Sat, 19 Nov 2022 10:22:02 +0800 Subject: [PATCH] Add test (#998) * Simplified DynamicThreadPool usage * Simplified DynamicThreadPool usage * init * add AssertTest --- .../hippo4j/common/toolkit/ArrayUtilTest.java | 3 + .../cn/hippo4j/common/toolkit/AssertTest.java | 88 +++++++++++++++++++ 2 files changed, 91 insertions(+) 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 1505d9ac..67d86932 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 @@ -21,6 +21,9 @@ import cn.hippo4j.common.function.Matcher; import org.junit.Test; import org.springframework.util.StringUtils; +/** + * test {@link ArrayUtil} + */ public class ArrayUtilTest { @Test diff --git a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/AssertTest.java b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/AssertTest.java index d2987c80..ce291c61 100644 --- a/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/AssertTest.java +++ b/hippo4j-common/src/test/java/cn/hippo4j/common/toolkit/AssertTest.java @@ -17,5 +17,93 @@ package cn.hippo4j.common.toolkit; +import java.util.Collections; + +import org.junit.Test; + +/** + * test {@link Assert} + */ public final class AssertTest { + + @Test(expected = IllegalArgumentException.class) + public void assertIsTrue() { + Assert.isTrue(false, "test message"); + } + + @Test(expected = IllegalArgumentException.class) + public void assertIsTrueAndMessageIsNull() { + Assert.isTrue(false); + } + + @Test(expected = IllegalArgumentException.class) + public void assertIsNullAndMessageIsNull() { + Assert.isNull(""); + } + + @Test(expected = IllegalArgumentException.class) + public void assertIsNull() { + Assert.isNull("", "object is null"); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotNull() { + Assert.notNull(null, "object is null"); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotNullAndMessageIsNull() { + Assert.notNull(null); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotEmptyByList() { + Assert.notEmpty(Collections.emptyList(), "object is null"); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotEmptyByListAndMessageIsNull() { + Assert.notEmpty(Collections.emptyList()); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotEmptyByMap() { + Assert.notEmpty(Collections.emptyMap(), "map is null"); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotEmptyByMapAndMessageIsNull() { + Assert.notEmpty(Collections.emptyMap()); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotEmptyByString() { + Assert.notEmpty("", "string is null"); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotEmptyByStringAndMessageIsNull() { + Assert.notEmpty(""); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotBlankByString() { + Assert.notBlank(" ", "string is null"); + } + + @Test(expected = IllegalArgumentException.class) + public void assertNotBlankByStringAndMessageIsNull() { + Assert.notBlank(" "); + } + + @Test(expected = IllegalArgumentException.class) + public void assertHasText() { + Assert.hasText(" ", "text is null"); + } + + @Test(expected = IllegalArgumentException.class) + public void assertHasTextAndMessageIsNull() { + Assert.hasText(" "); + } + }