mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-24 00:08:09 +08:00
#IB2BKP 添加测试用例
This commit is contained in:
@@ -5,6 +5,8 @@ import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.enums.FlowParserTypeEnum;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -17,6 +19,10 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.yomahub.liteflow.enums.NodeTypeEnum.SCRIPT;
|
||||
|
||||
/**
|
||||
* PARSE_ONE_ON_FIRST_EXEC 第一次执行时解析脚本节点
|
||||
@@ -35,6 +41,35 @@ public class LiteflowXmlScriptQLExpressELParseModeTest extends BaseTest {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
// 测试启动时未加载,执行后加载
|
||||
@Test
|
||||
public void testScript() {
|
||||
Map<String, Node> nodeMap = FlowBus.getNodeMap();
|
||||
|
||||
for (Map.Entry<String, Node> entry : nodeMap.entrySet()) {
|
||||
Node node = entry.getValue();
|
||||
if (SCRIPT.equals(node.getType())) {
|
||||
Assertions.assertFalse(node.isCompiled());
|
||||
}
|
||||
}
|
||||
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
DefaultContext context = response.getFirstContextBean();
|
||||
Assertions.assertTrue(response.isSuccess());
|
||||
Assertions.assertEquals(Integer.valueOf(6), context.getData("s1"));
|
||||
|
||||
// 验证脚本节点是否被重新编译
|
||||
Set<String> nodeIds = response.getExecuteStepQueue().stream().map(CmpStep::getNodeId).collect(Collectors.toSet());
|
||||
nodeMap = FlowBus.getNodeMap();
|
||||
for (Map.Entry<String, Node> entry : nodeMap.entrySet()) {
|
||||
Node node = entry.getValue();
|
||||
if (SCRIPT.equals(node.getType()) && nodeIds.contains(node.getId())) {
|
||||
Assertions.assertTrue(node.isCompiled());
|
||||
Assertions.assertNotNull(node.getInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 测试普通脚本节点
|
||||
@Test
|
||||
public void testScript1() {
|
||||
|
||||
Reference in New Issue
Block a user