Jay
2024-10-16 a40221c883c632630b4876ad846e08c0da8af388
提交 | 用户 | 时间
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.permission.PermissionApi;
5 import com.iailab.module.system.api.permission.RoleApi;
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 org.junit.jupiter.api.Assertions.assertEquals;
15 import static org.mockito.ArgumentMatchers.eq;
16 import static org.mockito.Mockito.when;
17
18 public class BpmTaskCandidateRoleStrategyTest extends BaseMockitoUnitTest {
19
20     @InjectMocks
21     private BpmTaskCandidateRoleStrategy strategy;
22
23     @Mock
24     private RoleApi roleApi;
25     @Mock
26     private PermissionApi permissionApi;
27
28     @Test
29     public void testCalculateUsers() {
30         // 准备参数
31         String param = "1,2";
32         // mock 方法
33         when(permissionApi.getUserRoleIdListByRoleIds(eq(asSet(1L, 2L))))
34             .thenReturn(success(asSet(11L, 22L)));
35
36         // 调用
37         Set<Long> results = strategy.calculateUsers(null, param);
38         // 断言
39         assertEquals(asSet(11L, 22L), results);
40     }
41
42 }