mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
fix code
This commit is contained in:
@@ -12,20 +12,16 @@
|
||||
|
||||
package org.dromara.hutool.core.classloader;
|
||||
|
||||
import org.dromara.hutool.core.collection.iter.EnumerationIter;
|
||||
import org.dromara.hutool.core.io.file.FileUtil;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.map.Dict;
|
||||
import org.dromara.hutool.core.reflect.ClassUtil;
|
||||
import org.dromara.hutool.core.reflect.FieldUtil;
|
||||
import org.dromara.hutool.core.reflect.method.MethodUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.Driver;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
public class ClassLoaderUtilTest {
|
||||
|
||||
|
||||
@@ -532,8 +532,8 @@ public class CollUtilTest {
|
||||
final List<Object> list1 = ListUtil.of(false);
|
||||
final List<Object> list2 = ListUtil.of(true);
|
||||
|
||||
Assertions.assertTrue(list1 instanceof ArrayList);
|
||||
Assertions.assertTrue(list2 instanceof LinkedList);
|
||||
Assertions.assertInstanceOf(ArrayList.class, list1);
|
||||
Assertions.assertInstanceOf(LinkedList.class, list2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,15 +22,15 @@ public class ArrayIterTest {
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
Assertions.assertTrue(iter.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNext() {
|
||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
Assertions.assertEquals((Integer)1, iter.next());
|
||||
Assertions.assertEquals((Integer)2, iter.next());
|
||||
Assertions.assertEquals((Integer)3, iter.next());
|
||||
@@ -38,22 +38,22 @@ public class ArrayIterTest {
|
||||
|
||||
@Test
|
||||
public void testRemove() {
|
||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
Assertions.assertThrows(UnsupportedOperationException.class, iter::remove);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetArray() {
|
||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
Assertions.assertEquals(arr, iter.getArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReset() {
|
||||
Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
final Integer[] arr = new Integer[]{ 1, 2, 3 };
|
||||
final ArrayIter<Integer> iter = new ArrayIter<>(arr);
|
||||
Assertions.assertEquals((Integer)1, iter.next());
|
||||
iter.reset();
|
||||
Assertions.assertEquals((Integer)1, iter.next());
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
package org.dromara.hutool.core.collection.iter;
|
||||
|
||||
import org.dromara.hutool.core.exception.HutoolException;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -27,13 +28,13 @@ public class LineIterTest {
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
LineIter iter = getItrFromClasspathFile();
|
||||
final LineIter iter = getItrFromClasspathFile();
|
||||
Assertions.assertTrue(iter.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNext() {
|
||||
LineIter iter = getItrFromClasspathFile();
|
||||
final LineIter iter = getItrFromClasspathFile();
|
||||
Assertions.assertEquals("is first line", iter.next());
|
||||
Assertions.assertEquals("is second line", iter.next());
|
||||
Assertions.assertEquals("is third line", iter.next());
|
||||
@@ -41,39 +42,39 @@ public class LineIterTest {
|
||||
|
||||
@Test
|
||||
public void testRemove() {
|
||||
LineIter iter = getItrFromClasspathFile();
|
||||
final LineIter iter = getItrFromClasspathFile();
|
||||
iter.next();
|
||||
Assertions.assertThrows(UnsupportedOperationException.class, iter::remove);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFinish() {
|
||||
LineIter iter = getItrFromClasspathFile();
|
||||
final LineIter iter = getItrFromClasspathFile();
|
||||
iter.finish();
|
||||
Assertions.assertThrows(NoSuchElementException.class, iter::next);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClose() throws IOException {
|
||||
URL url = LineIterTest.class.getClassLoader().getResource("text.txt");
|
||||
final URL url = LineIterTest.class.getClassLoader().getResource("text.txt");
|
||||
Assertions.assertNotNull(url);
|
||||
FileInputStream inputStream = new FileInputStream(url.getFile());
|
||||
LineIter iter = new LineIter(inputStream, StandardCharsets.UTF_8);
|
||||
final FileInputStream inputStream = new FileInputStream(url.getFile());
|
||||
final LineIter iter = new LineIter(inputStream, StandardCharsets.UTF_8);
|
||||
iter.close();
|
||||
Assertions.assertThrows(NoSuchElementException.class, iter::next);
|
||||
Assertions.assertThrows(IOException.class, inputStream::read);
|
||||
}
|
||||
|
||||
private static LineIter getItrFromClasspathFile() {
|
||||
URL url = LineIterTest.class.getClassLoader().getResource("text.txt");
|
||||
final URL url = LineIterTest.class.getClassLoader().getResource("text.txt");
|
||||
Assertions.assertNotNull(url);
|
||||
FileInputStream inputStream = null;
|
||||
final FileInputStream inputStream;
|
||||
try {
|
||||
inputStream = new FileInputStream(url.getFile());
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (final FileNotFoundException e) {
|
||||
throw new HutoolException(e);
|
||||
}
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
return new LineIter(bufferedReader);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,32 +27,32 @@ import java.util.Set;
|
||||
public class CastUtilTest {
|
||||
@Test
|
||||
public void testCastToSuper() {
|
||||
Collection<Integer> collection= ListUtil.of(1,2,3);
|
||||
List<Integer> list = ListUtil.of(1, 2, 3);
|
||||
Set<Integer> set = SetUtil.of(1, 2, 3);
|
||||
Map<Integer, Integer> map = new HashMap<>();
|
||||
final Collection<Integer> collection= ListUtil.of(1,2,3);
|
||||
final List<Integer> list = ListUtil.of(1, 2, 3);
|
||||
final Set<Integer> set = SetUtil.of(1, 2, 3);
|
||||
final Map<Integer, Integer> map = new HashMap<>();
|
||||
map.put(1, 1);
|
||||
|
||||
Collection<Number> collection2 = CastUtil.castUp(collection);
|
||||
final Collection<Number> collection2 = CastUtil.castUp(collection);
|
||||
collection2.add(new Double("123.1"));
|
||||
Assertions.assertSame(collection, collection2);
|
||||
|
||||
Collection<Integer> collection3 = CastUtil.castDown(collection2);
|
||||
final Collection<Integer> collection3 = CastUtil.castDown(collection2);
|
||||
Assertions.assertSame(collection2, collection3);
|
||||
|
||||
List<Number> list2 = CastUtil.castUp(list);
|
||||
final List<Number> list2 = CastUtil.castUp(list);
|
||||
Assertions.assertSame(list, list2);
|
||||
List<Integer> list3 = CastUtil.castDown(list2);
|
||||
final List<Integer> list3 = CastUtil.castDown(list2);
|
||||
Assertions.assertSame(list2, list3);
|
||||
|
||||
Set<Number> set2 = CastUtil.castUp(set);
|
||||
final Set<Number> set2 = CastUtil.castUp(set);
|
||||
Assertions.assertSame(set, set2);
|
||||
Set<Integer> set3 = CastUtil.castDown(set2);
|
||||
final Set<Integer> set3 = CastUtil.castDown(set2);
|
||||
Assertions.assertSame(set2, set3);
|
||||
|
||||
Map<Number, Serializable> map2 = CastUtil.castUp(map);
|
||||
final Map<Number, Serializable> map2 = CastUtil.castUp(map);
|
||||
Assertions.assertSame(map, map2);
|
||||
Map<Integer, Number> map3 = CastUtil.castDown(map2);
|
||||
final Map<Integer, Number> map3 = CastUtil.castDown(map2);
|
||||
Assertions.assertSame(map2, map3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.OffsetTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TemporalAccessorConverterTest {
|
||||
|
||||
@@ -32,7 +33,7 @@ public class TemporalAccessorConverterTest {
|
||||
|
||||
// 通过转换获取的Instant为UTC时间
|
||||
final Instant instant = Convert.convert(Instant.class, dateStr);
|
||||
final Instant instant1 = DateUtil.parse(dateStr).toInstant();
|
||||
final Instant instant1 = Objects.requireNonNull(DateUtil.parse(dateStr)).toInstant();
|
||||
Assertions.assertEquals(instant1, instant);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import org.dromara.hutool.core.date.chinese.GanZhi;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class GanzhiTest {
|
||||
|
||||
@Test
|
||||
@@ -27,7 +29,7 @@ public class GanzhiTest {
|
||||
@Test
|
||||
public void getCyclicalYMDTest(){
|
||||
//通过公历构建
|
||||
final ChineseDate chineseDate = new ChineseDate(DateUtil.parse("1993-01-06"));
|
||||
final ChineseDate chineseDate = new ChineseDate(Objects.requireNonNull(DateUtil.parse("1993-01-06")));
|
||||
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
||||
Assertions.assertEquals("壬申年癸丑月丁亥日",cyclicalYMD);
|
||||
}
|
||||
@@ -43,7 +45,7 @@ public class GanzhiTest {
|
||||
@Test
|
||||
public void getCyclicalYMDTest3(){
|
||||
//通过公历构建
|
||||
final ChineseDate chineseDate = new ChineseDate(DateUtil.parse("2020-08-28"));
|
||||
final ChineseDate chineseDate = new ChineseDate(Objects.requireNonNull(DateUtil.parse("2020-08-28")));
|
||||
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
||||
Assertions.assertEquals("庚子年甲申月癸卯日",cyclicalYMD);
|
||||
}
|
||||
@@ -51,7 +53,7 @@ public class GanzhiTest {
|
||||
@Test
|
||||
public void getCyclicalYMDTest4(){
|
||||
//通过公历构建
|
||||
final ChineseDate chineseDate = new ChineseDate(DateUtil.parse("1905-08-28"));
|
||||
final ChineseDate chineseDate = new ChineseDate(Objects.requireNonNull(DateUtil.parse("1905-08-28")));
|
||||
final String cyclicalYMD = chineseDate.getCyclicalYMD();
|
||||
Assertions.assertEquals("乙巳年甲申月己亥日",cyclicalYMD);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ package org.dromara.hutool.core.date;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class IssueI82Y1LTest {
|
||||
@Test
|
||||
public void parseTest() {
|
||||
final String dt1 = "2023-09-14T05:00:03.648519Z";
|
||||
Assertions.assertEquals("2023-09-14 05:10:51", DateUtil.parse(dt1).toString());
|
||||
Assertions.assertEquals("2023-09-14 05:10:51", Objects.requireNonNull(DateUtil.parse(dt1)).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,13 +111,13 @@ public class TimeUtilTest {
|
||||
Assertions.assertEquals("2020-01-23", localDate.toString());
|
||||
|
||||
localDate = TimeUtil.parseDate("2020-01-23T12:23:56", DateTimeFormatter.ISO_DATE_TIME);
|
||||
Assertions.assertEquals("2020-01-23", localDate.toString());
|
||||
Assertions.assertEquals("2020-01-23", Objects.requireNonNull(localDate).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseSingleMonthAndDayTest() {
|
||||
final LocalDate localDate = TimeUtil.parseDate("2020-1-1", "yyyy-M-d");
|
||||
Assertions.assertEquals("2020-01-01", localDate.toString());
|
||||
Assertions.assertEquals("2020-01-01", Objects.requireNonNull(localDate).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -47,8 +47,6 @@ public class ZodiacTest {
|
||||
@Test
|
||||
public void getZodiacOutOfRangeTest() {
|
||||
// https://github.com/dromara/hutool/issues/3036
|
||||
Assertions.assertThrows(IllegalArgumentException.class, ()->{
|
||||
DateUtil.getZodiac(Month.UNDECIMBER.getValue(), 10);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, ()-> DateUtil.getZodiac(Month.UNDECIMBER.getValue(), 10));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class LambdaFactoryTest {
|
||||
try {
|
||||
LambdaFactory.build(Function.class, Something.class, "setId", Long.class);
|
||||
} catch (final Exception e) {
|
||||
Assertions.assertTrue(e.getCause() instanceof LambdaConversionException);
|
||||
Assertions.assertInstanceOf(LambdaConversionException.class, e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
package org.dromara.hutool.core.io.file;
|
||||
|
||||
import org.dromara.hutool.core.array.ArrayUtil;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -14,14 +14,11 @@ package org.dromara.hutool.core.io.watch;
|
||||
|
||||
import org.dromara.hutool.core.io.file.PathUtil;
|
||||
import org.dromara.hutool.core.io.watch.watchers.DelayWatcher;
|
||||
import org.dromara.hutool.core.io.watch.watchers.SimpleWatcher;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.nio.file.WatchKey;
|
||||
|
||||
/**
|
||||
* 文件监听单元测试
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package org.dromara.hutool.core.io.watch;
|
||||
|
||||
import org.dromara.hutool.core.io.file.PathUtil;
|
||||
import org.dromara.hutool.core.io.watch.watchers.SimpleWatcher;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.file.WatchEvent;
|
||||
import java.nio.file.WatchKey;
|
||||
|
||||
public class WatchServiceWrapperTest {
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
|
||||
@@ -197,9 +197,9 @@ public class OptTest {
|
||||
return list.get(0);
|
||||
}).exceptionOrElse("hutool");
|
||||
|
||||
Assertions.assertTrue(Opt.ofTry(() -> {
|
||||
Assertions.assertInstanceOf(AssertionError.class, Opt.ofTry(() -> {
|
||||
throw new AssertionError("");
|
||||
}).getThrowable() instanceof AssertionError);
|
||||
}).getThrowable());
|
||||
Assertions.assertEquals(npe, npeSituation);
|
||||
Assertions.assertEquals(indexOut, indexOutSituation);
|
||||
Assertions.assertEquals("hutool", npe);
|
||||
|
||||
@@ -116,9 +116,7 @@ public class ValidatorTest {
|
||||
|
||||
@Test
|
||||
public void validateTest() throws ValidateException {
|
||||
Assertions.assertThrows(ValidateException.class, ()->{
|
||||
Validator.validateChinese("我是一段zhongwen", "内容中包含非中文");
|
||||
});
|
||||
Assertions.assertThrows(ValidateException.class, ()-> Validator.validateChinese("我是一段zhongwen", "内容中包含非中文"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -61,58 +61,58 @@ abstract class BaseMutableTest<V, M extends Mutable<V>> {
|
||||
|
||||
@Test
|
||||
void testGet() {
|
||||
Mutable<V> mutableObj = getMutable(getValue1());
|
||||
V value = mutableObj.get();
|
||||
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||
final V value = mutableObj.get();
|
||||
Assertions.assertEquals(getValue1(), value);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSet() {
|
||||
Mutable<V> mutableObj = getMutable(getValue2());
|
||||
final Mutable<V> mutableObj = getMutable(getValue2());
|
||||
mutableObj.set(getValue2());
|
||||
V value = mutableObj.get();
|
||||
final V value = mutableObj.get();
|
||||
Assertions.assertEquals(getValue2(), value);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTo() {
|
||||
Mutable<V> mutableObj = getMutable(getValue1());
|
||||
String value = mutableObj.to(String::valueOf);
|
||||
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||
final String value = mutableObj.to(String::valueOf);
|
||||
Assertions.assertEquals(String.valueOf(getValue1()), value);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToOpt() {
|
||||
Mutable<V> mutableObj = getMutable(getValue1());
|
||||
V value = mutableObj.toOpt().get();
|
||||
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||
final V value = mutableObj.toOpt().get();
|
||||
Assertions.assertEquals(getValue1(), value);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMap() {
|
||||
Mutable<V> mutableObj = getMutable(getValue1());
|
||||
V value = mutableObj.map(v -> getValue2()).get();
|
||||
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||
final V value = mutableObj.map(v -> getValue2()).get();
|
||||
Assertions.assertEquals(getValue2(), value);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTest() {
|
||||
Mutable<V> mutableObj = getMutable(getValue1());
|
||||
final Mutable<V> mutableObj = getMutable(getValue1());
|
||||
Assertions.assertTrue(mutableObj.test(Objects::nonNull));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPeek() {
|
||||
Mutable<V> m1 = getMutable(getValue1());
|
||||
Mutable<V> m2 = getMutable(getValue2());
|
||||
final Mutable<V> m1 = getMutable(getValue1());
|
||||
final Mutable<V> m2 = getMutable(getValue2());
|
||||
m1.peek(m2::set);
|
||||
Assertions.assertEquals(getValue1(), m2.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHashCode() {
|
||||
V value = getValue1();
|
||||
Mutable<V> mutableObj = new MutableObj<>(value);
|
||||
final V value = getValue1();
|
||||
final Mutable<V> mutableObj = new MutableObj<>(value);
|
||||
Assertions.assertEquals(value.hashCode(), mutableObj.hashCode());
|
||||
mutableObj.set(null);
|
||||
Assertions.assertEquals(0, mutableObj.hashCode());
|
||||
@@ -120,10 +120,9 @@ abstract class BaseMutableTest<V, M extends Mutable<V>> {
|
||||
|
||||
@Test
|
||||
void testEquals() {
|
||||
V value = getValue1();
|
||||
Mutable<V> mutableObj = new MutableObj<>(value);
|
||||
final V value = getValue1();
|
||||
final Mutable<V> mutableObj = new MutableObj<>(value);
|
||||
Assertions.assertNotEquals(value, mutableObj);
|
||||
Assertions.assertEquals(mutableObj, mutableObj);
|
||||
Assertions.assertEquals(mutableObj, new MutableObj<>(value));
|
||||
Assertions.assertNotEquals(mutableObj, new MutableObj<>(null));
|
||||
Assertions.assertNotEquals(mutableObj, null);
|
||||
@@ -132,8 +131,8 @@ abstract class BaseMutableTest<V, M extends Mutable<V>> {
|
||||
|
||||
@Test
|
||||
void testToString() {
|
||||
V value = getValue1();
|
||||
Mutable<V> mutableObj = new MutableObj<>(value);
|
||||
final V value = getValue1();
|
||||
final Mutable<V> mutableObj = new MutableObj<>(value);
|
||||
Assertions.assertEquals(value.toString(), mutableObj.toString());
|
||||
mutableObj.set(null);
|
||||
Assertions.assertEquals(StrValidator.NULL, mutableObj.toString());
|
||||
|
||||
@@ -25,7 +25,6 @@ public class BoundedRangeTest {
|
||||
final BoundedRange<Integer> range = new BoundedRange<>(
|
||||
Bound.greaterThan(0), Bound.lessThan(10)
|
||||
);
|
||||
Assertions.assertEquals(range, range);
|
||||
Assertions.assertNotEquals(range, null);
|
||||
Assertions.assertEquals(range, new BoundedRange<>(
|
||||
Bound.greaterThan(0), Bound.lessThan(10)
|
||||
@@ -66,7 +65,6 @@ public class BoundedRangeTest {
|
||||
|
||||
// isXXX
|
||||
Assertions.assertFalse(range.isDisjoint(BoundedRange.open(0, 5)));
|
||||
Assertions.assertEquals(range, range);
|
||||
Assertions.assertNotEquals(range, BoundedRange.open(0, 5));
|
||||
Assertions.assertTrue(range.isIntersected(BoundedRange.open(0, 5)));
|
||||
Assertions.assertTrue(range.isIntersected(range));
|
||||
@@ -113,7 +111,6 @@ public class BoundedRangeTest {
|
||||
Assertions.assertFalse(range.test(-1));
|
||||
|
||||
// isXXX
|
||||
Assertions.assertEquals(range, range);
|
||||
Assertions.assertTrue(range.isDisjoint(BoundedRange.open(-5, 0))); // (-5, 0)
|
||||
Assertions.assertTrue(range.isDisjoint(BoundedRange.close(-5, 0))); // [-5, 0]
|
||||
Assertions.assertTrue(range.isIntersected(BoundedRange.close(-5, 1))); // [-5, 1]
|
||||
@@ -154,7 +151,6 @@ public class BoundedRangeTest {
|
||||
Assertions.assertFalse(range.test(-1));
|
||||
|
||||
// isXXX
|
||||
Assertions.assertEquals(range, range);
|
||||
Assertions.assertTrue(range.isDisjoint(BoundedRange.open(-5, 0))); // (-5, 0)
|
||||
Assertions.assertTrue(range.isDisjoint(BoundedRange.close(-5, 0))); // [-5, 0]
|
||||
Assertions.assertTrue(range.isIntersected(BoundedRange.open(-5, 1))); // [-5, 1]
|
||||
|
||||
@@ -489,7 +489,7 @@ public class NumberUtilTest {
|
||||
final String numberStr = "429900013E20220812163344551";
|
||||
final Number number = NumberUtil.parseNumber(numberStr);
|
||||
Assertions.assertNotNull(number);
|
||||
Assertions.assertTrue(number instanceof BigDecimal);
|
||||
Assertions.assertInstanceOf(BigDecimal.class, number);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -63,14 +63,14 @@ class UrlDecoderTest {
|
||||
@Test
|
||||
void decodeCharSetIsNullToStrTest() {
|
||||
final String hello = "你好";
|
||||
String decode = UrlDecoder.decode(hello, null, true);
|
||||
final String decode = UrlDecoder.decode(hello, null, true);
|
||||
Assertions.assertEquals(hello, decode);
|
||||
}
|
||||
|
||||
@Test
|
||||
void decodeStrIsEmptyToStrTest() {
|
||||
final String strEmpty = "";
|
||||
String decode = UrlDecoder.decode(strEmpty, StandardCharsets.UTF_8, true);
|
||||
final String decode = UrlDecoder.decode(strEmpty, StandardCharsets.UTF_8, true);
|
||||
Assertions.assertEquals(strEmpty, decode);
|
||||
}
|
||||
|
||||
@@ -78,19 +78,19 @@ class UrlDecoderTest {
|
||||
void decodeStrWithUTF8ToStrTest() {
|
||||
final String exceptedDecode = "你好";
|
||||
final String encode = "%E4%BD%A0%E5%A5%BD";
|
||||
String s1 = UrlDecoder.decode(encode);
|
||||
final String s1 = UrlDecoder.decode(encode);
|
||||
Assertions.assertEquals(exceptedDecode, s1);
|
||||
|
||||
String s2 = UrlDecoder.decode(encode, StandardCharsets.UTF_8);
|
||||
final String s2 = UrlDecoder.decode(encode, StandardCharsets.UTF_8);
|
||||
Assertions.assertEquals(exceptedDecode, s2);
|
||||
|
||||
String s3 = UrlDecoder.decode(encode, true);
|
||||
final String s3 = UrlDecoder.decode(encode, true);
|
||||
Assertions.assertEquals(exceptedDecode, s3);
|
||||
|
||||
String s4 = UrlDecoder.decode(encode + "+", false);
|
||||
final String s4 = UrlDecoder.decode(encode + "+", false);
|
||||
Assertions.assertEquals(exceptedDecode + "+", s4);
|
||||
|
||||
String s5 = UrlDecoder.decode(encode, StandardCharsets.UTF_8, false);
|
||||
final String s5 = UrlDecoder.decode(encode, StandardCharsets.UTF_8, false);
|
||||
Assertions.assertEquals(exceptedDecode, s5);
|
||||
}
|
||||
|
||||
@@ -98,10 +98,10 @@ class UrlDecoderTest {
|
||||
void decodeStrWithUTF8ToByteTest(){
|
||||
final String exceptedDecode = "你好";
|
||||
final String encode = "%E4%BD%A0%E5%A5%BD";
|
||||
byte[] decode = UrlDecoder.decode(encode.getBytes(StandardCharsets.UTF_8));
|
||||
final byte[] decode = UrlDecoder.decode(encode.getBytes(StandardCharsets.UTF_8));
|
||||
Assertions.assertEquals(exceptedDecode, new String(decode,StandardCharsets.UTF_8));
|
||||
|
||||
byte[] decode1 = UrlDecoder.decode((encode + "+").getBytes(StandardCharsets.UTF_8));
|
||||
final byte[] decode1 = UrlDecoder.decode((encode + "+").getBytes(StandardCharsets.UTF_8));
|
||||
Assertions.assertEquals(exceptedDecode+" ",new String(decode1,StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class ClassUtilTest {
|
||||
@Test
|
||||
void testTraverseTypeHierarchy() {
|
||||
// collect all superclass of child by bfs (include child)
|
||||
List<Class<?>> superclasses = new ArrayList<>();
|
||||
final List<Class<?>> superclasses = new ArrayList<>();
|
||||
ClassUtil.traverseTypeHierarchy(
|
||||
Child.class, t -> !t.isInterface(), superclasses::add, true
|
||||
);
|
||||
@@ -80,7 +80,7 @@ class ClassUtilTest {
|
||||
@Test
|
||||
void testTraverseTypeHierarchyWithTerminator() {
|
||||
// collect all superclass of child until Parent by bfs (include child)
|
||||
List<Class<?>> superclasses = new ArrayList<>();
|
||||
final List<Class<?>> superclasses = new ArrayList<>();
|
||||
ClassUtil.traverseTypeHierarchyWhile(
|
||||
Child.class, t -> !t.isInterface(), t -> {
|
||||
if (!Objects.equals(t, GrandParent.class)) {
|
||||
|
||||
@@ -25,41 +25,41 @@ import java.lang.reflect.Method;
|
||||
*/
|
||||
class MethodMatcherTest {
|
||||
|
||||
private MethodMatcher matchToString = (MethodMatcher)t -> "toString".equals(t.getName());
|
||||
private final MethodMatcher matchToString = t -> "toString".equals(t.getName());
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
void test() {
|
||||
Method toString = Object.class.getDeclaredMethod("toString");
|
||||
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||
Assertions.assertTrue(matchToString.test(toString));
|
||||
Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||
final Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||
Assertions.assertFalse(matchToString.test(hashCode));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
void and() {
|
||||
Method toString = Object.class.getDeclaredMethod("toString");
|
||||
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||
Assertions.assertTrue(matchToString.test(toString));
|
||||
MethodMatcher newMatcher = matchToString.and(t -> t.getReturnType() == String.class);
|
||||
final MethodMatcher newMatcher = matchToString.and(t -> t.getReturnType() == String.class);
|
||||
Assertions.assertTrue(newMatcher.test(toString));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
void negate() {
|
||||
Method toString = Object.class.getDeclaredMethod("toString");
|
||||
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||
Assertions.assertTrue(matchToString.test(toString));
|
||||
MethodMatcher newMatcher = matchToString.negate();
|
||||
final MethodMatcher newMatcher = matchToString.negate();
|
||||
Assertions.assertFalse(newMatcher.test(toString));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
void or() {
|
||||
MethodMatcher newMatcher = matchToString.or(t -> "hashCode".equals(t.getName()));
|
||||
Method toString = Object.class.getDeclaredMethod("toString");
|
||||
Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||
final MethodMatcher newMatcher = matchToString.or(t -> "hashCode".equals(t.getName()));
|
||||
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||
final Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||
Assertions.assertTrue(newMatcher.test(toString));
|
||||
Assertions.assertTrue(newMatcher.test(hashCode));
|
||||
}
|
||||
@@ -67,9 +67,9 @@ class MethodMatcherTest {
|
||||
@SneakyThrows
|
||||
@Test
|
||||
void inspect() {
|
||||
Method toString = Object.class.getDeclaredMethod("toString");
|
||||
final Method toString = Object.class.getDeclaredMethod("toString");
|
||||
Assertions.assertTrue(matchToString.inspect(toString));
|
||||
Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||
final Method hashCode = Object.class.getDeclaredMethod("hashCode");
|
||||
Assertions.assertNull(matchToString.inspect(hashCode));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,7 +724,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
List<List<List<String>>> list = Arrays.asList(
|
||||
final List<List<List<String>>> list = Arrays.asList(
|
||||
Arrays.asList(
|
||||
Arrays.asList("a"),
|
||||
Arrays.asList("b", "c"),
|
||||
@@ -735,7 +735,7 @@ public class AbstractEnhancedWrappedStreamTest {
|
||||
Arrays.asList("j", "k", "l")
|
||||
)
|
||||
);
|
||||
List<String> r = EasyStream.of(list).<String>flat().toList();
|
||||
final List<String> r = EasyStream.of(list).<String>flat().toList();
|
||||
Assertions.assertArrayEquals(new String[]{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"}, r.toArray());
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class StreamUtilTest {
|
||||
// === iterator ===
|
||||
@Test
|
||||
public void streamTestNullIterator() {
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> StreamUtil.ofIter((Iterator<Object>) null));
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> StreamUtil.ofIter(null));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"RedundantOperationOnEmptyContainer", "RedundantCollectionOperation"})
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
package org.dromara.hutool.core.text;
|
||||
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
@@ -18,10 +18,6 @@ import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 文本相似度计算工具类单元测试
|
||||
*
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
package org.dromara.hutool.core.text.split;
|
||||
|
||||
import org.dromara.hutool.core.collection.ListUtil;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.text.finder.PatternFinder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
package org.dromara.hutool.core.thread;
|
||||
|
||||
import org.dromara.hutool.core.collection.ListUtil;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -68,7 +67,7 @@ public class AsyncUtilTest {
|
||||
return "真暖和";
|
||||
});
|
||||
// 等待完成
|
||||
List<String> list = AsyncUtil.allOfGet(ListUtil.of(hutool, sweater, warm));
|
||||
final List<String> list = AsyncUtil.allOfGet(ListUtil.of(hutool, sweater, warm));
|
||||
// 获取结果
|
||||
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
||||
}
|
||||
@@ -81,7 +80,7 @@ public class AsyncUtilTest {
|
||||
return "hutool";
|
||||
});
|
||||
final CompletableFuture<String> sweater = CompletableFuture.supplyAsync(() -> {
|
||||
int a = 1 / 0;
|
||||
final int a = 1 / 0;
|
||||
ThreadUtil.sleep(2, TimeUnit.SECONDS);
|
||||
return "卫衣";
|
||||
});
|
||||
@@ -90,7 +89,7 @@ public class AsyncUtilTest {
|
||||
return "真暖和";
|
||||
});
|
||||
// 等待完成
|
||||
List<String> list = AsyncUtil.allOfGet(ListUtil.of(hutool, sweater, warm), (e) -> "出错了");
|
||||
final List<String> list = AsyncUtil.allOfGet(ListUtil.of(hutool, sweater, warm), (e) -> "出错了");
|
||||
// 获取结果
|
||||
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
||||
}
|
||||
@@ -111,7 +110,7 @@ public class AsyncUtilTest {
|
||||
return "真暖和";
|
||||
});
|
||||
// 等待完成
|
||||
List<String> list = AsyncUtil.parallelAllOfGet(ListUtil.of(hutool, sweater, warm));
|
||||
final List<String> list = AsyncUtil.parallelAllOfGet(ListUtil.of(hutool, sweater, warm));
|
||||
// 获取结果
|
||||
Assertions.assertEquals(Arrays.asList("hutool", "卫衣", "真暖和"), list);
|
||||
}
|
||||
@@ -124,7 +123,7 @@ public class AsyncUtilTest {
|
||||
return "hutool";
|
||||
});
|
||||
final CompletableFuture<String> sweater = CompletableFuture.supplyAsync(() -> {
|
||||
int a = 1 / 0;
|
||||
final int a = 1 / 0;
|
||||
ThreadUtil.sleep(2, TimeUnit.SECONDS);
|
||||
return "卫衣";
|
||||
});
|
||||
@@ -133,7 +132,7 @@ public class AsyncUtilTest {
|
||||
return "真暖和";
|
||||
});
|
||||
// 等待完成
|
||||
List<String> list = AsyncUtil.parallelAllOfGet(ListUtil.of(hutool, sweater, warm), (e) -> "出错了");
|
||||
final List<String> list = AsyncUtil.parallelAllOfGet(ListUtil.of(hutool, sweater, warm), (e) -> "出错了");
|
||||
Assertions.assertEquals(Arrays.asList("hutool", "出错了", "真暖和"), list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class SyncFinisherTest {
|
||||
/**
|
||||
* https://gitee.com/dromara/hutool/issues/I716SX
|
||||
*/
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Test
|
||||
void executeExceptionTest() {
|
||||
final AtomicBoolean hasException = new AtomicBoolean(false);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.dromara.hutool.core.thread;
|
||||
|
||||
import org.dromara.hutool.core.date.TimeUtil;
|
||||
import org.dromara.hutool.core.exception.HutoolException;
|
||||
import org.dromara.hutool.core.util.RandomUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
@@ -38,14 +39,14 @@ public class ThreadUtilTest {
|
||||
@Test
|
||||
@Disabled
|
||||
public void phaserTest(){
|
||||
LocalDateTime now = TimeUtil.parse("2022-08-04T22:59:59+08:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
final LocalDateTime now = TimeUtil.parse("2022-08-04T22:59:59+08:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||
Assertions.assertNotNull(now);
|
||||
|
||||
int repeat = 30; // 执行的轮数配置
|
||||
Phaser phaser = new Phaser() { // 进行一些处理方法的覆写
|
||||
final int repeat = 30; // 执行的轮数配置
|
||||
final Phaser phaser = new Phaser() { // 进行一些处理方法的覆写
|
||||
//返回ture: 移相器终止,false: 移相器继续执行
|
||||
@Override
|
||||
protected boolean onAdvance(int phase, int registeredParties) { // 回调处理
|
||||
protected boolean onAdvance(final int phase, final int registeredParties) { // 回调处理
|
||||
System.out.printf("【onAdvance()处理】进阶处理操作,phase = %s、registeredParties = %s%n",
|
||||
phase, registeredParties);
|
||||
return phase + 1 >= repeat || registeredParties == 0; // 终止处理
|
||||
@@ -57,11 +58,11 @@ public class ThreadUtilTest {
|
||||
while (!phaser.isTerminated()) { // 现在没有终止Phaser执行
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(RandomUtil.randomInt(1, 10)); // 增加操作延迟,模拟各个线程执行时间不多。阿超、阿珍准备爱果的时间不同
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (final InterruptedException e) {
|
||||
throw new HutoolException(e);
|
||||
}
|
||||
phaser.arriveAndAwaitAdvance(); // 等待其他的线程就位; 准备就绪,并等待其他线程就绪; 阿超、阿珍准备好了爱果,相互等待见面共度美好的一天
|
||||
String date = TimeUtil.formatNormal(now.plusYears(phaser.getPhase() - 1)); // 增加一年
|
||||
final String date = TimeUtil.formatNormal(now.plusYears(phaser.getPhase() - 1)); // 增加一年
|
||||
System.out.printf("【%s】%s 阿超和阿珍共度了一个美好的七夕。%n", date, Thread.currentThread().getName());
|
||||
ThreadUtil.sleep(3, TimeUnit.SECONDS);
|
||||
}
|
||||
@@ -74,10 +75,10 @@ public class ThreadUtilTest {
|
||||
@Test
|
||||
public void cyclicBarrierTest(){
|
||||
//示例:7个同学,集齐7个龙珠,7个同学一起召唤神龙;前后集齐了2次
|
||||
AtomicInteger times = new AtomicInteger();
|
||||
CyclicBarrier barrier = new CyclicBarrier(7, ()->{
|
||||
System.out.println("");
|
||||
System.out.println("");
|
||||
final AtomicInteger times = new AtomicInteger();
|
||||
final CyclicBarrier barrier = new CyclicBarrier(7, ()->{
|
||||
System.out.println(" ");
|
||||
System.out.println(" ");
|
||||
System.out.println("【循环栅栏业务处理】7个子线程 都收集了一颗龙珠,七颗龙珠已经收集齐全,开始召唤神龙。" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
times.getAndIncrement();
|
||||
}); // 现在设置的栅栏的数量为2
|
||||
@@ -86,15 +87,15 @@ public class ThreadUtilTest {
|
||||
while (times.get() < 2) {
|
||||
try {
|
||||
System.out.printf("【Barrier - 收集龙珠】当前的线程名称:%s%n", Thread.currentThread().getName());
|
||||
int time = ThreadLocalRandom.current().nextInt(1, 10); // 等待一段时间,模拟线程的执行时间
|
||||
final int time = ThreadLocalRandom.current().nextInt(1, 10); // 等待一段时间,模拟线程的执行时间
|
||||
TimeUnit.SECONDS.sleep(time); // 模拟业务延迟,收集龙珠的时间
|
||||
barrier.await(); // 等待,凑够了7个等待的线程
|
||||
System.err.printf("〖Barrier - 举起龙珠召唤神龙〗当前的线程名称:%s\t%s%n", Thread.currentThread().getName(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
if (barrier.getParties() >= 7) {
|
||||
barrier.reset(); // 重置栅栏,等待下一次的召唤。
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (final Exception e) {
|
||||
throw new HutoolException(e);
|
||||
}
|
||||
}
|
||||
}, "线程 - " + x).start();
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
package org.dromara.hutool.core.util;
|
||||
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ package org.dromara.hutool.core.util;
|
||||
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.lang.mutable.MutableObj;
|
||||
import org.dromara.hutool.core.util.ReferenceUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -29,21 +28,21 @@ public class ReferenceUtilTest {
|
||||
@Test
|
||||
public void createWeakTest(){
|
||||
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.WEAK, 1);
|
||||
Assertions.assertTrue(integerReference instanceof WeakReference);
|
||||
Assertions.assertEquals(new Integer(1), integerReference.get());
|
||||
Assertions.assertInstanceOf(WeakReference.class, integerReference);
|
||||
Assertions.assertEquals(Integer.valueOf(1), integerReference.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createSoftTest(){
|
||||
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.SOFT, 1);
|
||||
Assertions.assertTrue(integerReference instanceof SoftReference);
|
||||
Assertions.assertEquals(new Integer(1), integerReference.get());
|
||||
Assertions.assertInstanceOf(SoftReference.class, integerReference);
|
||||
Assertions.assertEquals(Integer.valueOf(1), integerReference.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPhantomTest(){
|
||||
final Reference<Integer> integerReference = ReferenceUtil.of(ReferenceUtil.ReferenceType.PHANTOM, 1);
|
||||
Assertions.assertTrue(integerReference instanceof PhantomReference);
|
||||
Assertions.assertInstanceOf(PhantomReference.class, integerReference);
|
||||
// get方法永远都返回null,PhantomReference只能用来监控对象的GC状况
|
||||
Assertions.assertNull(integerReference.get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user