对齐 boot 与 cloud 的代码

This commit is contained in:
YunaiV 2023-07-27 13:59:20 +08:00
parent 0feb865ef0
commit 9ba06ec07e
11 changed files with 109 additions and 107 deletions

View File

@ -14,8 +14,8 @@ import cn.iocoder.yudao.framework.operatelog.core.service.OperateLog;
import cn.iocoder.yudao.framework.operatelog.core.service.OperateLogFrameworkService; import cn.iocoder.yudao.framework.operatelog.core.service.OperateLogFrameworkService;
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
@ -267,9 +267,9 @@ public class OperateLogAspect {
return null; return null;
} }
return Arrays.stream(requestMethods).filter(requestMethod -> return Arrays.stream(requestMethods).filter(requestMethod ->
requestMethod == RequestMethod.POST requestMethod == RequestMethod.POST
|| requestMethod == RequestMethod.PUT || requestMethod == RequestMethod.PUT
|| requestMethod == RequestMethod.DELETE) || requestMethod == RequestMethod.DELETE)
.findFirst().orElse(null); .findFirst().orElse(null);
} }

View File

@ -73,16 +73,18 @@ public interface BpmTaskConvert {
BpmTaskDonePageItemRespVO convert2(HistoricTaskInstance bean); BpmTaskDonePageItemRespVO convert2(HistoricTaskInstance bean);
@Mappings({@Mapping(source = "processInstance.id", target = "id"), @Mappings({
@Mapping(source = "processInstance.name", target = "name"), @Mapping(source = "processInstance.id", target = "id"),
@Mapping(source = "processInstance.startUserId", target = "startUserId"), @Mapping(source = "processInstance.name", target = "name"),
@Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"), @Mapping(source = "processInstance.startUserId", target = "startUserId"),
@Mapping(source = "startUser.nickname", target = "startUserNickname")}) @Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"),
@Mapping(source = "startUser.nickname", target = "startUserNickname")
})
BpmTaskTodoPageItemRespVO.ProcessInstance convert(ProcessInstance processInstance, AdminUserRespDTO startUser); BpmTaskTodoPageItemRespVO.ProcessInstance convert(ProcessInstance processInstance, AdminUserRespDTO startUser);
default List<BpmTaskRespVO> convertList3(List<HistoricTaskInstance> tasks, default List<BpmTaskRespVO> convertList3(List<HistoricTaskInstance> tasks,
Map<String, BpmTaskExtDO> bpmTaskExtDOMap, HistoricProcessInstance processInstance, Map<String, BpmTaskExtDO> bpmTaskExtDOMap, HistoricProcessInstance processInstance,
Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
return CollectionUtils.convertList(tasks, task -> { return CollectionUtils.convertList(tasks, task -> {
BpmTaskRespVO respVO = convert3(task); BpmTaskRespVO respVO = convert3(task);
BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId()); BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId());

View File

@ -89,7 +89,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
@Override @Override
public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId, public List<BpmTaskAssignRuleDO> getTaskAssignRuleListByProcessDefinitionId(String processDefinitionId,
String taskDefinitionKey) { String taskDefinitionKey) {
return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey); return taskRuleMapper.selectListByProcessDefinitionId(processDefinitionId, taskDefinitionKey);
} }
@ -128,14 +128,14 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions()); validTaskAssignRuleOptions(reqVO.getType(), reqVO.getOptions());
// 校验是否已经配置 // 校验是否已经配置
BpmTaskAssignRuleDO existRule = BpmTaskAssignRuleDO existRule =
taskRuleMapper.selectListByModelIdAndTaskDefinitionKey(reqVO.getModelId(), reqVO.getTaskDefinitionKey()); taskRuleMapper.selectListByModelIdAndTaskDefinitionKey(reqVO.getModelId(), reqVO.getTaskDefinitionKey());
if (existRule != null) { if (existRule != null) {
throw exception(TASK_ASSIGN_RULE_EXISTS, reqVO.getModelId(), reqVO.getTaskDefinitionKey()); throw exception(TASK_ASSIGN_RULE_EXISTS, reqVO.getModelId(), reqVO.getTaskDefinitionKey());
} }
// 存储 // 存储
BpmTaskAssignRuleDO rule = BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO) BpmTaskAssignRuleDO rule = BpmTaskAssignRuleConvert.INSTANCE.convert(reqVO)
.setProcessDefinitionId(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL); // 只有流程模型才允许新建 .setProcessDefinitionId(BpmTaskAssignRuleDO.PROCESS_DEFINITION_ID_NULL); // 只有流程模型才允许新建
taskRuleMapper.insert(rule); taskRuleMapper.insert(rule);
return rule.getId(); return rule.getId();
} }
@ -169,14 +169,14 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
// 遍历匹配对应的规则 // 遍历匹配对应的规则
Map<String, BpmTaskAssignRuleRespVO> processInstanceRuleMap = Map<String, BpmTaskAssignRuleRespVO> processInstanceRuleMap =
CollectionUtils.convertMap(processInstanceRules, BpmTaskAssignRuleRespVO::getTaskDefinitionKey); CollectionUtils.convertMap(processInstanceRules, BpmTaskAssignRuleRespVO::getTaskDefinitionKey);
for (BpmTaskAssignRuleRespVO modelRule : modelRules) { for (BpmTaskAssignRuleRespVO modelRule : modelRules) {
BpmTaskAssignRuleRespVO processInstanceRule = processInstanceRuleMap.get(modelRule.getTaskDefinitionKey()); BpmTaskAssignRuleRespVO processInstanceRule = processInstanceRuleMap.get(modelRule.getTaskDefinitionKey());
if (processInstanceRule == null) { if (processInstanceRule == null) {
return false; return false;
} }
if (!ObjectUtil.equals(modelRule.getType(), processInstanceRule.getType()) || !ObjectUtil.equal( if (!ObjectUtil.equals(modelRule.getType(), processInstanceRule.getType()) || !ObjectUtil.equal(
modelRule.getOptions(), processInstanceRule.getOptions())) { modelRule.getOptions(), processInstanceRule.getOptions())) {
return false; return false;
} }
} }
@ -192,7 +192,7 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
// 开始复制 // 开始复制
List<BpmTaskAssignRuleDO> newRules = BpmTaskAssignRuleConvert.INSTANCE.convertList2(rules); List<BpmTaskAssignRuleDO> newRules = BpmTaskAssignRuleConvert.INSTANCE.convertList2(rules);
newRules.forEach(rule -> rule.setProcessDefinitionId(toProcessDefinitionId).setId(null).setCreateTime(null) newRules.forEach(rule -> rule.setProcessDefinitionId(toProcessDefinitionId).setId(null).setCreateTime(null)
.setUpdateTime(null)); .setUpdateTime(null));
taskRuleMapper.insertBatch(newRules); taskRuleMapper.insertBatch(newRules);
} }
@ -215,17 +215,17 @@ public class BpmTaskAssignRuleServiceImpl implements BpmTaskAssignRuleService {
if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.ROLE.getType())) { if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.ROLE.getType())) {
roleApi.validRoleList(options); roleApi.validRoleList(options);
} else if (ObjectUtils.equalsAny(type, BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), } else if (ObjectUtils.equalsAny(type, BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(),
BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType())) { BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType())) {
deptApi.validateDeptList(options); deptApi.validateDeptList(options);
} else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.POST.getType())) { } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.POST.getType())) {
postApi.validPostList(options); postApi.validPostList(options);
} else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER.getType())) { } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER.getType())) {
adminUserApi.validUserList(options); adminUserApi.validateUserList(options);
} else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER_GROUP.getType())) { } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.USER_GROUP.getType())) {
userGroupService.validUserGroups(options); userGroupService.validUserGroups(options);
} else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.SCRIPT.getType())) { } else if (Objects.equals(type, BpmTaskAssignRuleTypeEnum.SCRIPT.getType())) {
dictDataApi.validateDictDatas(DictTypeConstants.TASK_ASSIGN_SCRIPT, dictDataApi.validateDictDataList(DictTypeConstants.TASK_ASSIGN_SCRIPT,
CollectionUtils.convertSet(options, String::valueOf)); CollectionUtils.convertSet(options, String::valueOf));
} else { } else {
throw new IllegalArgumentException(format("未知的规则类型({})", type)); throw new IllegalArgumentException(format("未知的规则类型({})", type));
} }

