Эх сурвалжийг харах

调整测试用例至核心

hubin 6 сар өмнө
parent
commit
0f3237448c

+ 0 - 88
src/main/java/com/aizuda/boot/modules/flw/flow/FlowHelper.java

@@ -1,21 +1,10 @@
 package com.aizuda.boot.modules.flw.flow;
 
 import com.aizuda.bpm.engine.FlowDataTransfer;
-import com.aizuda.bpm.engine.assist.ObjectUtils;
-import com.aizuda.bpm.engine.core.Execution;
 import com.aizuda.bpm.engine.core.FlowCreator;
-import com.aizuda.bpm.engine.core.FlowLongContext;
-import com.aizuda.bpm.engine.core.enums.TaskType;
 import com.aizuda.bpm.engine.entity.FlwTaskActor;
-import com.aizuda.bpm.engine.model.ConditionNode;
-import com.aizuda.bpm.engine.model.ModelHelper;
-import com.aizuda.bpm.engine.model.NodeModel;
 import com.aizuda.service.web.UserSession;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
 /**
  * 工作流辅助类
  */
@@ -41,81 +30,4 @@ public class FlowHelper {
     public static String getProcessApprovalOpinion() {
         return FlowDataTransfer.get("processApprovalOpinion");
     }
-
-    /**
-     * 获取下一个节点
-     */
-    public static List<NodeModel> getNextChildNodes(FlowLongContext flowLongContext, Execution execution, NodeModel rootNodeModel, String currentNodeKey) {
-        List<NodeModel> nextNodes = new ArrayList<>();
-        NodeModel currentNodeModel = rootNodeModel.getNode(currentNodeKey);
-        if (currentNodeModel.approvalOrMajor()) {
-            // 审批节点
-            NodeModel childNode = currentNodeModel.getChildNode();
-            if (null == childNode) {
-                // 子节点不存在,可能是结束节点
-                appendChildNode(flowLongContext, execution, currentNodeModel, nextNodes);
-                return nextNodes;
-            }
-
-            // 获取下一个待执行子节点
-            appendNextChildNodes(flowLongContext, execution, childNode, nextNodes);
-        }
-        return nextNodes;
-    }
-
-    public static void appendNextChildNodes(FlowLongContext flowLongContext, Execution execution, NodeModel childNode, List<NodeModel> nextNodes) {
-        if (childNode.conditionNode()) {
-            // 条件节点
-            flowLongContext.getFlowConditionHandler().getConditionNode(flowLongContext, execution, childNode)
-                    // 添加执行条件节点
-                    .ifPresent(t -> appendChildNode(flowLongContext, execution, t.getChildNode(), nextNodes));
-        } else if (childNode.parallelNode()) {
-            // 并行节点
-            nextNodes.addAll(childNode.getParallelNodes());
-        } else if (childNode.inclusiveNode()) {
-            // 包含节点
-            flowLongContext.getFlowConditionHandler().getInclusiveNodes(flowLongContext, execution, childNode)
-                    // 添加执行条件节点
-                    .ifPresent(inclusiveNodes -> inclusiveNodes.forEach(t ->
-                            appendChildNode(flowLongContext, execution, t.getChildNode(), nextNodes)));
-        } else if (childNode.routeNode()) {
-            // 路由节点
-            flowLongContext.getFlowConditionHandler().getRouteNode(flowLongContext, execution, childNode)
-                    // 添加执行条件节点
-                    .ifPresent(t -> nextNodes.add(childNode.getNode(t.getNodeKey())));
-        } else {
-            // 普通节点
-            nextNodes.add(childNode);
-        }
-    }
-
-    public static void appendChildNode(FlowLongContext flowLongContext, Execution execution, NodeModel nodeModel, List<NodeModel> nextNodes) {
-        NodeModel childNode = nodeModel.getChildNode();
-        if (null == childNode) {
-            NodeModel parentNode = nodeModel.getParentNode();
-            if (null == parentNode || TaskType.major.eq(parentNode.getType())) {
-                // 递归至发起节点,流程结束
-                return;
-            }
-            if (parentNode.conditionNode()) {
-                NodeModel parentChildNode = parentNode.getChildNode();
-                if (null != parentChildNode) {
-                    if (Objects.equals(parentChildNode.getNodeKey(), nodeModel.getNodeKey())) {
-                        appendChildNode(flowLongContext, execution, parentChildNode, nextNodes);
-                    } else {
-                        // 条件执行节点,返回子节点
-                        appendNextChildNodes(flowLongContext, execution, parentChildNode, nextNodes);
-                    }
-                }
-            } else if (parentNode.parallelNode() || parentNode.inclusiveNode()) {
-                // 条件执行节点,返回子节点
-                appendNextChildNodes(flowLongContext, execution, parentNode.getChildNode(), nextNodes);
-            }
-            return;
-        }
-        if (TaskType.approval.eq(nodeModel.getType())) {
-            // 追加审批节点
-            nextNodes.add(nodeModel);
-        }
-    }
 }

