feature #I5WNMG 脚本组件支持javascript的语法

This commit is contained in:
everywhere.z
2022-10-20 16:03:41 +08:00
parent 09db166b91
commit e584527d86
5 changed files with 93 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ public class LiteflowXmlScriptGroovyELTest extends BaseTest {
public void testScript2() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr());
Assert.assertEquals("d==>s2[选择脚本]==>a", response.getExecuteStepStr());
}
//测试脚本的热重载
@@ -57,7 +57,7 @@ public class LiteflowXmlScriptGroovyELTest extends BaseTest {
//根据配置加载的应该是flow.xml执行原来的规则
LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(responseOld.isSuccess());
Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr());
Assert.assertEquals("d==>s2[选择脚本]==>a", responseOld.getExecuteStepStr());
//更改规则重新加载更改的规则内容从flow_update.xml里读取这里只是为了模拟下获取新的内容。不一定是从文件中读取
String newContent = ResourceUtil.readUtf8Str("classpath: /xml-script/flow_update.el.xml");
//进行刷新

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.loop.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.script.groovy.loop.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.script.groovy.loop.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,29 @@
/**
* <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.loop.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.slot.DefaultContext;
import org.springframework.stereotype.Component;
@Component("d")
public class DCmp extends NodeComponent {
@Override
public void process() {
DefaultContext context = this.getFirstContextBean();
String key = "test";
if (context.hasData(key)){
int count = context.getData(key);
context.setData(key, ++count);
}else{
context.setData(key, 1);
}
}
}