Jay
2024-10-16 a40221c883c632630b4876ad846e08c0da8af388
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.bpm.framework.flowable.core.candidate.strategy;
H 2
3 import com.iailab.module.bpm.framework.flowable.core.util.FlowableUtils;
4 import com.iailab.framework.test.core.ut.BaseMockitoUnitTest;
5 import org.flowable.engine.delegate.DelegateExecution;
6 import org.junit.jupiter.api.Test;
7 import org.mockito.InjectMocks;
8 import org.mockito.MockedStatic;
9
10 import java.util.Set;
11
12 import static com.iailab.framework.common.util.collection.SetUtils.asSet;
13 import static org.junit.jupiter.api.Assertions.assertEquals;
14 import static org.mockito.ArgumentMatchers.eq;
15 import static org.mockito.Mockito.*;
16
17 public class BpmTaskCandidateExpressionStrategyTest extends BaseMockitoUnitTest {
18
19     @InjectMocks
20     private BpmTaskCandidateExpressionStrategy strategy;
21
22     @Test
23     public void testCalculateUsers() {
24         try (MockedStatic<FlowableUtils> flowableUtilMockedStatic = mockStatic(FlowableUtils.class)) {
25             // 准备参数
26             String param = "1,2";
27             DelegateExecution execution = mock(DelegateExecution.class);
28             // mock 方法
29             flowableUtilMockedStatic.when(() -> FlowableUtils.getExpressionValue(same(execution), eq(param)))
30                     .thenReturn(asSet(1L, 2L));
31
32             // 调用
33             Set<Long> results = strategy.calculateUsers(execution, param);
34             // 断言
35             assertEquals(asSet(1L, 2L), results);
36         }
37     }
38
39 }