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();
}
Console.log(queryMap);
final Map<String, List<String>> params = new LinkedHashMap<>();
queryMap.forEach((key, value) -> {
if(null != key){

View File

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

View File

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

View File

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

View File

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