package com.elab.test.utils;

import com.alibaba.fastjson.JSON;
import com.elab.core.bean.BaseInfo;
import com.elab.core.utils.ObjectUtils;
import com.elab.test.model.User;
import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 对象工具类测试
 *
 * @author Liukx
 * @create 2018-05-04 17:48
 * @email liukx@elab-plus.com
 **/
public class ObjectUtilsCase {


    @Test
    public void copyListPropertyValue() {
        BaseInfo info = new BaseInfo();
        info.setMessage("aaaa");
        BaseInfo info1 = new BaseInfo();
        info1.setMessage("bbbb");
        BaseInfo info2 = new BaseInfo();
        info2.setMessage("cccc");
        List<BaseInfo> list = new ArrayList<>();
        list.add(info);
        list.add(info1);
        list.add(info2);

        Map<String, String> propertyMap = new HashMap<>();
        propertyMap.put("message", "username");

        List<User> users = ObjectUtils.copyListPropertyValue(list, propertyMap, User.class);
        System.out.println(JSON.toJSONString(users));
    }

}
