mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
加入在使用Map作为context的测试用例
This commit is contained in:
@@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.script.groovy.scriptbean;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.exception.ScriptBeanMethodInvokeException;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.script.ScriptBeanManager;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
@@ -15,6 +16,8 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/scriptbean/application.properties")
|
||||
@@ -75,4 +78,15 @@ public class LiteFlowScriptScriptbeanGroovyELTest extends BaseTest {
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals(ScriptBeanMethodInvokeException.class, response.getCause().getClass());
|
||||
}
|
||||
|
||||
//测试在ScriptBeanManager里放入上下文,实现自定义脚本引用名称
|
||||
@Test
|
||||
public void testScriptBean7() throws Exception{
|
||||
Map<String, String> map = new HashMap<>();
|
||||
ScriptBeanManager.addScriptBean("abcCx", map);
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg", map);
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Map<String, String> context = response.getFirstContextBean();
|
||||
Assert.assertEquals("hello", context.get("demo"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,13 @@
|
||||
defaultContext.setData("demo", str)
|
||||
]]>
|
||||
</node>
|
||||
|
||||
<node id="s5" type="script" language="groovy">
|
||||
<![CDATA[
|
||||
def str = demo.getDemoStr1()
|
||||
abcCx.put("demo", str)
|
||||
]]>
|
||||
</node>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
@@ -68,4 +75,8 @@
|
||||
<chain name="chain6">
|
||||
THEN(a,b,c,s4);
|
||||
</chain>
|
||||
|
||||
<chain name="chain7">
|
||||
THEN(a,b,c,s5);
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user