View File

@ -15,7 +15,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
@ -86,8 +85,8 @@ public class BpmUserGroupServiceTest extends BaseDbUnitTest {
// 调用 // 调用
userGroupService.deleteUserGroup(id); userGroupService.deleteUserGroup(id);
// 校验数据不存在了 // 校验数据不存在了
Assertions.assertNull(userGroupMapper.selectById(id)); Assertions.assertNull(userGroupMapper.selectById(id));
} }
@Test @Test
@ -101,31 +100,31 @@ public class BpmUserGroupServiceTest extends BaseDbUnitTest {
@Test @Test
public void testGetUserGroupPage() { public void testGetUserGroupPage() {
// mock 数据 // mock 数据
BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到 BpmUserGroupDO dbUserGroup = RandomUtils.randomPojo(BpmUserGroupDO.class, o -> { // 等会查询到
o.setName("芋道源码"); o.setName("芋道源码");
o.setStatus(CommonStatusEnum.ENABLE.getStatus()); o.setStatus(CommonStatusEnum.ENABLE.getStatus());
o.setCreateTime(buildTime(2021, 11, 11)); o.setCreateTime(buildTime(2021, 11, 11));
}); });
userGroupMapper.insert(dbUserGroup); userGroupMapper.insert(dbUserGroup);
// 测试 name 不匹配 // 测试 name 不匹配
userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setName("芋道"))); userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setName("芋道")));
// 测试 status 不匹配 // 测试 status 不匹配
userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
// 测试 createTime 不匹配 // 测试 createTime 不匹配
userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setCreateTime(buildTime(2021, 12, 12)))); userGroupMapper.insert(cloneIgnoreId(dbUserGroup, o -> o.setCreateTime(buildTime(2021, 12, 12))));
// 准备参数 // 准备参数
BpmUserGroupPageReqVO reqVO = new BpmUserGroupPageReqVO(); BpmUserGroupPageReqVO reqVO = new BpmUserGroupPageReqVO();
reqVO.setName("源码"); reqVO.setName("源码");
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)})); reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)}));
// 调用 // 调用
PageResult<BpmUserGroupDO> pageResult = userGroupService.getUserGroupPage(reqVO); PageResult<BpmUserGroupDO> pageResult = userGroupService.getUserGroupPage(reqVO);
// 断言 // 断言
Assertions.assertEquals(1, pageResult.getTotal()); Assertions.assertEquals(1, pageResult.getTotal());
Assertions.assertEquals(1, pageResult.getList().size()); Assertions.assertEquals(1, pageResult.getList().size());
AssertUtils.assertPojoEquals(dbUserGroup, pageResult.getList().get(0)); AssertUtils.assertPojoEquals(dbUserGroup, pageResult.getList().get(0));
} }
} }

