diff --git a/src/main/java/xyz/zhouxy/plusone/commons/model/IDCardNumber.java b/src/main/java/xyz/zhouxy/plusone/commons/model/IDCardNumber.java index 05cfa4b..062afca 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/model/IDCardNumber.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/model/IDCardNumber.java @@ -26,9 +26,9 @@ import xyz.zhouxy.plusone.commons.util.StringTools; */ public interface IDCardNumber { - static final char DEFAULT_REPLACED_CHAR = '*'; - static final int DEFAULT_DISPLAY_FRONT = 1; - static final int DEFAULT_DISPLAY_END = 2; + char DEFAULT_REPLACED_CHAR = '*'; + int DEFAULT_DISPLAY_FRONT = 1; + int DEFAULT_DISPLAY_END = 2; /** * 身份证号 diff --git a/src/test/java/xyz/zhouxy/plusone/commons/base/IWithCodeTests.java b/src/test/java/xyz/zhouxy/plusone/commons/base/IWithCodeTests.java index 92c7da8..b1f4a8f 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/base/IWithCodeTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/base/IWithCodeTests.java @@ -81,7 +81,7 @@ class IWithCodeTests { assertThrows(NullPointerException.class, () -> WithLongCode.INSTANCE.isCodeEquals(longCode)); } - private static enum WithCode implements IWithCode { + private enum WithCode implements IWithCode { INSTANCE("testCode"), SAME_CODE_INSTANCE("testCode"), WRONG_CODE_INSTANCE("wrongCode"), @@ -102,7 +102,7 @@ class IWithCodeTests { } } - private static enum WithIntCode implements IWithIntCode { + private enum WithIntCode implements IWithIntCode { INSTANCE(0), SAME_CODE_INSTANCE(0), WRONG_CODE_INSTANCE(1), @@ -120,7 +120,7 @@ class IWithCodeTests { } } - private static enum WithLongCode implements IWithLongCode { + private enum WithLongCode implements IWithLongCode { INSTANCE(0L), SAME_CODE_INSTANCE(0L), WRONG_CODE_INSTANCE(108L), diff --git a/src/test/java/xyz/zhouxy/plusone/commons/model/dto/test/PagingAndSortingQueryParamsTests.java b/src/test/java/xyz/zhouxy/plusone/commons/model/dto/test/PagingAndSortingQueryParamsTests.java index ae973e4..8939ce6 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/model/dto/test/PagingAndSortingQueryParamsTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/model/dto/test/PagingAndSortingQueryParamsTests.java @@ -181,13 +181,13 @@ public class PagingAndSortingQueryParamsTests { } AccountQueryParams queryParams = jackson.readValue(WRONG_JSON_STR, AccountQueryParams.class); - assertThrows(IllegalArgumentException.class, () -> queryParams.buildPagingParams()); // NOSONAR + assertThrows(IllegalArgumentException.class, queryParams::buildPagingParams); } static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); @Test - void testGson() throws Exception { + void testGson() { Gson gson = new GsonBuilder() .registerTypeAdapter(LocalDate.class, new TypeAdapter() { @@ -226,7 +226,7 @@ public class PagingAndSortingQueryParamsTests { } AccountQueryParams queryParams = gson.fromJson(WRONG_JSON_STR, AccountQueryParams.class); - assertThrows(IllegalArgumentException.class, () -> queryParams.buildPagingParams()); // NOSONAR + assertThrows(IllegalArgumentException.class, queryParams::buildPagingParams); } } diff --git a/src/test/java/xyz/zhouxy/plusone/commons/time/QuarterTests.java b/src/test/java/xyz/zhouxy/plusone/commons/time/QuarterTests.java index 976ccc7..028de55 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/time/QuarterTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/time/QuarterTests.java @@ -38,9 +38,7 @@ class QuarterTests { assertEquals(1, quarter.getValue()); assertEquals("Q1", quarter.name()); - assertThrows(DateTimeException.class, () -> { - Quarter.of(0); - }); + assertThrows(DateTimeException.class, () -> Quarter.of(0)); // ========== @@ -85,9 +83,7 @@ class QuarterTests { assertEquals(2, quarter.getValue()); assertEquals("Q2", quarter.name()); - assertThrows(DateTimeException.class, () -> { - Quarter.of(5); - }); + assertThrows(DateTimeException.class, () -> Quarter.of(5)); // ========== @@ -132,9 +128,7 @@ class QuarterTests { assertEquals(3, quarter.getValue()); assertEquals("Q3", quarter.name()); - assertThrows(IllegalArgumentException.class, () -> { - Quarter.valueOf("Abc"); - }); + assertThrows(IllegalArgumentException.class, () -> Quarter.valueOf("Abc")); // ========== @@ -179,9 +173,7 @@ class QuarterTests { assertEquals(4, quarter.getValue()); assertEquals("Q4", quarter.name()); - assertThrows(IllegalArgumentException.class, () -> { - Quarter.valueOf("Q5"); - }); + assertThrows(IllegalArgumentException.class, () -> Quarter.valueOf("Q5")); // ========== diff --git a/src/test/java/xyz/zhouxy/plusone/commons/util/IdGeneratorTests.java b/src/test/java/xyz/zhouxy/plusone/commons/util/IdGeneratorTests.java index f970df1..e088960 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/util/IdGeneratorTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/util/IdGeneratorTests.java @@ -37,9 +37,8 @@ import cn.hutool.core.collection.ConcurrentHashSet; public class IdGeneratorTests { - final ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue()); + final ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>()); @Test void testSnowflakeIdGenerator() { // NOSONAR @@ -48,7 +47,7 @@ public class IdGeneratorTests { for (int i = 0; i < 10000; i++) { executor.execute(() -> { for (int j = 0; j < 50000; j++) { - if (false == ids.add(snowflake.nextId())) { + if (!ids.add(snowflake.nextId())) { throw new RuntimeException("重复ID!"); } } diff --git a/src/test/java/xyz/zhouxy/plusone/commons/util/TreeBuilderTests.java b/src/test/java/xyz/zhouxy/plusone/commons/util/TreeBuilderTests.java index 6a662ae..7cff9a8 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/util/TreeBuilderTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/util/TreeBuilderTests.java @@ -87,19 +87,19 @@ class TreeBuilderTests { Arrays.stream(new Menu[] { B001, B002, B003, B004 }) .sorted(Comparator.comparing(Menu::getOrderNum)) .collect(Collectors.toList()), - MenuList.class.cast(menuMap.get("B")).children); + ((MenuList) menuMap.get("B")).children); assertEquals( Arrays.stream(new Menu[] { C1, C2, C3 }) .sorted(Comparator.comparing(Menu::getOrderNum)) .collect(Collectors.toList()), - MenuList.class.cast(menuMap.get("C")).children); + ((MenuList) menuMap.get("C")).children); assertEquals( Arrays.stream(new Menu[] { C1001, C1002 }) .sorted(Comparator.comparing(Menu::getOrderNum)) .collect(Collectors.toList()), - MenuList.class.cast(menuMap.get("C1")).children); + ((MenuList) menuMap.get("C1")).children); } @@ -125,18 +125,18 @@ class TreeBuilderTests { } assertEquals(ImmutableList.of(B001, B002, B003, B004), - MenuList.class.cast(menuMap.get("B")).children); + ((MenuList) menuMap.get("B")).children); assertEquals(ImmutableList.of(C1, C2, C3), - MenuList.class.cast(menuMap.get("C")).children); + ((MenuList) menuMap.get("C")).children); assertEquals(ImmutableList.of(C1001, C1002), - MenuList.class.cast(menuMap.get("C1")).children); + ((MenuList) menuMap.get("C1")).children); } @ToString @EqualsAndHashCode - private static abstract class Menu implements Serializable { // NOSONAR + private abstract static class Menu implements Serializable { protected final String parentMenuCode; protected final String menuCode; protected final String title;