This commit is contained in:
Looly
2022-05-09 11:51:45 +08:00
parent fddaf71a8b
commit a727984f38
3 changed files with 44 additions and 1 deletions

View File

@@ -191,6 +191,23 @@ public class BeanUtilTest {
Assert.assertFalse(map.containsKey("SUBNAME"));
}
@Test
public void beanToMapNullPropertiesTest() {
final SubPerson person = new SubPerson();
person.setAge(14);
person.setOpenid("11213232");
person.setName("测试A11");
person.setSubName("sub名字");
final Map<String, Object> map = BeanUtil.beanToMap(person, (String[])null);
Assert.assertEquals("测试A11", map.get("name"));
Assert.assertEquals(14, map.get("age"));
Assert.assertEquals("11213232", map.get("openid"));
// static属性应被忽略
Assert.assertFalse(map.containsKey("SUBNAME"));
}
@Test
public void beanToMapTest2() {
final SubPerson person = new SubPerson();