From d31fd64178dc775c79c3da100611ab5d786d9f3c Mon Sep 17 00:00:00 2001 From: zy <953725892@qq.com> Date: Tue, 19 Sep 2023 11:32:40 +0800 Subject: [PATCH] =?UTF-8?q?test=20#I7SVZF=20=E8=A1=A5=E5=85=A8decl-multi-s?= =?UTF-8?q?pringboot=E4=B8=8B=E6=8A=BD=E8=B1=A1chain=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...actChainJsonELDeclMultiSpringBootTest.java | 53 +++++++++++++++++ ...ractChainXmlELDeclMultiSpringbootTest.java | 55 ++++++++++++++++++ ...ractChainYmlELDeclMultiSpringBootTest.java | 54 ++++++++++++++++++ .../test/abstractChain/cmp/CmpConfig.java | 57 +++++++++++++++++++ .../abstractChain/application-json.properties | 1 + .../abstractChain/application-yml.properties | 1 + .../abstractChain/application.properties | 1 + .../test/resources/abstractChain/flow.el.json | 32 +++++++++++ .../test/resources/abstractChain/flow.el.xml | 28 +++++++++ .../test/resources/abstractChain/flow.el.yml | 18 ++++++ 10 files changed, 300 insertions(+) create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainJsonELDeclMultiSpringBootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXmlELDeclMultiSpringbootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainYmlELDeclMultiSpringBootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/cmp/CmpConfig.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application-json.properties create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application-yml.properties create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application.properties create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.json create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.xml create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.yml diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainJsonELDeclMultiSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainJsonELDeclMultiSpringBootTest.java new file mode 100644 index 000000000..07cfe7f04 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainJsonELDeclMultiSpringBootTest.java @@ -0,0 +1,53 @@ +package com.yomahub.liteflow.test.abstractChain; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.test.BaseTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +import javax.annotation.Resource; + +/** + * 测试显示调用子流程(json) 单元测试 + * + * @author justin.xu + */ +@TestPropertySource(value = "classpath:/abstractChain/application-json.properties") +@SpringBootTest(classes = AbstractChainJsonELDeclMultiSpringBootTest.class) +@EnableAutoConfiguration +@ComponentScan({ "com.yomahub.liteflow.test.abstractChain.cmp" }) +public class AbstractChainJsonELDeclMultiSpringBootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + // 是否按照流程定义配置执行 + @Test + public void test1() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implA", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>d==>f==>j", response.getExecuteStepStrWithoutTime()); + } + + //测试嵌套继承的baseChain是否重复解析 + @Test + public void test2() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implB", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>j", response.getExecuteStepStrWithoutTime()); + } + + //测试嵌套继承的baseChain是否重复解析 + @Test + public void test3() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implC", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>a==>b", response.getExecuteStepStrWithoutTime()); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXmlELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXmlELDeclMultiSpringbootTest.java new file mode 100644 index 000000000..783ec11f1 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXmlELDeclMultiSpringbootTest.java @@ -0,0 +1,55 @@ +package com.yomahub.liteflow.test.abstractChain; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.test.BaseTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +import javax.annotation.Resource; + +/** + * springboot环境EL常规的例子测试 + * + * @author Bryan.Zhang + */ +@TestPropertySource(value = "classpath:/abstractChain/application.properties") +@SpringBootTest(classes = AbstractChainXmlELDeclMultiSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({ "com.yomahub.liteflow.test.abstractChain.cmp" }) +public class AbstractChainXmlELDeclMultiSpringbootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + + + // XML文件基本继承测试 + @Test + public void test1() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implA", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>d==>f==>j", response.getExecuteStepStrWithoutTime()); + } + + //测试嵌套继承的baseChain是否重复解析 + @Test + public void test2() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implB", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>j", response.getExecuteStepStrWithoutTime()); + } + + //测试嵌套继承的baseChain是否重复解析 + @Test + public void test3() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implC", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>a==>b", response.getExecuteStepStrWithoutTime()); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainYmlELDeclMultiSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainYmlELDeclMultiSpringBootTest.java new file mode 100644 index 000000000..42d3f8b0d --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainYmlELDeclMultiSpringBootTest.java @@ -0,0 +1,54 @@ +package com.yomahub.liteflow.test.abstractChain; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.test.BaseTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +import javax.annotation.Resource; + +/** + * 测试显示调用子流程(yml) 单元测试 + * + * @author justin.xu + */ +@TestPropertySource(value = "classpath:/abstractChain/application-yml.properties") +@SpringBootTest(classes = AbstractChainYmlELDeclMultiSpringBootTest.class) +@EnableAutoConfiguration +@ComponentScan({ "com.yomahub.liteflow.test.abstractChain.cmp" }) +public class AbstractChainYmlELDeclMultiSpringBootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + // 是否按照流程定义配置执行 + // XML文件基本继承测试 + @Test + public void test1() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implA", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>c==>d==>f==>j", response.getExecuteStepStrWithoutTime()); + } + + //测试嵌套继承的baseChain是否重复解析 + @Test + public void test2() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implB", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>j", response.getExecuteStepStrWithoutTime()); + } + + //测试嵌套继承的baseChain是否重复解析 + @Test + public void test3() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("implC", "arg"); + Assertions.assertTrue(response.isSuccess()); + Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>a==>b", response.getExecuteStepStrWithoutTime()); + } + +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/cmp/CmpConfig.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/cmp/CmpConfig.java new file mode 100644 index 000000000..9c9f78502 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/cmp/CmpConfig.java @@ -0,0 +1,57 @@ +package com.yomahub.liteflow.test.abstractChain.cmp; + +import cn.hutool.core.util.StrUtil; +import com.yomahub.liteflow.annotation.LiteflowComponent; +import com.yomahub.liteflow.annotation.LiteflowMethod; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.enums.NodeTypeEnum; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.test.exception.CustomStatefulException; + +import java.util.Iterator; +import java.util.List; + +@LiteflowComponent +public class CmpConfig { + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a") + public void processA(NodeComponent bindCmp) { + System.out.println("ACmp executed!"); + } + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "b") + public void processB(NodeComponent bindCmp) { + System.out.println("BCmp executed!"); + } + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_IF, nodeId = "c", nodeType = NodeTypeEnum.IF) + public boolean processIfC(NodeComponent bindCmp) throws Exception{ + return true; + } + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "d") + public void processD(NodeComponent bindCmp) { + System.out.println("DCmp executed!"); + } + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "e") + public void processE(NodeComponent bindCmp) { + System.out.println("ECmp executed!"); + } + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH, nodeId = "f", nodeType = NodeTypeEnum.SWITCH) + public String processF(NodeComponent bindCmp) { + return "j"; + } + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "j") + public void processJ(NodeComponent bindCmp) { + System.out.println("JCmp executed!"); + } + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "k") + public void processK(NodeComponent bindCmp) { + System.out.println("KCmp executed!"); + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application-json.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application-json.properties new file mode 100644 index 000000000..bd27c1b99 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application-json.properties @@ -0,0 +1 @@ +liteflow.rule-source=abstractChain/flow.el.json \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application-yml.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application-yml.properties new file mode 100644 index 000000000..e3b9c04c9 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application-yml.properties @@ -0,0 +1 @@ +liteflow.rule-source=abstractChain/flow.el.yml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application.properties b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application.properties new file mode 100644 index 000000000..f1132eca0 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=abstractChain/flow.el.xml \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.json b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.json new file mode 100644 index 000000000..453bda2d9 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.json @@ -0,0 +1,32 @@ +{ + "flow": { + "chain": [ + { + "id": "implB", + "extends": "base2", + "value": "{3}=THEN(a,b);\n {4}=j;" + }, + { + "id": "implC", + "extends": "base2", + "value": "{3}=THEN(a,b);\n {4}=THEN(a,b).id(\"j\");" + }, + { + "id": "base", + "abstract": true, + "value": "THEN(a, b, {0}, {1});" + }, + { + "id": "implA", + "extends": "base", + "value": "{0}=IF(c, d, e);\n {1}=SWITCH(f).to(j,k);" + }, + { + "id": "base2", + "extends": "base", + "abstract": true, + "value": "{0}=THEN(a,b,{3});\n {1}=SWITCH(f).to({4},k);" + } + ] + } +} \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.xml new file mode 100644 index 000000000..1994b64c5 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.xml @@ -0,0 +1,28 @@ + + + + {3}=THEN(a,b); + {4}=j; + + + + {3}=THEN(a,b); + {4}=THEN(a,b).id("j"); + + + + THEN(a, b, {0}, {1}) + + + + {0}=IF(c, d, e); + {1}=SWITCH(f).to(j,k); + + + + {0}=THEN(a,b,{3}); + {1}=SWITCH(f).to({4},k); + + + + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.yml b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.yml new file mode 100644 index 000000000..b79e458fe --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/abstractChain/flow.el.yml @@ -0,0 +1,18 @@ +flow: + chain: + - id: implB + extends: base2 + value: "{3}=THEN(a,b);\n {4}=j;" + - id: implC + extends: base2 + value: "{3}=THEN(a,b);\n {4}=THEN(a,b).id(\"j\");" + - id: base + abstract: true + value: "THEN(a, b, {0}, {1});" + - id: implA + extends: base + value: "{0}=IF(c, d, e);\n {1}=SWITCH(f).to(j,k);" + - id: base2 + extends: base + abstract: true + value: "{0}=THEN(a,b,{3});\n {1}=SWITCH(f).to({4},k);"