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