package cn.iselab.mooctest.user.web.wrapper;

import cn.iselab.mooctest.rpc.user.data.UserDTO;
import cn.iselab.mooctest.user.model.User;
import com.google.common.collect.Lists;
import org.junit.Test;
import org.mockito.InjectMocks;

import java.sql.Timestamp;
import java.util.List;

import static org.junit.Assert.*;

/**
 * @program: mooctest-user
 * @mail: menduo96@gmail.com
 * @author: menduo
 * @create: 2019-12-04 14:34
 **/
public class UserWrapperTest {
    @InjectMocks
    private UserWrapper userWrapper = new UserWrapper();

    @Test
    public void test_wrap_if_data_content_null() {
        User user1 = new User();
        user1.setId(1L);
        user1.setCreateTime(new Timestamp(System.currentTimeMillis()));
        User user2 = new User();
        user2.setId(2L);
        user2.setCreateTime(new Timestamp(System.currentTimeMillis()));
        User user3 = null;

        List<User> users = Lists.newArrayList(user1, user2, user3);
        List<UserDTO> userDTOS = userWrapper.wrap(users);
        assertEquals(users.size(),3);
        assertEquals(userDTOS.size(),2);
    }
}