diff --git a/pom.xml b/pom.xml
index 9ebd1b5..3c3373a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,8 +38,15 @@
org.projectlombok
lombok
${lombok.version}
+ compile
true
+
+ ch.qos.logback
+ logback-classic
+ 1.2.11
+ test
+
org.junit.jupiter
@@ -48,4 +55,4 @@
test
-
\ No newline at end of file
+
diff --git a/src/test/java/xyz/zhouxy/plusone/commons/EnumerationTests.java b/src/test/java/xyz/zhouxy/plusone/commons/EnumerationTests.java
index 6e950a7..6e6d552 100644
--- a/src/test/java/xyz/zhouxy/plusone/commons/EnumerationTests.java
+++ b/src/test/java/xyz/zhouxy/plusone/commons/EnumerationTests.java
@@ -2,21 +2,27 @@ package xyz.zhouxy.plusone.commons;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import xyz.zhouxy.plusone.commons.util.Enumeration;
+import javax.annotation.Nonnull;
+import java.util.Collection;
+
+@Slf4j
class EnumerationTests {
@Test
void testEnumeration() {
assertEquals(EntityStatus.AVAILABLE, EntityStatus.of(0));
+ log.info(EntityStatus.constants().toString());
}
}
final class EntityStatus extends Enumeration {
- private EntityStatus(int value, String name) {
+ private EntityStatus(int value, @Nonnull String name) {
super(value, name);
}
@@ -24,16 +30,16 @@ final class EntityStatus extends Enumeration {
public static final EntityStatus AVAILABLE = new EntityStatus(0, "正常");
public static final EntityStatus DISABLED = new EntityStatus(1, "禁用");
- private static final EnumerationValuesHolder ENUMERATION_VALUES = new EnumerationValuesHolder<>(
- AVAILABLE,
- DISABLED);
+ private static final ValueSet ENUMERATION_VALUES = new ValueSet<>(
+ AVAILABLE, DISABLED);
+ @Nonnull
public static EntityStatus of(int value) {
return ENUMERATION_VALUES.get(value);
}
- @Override
- public String toString() {
- return "EntityStatus" + super.toString();
+ @Nonnull
+ public static Collection constants() {
+ return ENUMERATION_VALUES.getValues();
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/xyz/zhouxy/plusone/commons/util/NumberUtilTest.java b/src/test/java/xyz/zhouxy/plusone/commons/util/NumberUtilTest.java
index f330013..3c42b12 100644
--- a/src/test/java/xyz/zhouxy/plusone/commons/util/NumberUtilTest.java
+++ b/src/test/java/xyz/zhouxy/plusone/commons/util/NumberUtilTest.java
@@ -3,8 +3,10 @@ package xyz.zhouxy.plusone.commons.util;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
+@Slf4j
class NumberUtilTest {
@Test
void testSum() {
@@ -12,24 +14,24 @@ class NumberUtilTest {
for (int i = 0; i < Integer.MAX_VALUE; i++) {
result += Short.MAX_VALUE;
}
- System.out.println("Integer.MAX_VALUE: " + Integer.MAX_VALUE);
- System.out.println("result: " + result);
+ log.info("Integer.MAX_VALUE: {}", Integer.MAX_VALUE);
+ log.info("result: {}", result);
assertFalse(Integer.MAX_VALUE > result);
result = 0;
for (int i = 0; i < Integer.MAX_VALUE; i++) {
result += Short.MAX_VALUE;
}
- System.out.println("Long.MAX_VALUE: " + Long.MAX_VALUE);
- System.out.println("result: " + result);
+ log.info("Long.MAX_VALUE: {}", Long.MAX_VALUE);
+ log.info("result: {}", result);
assertTrue(Long.MAX_VALUE > result);
result = 0;
for (int i = 0; i < Integer.MAX_VALUE; i++) {
result += Integer.MAX_VALUE;
}
- System.out.println("Long.MAX_VALUE: " + Long.MAX_VALUE);
- System.out.println("result: " + result);
+ log.info("Long.MAX_VALUE: {}", Long.MAX_VALUE);
+ log.info("result: {}", result);
assertTrue(Long.MAX_VALUE > result);
}
}
diff --git a/src/test/java/xyz/zhouxy/plusone/commons/util/RestfulResultTest.java b/src/test/java/xyz/zhouxy/plusone/commons/util/RestfulResultTest.java
index 177d05a..6255a67 100644
--- a/src/test/java/xyz/zhouxy/plusone/commons/util/RestfulResultTest.java
+++ b/src/test/java/xyz/zhouxy/plusone/commons/util/RestfulResultTest.java
@@ -2,8 +2,10 @@ package xyz.zhouxy.plusone.commons.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
+@Slf4j
class RestfulResultTest {
@Test
@@ -11,24 +13,24 @@ class RestfulResultTest {
String str = null;
RestfulResult result = RestfulResult.successIf(str != null, "成功")
.orError();
- System.out.println(result);
+ log.info(result.toString());
assertEquals(RestfulResult.DEFAULT_ERROR_STATUS, result.getStatus());
result = RestfulResult.successIf(str != null, "成功")
.orError(2333, "失败");
- System.out.println(result);
+ log.info(result.toString());
assertEquals(2333, result.getStatus());
assertEquals("失败", result.getMessage());
str = "";
result = RestfulResult.successIf(str != null, "成功")
.orError();
- System.out.println(result);
+ log.info(result.toString());
assertEquals(RestfulResult.SUCCESS_STATUS, result.getStatus());
result = RestfulResult.successIf(str != null, "成功", str)
.orError(2333, "失败");
- System.out.println(result);
+ log.info(result.toString());
assertEquals("成功", result.getMessage());
}
}