This commit is contained in:
Looly
2023-03-13 01:11:43 +08:00
parent f05e084a3b
commit 5b559d19bd
94 changed files with 320 additions and 309 deletions

View File

@@ -593,7 +593,7 @@ public class AnnotatedElementUtilTest {
private @interface Annotation4 {}
@Annotation4
private static class Super {};
private static class Super {}
// ================= interface =================
@@ -608,7 +608,7 @@ public class AnnotatedElementUtilTest {
private @interface Annotation6 {}
@Annotation6
private interface Interface {};
private interface Interface {}
// ================= foo =================

View File

@@ -115,6 +115,6 @@ public class GenericAnnotationMappingTest {
}
@Annotation1("foo")
private static class Foo {};
private static class Foo {}
}

View File

@@ -203,6 +203,6 @@ public class HierarchicalAnnotatedElementTest {
public String method() { return null; }
@Annotation1
public static String method2() { return null; }
};
}
}

View File

@@ -211,6 +211,6 @@ public class MetaAnnotatedElementTest {
@Annotation3(name = "foo")
@Annotation4("foo")
private static class Foo {};
private static class Foo {}
}

View File

@@ -296,6 +296,6 @@ public class ResolvedAnnotationMappingTest {
@Annotation3(value = "Annotation3", alias = 312)
@Annotation2(value = "Annotation2")
@Annotation1(value = "Annotation1", alias = "goo", unDefVal = "foo", unDefVal2 = "foo")
private static class Foo {};
private static class Foo {}
}

View File

@@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base32;
import cn.hutool.core.codec.binary.Base32;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.text.StrUtil;
import org.junit.Assert;

View File

@@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base58;
import cn.hutool.core.codec.binary.Base58;
import org.junit.Assert;
import org.junit.Test;

View File

@@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base62;
import cn.hutool.core.codec.binary.Base62;
import cn.hutool.core.util.RandomUtil;
import org.junit.Assert;
import org.junit.Test;

View File

@@ -1,6 +1,6 @@
package cn.hutool.core.codec;
import cn.hutool.core.codec.BaseN.Base64;
import cn.hutool.core.codec.binary.Base64;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.text.StrUtil;

View File

