From 1781e76e19132ca35a7633936ed259ba479ba364 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 15 Jan 2022 11:51:09 +0800 Subject: [PATCH] =?UTF-8?q?BPM=20=E6=A8=A1=E5=9E=8B=E9=87=8D=E6=9E=84=207?= =?UTF-8?q?=EF=BC=9A=E4=BB=BB=E5=8A=A1=E5=88=86=E9=85=8D=E8=A7=84=E5=88=99?= =?UTF-8?q?=E7=9A=84=E5=90=8E=E7=AB=AF=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../definition/BpmTaskRuleScriptEnum.java | 5 +- .../config/BpmActivitiConfiguration.java | 15 +- .../behavior/BpmActivityBehaviorFactory.java | 19 ++ .../behavior/BpmUserTaskActivitiBehavior.java | 38 ++- .../BpmUserTaskActivitiBehaviorTest.java | 216 ++++++++++++++++++ 5 files changed, 281 insertions(+), 12 deletions(-) create mode 100644 yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehaviorTest.java diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskRuleScriptEnum.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskRuleScriptEnum.java index 0f49d2191..ebc3f50de 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskRuleScriptEnum.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/enums/definition/BpmTaskRuleScriptEnum.java @@ -11,9 +11,10 @@ import lombok.Getter; */ @Getter @AllArgsConstructor -public class BpmTaskRuleScriptEnum { +public enum BpmTaskRuleScriptEnum { - ; + ONE(1L, ""), + TWO(2L, ""); /** * 脚本编号 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java index 374e78c89..bb12b8afa 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/config/BpmActivitiConfiguration.java @@ -1,14 +1,19 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.config; import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.BpmActivityBehaviorFactory; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.listener.BpmTackActivitiEventListener; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; +import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.Collections; +import java.util.List; import static org.activiti.spring.boot.ProcessEngineAutoConfiguration.BEHAVIOR_FACTORY_MAPPING_CONFIGURER; @@ -47,10 +52,18 @@ public class BpmActivitiConfiguration { @Bean public BpmActivityBehaviorFactory bpmActivityBehaviorFactory(BpmTaskAssignRuleService taskRuleService, - SysPermissionService permissionService) { + SysPermissionService permissionService, + SysDeptService deptService, + BpmUserGroupService userGroupService, + SysUserService userService, + List scripts) { BpmActivityBehaviorFactory bpmActivityBehaviorFactory = new BpmActivityBehaviorFactory(); bpmActivityBehaviorFactory.setBpmTaskRuleService(taskRuleService); bpmActivityBehaviorFactory.setPermissionService(permissionService); + bpmActivityBehaviorFactory.setDeptService(deptService); + bpmActivityBehaviorFactory.setUserGroupService(userGroupService); + bpmActivityBehaviorFactory.setUserService(userService); + bpmActivityBehaviorFactory.setScripts(scripts); return bpmActivityBehaviorFactory; } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java index 8521548a2..1e3f542fa 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmActivityBehaviorFactory.java @@ -1,7 +1,11 @@ package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; +import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Setter; @@ -10,6 +14,9 @@ import org.activiti.bpmn.model.UserTask; import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior; import org.activiti.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory; +import javax.annotation.Resource; +import java.util.List; + /** * 自定义的 ActivityBehaviorFactory 实现类,目的如下: * 1. 自定义 {@link #createUserTaskActivityBehavior(UserTask)}:实现自定义的流程任务的 assignee 负责人的分配 @@ -25,12 +32,24 @@ public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory { private BpmTaskAssignRuleService bpmTaskRuleService; @Setter private SysPermissionService permissionService; + @Setter + private SysDeptService deptService; + @Setter + private BpmUserGroupService userGroupService; + @Setter + private SysUserService userService; + @Setter + private List scripts; @Override public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) { BpmUserTaskActivitiBehavior userTaskActivityBehavior = new BpmUserTaskActivitiBehavior(userTask); userTaskActivityBehavior.setBpmTaskRuleService(bpmTaskRuleService); userTaskActivityBehavior.setPermissionService(permissionService); + userTaskActivityBehavior.setDeptService(deptService); + userTaskActivityBehavior.setUserGroupService(userGroupService); + userTaskActivityBehavior.setUserService(userService); + userTaskActivityBehavior.setScripts(scripts); return userTaskActivityBehavior; } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java index c79f76d7e..5a860f678 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehavior.java @@ -14,6 +14,8 @@ import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import com.google.common.annotations.VisibleForTesting; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.activiti.bpmn.model.UserTask; @@ -24,10 +26,7 @@ import org.activiti.engine.impl.el.ExpressionManager; import org.activiti.engine.impl.persistence.entity.TaskEntity; import org.activiti.engine.impl.persistence.entity.TaskEntityManager; -import javax.annotation.Resource; import java.util.*; -import java.util.function.Consumer; -import java.util.function.Function; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.TASK_ASSIGN_SCRIPT_NOT_EXISTS; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.TASK_CREATE_FAIL_NO_CANDIDATE_USER; @@ -52,7 +51,7 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { private SysDeptService deptService; @Setter private BpmUserGroupService userGroupService; - @Resource + @Setter private SysUserService userService; /** * 任务分配脚本 @@ -105,15 +104,18 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { return CollUtil.get(candidateUserIds, index); } - private Set calculateTaskCandidateUsers(TaskEntity task, BpmTaskAssignRuleDO rule) { + @VisibleForTesting + Set calculateTaskCandidateUsers(TaskEntity task, BpmTaskAssignRuleDO rule) { Set assigneeUserIds = null; if (Objects.equals(BpmTaskAssignRuleTypeEnum.ROLE.getType(), rule.getType())) { assigneeUserIds = calculateTaskCandidateUsersByRole(task, rule); } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) { - assigneeUserIds = calculateTaskCandidateUsersByMember(task, rule); + assigneeUserIds = calculateTaskCandidateUsersByDeptMember(task, rule); } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), rule.getType())) { assigneeUserIds = calculateTaskCandidateUsersByDeptLeader(task, rule); - } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER.getType(), rule.getType())) { + } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.POST.getType(), rule.getType())) { + assigneeUserIds = calculateTaskCandidateUsersByPost(task, rule); + } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER.getType(), rule.getType())) { assigneeUserIds = calculateTaskCandidateUsersByUser(task, rule); } else if (Objects.equals(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType(), rule.getType())) { assigneeUserIds = calculateTaskCandidateUsersByUserGroup(task, rule); @@ -121,7 +123,8 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { assigneeUserIds = calculateTaskCandidateUsersByScript(task, rule); } - // TODO 芋艿:统一过滤掉被禁用的用户 + // 移除被禁用的用户 + removeDisableUsers(assigneeUserIds); // 如果候选人为空,抛出异常 TODO 芋艿:没候选人的策略选择。1 - 挂起;2 - 直接结束;3 - 强制一个兜底人 if (CollUtil.isEmpty(assigneeUserIds)) { log.error("[calculateTaskCandidateUsers][流程任务({}/{}/{}) 任务规则({}) 找不到候选人]", @@ -135,7 +138,7 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { return permissionService.getUserRoleIdListByRoleIds(rule.getOptions()); } - private Set calculateTaskCandidateUsersByMember(TaskEntity task, BpmTaskAssignRuleDO rule) { + private Set calculateTaskCandidateUsersByDeptMember(TaskEntity task, BpmTaskAssignRuleDO rule) { List users = userService.getUsersByPostIds(rule.getOptions()); return convertSet(users, SysUserDO::getId); } @@ -145,6 +148,11 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { return convertSet(depts, SysDeptDO::getLeaderUserId); } + private Set calculateTaskCandidateUsersByPost(TaskEntity task, BpmTaskAssignRuleDO rule) { + List users = userService.getUsersByPostIds(rule.getOptions()); + return convertSet(users, SysUserDO::getId); + } + private Set calculateTaskCandidateUsersByUser(TaskEntity task, BpmTaskAssignRuleDO rule) { return rule.getOptions(); } @@ -172,4 +180,16 @@ public class BpmUserTaskActivitiBehavior extends UserTaskActivityBehavior { return userIds; } + @VisibleForTesting + void removeDisableUsers(Set assigneeUserIds) { + if (CollUtil.isEmpty(assigneeUserIds)) { + return; + } + Map userMap = userService.getUserMap(assigneeUserIds); + assigneeUserIds.removeIf(id -> { + SysUserDO user = userMap.get(id); + return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus()); + }); + } + } diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehaviorTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehaviorTest.java new file mode 100644 index 000000000..39b88e436 --- /dev/null +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/bpm/framework/activiti/core/behavior/BpmUserTaskActivitiBehaviorTest.java @@ -0,0 +1,216 @@ +package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior; + +import cn.hutool.core.map.MapUtil; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; +import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO; +import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; +import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskRuleScriptEnum; +import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript; +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmTaskAssignRuleService; +import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmUserGroupService; +import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO; +import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService; +import cn.iocoder.yudao.adminserver.modules.system.service.permission.SysPermissionService; +import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService; +import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.common.util.collection.SetUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import org.activiti.engine.impl.persistence.entity.TaskEntity; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Function; + +import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static java.util.Collections.singletonList; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.anySet; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +class BpmUserTaskActivitiBehaviorTest extends BaseMockitoUnitTest { + + @InjectMocks + private BpmUserTaskActivitiBehavior behavior; + @Mock + private BpmTaskAssignRuleService bpmTaskRuleService; + @Mock + private SysPermissionService permissionService; + @Mock + private SysDeptService deptService; + @Mock + private BpmUserGroupService userGroupService; + @Mock + private SysUserService userService; + + @Test + public void testCalculateTaskCandidateUsers_Role() { + // 准备参数 + BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) + .setType(BpmTaskAssignRuleTypeEnum.ROLE.getType()); + // mock 方法 + when(permissionService.getUserRoleIdListByRoleIds(eq(rule.getOptions()))) + .thenReturn(asSet(11L, 22L)); + mockGetUserMap(asSet(11L, 22L)); + + // 调用 + Set results = behavior.calculateTaskCandidateUsers(null, rule); + // 断言 + assertEquals(asSet(11L, 22L), results); + } + + @Test + public void testCalculateTaskCandidateUsers_DeptMember() { + // 准备参数 + BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) + .setType(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType()); + // mock 方法 + List users = CollectionUtils.convertList(asSet(11L, 22L), + id -> new SysUserDO().setId(id)); + when(userService.getUsersByPostIds(eq(rule.getOptions()))).thenReturn(users); + mockGetUserMap(asSet(11L, 22L)); + + // 调用 + Set results = behavior.calculateTaskCandidateUsers(null, rule); + // 断言 + assertEquals(asSet(11L, 22L), results); + } + + @Test + public void testCalculateTaskCandidateUsers_DeptLeader() { + // 准备参数 + BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) + .setType(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType()); + // mock 方法 + SysDeptDO dept1 = randomPojo(SysDeptDO.class, o -> o.setLeaderUserId(11L)); + SysDeptDO dept2 = randomPojo(SysDeptDO.class, o -> o.setLeaderUserId(22L)); + when(deptService.getDepts(eq(rule.getOptions()))).thenReturn(Arrays.asList(dept1, dept2)); + mockGetUserMap(asSet(11L, 22L)); + + // 调用 + Set results = behavior.calculateTaskCandidateUsers(null, rule); + // 断言 + assertEquals(asSet(11L, 22L), results); + } + + @Test + public void testCalculateTaskCandidateUsers_Post() { + // 准备参数 + BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) + .setType(BpmTaskAssignRuleTypeEnum.POST.getType()); + // mock 方法 + List users = CollectionUtils.convertList(asSet(11L, 22L), + id -> new SysUserDO().setId(id)); + when(userService.getUsersByPostIds(eq(rule.getOptions()))).thenReturn(users); + mockGetUserMap(asSet(11L, 22L)); + + // 调用 + Set results = behavior.calculateTaskCandidateUsers(null, rule); + // 断言 + assertEquals(asSet(11L, 22L), results); + } + + @Test + public void testCalculateTaskCandidateUsers_User() { + // 准备参数 + BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) + .setType(BpmTaskAssignRuleTypeEnum.USER.getType()); + // mock 方法 + mockGetUserMap(asSet(1L, 2L)); + + // 调用 + Set results = behavior.calculateTaskCandidateUsers(null, rule); + // 断言 + assertEquals(asSet(1L, 2L), results); + } + + @Test + public void testCalculateTaskCandidateUsers_UserGroup() { + // 准备参数 + BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) + .setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType()); + // mock 方法 + BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L))); + BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(21L, 22L))); + when(userGroupService.getUserGroupList(eq(rule.getOptions()))).thenReturn(Arrays.asList(userGroup1, userGroup2)); + mockGetUserMap(asSet(11L, 12L, 21L, 22L)); + + // 调用 + Set results = behavior.calculateTaskCandidateUsers(null, rule); + // 断言 + assertEquals(asSet(11L, 12L, 21L, 22L), results); + } + + @Test + public void testCalculateTaskCandidateUsers_Script() { + // 准备参数 + BpmTaskAssignRuleDO rule = new BpmTaskAssignRuleDO().setOptions(asSet(1L, 2L)) + .setType(BpmTaskAssignRuleTypeEnum.SCRIPT.getType()); + // mock 方法 + BpmTaskAssignScript script1 = new BpmTaskAssignScript() { + + @Override + public List calculateTaskCandidateUsers(TaskEntity task) { + return singletonList(11L); + } + + @Override + public BpmTaskRuleScriptEnum getEnum() { + return BpmTaskRuleScriptEnum.ONE; + } + }; + BpmTaskAssignScript script2 = new BpmTaskAssignScript() { + + @Override + public List calculateTaskCandidateUsers(TaskEntity task) { + return singletonList(22L); + } + + @Override + public BpmTaskRuleScriptEnum getEnum() { + return BpmTaskRuleScriptEnum.TWO; + } + }; + behavior.setScripts(Arrays.asList(script1, script2)); + mockGetUserMap(asSet(11L, 22L)); + + // 调用 + Set results = behavior.calculateTaskCandidateUsers(null, rule); + // 断言 + assertEquals(asSet(11L, 22L), results); + } + + @Test + public void testRemoveDisableUsers() { + // 准备参数 + Set assigneeUserIds = asSet(1L, 2L, 3L); + // mock 方法 + SysUserDO user1 = randomPojo(SysUserDO.class, o -> o.setId(1L)); + SysUserDO user2 = randomPojo(SysUserDO.class, o -> o.setId(2L) + .setStatus(CommonStatusEnum.DISABLE.getStatus())); + Map userMap = MapUtil.builder(user1.getId(), user1) + .put(user2.getId(), user2).build(); + when(userService.getUserMap(eq(assigneeUserIds))).thenReturn(userMap); + + // 调用 + behavior.removeDisableUsers(assigneeUserIds); + // 断言 + assertEquals(asSet(1L), assigneeUserIds); + } + + private void mockGetUserMap(Set assigneeUserIds) { + Map userMap = CollectionUtils.convertMap(assigneeUserIds, id -> id, + id -> new SysUserDO().setId(id).setStatus(CommonStatusEnum.ENABLE.getStatus())); + when(userService.getUserMap(eq(assigneeUserIds))).thenReturn(userMap); + } + +}