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

This commit is contained in:
everywhere.z 2022-06-28 22:31:46 +08:00
parent 0764214b7b
commit 7ed969f465
35 changed files with 902 additions and 1 deletions

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>liteflow-testcase-el</artifactId>
<groupId>com.yomahub</groupId>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>liteflow-testcase-el-script-groovy-springboot</artifactId>
<dependencies>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-script-groovy</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,22 @@
package com.yomahub.liteflow.test;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.flow.id.IdGeneratorHelper;
import com.yomahub.liteflow.property.LiteflowConfigGetter;
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
import com.yomahub.liteflow.spring.ComponentScanner;
import com.yomahub.liteflow.thread.ExecutorHelper;
import org.junit.AfterClass;
public class BaseTest {
@AfterClass
public static void cleanScanCache(){
ComponentScanner.cleanCache();
FlowBus.cleanCache();
ExecutorHelper.loadInstance().clearExecutorServiceMap();
SpiFactoryCleaner.clean();
LiteflowConfigGetter.clean();
IdGeneratorHelper.getInstance().clear();
}
}

View File

@ -0,0 +1,99 @@
package com.yomahub.liteflow.test.script.groovy;
import com.yomahub.liteflow.builder.LiteFlowChainBuilder;
import com.yomahub.liteflow.builder.LiteFlowConditionBuilder;
import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import com.yomahub.liteflow.slot.DefaultContext;
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.junit4.SpringRunner;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = LiteFlowXmlScriptBuilderGroovyELTest.class)
@EnableAutoConfiguration
public class LiteFlowXmlScriptBuilderGroovyELTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试通过builder方式运行普通script节点以脚本文本的方式运行
@Test
public void testBuilderScript1() {
LiteFlowNodeBuilder.createNode().setId("a")
.setName("组件A")
.setType(NodeTypeEnum.COMMON)
.setClazz("com.yomahub.liteflow.test.script.groovy.cmp.ACmp")
.build();
LiteFlowNodeBuilder.createNode().setId("b")
.setName("组件B")
.setType(NodeTypeEnum.COMMON)
.setClazz("com.yomahub.liteflow.test.script.groovy.cmp.BCmp")
.build();
LiteFlowNodeBuilder.createNode().setId("c")
.setName("组件C")
.setType(NodeTypeEnum.COMMON)
.setClazz("com.yomahub.liteflow.test.script.groovy.cmp.CCmp")
.build();
LiteFlowNodeBuilder.createScriptNode()
.setId("s1")
.setName("普通脚本S1")
.setType(NodeTypeEnum.SCRIPT)
.setScript("Integer a=3;Integer b=2;defaultContext.setData(\"s1\",a*b)")
.build();
LiteFlowChainELBuilder.createChain().setChainName("chain1")
.setEL("THEN(a,b,c,s1)")
.build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(Integer.valueOf(6), context.getData("s1"));
}
//测试通过builder方式运行普通script节点以file的方式运行
@Test
public void testBuilderScript2() {
LiteFlowNodeBuilder.createNode().setId("d")
.setName("组件D")
.setType(NodeTypeEnum.COMMON)
.setClazz("com.yomahub.liteflow.test.script.groovy.cmp.DCmp")
.build();
LiteFlowNodeBuilder.createNode().setId("s2")
.setName("条件脚本S2")
.setType(NodeTypeEnum.SWITCH_SCRIPT)
.setFile("builder/s2.groovy")
.build();
LiteFlowNodeBuilder.createNode().setId("a")
.setName("组件A")
.setType(NodeTypeEnum.COMMON)
.setClazz("com.yomahub.liteflow.test.script.groovy.cmp.ACmp")
.build();
LiteFlowNodeBuilder.createNode().setId("b")
.setName("组件B")
.setType(NodeTypeEnum.COMMON)
.setClazz("com.yomahub.liteflow.test.script.groovy.cmp.BCmp")
.build();
LiteFlowChainELBuilder.createChain().setChainName("chain2")
.setEL("THEN(d,SWITCH(s2).to(a,b))")
.build();
LiteflowResponse response = flowExecutor.execute2Resp("chain2","arg1");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("d[组件D]==>s2[条件脚本S2]==>a[组件A]", response.getExecuteStepStr());
}
}

View File

