修改测试用例

This commit is contained in:
bryan31 2021-04-06 13:18:32 +08:00
parent 55badd0b0e
commit b2cfc58d2e
24 changed files with 271 additions and 11 deletions

View File

@ -122,10 +122,7 @@ public abstract class NodeComponent {
}
}
/**
* 设置是否结束整个流程
* @param isEnd
*/
//设置是否结束整个流程
public void setIsEnd(boolean isEnd){
this.isEndTL.set(isEnd);
}

View File

@ -1,7 +1,7 @@
package com.yomahub.liteflow.enums;
/**
* @Author: guodongqing
* @author guodongqing
* @since 2.5.0
*/
public enum FlowParserTypeEnum {

View File

@ -33,9 +33,7 @@ public abstract class JsonFlowParser extends FlowParser{
parse(flowJsonObject);
}
/**
* json格式解析过程
*/
//json格式解析过程
public void parse(JSONObject flowJsonObject) throws Exception {
try {
//判断是以spring方式注册节点还是以json方式注册

View File

@ -36,9 +36,7 @@ public abstract class XmlFlowParser extends FlowParser{
parse(document);
}
/**
* xml形式的主要解析过程
*/
//xml形式的主要解析过程
public void parse(Document document) throws Exception {
try {
Element rootElement = document.getRootElement();

View File

@ -0,0 +1,12 @@
package com.yomahub.liteflow.test;
import com.yomahub.liteflow.spring.ComponentScanner;
import org.junit.AfterClass;
public class BaseTest {
@AfterClass
public static void cleanScanCache(){
ComponentScanner.cleanCache();
}
}

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.parser.cmp;
import cn.hutool.core.util.StrUtil;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.exception.FlowSystemException;
import org.springframework.stereotype.Component;
@Component("a")
public class ACmp extends NodeComponent {
@Override
public void process() {
String str = this.getSlot().getRequestData();
if(StrUtil.isNotBlank(str) && str.equals("exception")) {
throw new FlowSystemException("chain execute execption");
}
System.out.println("ACmp executed!");
}
}

View File

@ -0,0 +1,21 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.parser.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("b")
public class BCmp extends NodeComponent {
@Override
public void process() {
System.out.println("BCmp executed!");
}
}

View File

@ -0,0 +1,21 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.parser.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("c")
public class CCmp extends NodeComponent {
@Override
public void process() {
System.out.println("CCmp executed!");
}
}

View File

@ -0,0 +1,21 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.parser.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("d")
public class DCmp extends NodeComponent {
@Override
public void process() {
System.out.println("DCmp executed!");
}
}

View File

@ -0,0 +1,20 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.parser.cmp;
import com.yomahub.liteflow.core.NodeCondComponent;
import org.springframework.stereotype.Component;
@Component("e")
public class ECmp extends NodeCondComponent {
@Override
public String processCond() throws Exception {
return "g";
}
}

View File

@ -0,0 +1,21 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.parser.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("f")
public class FCmp extends NodeComponent {
@Override
public void process() {
System.out.println("FCmp executed!");
}
}

View File

@ -0,0 +1,21 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.parser.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("g")
public class GCmp extends NodeComponent {
@Override
public void process() {
System.out.println("GCmp executed!");
}
}

View File

@ -0,0 +1,52 @@
{
"flow": {
"nodes": {
"node": [
{
"id": "a",
"class": "com.yomahub.liteflow.test.parser.cmp.ACmp"
},
{
"id": "b",
"class": "com.yomahub.liteflow.test.parser.cmp.BCmp"
},
{
"id": "c",
"class": "com.yomahub.liteflow.test.parser.cmp.CCmp"
},
{
"id": "d",
"class": "com.yomahub.liteflow.test.parser.cmp.DCmp"
},
{
"id": "e",
"class": "com.yomahub.liteflow.test.parser.cmp.ECmp"
},
{
"id": "f",
"class": "com.yomahub.liteflow.test.parser.cmp.FCmp"
},
{
"id": "g",
"class": "com.yomahub.liteflow.test.parser.cmp.GCmp"
}
]
},
"chain": [
{
"name": "chain2",
"condition": [
{"type": "then", "value": "c,g,f"}
]
},
{
"name": "chain1",
"condition": [
{"type": "then", "value": "a,c"},
{"type": "when", "value": "b,d,e(f|g)"},
{"type": "then", "value": "chain2"}
]
}
]
}
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<nodes>
<node id="a" class="com.yomahub.liteflow.test.parser.cmp.ACmp"/>
<node id="b" class="com.yomahub.liteflow.test.parser.cmp.BCmp"/>
<node id="c" class="com.yomahub.liteflow.test.parser.cmp.CCmp"/>
<node id="d" class="com.yomahub.liteflow.test.parser.cmp.DCmp"/>
<node id="e" class="com.yomahub.liteflow.test.parser.cmp.ECmp"/>
<node id="f" class="com.yomahub.liteflow.test.parser.cmp.FCmp"/>
<node id="g" class="com.yomahub.liteflow.test.parser.cmp.GCmp"/>
</nodes>
<chain name="chain1">
<then value="a,c"/>
<when value="b,d,e(f|g)"/>
<then value="chain2"/>
</chain>
<chain name="chain2">
<then value="c,g,f"/>
</chain>
</flow>

View File

@ -0,0 +1,30 @@
flow:
nodes:
node:
- id: a
class: com.yomahub.liteflow.test.parser.cmp.ACmp
- id: b
class: com.yomahub.liteflow.test.parser.cmp.BCmp
- id: c
class: com.yomahub.liteflow.test.parser.cmp.CCmp
- id: d
class: com.yomahub.liteflow.test.parser.cmp.DCmp
- id: e
class: com.yomahub.liteflow.test.parser.cmp.ECmp
- id: f
class: com.yomahub.liteflow.test.parser.cmp.FCmp
- id: g
class: com.yomahub.liteflow.test.parser.cmp.GCmp
chain:
- name: chain1
condition:
- type: then
value: 'a,c'
- type: when
value: 'b,d,e(f|g)'
- type: then
value: 'chain2'
- name: chain2
condition:
- type: then
value: 'c,g,f'