feature #I5CW7I 【版本特性】构造全新的EL规则表达式

This commit is contained in:
everywhere.z
2022-06-26 00:13:25 +08:00
parent 6ffa97206e
commit f0b6dd2d57
21 changed files with 409 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* spring环境的json parser单元测试
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/parser/application-json.properties")
@SpringBootTest(classes = JsonParserELSpringbootTest.class)
@EnableAutoConfiguration
public class JsonParserELSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试spring场景的json parser
@Test
public void testJsonParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
}
}

View File

@@ -0,0 +1,31 @@
package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/parser/application-springEL.properties")
@SpringBootTest(classes = SpringELSupportELSpringbootTest.class)
@EnableAutoConfiguration
public class SpringELSupportELSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试springEL的解析情况
@Test
public void testSpringELParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg");
Assert.assertTrue(response.isSuccess());
}
}

View File

@@ -0,0 +1,36 @@
package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* springboot环境的xml parser单元测试
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/parser/application-xml.properties")
@SpringBootTest(classes = XmlParserELSpringbootTest.class)
@EnableAutoConfiguration
public class XmlParserELSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试无springboot场景的xml parser
@Test
public void testXmlParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
}
}

View File

@@ -0,0 +1,36 @@
package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* springboot下的yml parser测试用例
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/parser/application-yml.properties")
@SpringBootTest(classes = YmlParserELSpringbootTest.class)
@EnableAutoConfiguration
public class YmlParserELSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试无springboot场景的yml parser
@Test
public void testYmlParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
}
}

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.NodeComponent;
import org.springframework.stereotype.Component;
@Component("a")
public class ACmp extends NodeComponent {
@Override
public void process() {
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.NodeSwitchComponent;
import org.springframework.stereotype.Component;
@Component("e")
public class ECmp extends NodeSwitchComponent {
@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 @@
liteflow.rule-source=parser/flow.el.json

View File

@@ -0,0 +1 @@
liteflow.rule-source=parser/**/*.el.xml

View File

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

View File

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

View File

@@ -0,0 +1,46 @@
{
"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",
"value": "THEN(c,g,f)"
},
{
"name": "chain1",
"value": "THEN(a,c,WHEN(b,d,SWITCH(e).to(f,g)), chain2)"
}
]
}
}

View File

@@ -0,0 +1,20 @@
<?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(a, c, WHEN(b, d, SWITCH(e).to(f,g)), chain2)
</chain>
<chain name="chain2">
THEN(c, g, f)
</chain>
</flow>

View File

@@ -0,0 +1,22 @@
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
value: "THEN(a, c, WHEN(b, d, SWITCH(e).to(f, g)), chain2)"
- name: chain2
value: "THEN(c, g, f)"

View File

@@ -0,0 +1,20 @@
<?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="chain11">
THEN(a, c, WHEN(b, d, SWITCH(e).to(f,g)), chain2)
</chain>
<chain name="chain12">
THEN(c, g, f)
</chain>
</flow>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain21">
THEN(a, c, WHEN(b, d, SWITCH(e).to(f, g)), chain2)
</chain>
</flow>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain32">
THEN(c, g, f)
</chain>
</flow>