提交 | 用户 | 时间
|
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.DeptApi; |
|
5 |
import com.iailab.module.system.api.dept.dto.DeptRespDTO; |
|
6 |
import org.junit.jupiter.api.Test; |
|
7 |
import org.mockito.InjectMocks; |
|
8 |
import org.mockito.Mock; |
|
9 |
|
|
10 |
import java.util.Set; |
|
11 |
|
|
12 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
13 |
import static com.iailab.framework.common.util.collection.SetUtils.asSet; |
|
14 |
import static com.iailab.framework.test.core.util.RandomUtils.randomPojo; |
|
15 |
import static java.util.Arrays.asList; |
|
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 BpmTaskCandidateDeptLeaderStrategyTest extends BaseMockitoUnitTest { |
|
21 |
|
|
22 |
@InjectMocks |
|
23 |
private BpmTaskCandidateDeptLeaderStrategy strategy; |
|
24 |
|
|
25 |
@Mock |
|
26 |
private DeptApi deptApi; |
|
27 |
|
|
28 |
@Test |
|
29 |
public void testCalculateUsers() { |
|
30 |
// 准备参数 |
|
31 |
String param = "1,2"; |
|
32 |
// mock 方法 |
|
33 |
DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L)); |
|
34 |
DeptRespDTO dept2 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(22L)); |
|
35 |
when(deptApi.getDeptList(eq(asSet(1L, 2L)))).thenReturn(success(asList(dept1, dept2))); |
|
36 |
|
|
37 |
// 调用 |
|
38 |
Set<Long> results = strategy.calculateUsers(null, param); |
|
39 |
// 断言 |
|
40 |
assertEquals(asSet(11L, 22L), results); |
|
41 |
} |
|
42 |
|
|
43 |
} |