1. 修复 LoginLogServiceImplTest

2. 修复 OperateLogServiceImplTest
3. 修复 SmsLogServiceTest
This commit is contained in:
YunaiV 2022-11-11 01:39:50 +08:00
parent 40ba456fde
commit b2e6e36fc5
4 changed files with 28 additions and 21 deletions

View File

@ -20,7 +20,7 @@ public interface SmsLogMapper extends BaseMapperX<SmsLogDO> {
.likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile()) .likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile())
.eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus()) .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus())
.betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime()) .betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime())
.eqIfPresent(SmsLogDO::getSendStatus, reqVO.getReceiveStatus()) .eqIfPresent(SmsLogDO::getReceiveStatus, reqVO.getReceiveStatus())
.betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime()) .betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime())
.orderByDesc(SmsLogDO::getId)); .orderByDesc(SmsLogDO::getId));
} }
@ -32,7 +32,7 @@ public interface SmsLogMapper extends BaseMapperX<SmsLogDO> {
.likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile()) .likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile())
.eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus()) .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus())
.betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime()) .betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime())
.eqIfPresent(SmsLogDO::getSendStatus, reqVO.getReceiveStatus()) .eqIfPresent(SmsLogDO::getReceiveStatus, reqVO.getReceiveStatus())
.betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime()) .betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime())
.orderByDesc(SmsLogDO::getId)); .orderByDesc(SmsLogDO::getId));
} }

View File

@ -1,19 +1,18 @@
package cn.iocoder.yudao.module.system.service.logger; package cn.iocoder.yudao.module.system.service.logger;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO;
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO;
import cn.iocoder.yudao.module.system.dal.mysql.logger.LoginLogMapper; import cn.iocoder.yudao.module.system.dal.mysql.logger.LoginLogMapper;
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum;
import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum;
import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -22,8 +21,9 @@ import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import static cn.hutool.core.util.RandomUtil.randomEle; import static cn.hutool.core.util.RandomUtil.randomEle;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildLocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildLocalDateTime;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.*;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@Import(LoginLogServiceImpl.class) @Import(LoginLogServiceImpl.class)
@ -47,13 +47,13 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest {
logDO.setUserIp("192.168.199.16"); logDO.setUserIp("192.168.199.16");
logDO.setUsername("wangkai"); logDO.setUsername("wangkai");
logDO.setCreateTime(buildLocalDateTime(2021, 3, 6)); logDO.setCreateTime(buildLocalDateTime(2021, 3, 6));
logDO.setResult(cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.SUCCESS.getResult()); logDO.setResult(SUCCESS.getResult());
}); });
loginLogMapper.insert(loginLogDO); loginLogMapper.insert(loginLogDO);
// 下面几个都是不匹配的数据 // 下面几个都是不匹配的数据
// 登录失败的 // 登录失败的
loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setResult(cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.CAPTCHA_CODE_ERROR.getResult()))); loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setResult(CAPTCHA_CODE_ERROR.getResult())));
// 不同ip段的 // 不同ip段的
loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setUserIp("192.168.128.18"))); loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setUserIp("192.168.128.18")));
// 不同username // 不同username
@ -67,7 +67,8 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest {
reqVO.setUsername("wangkai"); reqVO.setUsername("wangkai");
reqVO.setUserIp("192.168.199"); reqVO.setUserIp("192.168.199");
reqVO.setStatus(true); reqVO.setStatus(true);
reqVO.setCreateTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),buildLocalDateTime(2021, 3, 5)})); reqVO.setCreateTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),
buildLocalDateTime(2021, 3, 7)}));
// 调用service方法 // 调用service方法
PageResult<LoginLogDO> pageResult = loginLogService.getLoginLogPage(reqVO); PageResult<LoginLogDO> pageResult = loginLogService.getLoginLogPage(reqVO);
@ -91,13 +92,13 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest {
logDO.setUserIp("192.168.111.16"); logDO.setUserIp("192.168.111.16");
logDO.setUsername("wangxiaokai"); logDO.setUsername("wangxiaokai");
logDO.setCreateTime(buildLocalDateTime(2021, 3, 6)); logDO.setCreateTime(buildLocalDateTime(2021, 3, 6));
logDO.setResult(cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.SUCCESS.getResult()); logDO.setResult(SUCCESS.getResult());
}); });
loginLogMapper.insert(loginLogDO); loginLogMapper.insert(loginLogDO);
// 下面几个都是不匹配的数据 // 下面几个都是不匹配的数据
// 登录失败的 // 登录失败的
loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setResult(cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.CAPTCHA_CODE_ERROR.getResult()))); loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setResult(CAPTCHA_CODE_ERROR.getResult())));
// 不同ip段的 // 不同ip段的
loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setUserIp("192.168.128.18"))); loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setUserIp("192.168.128.18")));
// 不同username // 不同username
@ -110,7 +111,8 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest {
reqVO.setUsername("wangxiaokai"); reqVO.setUsername("wangxiaokai");
reqVO.setUserIp("192.168.111"); reqVO.setUserIp("192.168.111");
reqVO.setStatus(true); reqVO.setStatus(true);
reqVO.setCreateTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),buildLocalDateTime(2021, 3, 5)})); reqVO.setCreateTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),
buildLocalDateTime(2021, 3, 7)}));
// 调用service方法 // 调用service方法
List<LoginLogDO> loginLogList = loginLogService.getLoginLogList(reqVO); List<LoginLogDO> loginLogList = loginLogService.getLoginLogList(reqVO);
@ -126,7 +128,7 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest {
// 指定随机的范围,避免超出范围入库失败 // 指定随机的范围,避免超出范围入库失败
vo.setUserType(randomEle(UserTypeEnum.values()).getValue()); vo.setUserType(randomEle(UserTypeEnum.values()).getValue());
vo.setLogType(randomEle(LoginLogTypeEnum.values()).getType()); vo.setLogType(randomEle(LoginLogTypeEnum.values()).getType());
vo.setResult(randomEle(LoginResultEnum.values()).getResult()); vo.setResult(randomEle(values()).getResult());
vo.setTraceId(TracerUtils.getTraceId()); vo.setTraceId(TracerUtils.getTraceId());
}); });

