mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
test #I7SVZF 补全decl-multi-springboot下抽象chain解析相关测试用例
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
liteflow.rule-source=abstractChain/flow.el.json
|
||||
@@ -0,0 +1 @@
|
||||
liteflow.rule-source=abstractChain/flow.el.yml
|
||||
@@ -0,0 +1 @@
|
||||
liteflow.rule-source=abstractChain/flow.el.xml
|
||||
@@ -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);"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain id="implB" extends="base2">
|
||||
{3}=THEN(a,b);
|
||||
{4}=j;
|
||||
</chain>
|
||||
|
||||
<chain id="implC" extends="base2">
|
||||
{3}=THEN(a,b);
|
||||
{4}=THEN(a,b).id("j");
|
||||
</chain>
|
||||
|
||||
<chain abstract="true" name="base">
|
||||
THEN(a, b, {0}, {1})
|
||||
</chain>
|
||||
|
||||
<chain id="implA" extends="base">
|
||||
{0}=IF(c, d, e);
|
||||
{1}=SWITCH(f).to(j,k);
|
||||
</chain>
|
||||
|
||||
<chain abstract="true" id="base2" extends="base">
|
||||
{0}=THEN(a,b,{3});
|
||||
{1}=SWITCH(f).to({4},k);
|
||||
</chain>
|
||||
|
||||
|
||||
</flow>
|
||||
@@ -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);"
|
||||
Reference in New Issue
Block a user