package com.YuyeTech.TPlat.repository;

import com.YuyeTech.TPlat.utils.KeyUtil;
import com.YuyeTech.TPlat.dataobject.UserInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;

@RunWith(SpringRunner.class)
@SpringBootTest
public class UserInfoRepositoryTest {
    @Autowired
    private UserInfoRepository userInfoRepository;

    @Test
    public void findUserInfoOneTest(){
        UserInfo userInfo = userInfoRepository.findById("1").orElse(null);
        System.out.println(userInfo.toString());
    }

    @Test
    public void ModifyUserInfo(){
//        UserInfo userInfo = new UserInfo();
//        UserInfo userInfo = userInfoRepository.findById("1").orElse(null);

        UserInfo userInfo = new UserInfo();
        userInfo.setUserId(KeyUtil.genUniqueKey());
        userInfo.setUsername("peng");
        userInfo.setBirthday(new Date());
        userInfo.setRegisterTime(new Date());
        userInfo.setHeight(120.0);
        userInfo.setWeight(130.0);
        userInfo.setAvatarUrl("http://xxxx.jpg");
        userInfo.setGender("女");
        userInfo.setSignature("我很帅111");
        userInfo.setStatus(1);

        UserInfo  result = userInfoRepository.save(userInfo);
        Assert.assertNotEquals(null,result);
    }

    @Test
    public void DeleteUserInfo(){
        userInfoRepository.deleteById("sadf");
    }
}