View File

@ -104,7 +104,8 @@ public class OperateLogServiceImplTest extends BaseDbUnitTest {
reqVO.setUserNickname("wangkai"); reqVO.setUserNickname("wangkai");
reqVO.setModule("order"); reqVO.setModule("order");
reqVO.setType(OperateTypeEnum.CREATE.getType()); reqVO.setType(OperateTypeEnum.CREATE.getType());
reqVO.setStartTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),buildLocalDateTime(2021, 3, 7)})); reqVO.setStartTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),
buildLocalDateTime(2021, 3, 7)}));
reqVO.setSuccess(true); reqVO.setSuccess(true);
// 调用service方法 // 调用service方法

View File

@ -74,9 +74,11 @@ public class SmsLogServiceTest extends BaseDbUnitTest {
reqVO.setTemplateId(10L); reqVO.setTemplateId(10L);
reqVO.setMobile("156"); reqVO.setMobile("156");
reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus()); reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus());
reqVO.setSendTime((new LocalDateTime[]{buildLocalDateTime(2020, 11, 1),buildLocalDateTime(2020, 11, 30)})); reqVO.setSendTime((new LocalDateTime[]{buildLocalDateTime(2020, 11, 1),
buildLocalDateTime(2020, 11, 30)}));
reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus()); reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus());
reqVO.setReceiveTime((new LocalDateTime[]{buildLocalDateTime(2021, 11, 1),buildLocalDateTime(2021, 11, 30)})); reqVO.setReceiveTime((new LocalDateTime[]{buildLocalDateTime(2021, 11, 1),
buildLocalDateTime(2021, 11, 30)}));
// 调用 // 调用
PageResult<SmsLogDO> pageResult = smsLogService.getSmsLogPage(reqVO); PageResult<SmsLogDO> pageResult = smsLogService.getSmsLogPage(reqVO);
@ -119,9 +121,11 @@ public class SmsLogServiceTest extends BaseDbUnitTest {
reqVO.setTemplateId(10L); reqVO.setTemplateId(10L);
reqVO.setMobile("156"); reqVO.setMobile("156");
reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus()); reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus());
reqVO.setSendTime((new LocalDateTime[]{buildLocalDateTime(2020, 11, 1),buildLocalDateTime(2020, 11, 30)})); reqVO.setSendTime((new LocalDateTime[]{buildLocalDateTime(2020, 11, 1),
buildLocalDateTime(2020, 11, 30)}));
reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus()); reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus());
reqVO.setReceiveTime((new LocalDateTime[]{buildLocalDateTime(2021, 11, 1),buildLocalDateTime(2021, 11, 30)})); reqVO.setReceiveTime((new LocalDateTime[]{buildLocalDateTime(2021, 11, 1),
buildLocalDateTime(2021, 11, 30)}));
// 调用 // 调用
List<SmsLogDO> list = smsLogService.getSmsLogList(reqVO); List<SmsLogDO> list = smsLogService.getSmsLogList(reqVO);