@@ -152,7 +152,9 @@ public class CollStreamUtilTest {
// 对null友好
final Map<Long, Map<Long, Student>> termIdClassIdStudentMap = CollStreamUtil.group2Map(Arrays.asList(null, new Student(2, 2, 1, "王五")), Student::getTermId, Student::getClassId);
final Map<Long, Map<Long, Student>> termIdClassIdStudentCompareMap = new HashMap<Long, Map<Long, Student>>() {{
final Map<Long, Map<Long, Student>> termIdClassIdStudentCompareMap = new HashMap<Long, Map<Long, Student>>() {
private static final long serialVersionUID = 1L;
{
put(null, MapUtil.empty());
put(2L, MapUtil.of(2L, new Student(2, 2, 1, "王五")));
}};
@@ -269,6 +271,7 @@ public class CollStreamUtilTest {
Assert.assertEquals(set, compare);
}
@SuppressWarnings("ConstantValue")
@Test
public void testMerge() {
Map<Long, Student> map1 = null;

View File

@@ -152,8 +152,8 @@ public class NumberChineseFormatterTest {
@Test
public void formatTest3() {
// String f1 = NumberChineseFormatter.format(5000_8000, false, false);
// Assert.assertEquals("五千万零八千", f1);
final String f1 = NumberChineseFormatter.format(5000_8000, false, false);
Assert.assertEquals("五千万零八千", f1);
final String f2 = NumberChineseFormatter.format(1_0035_0089, false, false);
Assert.assertEquals("一亿零三十五万零八十九", f2);

View File

@@ -28,7 +28,7 @@ public class NioUtilTest {
@Test
@Ignore
public void copyByNIOTest2() throws IOException {
public void copyByNIOTest2() {
final File file = FileUtil.file("d:/test/logo.jpg");
final BufferedInputStream in = FileUtil.getInputStream(file);
final BufferedOutputStream out = FileUtil.getOutputStream("d:/test/2logo.jpg");

View File

@@ -11,12 +11,14 @@ import java.util.Map;
public class AssertTest {
@SuppressWarnings("ConstantValue")
@Test
public void isNullTest() {
final String a = null;
Assert.isNull(a);
}
@SuppressWarnings("ConstantValue")
@Test
public void notNullTest() {
final String a = null;
@@ -113,10 +115,9 @@ public class AssertTest {
Assert.isTrue(i > 0, () -> new IndexOutOfBoundsException("relation message to return"));
}
@SuppressWarnings("ConstantValue")
@Test
public void equalsTest() {
//String a="ab";
//final String b = new String("abc");
final String a = null;
final String b = null;
Assert.equals(a, b);
@@ -124,18 +125,16 @@ public class AssertTest {
Assert.equals(a, b, () -> new RuntimeException(StrUtil.format("{}和{}不相等", a, b)));
}
@SuppressWarnings("ConstantValue")
@Test
public void notEqualsTest() {
//String c="19";
//final String d = new String("19");
final String c = null;
final String d = "null";
//Assert.notEquals(c,d);
//Assert.notEquals(c,d,"{}等于{}",c,d);
Assert.notEquals(c, d, () -> new RuntimeException(StrUtil.format("{}和{}相等", c, d)));
}
@SuppressWarnings("ConstantValue")
@Test
public void notEqualsTest2() {
final Object c = null;

View File

@@ -162,16 +162,25 @@ public class EntryStreamTest {
@Test
public void testAppend() {
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){{
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){
private static final long serialVersionUID = 2091911960221937275L;
{
put(1, 1);
put(2, 2);
}};
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){{
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){
private static final long serialVersionUID = 4802315578432177802L;
{
put(3, 3);
put(4, 4);
}};
Assert.assertEquals(
new ArrayList<Map.Entry<Integer, Integer>>(){{
new ArrayList<Map.Entry<Integer, Integer>>(){
private static final long serialVersionUID = -4045530648496761947L;
{
addAll(map1.entrySet());
addAll(map2.entrySet());
}},
@@ -184,16 +193,25 @@ public class EntryStreamTest {
@Test
public void testPrepend() {
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){{
final Map<Integer, Integer> map1 = new HashMap<Integer, Integer>(){
private static final long serialVersionUID = -8772310525807986780L;
{
put(1, 1);
put(2, 2);
}};
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){{
final Map<Integer, Integer> map2 = new HashMap<Integer, Integer>(){
private static final long serialVersionUID = -8453400649627773936L;
{
put(3, 3);
put(4, 4);
}};
Assert.assertEquals(
new ArrayList<Map.Entry<Integer, Integer>>(){{
new ArrayList<Map.Entry<Integer, Integer>>(){
private static final long serialVersionUID = 7564826138581563332L;
{
addAll(map2.entrySet());
addAll(map1.entrySet());
}},
@@ -254,7 +272,7 @@ public class EntryStreamTest {
map.put(1, 1);
map.put(2, 2);
map.put(3, 3);
List<Integer> keys = EntryStream.of(map).collectKeys(Collectors.toList());
final List<Integer> keys = EntryStream.of(map).collectKeys(Collectors.toList());
Assert.assertEquals(new ArrayList<>(map.keySet()), keys);
}
@@ -264,7 +282,7 @@ public class EntryStreamTest {
map.put(1, 1);
map.put(2, 2);
map.put(3, 3);
List<Integer> keys = EntryStream.of(map).collectValues(Collectors.toList());
final List<Integer> keys = EntryStream.of(map).collectValues(Collectors.toList());
Assert.assertEquals(new ArrayList<>(map.keySet()), keys);
}
@@ -324,7 +342,7 @@ public class EntryStreamTest {
map.put(1, 1);
map.put(2, 2);
map.put(3, 3);
List<Integer> list = EntryStream.of(map)
final List<Integer> list = EntryStream.of(map)
.flatMap(e -> Stream.of(e.getKey(), e.getKey() + 1))
.collect(Collectors.toList());
Assert.assertEquals(Arrays.asList(1, 2, 2, 3, 3, 4), list);
@@ -567,7 +585,7 @@ public class EntryStreamTest {
private final K key;
private final V value;
public Entry(K key, V value) {
public Entry(final K key, final V value) {
this.key = key;
this.value = value;
}
@@ -583,7 +601,7 @@ public class EntryStreamTest {
}
@Override
public V setValue(V value) {
public V setValue(final V value) {
return null;
}
}

View File

@@ -20,6 +20,7 @@ import java.util.function.Function;
*/
public class ObjUtilTest {
@SuppressWarnings("ConstantValue")
@Test
public void equalsTest() {
Object a = null;
@@ -109,6 +110,7 @@ public class ObjUtilTest {
Assert.assertFalse(ObjUtil.isNotEmpty(Collections.emptyIterator()));
}
@SuppressWarnings("ConstantValue")
@Test
public void defaultIfNullTest() {
final Object val1 = new Object();
@@ -227,7 +229,7 @@ public class ObjUtilTest {
private final Integer id;
@Override
protected Object clone() throws CloneNotSupportedException {
throw new RuntimeException("can not clone this object");
throw new CloneNotSupportedException("can not clone this object");
}
}
@@ -255,6 +257,6 @@ public class ObjUtilTest {
}
@SuppressWarnings("unused")
private interface TypeArgument<A, B> {};
private interface TypeArgument<A, B> {}
}