feature #I9DQDU 允许对不存在的组件增加全局参数

This commit is contained in:
everywhere.z
2024-04-08 12:23:15 +08:00
parent 07b45657bf
commit 4abeabbcb1
14 changed files with 246 additions and 11 deletions

View File

@@ -0,0 +1,46 @@
package com.yomahub.liteflow.test.uncheckNode;
import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import com.yomahub.liteflow.test.uncheckNode.cmp.XCmp;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import javax.annotation.Resource;
/**
* springboot环境不检查Node存在与否测试
*
* @author Bryan.Zhang
*/
@TestPropertySource(value = "classpath:/uncheckNode/application.properties")
@SpringBootTest(classes = UnCheckNodeSpringbootTest.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.uncheckNode.cmp" })
public class UnCheckNodeSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
// X不存在,能启动就算成功
@Test
public void testUncheckNode1() throws Exception {
}
// X不存在但是启动好加入进去就可以
@Test
public void testUncheckNode2() throws Exception {
LiteFlowNodeBuilder.createCommonNode().setId("x").setClazz(XCmp.class).build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1");
Assertions.assertTrue(response.isSuccess());
}
}

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.uncheckNode.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.uncheckNode.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,19 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.uncheckNode.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
public class XCmp extends NodeComponent {
@Override
public void process() {
System.out.println("XCmp executed!");
}
}

View File

@@ -0,0 +1,2 @@
liteflow.rule-source=uncheckNode/flow.el.xml
liteflow.check-node-exists=false

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE flow PUBLIC "liteflow" "liteflow.dtd">
<flow>
<chain name="chain1">
THEN(a,b,x);
</chain>
</flow>