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

This commit is contained in:
zy 2023-09-19 11:47:01 +08:00
parent d31fd64178
commit 763b5e4694
17 changed files with 397 additions and 0 deletions

View File

@ -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 = AbstractChainJsonELDeclSpringBootTest.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.abstractChain.cmp" })
public class AbstractChainJsonELDeclSpringBootTest 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());
}
}

View File

@ -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 = AbstractChainXmlELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.abstractChain.cmp" })
public class AbstractChainXmlELDeclSpringbootTest 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,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 = AbstractChainYmlELDeclSpringBootTest.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.abstractChain.cmp" })
public class AbstractChainYmlELDeclSpringBootTest 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,26 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
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 org.springframework.stereotype.Component;
@Component("a")
@LiteflowCmpDefine(NodeTypeEnum.COMMON)
public class ACmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("ACmp executed!");
}
}

View File

@ -0,0 +1,26 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
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 org.springframework.stereotype.Component;
@Component("b")
@LiteflowCmpDefine(NodeTypeEnum.COMMON)
public class BCmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("BCmp executed!");
}
}

View File

@ -0,0 +1,17 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
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 org.springframework.stereotype.Component;
@Component("c")
@LiteflowCmpDefine(NodeTypeEnum.IF)
public class CCmp {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_IF, nodeType = NodeTypeEnum.IF)
public boolean processIf(NodeComponent bindCmp) throws Exception {
return true;
}
}

View File

@ -0,0 +1,17 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
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 org.springframework.stereotype.Component;
@Component("d")
@LiteflowCmpDefine(NodeTypeEnum.COMMON)
public class DCmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("DCmp executed!");
}
}

View File

@ -0,0 +1,17 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
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 org.springframework.stereotype.Component;
@Component("e")
@LiteflowCmpDefine(NodeTypeEnum.COMMON)
public class ECmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("ECmp executed!");
}
}

View File

@ -0,0 +1,17 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
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 org.springframework.stereotype.Component;
@Component("f")
@LiteflowCmpDefine(NodeTypeEnum.SWITCH)
public class FCmp {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH, nodeType = NodeTypeEnum.SWITCH)
public String processSwitch(NodeComponent bindCmp) throws Exception {
return "j";
}
}

View File

@ -0,0 +1,17 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
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 org.springframework.stereotype.Component;
@Component("j")
@LiteflowCmpDefine(NodeTypeEnum.COMMON)
public class JCmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("JCmp executed!");
}
}

View File

@ -0,0 +1,17 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
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 org.springframework.stereotype.Component;
@Component("k")
@LiteflowCmpDefine(NodeTypeEnum.COMMON)
public class KCmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("KCmp executed!");
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

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