提交 | 用户 | 时间
|
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.bpm.dal.dataobject.definition.BpmUserGroupDO; |
|
5 |
import com.iailab.module.bpm.service.definition.BpmUserGroupService; |
|
6 |
import org.junit.jupiter.api.Test; |
|
7 |
import org.mockito.InjectMocks; |
|
8 |
import org.mockito.Mock; |
|
9 |
|
|
10 |
import java.util.Arrays; |
|
11 |
import java.util.Set; |
|
12 |
|
|
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 org.junit.jupiter.api.Assertions.assertEquals; |
|
16 |
import static org.mockito.ArgumentMatchers.eq; |
|
17 |
import static org.mockito.Mockito.when; |
|
18 |
|
|
19 |
public class BpmTaskCandidateGroupStrategyTest extends BaseMockitoUnitTest { |
|
20 |
|
|
21 |
@InjectMocks |
|
22 |
private BpmTaskCandidateGroupStrategy strategy; |
|
23 |
|
|
24 |
@Mock |
|
25 |
private BpmUserGroupService userGroupService; |
|
26 |
|
|
27 |
@Test |
|
28 |
public void testCalculateUsers() { |
|
29 |
// 准备参数 |
|
30 |
String param = "1,2"; |
|
31 |
// mock 方法 |
|
32 |
BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setUserIds(asSet(11L, 12L))); |
|
33 |
BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setUserIds(asSet(21L, 22L))); |
|
34 |
when(userGroupService.getUserGroupList(eq(asSet(1L, 2L)))).thenReturn(Arrays.asList(userGroup1, userGroup2)); |
|
35 |
|
|
36 |
// 调用 |
|
37 |
Set<Long> results = strategy.calculateUsers(null, param); |
|
38 |
// 断言 |
|
39 |
assertEquals(asSet(11L, 12L, 21L, 22L), results); |
|
40 |
} |
|
41 |
|
|
42 |
} |