|
@@ -1,5 +1,6 @@
|
|
|
package com.yomahub.liteflow.test.script.groovy.common;
|
|
|
|
|
|
+import cn.hutool.core.io.resource.ClassPathResource;
|
|
|
import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
|
|
|
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
|
|
|
import com.yomahub.liteflow.core.FlowExecutor;
|
|
@@ -25,6 +26,44 @@ public class LiteFlowXmlScriptBuilderGroovyELTest extends BaseTest {
|
|
|
@Resource
|
|
|
private FlowExecutor flowExecutor;
|
|
|
|
|
|
+ /**
|
|
|
+ * 测试通过builder方式运行普通script节点,以file绝对路径的方式运行
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void testAbsoluteScriptFilePath(){
|
|
|
+ String absolutePath = new ClassPathResource("classpath:builder/s2.groovy").getAbsolutePath();
|
|
|
+ LiteFlowNodeBuilder.createNode().setId("d")
|
|
|
+ .setName("组件D")
|
|
|
+ .setType(NodeTypeEnum.COMMON)
|
|
|
+ .setClazz("com.yomahub.liteflow.test.script.groovy.common.cmp.DCmp")
|
|
|
+ .build();
|
|
|
+ LiteFlowNodeBuilder.createNode().setId("s2")
|
|
|
+ .setName("条件脚本S2")
|
|
|
+ .setType(NodeTypeEnum.SWITCH_SCRIPT)
|
|
|
+ .setFile(absolutePath)
|
|
|
+ .build();
|
|
|
+ LiteFlowNodeBuilder.createNode().setId("a")
|
|
|
+ .setName("组件A")
|
|
|
+ .setType(NodeTypeEnum.COMMON)
|
|
|
+ .setClazz("com.yomahub.liteflow.test.script.groovy.common.cmp.ACmp")
|
|
|
+ .build();
|
|
|
+ LiteFlowNodeBuilder.createNode().setId("b")
|
|
|
+ .setName("组件B")
|
|
|
+ .setType(NodeTypeEnum.COMMON)
|
|
|
+ .setClazz("com.yomahub.liteflow.test.script.groovy.common.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());
|
|
|
+ }
|
|
|
+
|
|
|
//测试通过builder方式运行普通script节点,以脚本文本的方式运行
|
|
|
@Test
|
|
|
public void testBuilderScript1() {
|