test #I7SVZF 补全springboot下抽象chain解析相关测试用例

This commit is contained in:
zy
2023-09-19 11:10:25 +08:00
parent bc7d998166
commit a35a917475
7 changed files with 112 additions and 7 deletions

View File

@@ -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());
}
}

View File

@@ -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;

View File

@@ -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());
}
}

View File

@@ -0,0 +1 @@
liteflow.rule-source=abstractChain/flow.el.yml

View File

@@ -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);"
}
]
}

View File

@@ -10,7 +10,7 @@
{4}=THEN(a,b).id("j");
</chain>
<chain abstract="true" id="base">
<chain abstract="true" name="base">
THEN(a, b, {0}, {1})
</chain>

View File

@@ -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);"