2026-06-25 a26b31cc9f3ee9b21b1a754e80fa7359e8a7a8f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.strategy.other;
 
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
import org.flowable.engine.delegate.DelegateExecution;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.MockedStatic;
 
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
 
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
 
@Disabled // TODO 芋艿:临时注释
public class BpmTaskCandidateExpressionStrategyTest extends BaseMockitoUnitTest {
 
    @InjectMocks
    private BpmTaskCandidateExpressionStrategy strategy;
 
    @Test
    public void testCalculateUsersByTask() {
        try (MockedStatic<FlowableUtils> flowableUtilMockedStatic = mockStatic(FlowableUtils.class)) {
            // 准备参数
            String param = "1,2";
            DelegateExecution execution = mock(DelegateExecution.class);
            // mock 方法
            flowableUtilMockedStatic.when(() -> FlowableUtils.getExpressionValue(same(execution), eq(param)))
                    .thenReturn(asSet(1L, 2L));
 
            // 调用
            Set<Long> results = strategy.calculateUsersByTask(execution, param);
            // 断言
            assertEquals(asSet(1L, 2L), results);
        }
    }
 
    @Test
    public void testCalculateUsersByActivity() {
        try (MockedStatic<FlowableUtils> flowableUtilMockedStatic = mockStatic(FlowableUtils.class)) {
            // 准备参数
            String param = "1,2";
            Map<String, Object> processVariables = new HashMap<>();
            // mock 方法
            flowableUtilMockedStatic.when(() -> FlowableUtils.getExpressionValue(same(processVariables), eq(param)))
                    .thenReturn(asSet(1L, 2L));
 
            // 调用
            Set<Long> results = strategy.calculateUsersByActivity(null, null, param,
                    null, null, processVariables);
            // 断言
            assertEquals(asSet(1L, 2L), results);
        }
    }
 
}