@ -0,0 +1,93 @@
package com.yomahub.liteflow.test.script.groovy;
import cn.hutool.core.io.resource.ResourceUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.enums.FlowParserTypeEnum;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.slot.DefaultContext;
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.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* 测试springboot下的groovy脚本组件基于json配置
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/json-script-file/application.properties")
@SpringBootTest(classes = LiteflowJsonScriptFileGroovyELTest.class)
@EnableAutoConfiguration
@ComponentScan({"com.yomahub.liteflow.test.script.groovy.cmp"})
public class LiteflowJsonScriptFileGroovyELTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试普通脚本节点
@Test
public void testScript1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(Integer.valueOf(6), context.getData("s1"));
}
//测试条件脚本节点
@Test
public void testScript2() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr());
}
//测试脚本的热重载
@Test
public void testScript3() throws Exception{
//根据配置加载的应该是flow.xml执行原来的规则
LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseOld.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr());
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.el.json");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_JSON, newContent);
//重新执行chain2这个链路结果会变
LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr());
}
//测试脚本&规则平滑重载刷新
@Test
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(2000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /json-script-file/flow_update.el.json");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_JSON, newContent);
}catch (Exception e){
e.printStackTrace();
}
}).start();
for (int i = 0; i < 300; i++) {
LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);
}
}
}

View File

@ -0,0 +1,71 @@
package com.yomahub.liteflow.test.script.groovy;
import cn.hutool.core.io.resource.ResourceUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.enums.FlowParserTypeEnum;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.slot.DefaultContext;
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.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* 测试springboot下的groovy脚本组件基于json配置
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/json-script/application.properties")
@SpringBootTest(classes = LiteflowJsonScriptGroovyELTest.class)
@EnableAutoConfiguration
@ComponentScan({"com.yomahub.liteflow.test.script.groovy.cmp"})
public class LiteflowJsonScriptGroovyELTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试普通脚本节点
@Test
public void testScript1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(Integer.valueOf(6), context.getData("s1"));
}
//测试条件脚本节点
@Test
public void testScript2() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr());
}
//测试脚本的热重载
@Test
public void testScript3() throws Exception{
//根据配置加载的应该是flow.xml执行原来的规则
LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseOld.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr());
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /json-script/flow_update.el.json");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_JSON, newContent);
//重新执行chain2这个链路结果会变
LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr());
}
}

View File

@ -0,0 +1,93 @@
package com.yomahub.liteflow.test.script.groovy;
import cn.hutool.core.io.resource.ResourceUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.enums.FlowParserTypeEnum;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.slot.DefaultContext;
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.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* 测试springboot下的groovy脚本组件基于xml配置file脚本
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/xml-script-file/application.properties")
@SpringBootTest(classes = LiteflowXmlScriptFileGroovyELTest.class)
@EnableAutoConfiguration
@ComponentScan({"com.yomahub.liteflow.test.script.groovy.cmp"})
public class LiteflowXmlScriptFileGroovyELTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试普通脚本节点
@Test
public void testScript1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(Integer.valueOf(6), context.getData("s1"));
}
//测试条件脚本节点
@Test
public void testScript2() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr());
}
//测试脚本的热重载
@Test
public void testScript3() throws Exception{
//根据配置加载的应该是flow.xml执行原来的规则
LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseOld.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr());
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.el.xml");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, newContent);
//重新执行chain2这个链路结果会变
LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr());
}
//测试脚本&规则平滑重载刷新
@Test
public void testScript4() throws Exception{
new Thread(() -> {
try{
Thread.sleep(2000L);
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script-file/flow_update.el.xml");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, newContent);
}catch (Exception e){
e.printStackTrace();
}
}).start();
for (int i = 0; i < 300; i++) {
LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Thread.sleep(10L);
}
}
}

View File