View File

@ -25,8 +25,8 @@ public interface DictDataApi {
@Parameter(name = "dictType", description = "字典类型", example = "SEX", required = true), @Parameter(name = "dictType", description = "字典类型", example = "SEX", required = true),
@Parameter(name = "descriptions", description = "字典数据值的数组", example = "1,2", required = true) @Parameter(name = "descriptions", description = "字典数据值的数组", example = "1,2", required = true)
}) })
CommonResult<Boolean> validateDictDatas(@RequestParam("dictType") String dictType, CommonResult<Boolean> validateDictDataList(@RequestParam("dictType") String dictType,
@RequestParam("values") Collection<String> values); @RequestParam("values") Collection<String> values);
@GetMapping(PREFIX + "/get") @GetMapping(PREFIX + "/get")
@Operation(summary = "获得指定的字典数据") @Operation(summary = "获得指定的字典数据")

View File

@ -55,6 +55,6 @@ public interface AdminUserApi {
@GetMapping(PREFIX + "/valid") @GetMapping(PREFIX + "/valid")
@Operation(summary = "校验用户们是否有效") @Operation(summary = "校验用户们是否有效")
@Parameter(name = "ids", description = "用户编号数组", example = "3,5", required = true) @Parameter(name = "ids", description = "用户编号数组", example = "3,5", required = true)
CommonResult<Boolean> validUserList(@RequestParam("ids") Set<Long> ids); CommonResult<Boolean> validateUserList(@RequestParam("ids") Set<Long> ids);
} }

