add BeanUtilTest test case

pull/705/head
guoz 3 years ago
parent 682a8bd6e0
commit 7d62cccb03

@ -17,6 +17,18 @@
package cn.hippo4j.config.toolkit;
import cn.hippo4j.common.toolkit.Assert;
import com.github.dozermapper.core.converters.ConversionException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.*;
import org.junit.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* BeanUtil Test
*/
@ -40,7 +52,7 @@ public class BeanUtilTest {
@Test
public void mapToBeanConvertTest() {
// 测试MapToBean
final HashMap<String, Object> map = MapUtil.newHashMap();
final HashMap<String, Object> map = Maps.newHashMap();
map.put("name", "Hippo4j");
map.put("age", 1);
map.put("address", "hippo4j.cn");
@ -76,6 +88,16 @@ public class BeanUtilTest {
Assert.isTrue(!convert.containsKey("STATIC_NAME"));
}
/**
*
*/
@Test(expected = ConversionException.class)
public void mapToBeanWinErrorTest() {
final Map<String, String> map = new HashMap<>();
map.put("age", "Hippo4j");
BeanUtil.convert(map, Person.class);
}
// -----------------------------------------------------------------------------------------------------------------
@Getter

Loading…
Cancel
Save