@ -0,0 +1,71 @@
package com.yomahub.liteflow.test.script.groovy;
import cn.hutool.core.io.resource.ResourceUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.enums.FlowParserTypeEnum;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.slot.DefaultContext;
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.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* 测试springboot下的groovy脚本组件基于xml配置
* @author Bryan.Zhang
* @since 2.6.0
*/
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/xml-script/application.properties")
@SpringBootTest(classes = LiteflowXmlScriptGroovyELTest.class)
@EnableAutoConfiguration
@ComponentScan({"com.yomahub.liteflow.test.script.groovy.cmp"})
public class LiteflowXmlScriptGroovyELTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试普通脚本节点
@Test
public void testScript1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(Integer.valueOf(6), context.getData("s1"));
}
//测试条件脚本节点
@Test
public void testScript2() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr());
}
//测试脚本的热重载
@Test
public void testScript3() throws Exception{
//根据配置加载的应该是flow.xml执行原来的规则
LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseOld.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr());
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script/flow_update.el.xml");
//进行刷新
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, newContent);
//重新执行chain2这个链路结果会变
LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseNew.isSuccess());
Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr());
}
}

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.script.groovy.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("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.script.groovy.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("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.script.groovy.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("c")
public class CCmp extends NodeComponent {
@Override
public void process() {
System.out.println("CCmp executed!");
}
}

View File

@ -0,0 +1,25 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.script.groovy.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.slot.Slot;
@LiteflowComponent("d")
public class DCmp extends NodeComponent {
@Override
public void process() {
DefaultContext context = this.getFirstContextBean();
context.setData("count",198);
System.out.println("DCmp executed!");
}
}

View File

@ -0,0 +1,3 @@
Integer a=3
Integer b=2
defaultContext.setData("s1",a*b)

View File

@ -0,0 +1,6 @@
Integer count = defaultContext.getData("count")
if(count > 100){
return "a"
}else{
return "b"
}

View File

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

View File

@ -0,0 +1,30 @@
{
"flow": {
"nodes": {
"node": [
{
"id": "s1",
"name": "普通脚本",
"type": "script",
"file": "json-script-file/s1.groovy"
},
{
"id": "s2",
"name": "条件脚本",
"type": "switch_script",
"file": "json-script-file/s2.groovy"
}
]
},
"chain": [
{
"name": "chain1",
"value": "THEN(a, b, c, s1)"
},
{
"name": "chain2",
"value": "THEN(d, SWITCH(s2).to(a, b))"
}
]
}
}

View File

@ -0,0 +1,36 @@
{
"flow": {
"nodes": {
"node": [
{
"id": "s1",
"name": "普通脚本",
"type": "script",
"file": "json-script-file/s1.groovy"
},
{
"id": "s2",
"name": "条件脚本_改",
"type": "switch_script",
"file": "json-script-file/s2_update.groovy"
},
{
"id": "s3",
"name": "普通脚本_新增",
"type": "script",
"file": "json-script-file/s2_update.groovy"
}
]
},
"chain": [
{
"name": "chain1",
"value": "THEN(a, b, c, s1)"
},
{
"name": "chain2",
"value": "THEN(d, SWITCH(s2).to(a, b), s3)"
}
]
}
}

View File

@ -0,0 +1,3 @@
Integer a=3
Integer b=2
defaultContext.setData("s1",a*b)

View File

@ -0,0 +1,6 @@
Integer count = defaultContext.getData("count")
if(count > 100){
return "a"
}else{
return "b"
}

View File

@ -0,0 +1,6 @@
Integer count = defaultContext.getData("count")
if(count > 150){
return "b"
}else{
return "a"
}

View File

@ -0,0 +1,4 @@
Integer a=3
Integer b=2
Integer c=10
defaultContext.setData("s1",a*b+c)

View File

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

View File

@ -0,0 +1,36 @@
{
"flow": {
"nodes": {
"node": [
{
"id": "s1",
"name": "普通脚本",
"type": "script",
"value": "def a=3;def b=2;defaultContext.setData(\"s1\",a*b);"
},
{
"id": "s2",
"name": "条件脚本",
"type": "switch_script",
"value": "count = defaultContext.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}"
},
{
"id": "s3",
"name": "普通脚本2",
"type": "script",
"value": "def a=30;def b=2;defaultContext.setData(\"s1\",a*b);"
}
]
},
"chain": [
{
"name": "chain1",
"value": "THEN(a,b,c,s1)"
},
{
"name": "chain2",
"value": "THEN(d, SWITCH(s2).to(a, b))"
}
]
}
}

View File

@ -0,0 +1,36 @@
{
"flow": {
"nodes": {
"node": [
{
"id": "s1",
"name": "普通脚本",
"type": "script",
"value": "def a=3;def b=2;defaultContext.setData(\"s1\",a*b);"
},
{
"id": "s2",
"name": "条件脚本_改",
"type": "switch_script",
"value": "count = defaultContext.getData(\"count\");if(count > 150){return \"b\";}else{return \"a\";}"
},
{
"id": "s3",
"name": "普通脚本_新增",
"type": "script",
"value": "def a=3;def b=2;def c=10;defaultContext.setData(\"s1\",a*b+c);"
}
]
},
"chain": [
{
"name": "chain1",
"value": "THEN(a, b, c, s1)"
},
{
"name": "chain2",
"value": "THEN(d, SWITCH(s2).to(a, b), s3)"
}
]
}
}

View File

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

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<nodes>
<node id="s1" name="普通脚本" type="script" file="xml-script-file/s1.groovy"/>
<node id="s2" name="条件脚本" type="switch_script" file="xml-script-file/s2.groovy"/>
</nodes>
<chain name="chain1">
THEN(a, b, c, s1)
</chain>
<chain name="chain2">
THEN(d, SWITCH(s2).to(a,b))
</chain>
</flow>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<nodes>
<node id="s1" name="普通脚本" type="script" file="xml-script-file/s1.groovy"/>
<node id="s2" name="条件脚本_改" type="switch_script" file="xml-script-file/s2_update.groovy"/>
<node id="s3" name="普通脚本_新增" type="script" file="xml-script-file/s3.groovy"/>
</nodes>
<chain name="chain1">
THEN(a, b, c, s1)
</chain>
<chain name="chain2">
THEN(d, SWITCH(s2).to(a,b), s3)
</chain>
</flow>

View File

@ -0,0 +1,3 @@
Integer a=3
Integer b=2
defaultContext.setData("s1",a*b)

View File

@ -0,0 +1,6 @@
Integer count = defaultContext.getData("count")
if(count > 100){
return "a"
}else{
return "b"
}

View File

@ -0,0 +1,6 @@
Integer count = defaultContext.getData("count")
if(count > 150){
return "b"
}else{
return "a"
}

View File

@ -0,0 +1,4 @@
Integer a=3
Integer b=2
Integer c=10
defaultContext.setData("s1",a*b+c);

View File

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

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<nodes>
<node id="s1" name="普通脚本1" type="script">
<![CDATA[
def a=3;
def b=2;
defaultContext.setData("s1",a*b);
]]>
</node>
<node id="s2" name="条件脚本" type="switch_script">
<![CDATA[
count = defaultContext.getData("count");
if(count > 100){
return "a";
}else{
return "b";
}
]]>
</node>
<!-- 定义s3的目的是验证在多个脚本节点同时存在情况下的运行情况是否正确本身s3不会被引用到 -->
<node id="s3" name="普通脚本2" type="script">
<![CDATA[
def a=30;
def b=2;
defaultContext.setData("s1",a*b);
]]>
</node>
</nodes>
<chain name="chain1">
THEN(a, b, c, s1)
</chain>
<chain name="chain2">
THEN(d, SWITCH(s2).to(a,b))
</chain>
</flow>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<nodes>
<node id="s1" name="普通脚本" type="script">
<![CDATA[
def a=3;
def b=2;
defaultContext.setData("s1",a*b);
]]>
</node>
<node id="s2" name="条件脚本_改" type="switch_script">
<![CDATA[
count = defaultContext.getData("count");
if(count > 150){
return "b";
}else{
return "a";
}
]]>
</node>
<node id="s3" name="普通脚本_新增" type="script">
<![CDATA[
def a=3;
def b=2;
def c=10;
defaultContext.setData("s1",a*b+c);
]]>
</node>
</nodes>
<chain name="chain1">
THEN(a, b, c, s1)
</chain>
<chain name="chain2">
THEN(d, SWITCH(s2).to(a,b), s3)
</chain>
</flow>

View File

@ -16,5 +16,6 @@
<modules>
<module>liteflow-testcase-el-springboot</module>
<module>liteflow-testcase-el-declare-springboot</module>
<module>liteflow-testcase-el-script-groovy-springboot</module>
</modules>
</project>

View File

@ -35,5 +35,4 @@ public class LiteflowRequestIdSpringbootTest extends BaseTest {
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("1", response.getSlot().getRequestId());
}
}