|
@@ -1,134 +0,0 @@
|
|
-package cn.newfeifan.mall.module.distri.service.ptprofitdailystatisticslog;
|
|
|
|
-
|
|
|
|
-import org.junit.jupiter.api.Disabled;
|
|
|
|
-import org.junit.jupiter.api.Test;
|
|
|
|
-
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-
|
|
|
|
-import cn.newfeifan.mall.framework.test.core.ut.BaseDbUnitTest;
|
|
|
|
-
|
|
|
|
-import cn.newfeifan.mall.module.distri.controller.admin.ptprofitdailystatisticslog.vo.*;
|
|
|
|
-import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitdailystatisticslog.PtProfitDailyStatisticsLogDO;
|
|
|
|
-import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitdailystatisticslog.PtProfitDailyStatisticsLogMapper;
|
|
|
|
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
|
|
|
|
-
|
|
|
|
-import org.springframework.context.annotation.Import;
|
|
|
|
-import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
|
|
|
|
-import static cn.newfeifan.mall.framework.test.core.util.AssertUtils.*;
|
|
|
|
-import static cn.newfeifan.mall.framework.test.core.util.RandomUtils.*;
|
|
|
|
-import static cn.newfeifan.mall.framework.common.util.date.LocalDateTimeUtils.*;
|
|
|
|
-import static cn.newfeifan.mall.framework.common.util.object.ObjectUtils.*;
|
|
|
|
-import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * {@link PtProfitDailyStatisticsLogServiceImpl} 的单元测试类
|
|
|
|
- *
|
|
|
|
- * @author 非繁人
|
|
|
|
- */
|
|
|
|
-@Import(PtProfitDailyStatisticsLogServiceImpl.class)
|
|
|
|
-public class PtProfitDailyStatisticsLogServiceImplTest extends BaseDbUnitTest {
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private PtProfitDailyStatisticsLogServiceImpl ptProfitDailyStatisticsLogService;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private PtProfitDailyStatisticsLogMapper ptProfitDailyStatisticsLogMapper;
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testCreatePtProfitDailyStatisticsLog_success() {
|
|
|
|
- // 准备参数
|
|
|
|
- PtProfitDailyStatisticsLogSaveReqVO createReqVO = randomPojo(PtProfitDailyStatisticsLogSaveReqVO.class).setId(null);
|
|
|
|
-
|
|
|
|
- // 调用
|
|
|
|
- Long ptProfitDailyStatisticsLogId = ptProfitDailyStatisticsLogService.createPtProfitDailyStatisticsLog(createReqVO);
|
|
|
|
- // 断言
|
|
|
|
- assertNotNull(ptProfitDailyStatisticsLogId);
|
|
|
|
- // 校验记录的属性是否正确
|
|
|
|
- PtProfitDailyStatisticsLogDO ptProfitDailyStatisticsLog = ptProfitDailyStatisticsLogMapper.selectById(ptProfitDailyStatisticsLogId);
|
|
|
|
- assertPojoEquals(createReqVO, ptProfitDailyStatisticsLog, "id");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testUpdatePtProfitDailyStatisticsLog_success() {
|
|
|
|
- // mock 数据
|
|
|
|
- PtProfitDailyStatisticsLogDO dbPtProfitDailyStatisticsLog = randomPojo(PtProfitDailyStatisticsLogDO.class);
|
|
|
|
- ptProfitDailyStatisticsLogMapper.insert(dbPtProfitDailyStatisticsLog);// @Sql: 先插入出一条存在的数据
|
|
|
|
- // 准备参数
|
|
|
|
- PtProfitDailyStatisticsLogSaveReqVO updateReqVO = randomPojo(PtProfitDailyStatisticsLogSaveReqVO.class, o -> {
|
|
|
|
- o.setId(dbPtProfitDailyStatisticsLog.getId()); // 设置更新的 ID
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // 调用
|
|
|
|
- ptProfitDailyStatisticsLogService.updatePtProfitDailyStatisticsLog(updateReqVO);
|
|
|
|
- // 校验是否更新正确
|
|
|
|
- PtProfitDailyStatisticsLogDO ptProfitDailyStatisticsLog = ptProfitDailyStatisticsLogMapper.selectById(updateReqVO.getId()); // 获取最新的
|
|
|
|
- assertPojoEquals(updateReqVO, ptProfitDailyStatisticsLog);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testUpdatePtProfitDailyStatisticsLog_notExists() {
|
|
|
|
- // 准备参数
|
|
|
|
- PtProfitDailyStatisticsLogSaveReqVO updateReqVO = randomPojo(PtProfitDailyStatisticsLogSaveReqVO.class);
|
|
|
|
-
|
|
|
|
- // 调用, 并断言异常
|
|
|
|
- assertServiceException(() -> ptProfitDailyStatisticsLogService.updatePtProfitDailyStatisticsLog(updateReqVO), PT_PROFIT_DAILY_STATISTICS_LOG_NOT_EXISTS);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testDeletePtProfitDailyStatisticsLog_success() {
|
|
|
|
- // mock 数据
|
|
|
|
- PtProfitDailyStatisticsLogDO dbPtProfitDailyStatisticsLog = randomPojo(PtProfitDailyStatisticsLogDO.class);
|
|
|
|
- ptProfitDailyStatisticsLogMapper.insert(dbPtProfitDailyStatisticsLog);// @Sql: 先插入出一条存在的数据
|
|
|
|
- // 准备参数
|
|
|
|
- Long id = dbPtProfitDailyStatisticsLog.getId();
|
|
|
|
-
|
|
|
|
- // 调用
|
|
|
|
- ptProfitDailyStatisticsLogService.deletePtProfitDailyStatisticsLog(id);
|
|
|
|
- // 校验数据不存在了
|
|
|
|
- assertNull(ptProfitDailyStatisticsLogMapper.selectById(id));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testDeletePtProfitDailyStatisticsLog_notExists() {
|
|
|
|
- // 准备参数
|
|
|
|
- Long id = randomLongId();
|
|
|
|
-
|
|
|
|
- // 调用, 并断言异常
|
|
|
|
- assertServiceException(() -> ptProfitDailyStatisticsLogService.deletePtProfitDailyStatisticsLog(id), PT_PROFIT_DAILY_STATISTICS_LOG_NOT_EXISTS);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
|
|
|
- public void testGetPtProfitDailyStatisticsLogPage() {
|
|
|
|
- // mock 数据
|
|
|
|
- PtProfitDailyStatisticsLogDO dbPtProfitDailyStatisticsLog = randomPojo(PtProfitDailyStatisticsLogDO.class, o -> { // 等会查询到
|
|
|
|
- o.setEveryday(null);
|
|
|
|
- o.setTotalCollisionAmount(null);
|
|
|
|
- o.setTotalRemainingAmount(null);
|
|
|
|
- o.setCreateTime(null);
|
|
|
|
- });
|
|
|
|
- ptProfitDailyStatisticsLogMapper.insert(dbPtProfitDailyStatisticsLog);
|
|
|
|
- // 测试 everyday 不匹配
|
|
|
|
- ptProfitDailyStatisticsLogMapper.insert(cloneIgnoreId(dbPtProfitDailyStatisticsLog, o -> o.setEveryday(null)));
|
|
|
|
- // 测试 totalCollisionAmount 不匹配
|
|
|
|
- ptProfitDailyStatisticsLogMapper.insert(cloneIgnoreId(dbPtProfitDailyStatisticsLog, o -> o.setTotalCollisionAmount(null)));
|
|
|
|
- // 测试 totalRemainingAmount 不匹配
|
|
|
|
- ptProfitDailyStatisticsLogMapper.insert(cloneIgnoreId(dbPtProfitDailyStatisticsLog, o -> o.setTotalRemainingAmount(null)));
|
|
|
|
- // 测试 createTime 不匹配
|
|
|
|
- ptProfitDailyStatisticsLogMapper.insert(cloneIgnoreId(dbPtProfitDailyStatisticsLog, o -> o.setCreateTime(null)));
|
|
|
|
- // 准备参数
|
|
|
|
- PtProfitDailyStatisticsLogPageReqVO reqVO = new PtProfitDailyStatisticsLogPageReqVO();
|
|
|
|
- reqVO.setEveryday(null);
|
|
|
|
- reqVO.setTotalCollisionAmount(null);
|
|
|
|
- reqVO.setTotalRemainingAmount(null);
|
|
|
|
- reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
|
|
|
-
|
|
|
|
- // 调用
|
|
|
|
- PageResult<PtProfitDailyStatisticsLogDO> pageResult = ptProfitDailyStatisticsLogService.getPtProfitDailyStatisticsLogPage(reqVO);
|
|
|
|
- // 断言
|
|
|
|
- assertEquals(1, pageResult.getTotal());
|
|
|
|
- assertEquals(1, pageResult.getList().size());
|
|
|
|
- assertPojoEquals(dbPtProfitDailyStatisticsLog, pageResult.getList().get(0));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-}
|
|
|