mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
remove pair
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
package cn.hutool.core.bean;
|
||||
|
||||
import cn.hutool.core.lang.test.bean.ExamInfoDict;
|
||||
import cn.hutool.core.lang.test.bean.UserInfoDict;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.lang.test.bean.ExamInfoDict;
|
||||
import cn.hutool.core.lang.test.bean.UserInfoDict;
|
||||
|
||||
/**
|
||||
* {@link BeanPath} 单元测试
|
||||
*
|
||||
@@ -103,8 +102,19 @@ public class BeanPathTest {
|
||||
@Test
|
||||
public void getMapTest () {
|
||||
final BeanPath pattern = BeanPath.create("userInfo[id, photoPath]");
|
||||
@SuppressWarnings("unchecked") final Map<String, Object> result = (Map<String, Object>)pattern.get(tempMap);
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<String, Object> result = (Map<String, Object>)pattern.get(tempMap);
|
||||
Assert.assertEquals(1, result.get("id"));
|
||||
Assert.assertEquals("yx.mm.com", result.get("photoPath"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getKeyWithDotTest () {
|
||||
Map<String, Object> dataMap = new HashMap<>(16);
|
||||
dataMap.put("aa", "value0");
|
||||
dataMap.put("aa.bb.cc", "value111111");// key 是类名 格式 带 ' . '
|
||||
|
||||
final BeanPath pattern = BeanPath.create("'aa.bb.cc'");
|
||||
Assert.assertEquals("value111111", pattern.get(dataMap));
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package cn.hutool.core.map;
|
||||
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CaseInsensitiveMapTest {
|
||||
|
||||
@Test
|
||||
@@ -25,8 +26,8 @@ public class CaseInsensitiveMapTest {
|
||||
@Test
|
||||
public void mergeTest(){
|
||||
//https://github.com/dromara/hutool/issues/2086
|
||||
final Pair<String, String> b = new Pair<>("a", "value");
|
||||
final Pair<String, String> a = new Pair<>("A", "value");
|
||||
final Map.Entry<String, String> b = MapUtil.entry("a", "value");
|
||||
final Map.Entry<String, String> a = MapUtil.entry("A", "value");
|
||||
final CaseInsensitiveMap<Object, Object> map = new CaseInsensitiveMap<>();
|
||||
map.merge(b.getKey(), b.getValue(), (A, B) -> A);
|
||||
map.merge(a.getKey(), a.getValue(), (A, B) -> A);
|
||||
|
Reference in New Issue
Block a user