This commit is contained in:
Looly
2025-06-23 19:22:19 +08:00
parent 9d9d326aa8
commit e0275c56ac
5 changed files with 41 additions and 51 deletions

View File

@@ -216,8 +216,6 @@ public class UrlQueryUtil {
return MapUtil.empty(); return MapUtil.empty();
} }
Console.log(queryMap);
final Map<String, List<String>> params = new LinkedHashMap<>(); final Map<String, List<String>> params = new LinkedHashMap<>();
queryMap.forEach((key, value) -> { queryMap.forEach((key, value) -> {
if(null != key){ if(null != key){

View File

@@ -23,6 +23,7 @@ import lombok.Setter;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.Serial;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function; import java.util.function.Function;
@@ -79,6 +80,7 @@ public class AbstractEnhancedWrappedStreamTest {
final List<Integer> list = asList(1, 2, 3); final List<Integer> list = asList(1, 2, 3);
final Map<String, Integer> identityMap = wrap(list).toMap(String::valueOf); final Map<String, Integer> identityMap = wrap(list).toMap(String::valueOf);
Assertions.assertEquals(new HashMap<String, Integer>() { Assertions.assertEquals(new HashMap<String, Integer>() {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
@@ -103,6 +105,7 @@ public class AbstractEnhancedWrappedStreamTest {
final List<String> list = asList("bugotech", "hutool", "sweet"); final List<String> list = asList("bugotech", "hutool", "sweet");
final Map<Integer, String> toZip = wrap(orders).toZip(list); final Map<Integer, String> toZip = wrap(orders).toZip(list);
Assertions.assertEquals(new HashMap<Integer, String>() { Assertions.assertEquals(new HashMap<Integer, String>() {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
@@ -169,6 +172,7 @@ public class AbstractEnhancedWrappedStreamTest {
public void testGrouping() { public void testGrouping() {
final List<Integer> list = asList(1, 2, 3); final List<Integer> list = asList(1, 2, 3);
final Map<String, List<Integer>> map = new HashMap<String, List<Integer>>() { final Map<String, List<Integer>> map = new HashMap<String, List<Integer>>() {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
@@ -190,6 +194,7 @@ public class AbstractEnhancedWrappedStreamTest {
public void testPartitioning() { public void testPartitioning() {
final List<Integer> list = asList(1, 2, 3); final List<Integer> list = asList(1, 2, 3);
final Map<Boolean, List<Integer>> map = new HashMap<Boolean, List<Integer>>() { final Map<Boolean, List<Integer>> map = new HashMap<Boolean, List<Integer>>() {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
@@ -632,6 +637,7 @@ public class AbstractEnhancedWrappedStreamTest {
@Test @Test
public void testToEntries() { public void testToEntries() {
final Map<Integer, Integer> expect = new HashMap<Integer, Integer>() { final Map<Integer, Integer> expect = new HashMap<Integer, Integer>() {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
@@ -730,7 +736,7 @@ public class AbstractEnhancedWrappedStreamTest {
void test() { void test() {
final List<List<List<String>>> list = Arrays.asList( final List<List<List<String>>> list = Arrays.asList(
Arrays.asList( Arrays.asList(
Arrays.asList("a"), List.of("a"),
Arrays.asList("b", "c"), Arrays.asList("b", "c"),
Arrays.asList("d", "e", "f") Arrays.asList("d", "e", "f")
), ),

View File

@@ -16,6 +16,8 @@
package cn.hutool.v7.core.text.finder; package cn.hutool.v7.core.text.finder;
import cn.hutool.v7.core.lang.Console;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList; import java.util.ArrayList;
@@ -24,43 +26,34 @@ import java.util.Map;
/** /**
* @author cmm * @author cmm
* @date 2024/8/12 11:16
*/ */
public class MultiStrFinderTest { public class MultiStrFinderTest {
@Test @Test
public void test1(){ public void test1(){
ArrayList<String> strings = new ArrayList<>(); final ArrayList<String> strings = new ArrayList<>();
strings.add("sha"); strings.add("sha");
strings.add("asa"); strings.add("asa");
strings.add("ha"); strings.add("ha");
strings.add("hex"); strings.add("hex");
MultiStrFinder finder = MultiStrFinder.of(strings); final MultiStrFinder finder = MultiStrFinder.of(strings);
String text = "asdasahhxxeshaaahexaaasa"; final String text = "asdasahhxxeshaaahexaaasa";
Map<String, List<Integer>> match = finder.findMatch(text); final Map<String, List<Integer>> match = finder.findMatch(text);
System.out.println(text); Assertions.assertEquals(3, match.size());
match.forEach((k,v) -> {
System.out.println(k + ":" + v);
});
} }
@Test @Test
public void test2(){ public void test2(){
ArrayList<String> strings = new ArrayList<>(); final ArrayList<String> strings = new ArrayList<>();
strings.add("沙漠"); strings.add("沙漠");
strings.add(""); strings.add("");
strings.add(""); strings.add("");
strings.add("害克斯"); strings.add("害克斯");
MultiStrFinder finder = MultiStrFinder.of(strings); final MultiStrFinder finder = MultiStrFinder.of(strings);
String text = "撒哈拉大沙漠你看哈哈哈。hex码中文写成海克斯科技"; final String text = "撒哈拉大沙漠你看哈哈哈。hex码中文写成海克斯科技";
Map<String, List<Integer>> match = finder.findMatch(text); final Map<String, List<Integer>> match = finder.findMatch(text);
System.out.println(text); Assertions.assertEquals(3, match.size());
match.forEach((k,v) -> {
System.out.println(k + ":" + v);
});
} }
} }

View File

@@ -16,13 +16,10 @@
package cn.hutool.v7.core.text.replacer; package cn.hutool.v7.core.text.replacer;
import cn.hutool.v7.core.text.finder.MultiStrFinder; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author cmm * @author cmm
@@ -31,37 +28,34 @@ import java.util.Map;
public class HighMultiReplacerV2Test { public class HighMultiReplacerV2Test {
@Test @Test
public void test1(){ public void test1(){
HashMap<String, String> replaceMap = new HashMap<>(); final HashMap<String, String> replaceMap = new HashMap<>();
replaceMap.put("sha","SHA"); replaceMap.put("sha","SHA");
replaceMap.put("asa","ASA"); replaceMap.put("asa","ASA");
replaceMap.put("ha","HA"); replaceMap.put("ha","HA");
replaceMap.put("hex","HEX"); replaceMap.put("hex","HEX");
HighMultiReplacerV2 replacer = new HighMultiReplacerV2(replaceMap); final HighMultiReplacerV2 replacer = new HighMultiReplacerV2(replaceMap);
String text = "asdasahhxxeshaaahexaaasa"; final String text = "asdasahhxxeshaaahexaaasa";
CharSequence apply = replacer.apply(text); final CharSequence apply = replacer.apply(text);
replaceMap.forEach((k,v) -> { // replaceMap.forEach((k,v) -> {
System.out.println(k + ":" + v); // System.out.println(k + ":" + v);
}); // });
System.out.println(text); Assertions.assertEquals("asdASAhhxxeSHAaaHEXaaASA", apply.toString());
System.out.println(apply);
} }
@Test @Test
public void test2(){ public void test2(){
HashMap<String, String> replaceMap = new HashMap<>(); final HashMap<String, String> replaceMap = new HashMap<>();
replaceMap.put("沙漠","什么"); replaceMap.put("沙漠","什么");
replaceMap.put("",""); replaceMap.put("","");
replaceMap.put("",""); replaceMap.put("","");
replaceMap.put("海克斯","害可是"); replaceMap.put("海克斯","害可是");
HighMultiReplacerV2 replacer = new HighMultiReplacerV2(replaceMap); final HighMultiReplacerV2 replacer = new HighMultiReplacerV2(replaceMap);
String text = "撒哈拉大沙漠你看哈哈哈。hex码中文写成海克斯科技海克沙子收拾收拾撤退撒下了句点"; final String text = "撒哈拉大沙漠你看哈哈哈。hex码中文写成海克斯科技海克沙子收拾收拾撤退撒下了句点";
CharSequence apply = replacer.apply(text); final CharSequence apply = replacer.apply(text);
replaceMap.forEach((k,v) -> { // replaceMap.forEach((k,v) -> {
System.out.println(k + ":" + v); // System.out.println(k + ":" + v);
}); // });
System.out.println(text); Assertions.assertEquals("厦蛤拉大什么你看蛤蛤蛤。hex码中文写成害可是科技海克沙子收拾收拾撤退厦下了句点", apply.toString());
System.out.println(apply);
} }
} }

View File

@@ -16,10 +16,9 @@
package cn.hutool.v7.core.tree; package cn.hutool.v7.core.tree;
import lombok.Data;
import cn.hutool.v7.core.collection.ListUtil; import cn.hutool.v7.core.collection.ListUtil;
import cn.hutool.v7.core.lang.Console;
import cn.hutool.v7.core.tree.parser.DefaultNodeParser; import cn.hutool.v7.core.tree.parser.DefaultNodeParser;
import lombok.Data;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -84,7 +83,7 @@ public class TreeTest {
tree.putExtra("other", new Object()); tree.putExtra("other", new Object());
}); });
Assertions.assertEquals(treeNodes.size(), 2); Assertions.assertEquals(2, treeNodes.size());
} }
@Test @Test
@@ -100,7 +99,7 @@ public class TreeTest {
public void walkBroadFirstTest() { public void walkBroadFirstTest() {
final List<String> ids = new ArrayList<>(); final List<String> ids = new ArrayList<>();
final MapTree<String> tree = TreeUtil.buildSingle(nodeList, "0"); final MapTree<String> tree = TreeUtil.buildSingle(nodeList, "0");
Console.log(tree); //Console.log(tree);
tree.walk((tr) -> ids.add(tr.getId()), true); tree.walk((tr) -> ids.add(tr.getId()), true);
Assertions.assertEquals(7, ids.size()); Assertions.assertEquals(7, ids.size());
@@ -166,11 +165,11 @@ public class TreeTest {
treeNodeConfig.setDeep(3); treeNodeConfig.setDeep(3);
final List<MapTree<String>> treeNodes = TreeUtil.build(nodeList, "0", treeNodeConfig, new DefaultNodeParser<>()); final List<MapTree<String>> treeNodes = TreeUtil.build(nodeList, "0", treeNodeConfig, new DefaultNodeParser<>());
Assertions.assertEquals(treeNodes.size(), 2); Assertions.assertEquals(2, treeNodes.size());
final MapTree<String> treeNode1 = treeNodes.get(1); final MapTree<String> treeNode1 = treeNodes.get(1);
Assertions.assertNotNull(treeNode1); Assertions.assertNotNull(treeNode1);
Assertions.assertNotNull(treeNode1.getConfig()); Assertions.assertNotNull(treeNode1.getConfig());
Assertions.assertEquals(treeNode1.getChildren().size(), 1); Assertions.assertEquals(1, treeNode1.getChildren().size());
} }
/** /**