潘志宝
2024-11-11 31bd2c17088ec34072deabe106ff1d695c8b2b49
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.bpm.framework.flowable.core.candidate.strategy;
H 2
3 import com.iailab.framework.test.core.ut.BaseMockitoUnitTest;
4 import com.iailab.module.system.api.user.AdminUserApi;
5 import com.iailab.module.system.api.user.dto.AdminUserRespDTO;
6 import org.junit.jupiter.api.Test;
7 import org.mockito.InjectMocks;
8 import org.mockito.Mock;
9
10 import java.util.List;
11 import java.util.Set;
12
13 import static com.iailab.framework.common.pojo.CommonResult.success;
14 import static com.iailab.framework.common.util.collection.CollectionUtils.convertList;
15 import static com.iailab.framework.common.util.collection.SetUtils.asSet;
16 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import static org.mockito.ArgumentMatchers.eq;
18 import static org.mockito.Mockito.when;
19
20 public class BpmTaskCandidateDeptMemberStrategyTest extends BaseMockitoUnitTest {
21
22     @InjectMocks
23     private BpmTaskCandidateDeptMemberStrategy strategy;
24
25     @Mock
26     private AdminUserApi adminUserApi;
27
28     @Test
29     public void testCalculateUsers() {
30         // 准备参数
31         String param = "11,22";
32         // mock 方法
33         List<AdminUserRespDTO> users = convertList(asSet(11L, 22L),
34                 id -> new AdminUserRespDTO().setId(id));
35         when(adminUserApi.getUserListByDeptIds(eq(asSet(11L, 22L)))).thenReturn(success(users));
36
37         // 调用
38         Set<Long> results = strategy.calculateUsers(null, param);
39         // 断言
40         assertEquals(asSet(11L, 22L), results);
41     }
42
43 }