mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
fix bean editor invalid bug
This commit is contained in:
@@ -713,7 +713,7 @@ public class BeanUtilTest {
|
||||
CopyOptions copyOptions = CopyOptions.create().
|
||||
//setIgnoreNullValue(true).
|
||||
//setIgnoreCase(false).
|
||||
setFieldNameEditor(StrUtil::toUnderlineCase);
|
||||
setFieldNameEditor(StrUtil::toCamelCase);
|
||||
|
||||
ChildVo2 childVo2 = new ChildVo2();
|
||||
BeanUtil.copyProperties(childVo1, childVo2, copyOptions);
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package cn.hutool.core.bean;
|
||||
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.text.NamingCase;
|
||||
import lombok.Data;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -11,15 +11,23 @@ import java.util.Map;
|
||||
|
||||
public class Issue2202Test {
|
||||
|
||||
/**
|
||||
* https://github.com/dromara/hutool/issues/2202
|
||||
*/
|
||||
@Test
|
||||
public void toBeanWithFieldNameEditorTest(){
|
||||
public void mapToBeanWithFieldNameEditorTest(){
|
||||
Map<String, String> headerMap = new HashMap<>(5);
|
||||
headerMap.put("wechatpay-serial", "serial");
|
||||
headerMap.put("wechatpay-nonce", "nonce");
|
||||
headerMap.put("wechatpay-timestamp", "timestamp");
|
||||
headerMap.put("wechatpay-signature", "signature");
|
||||
ResponseSignVerifyParams case1 = BeanUtil.toBean(headerMap, ResponseSignVerifyParams.class, CopyOptions.create().setFieldNameEditor(field -> NamingCase.toCamelCase(field, '-')));
|
||||
Console.log(case1);
|
||||
ResponseSignVerifyParams case1 = BeanUtil.toBean(headerMap, ResponseSignVerifyParams.class,
|
||||
CopyOptions.create().setFieldNameEditor(field -> NamingCase.toCamelCase(field, '-')));
|
||||
|
||||
Assert.assertEquals("serial", case1.getWechatpaySerial());
|
||||
Assert.assertEquals("nonce", case1.getWechatpayNonce());
|
||||
Assert.assertEquals("timestamp", case1.getWechatpayTimestamp());
|
||||
Assert.assertEquals("signature", case1.getWechatpaySignature());
|
||||
}
|
||||
|
||||
@Data
|
||||
|
Reference in New Issue
Block a user