// package cn.iocoder.yudao.module.asset.service.assetreceiveinfo;
//
// import org.junit.jupiter.api.Disabled;
// import org.junit.jupiter.api.Test;
// import org.springframework.boot.test.mock.mockito.MockBean;
//
// import javax.annotation.Resource;
//
// import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
//
// import cn.iocoder.yudao.module.asset.controller.admin.assetreceiveinfo.vo.*;
// import cn.iocoder.yudao.module.asset.dal.dataobject.assetreceiveinfo.AssetReceiveInfoDO;
// import cn.iocoder.yudao.module.asset.dal.mysql.assetreceiveinfo.AssetReceiveInfoMapper;
// import cn.iocoder.yudao.framework.common.pojo.PageResult;
//
// import javax.annotation.Resource;
// import org.springframework.context.annotation.Import;
// import java.util.*;
// import java.time.LocalDateTime;
//
// import static cn.hutool.core.util.RandomUtil.*;
// import static cn.iocoder.yudao.module.asset.enums.ErrorCodeConstants.*;
// import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
// import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
// import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
// import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
// import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
// import static org.junit.jupiter.api.Assertions.*;
// import static org.mockito.Mockito.*;
//
// /**
//  * {@link AssetReceiveInfoServiceImpl} 的单元测试类
//  *
//  * @author dp
//  */
// @Import(AssetReceiveInfoServiceImpl.class)
// public class AssetReceiveInfoServiceImplTest extends BaseDbUnitTest {
//
//     @Resource
//     private AssetReceiveInfoServiceImpl receiveInfoService;
//
//     @Resource
//     private AssetReceiveInfoMapper receiveInfoMapper;
//
//     @Test
//     public void testCreateReceiveInfo_success() {
//         // 准备参数
//         AssetReceiveInfoSaveReqVO createReqVO = randomPojo(AssetReceiveInfoSaveReqVO.class).setId(null);
//
//         // 调用
//         Long receiveInfoId = receiveInfoService.createReceiveInfo(createReqVO);
//         // 断言
//         assertNotNull(receiveInfoId);
//         // 校验记录的属性是否正确
//         AssetReceiveInfoDO receiveInfo = receiveInfoMapper.selectById(receiveInfoId);
//         assertPojoEquals(createReqVO, receiveInfo, "id");
//     }
//
//     @Test
//     public void testUpdateReceiveInfo_success() {
//         // mock 数据
//         AssetReceiveInfoDO dbReceiveInfo = randomPojo(AssetReceiveInfoDO.class);
//         receiveInfoMapper.insert(dbReceiveInfo);// @Sql: 先插入出一条存在的数据
//         // 准备参数
//         AssetReceiveInfoSaveReqVO updateReqVO = randomPojo(AssetReceiveInfoSaveReqVO.class, o -> {
//             o.setId(dbReceiveInfo.getId()); // 设置更新的 ID
//         });
//
//         // 调用
//         receiveInfoService.updateReceiveInfo(updateReqVO);
//         // 校验是否更新正确
//         AssetReceiveInfoDO receiveInfo = receiveInfoMapper.selectById(updateReqVO.getId()); // 获取最新的
//         assertPojoEquals(updateReqVO, receiveInfo);
//     }
//
//     @Test
//     public void testUpdateReceiveInfo_notExists() {
//         // 准备参数
//         AssetReceiveInfoSaveReqVO updateReqVO = randomPojo(AssetReceiveInfoSaveReqVO.class);
//
//         // 调用, 并断言异常
//         assertServiceException(() -> receiveInfoService.updateReceiveInfo(updateReqVO), RECEIVE_INFO_NOT_EXISTS);
//     }
//
//     @Test
//     public void testDeleteReceiveInfo_success() {
//         // mock 数据
//         AssetReceiveInfoDO dbReceiveInfo = randomPojo(AssetReceiveInfoDO.class);
//         receiveInfoMapper.insert(dbReceiveInfo);// @Sql: 先插入出一条存在的数据
//         // 准备参数
//         Long id = dbReceiveInfo.getId();
//
//         // 调用
//         receiveInfoService.deleteReceiveInfo(id);
//        // 校验数据不存在了
//        assertNull(receiveInfoMapper.selectById(id));
//     }
//
//     @Test
//     public void testDeleteReceiveInfo_notExists() {
//         // 准备参数
//         Long id = randomLongId();
//
//         // 调用, 并断言异常
//         assertServiceException(() -> receiveInfoService.deleteReceiveInfo(id), RECEIVE_INFO_NOT_EXISTS);
//     }
//
//     @Test
//     @Disabled  // TODO 请修改 null 为需要的值，然后删除 @Disabled 注解
//     public void testGetReceiveInfoPage() {
//        // mock 数据
//        AssetReceiveInfoDO dbReceiveInfo = randomPojo(AssetReceiveInfoDO.class, o -> { // 等会查询到
//            o.setEmployeeId(null);
//            o.setDeptId(null);
//            o.setPostId(null);
//            o.setAssetInfoName(null);
//            o.setReceiveDate(null);
//            o.setReturned(null);
//            o.setReturnDate(null);
//            o.setInfoSource(null);
//            o.setCreator(null);
//        });
//        receiveInfoMapper.insert(dbReceiveInfo);
//        // 测试 employeeId 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setEmployeeId(null)));
//        // 测试 deptId 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setDeptId(null)));
//        // 测试 postId 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setPostId(null)));
//        // 测试 assetInfoName 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setAssetInfoName(null)));
//        // 测试 receiveDate 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setReceiveDate(null)));
//        // 测试 returned 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setReturned(null)));
//        // 测试 returnDate 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setReturnDate(null)));
//        // 测试 infoSource 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setInfoSource(null)));
//        // 测试 creator 不匹配
//        receiveInfoMapper.insert(cloneIgnoreId(dbReceiveInfo, o -> o.setCreator(null)));
//        // 准备参数
//        AssetReceiveInfoPageReqVO reqVO = new AssetReceiveInfoPageReqVO();
//        reqVO.setEmployeeId(null);
//        reqVO.setDeptId(null);
//        reqVO.setPostId(null);
//        reqVO.setAssetInfoName(null);
//        reqVO.setReceiveDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
//        reqVO.setReturned(null);
//        reqVO.setReturnDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
//        reqVO.setInfoSource(null);
//        reqVO.setCreator(null);
//
//        // 调用
//        PageResult<AssetReceiveInfoDO> pageResult = receiveInfoService.getReceiveInfoPage(reqVO);
//        // 断言
//        assertEquals(1, pageResult.getTotal());
//        assertEquals(1, pageResult.getList().size());
//        assertPojoEquals(dbReceiveInfo, pageResult.getList().get(0));
//     }
//
// }