加入在使用Map作为context的测试用例

This commit is contained in:
everywhere.z
2023-01-09 19:11:11 +08:00
parent c841098d6d
commit c7c795f5b2
2 changed files with 25 additions and 0 deletions

View File

@@ -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"));
}
}

View File

@@ -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>