From a35a917475ca2ab06b0ee1eca98ff70b9c9f9bd0 Mon Sep 17 00:00:00 2001 From: zy <953725892@qq.com> Date: Tue, 19 Sep 2023 11:10:25 +0800 Subject: [PATCH] =?UTF-8?q?test=20#I7SVZF=20=E8=A1=A5=E5=85=A8springboot?= =?UTF-8?q?=E4=B8=8B=E6=8A=BD=E8=B1=A1chain=E8=A7=A3=E6=9E=90=E7=9B=B8?= =?UTF-8?q?=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 --- .../AbstractChainJsonELSpringBootTest.java | 20 ++++++- ... => AbstractChainXmlELSpringbootTest.java} | 4 +- .../AbstractChainYmlELSpringBootTest.java | 54 +++++++++++++++++++ .../abstractChain/application-yml.properties | 1 + .../test/resources/abstractChain/flow.el.json | 20 ++++++- .../test/resources/abstractChain/flow.el.xml | 2 +- .../test/resources/abstractChain/flow.el.yml | 18 +++++++ 7 files changed, 112 insertions(+), 7 deletions(-) rename liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/{AbstractChainXMLELSpringbootTest.java => AbstractChainXmlELSpringbootTest.java} (93%) create mode 100644 liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainYmlELSpringBootTest.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/application-yml.properties create mode 100644 liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.yml diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainJsonELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainJsonELSpringBootTest.java index 47856b191..63d25911c 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainJsonELSpringBootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainJsonELSpringBootTest.java @@ -28,10 +28,26 @@ public class AbstractChainJsonELSpringBootTest extends BaseTest { // 是否按照流程定义配置执行 @Test - public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("implA", "it's a request"); + 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-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXMLELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXmlELSpringbootTest.java similarity index 93% rename from liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXMLELSpringbootTest.java rename to liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXmlELSpringbootTest.java index 099436baf..efc11bec2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXMLELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainXmlELSpringbootTest.java @@ -18,10 +18,10 @@ import javax.annotation.Resource; * @author Bryan.Zhang */ @TestPropertySource(value = "classpath:/abstractChain/application.properties") -@SpringBootTest(classes = AbstractChainXMLELSpringbootTest.class) +@SpringBootTest(classes = AbstractChainXmlELSpringbootTest.class) @EnableAutoConfiguration @ComponentScan({ "com.yomahub.liteflow.test.abstractChain.cmp" }) -public class AbstractChainXMLELSpringbootTest extends BaseTest { +public class AbstractChainXmlELSpringbootTest extends BaseTest { @Resource private FlowExecutor flowExecutor; diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainYmlELSpringBootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainYmlELSpringBootTest.java new file mode 100644 index 000000000..b6fb89330 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/abstractChain/AbstractChainYmlELSpringBootTest.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 = AbstractChainYmlELSpringBootTest.class) +@EnableAutoConfiguration +@ComponentScan({ "com.yomahub.liteflow.test.abstractChain.cmp" }) +public class AbstractChainYmlELSpringBootTest 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-springboot/src/test/resources/abstractChain/application-yml.properties b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/application-yml.properties new file mode 100644 index 000000000..e3b9c04c9 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-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-springboot/src/test/resources/abstractChain/flow.el.json b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.json index 759672bb7..453bda2d9 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.json +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.json @@ -2,14 +2,30 @@ "flow": { "chain": [ { - "name": "base", + "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});" }, { - "name": "implA", + "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);" } ] } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.xml index 2cfe33ef4..1994b64c5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.xml @@ -10,7 +10,7 @@ {4}=THEN(a,b).id("j"); - + THEN(a, b, {0}, {1}) diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.yml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/abstractChain/flow.el.yml new file mode 100644 index 000000000..b79e458fe --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-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);"