CopyOptions中增加setAutoTransCamelCase方法

This commit is contained in:
Looly
2023-12-30 01:13:42 +08:00
parent da276f801c
commit f651a18c1d
6 changed files with 89 additions and 27 deletions

View File

@@ -0,0 +1,29 @@
package cn.hutool.core.bean;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
public class Issue3452Test {
@Test
public void fillBeanWithMapTest() {
final Map<String, Object> properties = new HashMap<>();
properties.put("name", "JohnDoe");
properties.put("user_age", 25);
final User user = BeanUtil.fillBeanWithMap(
properties, new User(), CopyOptions.create());
Assert.assertEquals("JohnDoe", user.getName());
Assert.assertEquals(25, user.getUserAge());
}
@Data
static class User {
private String name;
private int userAge;
}
}