View File

@ -24,7 +24,7 @@ public class DictDataApiImpl implements DictDataApi {
private DictDataService dictDataService; private DictDataService dictDataService;
@Override @Override
public CommonResult<Boolean> validateDictDatas(String dictType, Collection<String> values) { public CommonResult<Boolean> validateDictDataList(String dictType, Collection<String> values) {
dictDataService.validateDictDataList(dictType, values); dictDataService.validateDictDataList(dictType, values);
return success(true); return success(true);
} }

View File

@ -51,7 +51,7 @@ public class AdminUserApiImpl implements AdminUserApi {
} }
@Override @Override
public CommonResult<Boolean> validUserList(Set<Long> ids) { public CommonResult<Boolean> validateUserList(Set<Long> ids) {
userService.validateUserList(ids); userService.validateUserList(ids);
return success(true); return success(true);
} }

View File

@ -27,7 +27,8 @@ public interface AuthConvert {
default AuthPermissionInfoRespVO convert(AdminUserDO user, List<RoleDO> roleList, List<MenuDO> menuList) { default AuthPermissionInfoRespVO convert(AdminUserDO user, List<RoleDO> roleList, List<MenuDO> menuList) {
return AuthPermissionInfoRespVO.builder() return AuthPermissionInfoRespVO.builder()
.user(AuthPermissionInfoRespVO.UserVO.builder().id(user.getId()).nickname(user.getNickname()).avatar(user.getAvatar()).build()) .user(AuthPermissionInfoRespVO.UserVO.builder().id(user.getId()).nickname(user.getNickname())
.avatar(user.getAvatar()).build())
.roles(convertSet(roleList, RoleDO::getCode)) .roles(convertSet(roleList, RoleDO::getCode))
.permissions(convertSet(menuList, MenuDO::getPermission)) .permissions(convertSet(menuList, MenuDO::getPermission))
.build(); .build();
@ -54,7 +55,7 @@ public interface AuthConvert {
AuthMenuRespVO parentNode = treeNodeMap.get(childNode.getParentId()); AuthMenuRespVO parentNode = treeNodeMap.get(childNode.getParentId());
if (parentNode == null) { if (parentNode == null) {
LoggerFactory.getLogger(getClass()).error("[buildRouterTree][resource({}) 找不到父资源({})]", LoggerFactory.getLogger(getClass()).error("[buildRouterTree][resource({}) 找不到父资源({})]",
childNode.getId(), childNode.getParentId()); childNode.getId(), childNode.getParentId());
return; return;
} }
// 将自己添加到父节点中 // 将自己添加到父节点中

View File

@ -17,8 +17,8 @@ import javax.annotation.Resource;
import java.util.Map; import java.util.Map;
import static cn.hutool.core.util.RandomUtil.randomEle; import static cn.hutool.core.util.RandomUtil.randomEle;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
@ -132,48 +132,48 @@ public class MailLogServiceImplTest extends BaseDbUnitTest {
@Test @Test
public void testGetMailLogPage() { public void testGetMailLogPage() {
// mock 数据 // mock 数据
MailLogDO dbMailLog = randomPojo(MailLogDO.class, o -> { // 等会查询到 MailLogDO dbMailLog = randomPojo(MailLogDO.class, o -> { // 等会查询到
o.setUserId(1L); o.setUserId(1L);
o.setUserType(UserTypeEnum.ADMIN.getValue()); o.setUserType(UserTypeEnum.ADMIN.getValue());
o.setToMail("768@qq.com"); o.setToMail("768@qq.com");
o.setAccountId(10L); o.setAccountId(10L);
o.setTemplateId(100L); o.setTemplateId(100L);
o.setSendStatus(MailSendStatusEnum.INIT.getStatus()); o.setSendStatus(MailSendStatusEnum.INIT.getStatus());
o.setSendTime(buildTime(2023, 2, 10)); o.setSendTime(buildTime(2023, 2, 10));
o.setTemplateParams(randomTemplateParams()); o.setTemplateParams(randomTemplateParams());
}); });
mailLogMapper.insert(dbMailLog); mailLogMapper.insert(dbMailLog);
// 测试 userId 不匹配 // 测试 userId 不匹配
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserId(2L))); mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserId(2L)));
// 测试 userType 不匹配 // 测试 userType 不匹配
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserType(UserTypeEnum.MEMBER.getValue()))); mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
// 测试 toMail 不匹配 // 测试 toMail 不匹配
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setToMail("788@.qq.com"))); mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setToMail("788@.qq.com")));
// 测试 accountId 不匹配 // 测试 accountId 不匹配
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setAccountId(11L))); mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setAccountId(11L)));
// 测试 templateId 不匹配 // 测试 templateId 不匹配
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setTemplateId(101L))); mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setTemplateId(101L)));
// 测试 sendStatus 不匹配 // 测试 sendStatus 不匹配
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendStatus(MailSendStatusEnum.SUCCESS.getStatus()))); mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendStatus(MailSendStatusEnum.SUCCESS.getStatus())));
// 测试 sendTime 不匹配 // 测试 sendTime 不匹配
mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendTime(buildTime(2023, 3, 10)))); mailLogMapper.insert(cloneIgnoreId(dbMailLog, o -> o.setSendTime(buildTime(2023, 3, 10))));
// 准备参数 // 准备参数
MailLogPageReqVO reqVO = new MailLogPageReqVO(); MailLogPageReqVO reqVO = new MailLogPageReqVO();
reqVO.setUserId(1L); reqVO.setUserId(1L);
reqVO.setUserType(UserTypeEnum.ADMIN.getValue()); reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
reqVO.setToMail("768"); reqVO.setToMail("768");
reqVO.setAccountId(10L); reqVO.setAccountId(10L);
reqVO.setTemplateId(100L); reqVO.setTemplateId(100L);
reqVO.setSendStatus(MailSendStatusEnum.INIT.getStatus()); reqVO.setSendStatus(MailSendStatusEnum.INIT.getStatus());
reqVO.setSendTime((buildBetweenTime(2023, 2, 1, 2023, 2, 15))); reqVO.setSendTime((buildBetweenTime(2023, 2, 1, 2023, 2, 15)));
// 调用 // 调用
PageResult<MailLogDO> pageResult = mailLogService.getMailLogPage(reqVO); PageResult<MailLogDO> pageResult = mailLogService.getMailLogPage(reqVO);
// 断言 // 断言
assertEquals(1, pageResult.getTotal()); assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size()); assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbMailLog, pageResult.getList().get(0)); assertPojoEquals(dbMailLog, pageResult.getList().get(0));
} }
private static Map<String, Object> randomTemplateParams() { private static Map<String, Object> randomTemplateParams() {

View File

@ -279,16 +279,16 @@ public class MailSendServiceImplTest extends BaseMockitoUnitTest {
// mock 方法发送邮件 // mock 方法发送邮件
String messageId = randomString(); String messageId = randomString();
mailUtilMock.when(() -> MailUtil.send( mailUtilMock.when(() -> MailUtil.send(
argThat(mailAccount -> { argThat(mailAccount -> {
assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom()); assertEquals("芋艿 <7685@qq.com>", mailAccount.getFrom());
assertTrue(mailAccount.isAuth()); assertTrue(mailAccount.isAuth());
assertEquals(account.getUsername(), mailAccount.getUser()); assertEquals(account.getUsername(), mailAccount.getUser());
assertEquals(account.getPassword(), mailAccount.getPass()); assertEquals(account.getPassword(), mailAccount.getPass());
assertEquals(account.getHost(), mailAccount.getHost()); assertEquals(account.getHost(), mailAccount.getHost());
assertEquals(account.getPort(), mailAccount.getPort()); assertEquals(account.getPort(), mailAccount.getPort());
assertEquals(account.getSslEnable(), mailAccount.isSslEnable()); assertEquals(account.getSslEnable(), mailAccount.isSslEnable());
return true; return true;
}), eq(message.getMail()), eq(message.getTitle()), eq(message.getContent()), eq(true))) }), eq(message.getMail()), eq(message.getTitle()), eq(message.getContent()), eq(true)))
.thenReturn(messageId); .thenReturn(messageId);
// 调用 // 调用