+ 1 - 53
src/test/java/com/aizuda/boot/modules/flw/TestModel.java

@@ -1,70 +1,18 @@
 package com.aizuda.boot.modules.flw;
 
-import com.aizuda.boot.modules.flw.flow.FlowHelper;
 import com.aizuda.bpm.engine.FlowLongEngine;
-import com.aizuda.bpm.engine.assist.StreamUtils;
-import com.aizuda.bpm.engine.core.Execution;
-import com.aizuda.bpm.engine.core.FlowCreator;
-import com.aizuda.bpm.engine.core.FlowLongContext;
-import com.aizuda.bpm.engine.model.ProcessModel;
-import com.aizuda.bpm.spring.adaptive.FlowJacksonHandler;
-import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
-import java.io.IOException;
-import java.util.HashMap;
-
 @SpringBootTest
 public class TestModel {
 
     @Autowired
     protected FlowLongEngine flowLongEngine;
-    protected FlowCreator testCreator = FlowCreator.of("test001", "测试001");
-
-    public ProcessModel getProcessModel(String name) {
-        try {
-            String modeContent = StreamUtils.readBytes(StreamUtils.getResourceAsStream(name));
-            FlowLongContext.setFlowJsonHandler(new FlowJacksonHandler());
-            return FlowLongContext.fromJson(modeContent, ProcessModel.class);
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
 
     @Test
-    public void testNextChildNodes() {
-        ProcessModel processModel = getProcessModel("test/TestNextChildNodes.json");
-        processModel.buildParentNode(processModel.getNodeConfig());
-
-//        Assertions.assertEquals("flk1733396309547", FlowHelper.getNextChildNodes(flowLongEngine.getContext(), new Execution(testCreator, null),
-//                processModel.getNodeConfig(), "flk1733380944015").get(0).getNodeKey());
-//
-//        Assertions.assertEquals("flk1733380972879", FlowHelper.getNextChildNodes(flowLongEngine.getContext(), new Execution(testCreator, null),
-//                processModel.getNodeConfig(), "flk1733396309547").get(0).getNodeKey());
-//
-//        Assertions.assertEquals("flk1733446929109", FlowHelper.getNextChildNodes(flowLongEngine.getContext(), new Execution(testCreator, null),
-//                processModel.getNodeConfig(), "flk1733380972879").get(0).getNodeKey());
-//
-//        Assertions.assertEquals("flk1733446923640", FlowHelper.getNextChildNodes(flowLongEngine.getContext(), new Execution(testCreator, new HashMap<String, Object>(){{
-//            put("aaa", "11");
-//        }}), processModel.getNodeConfig(), "flk1733380972879").get(0).getNodeKey());
-//
-//        // 下一步执行到并行分支
-//        Assertions.assertEquals(2, FlowHelper.getNextChildNodes(flowLongEngine.getContext(), new Execution(testCreator, null),
-//                processModel.getNodeConfig(), "flk1733446929109").size());
-
-        Assertions.assertEquals("flk1733446917296", FlowHelper.getNextChildNodes(flowLongEngine.getContext(), new Execution(testCreator, null),
-                processModel.getNodeConfig(), "flk1733446912655").get(0).getNodeKey());
-
-        // 包容分支
-        Assertions.assertEquals("flk1733658095760", FlowHelper.getNextChildNodes(flowLongEngine.getContext(), new Execution(testCreator, new HashMap<String, Object>(){{
-            put("bbb", "11");
-        }}), processModel.getNodeConfig(), "flk1733446917296").get(0).getNodeKey());
-
-        Assertions.assertEquals("flk1733658019276", FlowHelper.getNextChildNodes(flowLongEngine.getContext(), new Execution(testCreator, null),
-                processModel.getNodeConfig(), "flk1733658095760").get(0).getNodeKey());
+    public void test() {
 
     }
 }

+ 0 - 380
src/test/resources/test/TestNextChildNodes.json

@@ -1,380 +0,0 @@
-{
-  "key": "testNextChildNodes",
-  "name": "测试获取子节点",
-  "nodeConfig": {
-    "nodeName": "发起人",
-    "nodeKey": "flk1733380944015",
-    "type": 0,
-    "childNode": {
-      "nodeName": "审核人q",
-      "nodeKey": "flk1733396309547",
-      "type": 1,
-      "setType": 1,
-      "nodeAssigneeList": [
-        {
-          "id": "0",
-          "name": "CEO"
-        },
-        {
-          "id": "1778236187025342466",
-          "name": "夏小华"
-        }
-      ],
-      "examineLevel": 1,
-      "directorLevel": 1,
-      "selectMode": 1,
-      "termAuto": false,
-      "term": 1,
-      "termMode": 1,
-      "examineMode": 3,
-      "directorMode": 0,
-      "typeOfApprove": 1,
-      "remind": false,
-      "allowTransfer": false,
-      "allowAppendNode": false,
-      "allowRollback": false,
-      "approveSelf": 0,
-      "childNode": {
-        "nodeName": "审核人w",
-        "nodeKey": "flk1733380972879",
-        "type": 1,
-        "setType": 1,
-        "nodeAssigneeList": [
-          {
-            "id": "1778264912529981441",
-            "name": "陈小辉"
-          }
-        ],
-        "examineLevel": 1,
-        "directorLevel": 1,
-        "selectMode": 1,
-        "termAuto": true,
-        "term": 5,
-        "termMode": 0,
-        "examineMode": 1,
-        "directorMode": 0,
-        "typeOfApprove": 1,
-        "remind": true,
-        "allowTransfer": false,
-        "allowAppendNode": false,
-        "allowRollback": false,
-        "approveSelf": 0,
-        "childNode": {
-          "nodeName": "条件路由",
-          "nodeKey": "flk1733446921670",
-          "type": 4,
-          "conditionNodes": [
-            {
-              "nodeName": "条件 1",
-              "nodeKey": "flk1733446921670-1",
-              "type": 3,
-              "priorityLevel": 1,
-              "conditionMode": 1,
-              "conditionList": [
-                [
-                  {
-                    "label": "aaa",
-                    "field": "aaa",
-                    "operator": "==",
-                    "value": "11",
-                    "type": "custom"
-                  }
-                ]
-              ],
-              "childNode": {
-                "nodeName": "审核人aa",
-                "nodeKey": "flk1733446923640",
-                "type": 1,
-                "setType": 1,
-                "nodeAssigneeList": [],
-                "examineLevel": 1,
-                "directorLevel": 1,
-                "selectMode": 1,
-                "termAuto": false,
-                "remind": false,
-                "term": 1,
-                "termMode": 1,
-                "examineMode": 1,
-                "approveSelf": 0,
-                "directorMode": 0,
-                "typeOfApprove": 1,
-                "extendConfig": {},
-                "allowTransfer": false,
-                "allowAppendNode": false,
-                "allowRollback": false,
-                "rejectStrategy": 2,
-                "rejectStart": 1
-              }
-            },
-            {
-              "nodeName": "默认条件",
-              "nodeKey": "flk1733446921670-default",
-              "type": 3,
-              "priorityLevel": 2,
-              "conditionMode": 1,
-              "conditionList": [],
-              "childNode": {
-                "nodeName": "审核人bbb",
-                "nodeKey": "flk1733446929109",
-                "type": 1,
-                "setType": 1,
-                "nodeAssigneeList": [],
-                "examineLevel": 1,
-                "directorLevel": 1,
-                "selectMode": 1,
-                "termAuto": false,
-                "remind": false,
-                "term": 1,
-                "termMode": 1,
-                "examineMode": 1,
-                "approveSelf": 0,
-                "directorMode": 0,
-                "typeOfApprove": 1,
-                "extendConfig": {},
-                "allowTransfer": false,
-                "allowAppendNode": false,
-                "allowRollback": false,
-                "rejectStrategy": 2,
-                "rejectStart": 1
-              }
-            }
-          ],
-          "childNode": {
-            "nodeName": "并行路由",
-            "nodeKey": "flk1733381026712",
-            "type": 8,
-            "parallelNodes": [
-              {
-                "nodeName": "并行分支 1",
-                "nodeKey": "flk1733381026712-1",
-                "type": 3,
-                "childNode": {
-                  "nodeName": "审核人222",
-                  "nodeKey": "flk1733446908604",
-                  "type": 1,
-                  "setType": 1,
-                  "nodeAssigneeList": [],
-                  "examineLevel": 1,
-                  "directorLevel": 1,
-                  "selectMode": 1,
-                  "termAuto": false,
-                  "remind": false,
-                  "term": 1,
-                  "termMode": 1,
-                  "examineMode": 1,
-                  "approveSelf": 0,
-                  "directorMode": 0,
-                  "typeOfApprove": 1,
-                  "extendConfig": {},
-                  "allowTransfer": false,
-                  "allowAppendNode": false,
-                  "allowRollback": false,
-                  "rejectStrategy": 2,
-                  "rejectStart": 1
-                }
-              },
-              {
-                "nodeName": "并行分支 3",
-                "nodeKey": "flk1733381029419-3",
-                "type": 3,
-                "childNode": {
-                  "nodeName": "审核人333",
-                  "nodeKey": "flk1733446912655",
-                  "type": 1,
-                  "setType": 1,
-                  "nodeAssigneeList": [],
-                  "examineLevel": 1,
-                  "directorLevel": 1,
-                  "selectMode": 1,
-                  "termAuto": false,
-                  "remind": false,
-                  "term": 1,
-                  "termMode": 1,
-                  "examineMode": 1,
-                  "approveSelf": 0,
-                  "directorMode": 0,
-                  "typeOfApprove": 1,
-                  "extendConfig": {},
-                  "allowTransfer": false,
-                  "allowAppendNode": false,
-                  "allowRollback": false,
-                  "rejectStrategy": 2,
-                  "rejectStart": 1
-                }
-              }
-            ],
-            "childNode": {
-              "nodeName": "审核人e",
-              "nodeKey": "flk1733446917296",
-              "type": 1,
-              "setType": 1,
-              "nodeAssigneeList": [],
-              "examineLevel": 1,
-              "directorLevel": 1,
-              "selectMode": 1,
-              "termAuto": false,
-              "remind": false,
-              "term": 1,
-              "termMode": 1,
-              "examineMode": 1,
-              "approveSelf": 0,
-              "directorMode": 0,
-              "typeOfApprove": 1,
-              "extendConfig": {},
-              "allowTransfer": false,
-              "allowAppendNode": false,
-              "allowRollback": false,
-              "rejectStrategy": 2,
-              "rejectStart": 1,
-              "childNode": {
-                "nodeName": "路由分支",
-                "nodeKey": "flk1733657975648",
-                "type": 23,
-                "routeNodes": [
-                  {
-                    "nodeKey": "flk1733446923640",
-                    "nodeName": "路由 1",
-                    "conditionList": [
-                      [
-                        {
-                          "label": "aaa",
-                          "field": "aaa",
-                          "operator": "==",
-                          "value": "11",
-                          "type": "custom"
-                        }
-                      ]
-                    ]
-                  }
-                ],
-                "childNode": {
-                  "nodeName": "包容路由",
-                  "nodeKey": "flk1733658085822",
-                  "type": 9,
-                  "inclusiveNodes": [
-                    {
-                      "nodeName": "包容条件 1",
-                      "nodeKey": "flk1733658085822-1",
-                      "type": 3,
-                      "priorityLevel": 1,
-                      "conditionMode": 1,
-                      "conditionList": [
-                        [
-                          {
-                            "label": "aaa",
-                            "field": "aaa",
-                            "operator": "==",
-                            "value": "11",
-                            "type": "custom"
-                          }
-                        ]
-                      ],
-                      "childNode": {
-                        "nodeName": "审核人jj",
-                        "nodeKey": "flk1733658090878",
-                        "type": 1,
-                        "setType": 1,
-                        "nodeAssigneeList": [],
-                        "examineLevel": 1,
-                        "directorLevel": 1,
-                        "selectMode": 1,
-                        "termAuto": false,
-                        "remind": false,
-                        "term": 1,
-                        "termMode": 1,
-                        "examineMode": 1,
-                        "approveSelf": 0,
-                        "directorMode": 0,
-                        "typeOfApprove": 1,
-                        "extendConfig": {},
-                        "allowTransfer": false,
-                        "allowAppendNode": false,
-                        "allowRollback": false,
-                        "rejectStrategy": 2,
-                        "rejectStart": 1
-                      }
-                    },
-                    {
-                      "nodeName": "并行分支 2",
-                      "nodeKey": "flk1733658093167-2",
-                      "type": 3,
-                      "priorityLevel": 2,
-                      "conditionMode": 1,
-                      "conditionList": [
-                        [
-                          {
-                            "label": "bbb",
-                            "field": "bbb",
-                            "operator": "==",
-                            "value": "11",
-                            "type": "custom"
-                          }
-                        ]
-                      ],
-                      "childNode": {
-                        "nodeName": "审核人kk",
-                        "nodeKey": "flk1733658095760",
-                        "type": 1,
-                        "setType": 1,
-                        "nodeAssigneeList": [],
-                        "examineLevel": 1,
-                        "directorLevel": 1,
-                        "selectMode": 1,
-                        "termAuto": false,
-                        "remind": false,
-                        "term": 1,
-                        "termMode": 1,
-                        "examineMode": 1,
-                        "approveSelf": 0,
-                        "directorMode": 0,
-                        "typeOfApprove": 1,
-                        "extendConfig": {},
-                        "allowTransfer": false,
-                        "allowAppendNode": false,
-                        "allowRollback": false,
-                        "rejectStrategy": 2,
-                        "rejectStart": 1
-                      }
-                    },
-                    {
-                      "nodeName": "默认条件",
-                      "nodeKey": "flk1733658085822-default",
-                      "type": 3,
-                      "priorityLevel": 3,
-                      "conditionMode": 1,
-                      "conditionList": []
-                    }
-                  ],
-                  "childNode": {
-                    "nodeName": "审核人f",
-                    "nodeKey": "flk1733658019276",
-                    "type": 1,
-                    "setType": 1,
-                    "nodeAssigneeList": [],
-                    "examineLevel": 1,
-                    "directorLevel": 1,
-                    "selectMode": 1,
-                    "termAuto": false,
-                    "remind": false,
-                    "term": 1,
-                    "termMode": 1,
-                    "examineMode": 1,
-                    "approveSelf": 0,
-                    "directorMode": 0,
-                    "typeOfApprove": 1,
-                    "extendConfig": {},
-                    "allowTransfer": false,
-                    "allowAppendNode": false,
-                    "allowRollback": false,
-                    "rejectStrategy": 2,
-                    "rejectStart": 1
-                  }
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-}