mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
test #I7SVZF 补全nospring下抽象chain解析相关测试用例
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.yomahub.liteflow.test.abstractChain;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
|
||||
|
||||
public class AbstractChainJsonELTest extends BaseTest {
|
||||
|
||||
private static FlowExecutor flowExecutor;
|
||||
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("abstractChain/flow.el.json");
|
||||
flowExecutor = FlowExecutorHolder.loadInstance(config);
|
||||
}
|
||||
|
||||
|
||||
// 是否按照流程定义配置执行
|
||||
@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,50 @@
|
||||
package com.yomahub.liteflow.test.abstractChain;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class AbstractChainXmlELTest extends BaseTest {
|
||||
|
||||
private static FlowExecutor flowExecutor;
|
||||
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("abstractChain/flow.el.xml");
|
||||
flowExecutor = FlowExecutorHolder.loadInstance(config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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,49 @@
|
||||
package com.yomahub.liteflow.test.abstractChain;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class AbstractChainYmlELTest extends BaseTest {
|
||||
|
||||
private static FlowExecutor flowExecutor;
|
||||
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("abstractChain/flow.el.yml");
|
||||
flowExecutor = FlowExecutorHolder.loadInstance(config);
|
||||
}
|
||||
|
||||
// 是否按照流程定义配置执行
|
||||
// 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,12 @@
|
||||
package com.yomahub.liteflow.test.abstractChain.cmp;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
|
||||
public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("ACmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yomahub.liteflow.test.abstractChain.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
|
||||
public class BCmp extends NodeComponent {
|
||||
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("BCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yomahub.liteflow.test.abstractChain.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeIfComponent;
|
||||
|
||||
|
||||
public class CCmp extends NodeIfComponent {
|
||||
@Override
|
||||
public boolean processIf() throws Exception {
|
||||
//do your biz
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yomahub.liteflow.test.abstractChain.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
public class DCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("DCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yomahub.liteflow.test.abstractChain.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
public class ECmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("ECmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yomahub.liteflow.test.abstractChain.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeSwitchComponent;
|
||||
|
||||
public class FSwitchCmp extends NodeSwitchComponent {
|
||||
|
||||
@Override
|
||||
public String processSwitch() throws Exception {
|
||||
return "j";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yomahub.liteflow.test.abstractChain.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
public class JCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("JCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yomahub.liteflow.test.abstractChain.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
public class KCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("KCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"flow": {
|
||||
"nodes": {
|
||||
"node": [
|
||||
{
|
||||
"id": "a",
|
||||
"class": "com.yomahub.liteflow.test.abstractChain.cmp.ACmp"
|
||||
},
|
||||
{
|
||||
"id": "b",
|
||||
"class": "com.yomahub.liteflow.test.abstractChain.cmp.BCmp"
|
||||
},
|
||||
{
|
||||
"id": "c",
|
||||
"class": "com.yomahub.liteflow.test.abstractChain.cmp.CCmp"
|
||||
},
|
||||
{
|
||||
"id": "d",
|
||||
"class": "com.yomahub.liteflow.test.abstractChain.cmp.DCmp"
|
||||
},
|
||||
{
|
||||
"id": "e",
|
||||
"class": "com.yomahub.liteflow.test.abstractChain.cmp.ECmp"
|
||||
},
|
||||
{
|
||||
"id": "f",
|
||||
"class": "com.yomahub.liteflow.test.abstractChain.cmp.FSwitchCmp"
|
||||
},
|
||||
{
|
||||
"id": "j",
|
||||
"class": "com.yomahub.liteflow.test.abstractChain.cmp.JCmp"
|
||||
},
|
||||
{
|
||||
"id": "k",
|
||||
"class": "com.yomahub.liteflow.test.abstractChain.cmp.KCmp"
|
||||
}
|
||||
]
|
||||
},
|
||||
"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,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<nodes>
|
||||
<node id="a" class="com.yomahub.liteflow.test.abstractChain.cmp.ACmp"/>
|
||||
<node id="b" class="com.yomahub.liteflow.test.abstractChain.cmp.BCmp"/>
|
||||
<node id="c" class="com.yomahub.liteflow.test.abstractChain.cmp.CCmp"/>
|
||||
<node id="d" class="com.yomahub.liteflow.test.abstractChain.cmp.DCmp"/>
|
||||
<node id="e" class="com.yomahub.liteflow.test.abstractChain.cmp.ECmp"/>
|
||||
<node id="f" class="com.yomahub.liteflow.test.abstractChain.cmp.FSwitchCmp"/>
|
||||
<node id="j" class="com.yomahub.liteflow.test.abstractChain.cmp.JCmp"/>
|
||||
<node id="k" class="com.yomahub.liteflow.test.abstractChain.cmp.KCmp"/>
|
||||
</nodes>
|
||||
|
||||
<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,36 @@
|
||||
flow:
|
||||
nodes:
|
||||
node:
|
||||
- id: a
|
||||
class: com.yomahub.liteflow.test.abstractChain.cmp.ACmp
|
||||
- id: b
|
||||
class: com.yomahub.liteflow.test.abstractChain.cmp.BCmp
|
||||
- id: c
|
||||
class: com.yomahub.liteflow.test.abstractChain.cmp.CCmp
|
||||
- id: d
|
||||
class: com.yomahub.liteflow.test.abstractChain.cmp.DCmp
|
||||
- id: e
|
||||
class: com.yomahub.liteflow.test.abstractChain.cmp.ECmp
|
||||
- id: f
|
||||
class: com.yomahub.liteflow.test.abstractChain.cmp.FSwitchCmp
|
||||
- id: j
|
||||
class: com.yomahub.liteflow.test.abstractChain.cmp.JCmp
|
||||
- id: k
|
||||
class: com.yomahub.liteflow.test.abstractChain.cmp.KCmp
|
||||
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