mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
补充测试用例
This commit is contained in:
@@ -12,7 +12,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
*/
|
||||
public class LiteflowExecutorInit implements InitializingBean {
|
||||
|
||||
private FlowExecutor flowExecutor;
|
||||
private final FlowExecutor flowExecutor;
|
||||
|
||||
public LiteflowExecutorInit(FlowExecutor flowExecutor) {
|
||||
this.flowExecutor = flowExecutor;
|
||||
|
||||
@@ -34,7 +34,9 @@ public class LiteflowMainAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public FlowExecutor flowExecutor(LiteflowConfig liteflowConfig) {
|
||||
return new FlowExecutor(liteflowConfig);
|
||||
FlowExecutor flowExecutor = new FlowExecutor();
|
||||
flowExecutor.setLiteflowConfig(liteflowConfig);
|
||||
return flowExecutor;
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.subflow.cmp2;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -13,7 +14,7 @@ import static com.yomahub.liteflow.test.subflow.ImplicitSubFlowTest.RUN_TIME_SLO
|
||||
@Component("g")
|
||||
public class GCmp extends NodeComponent {
|
||||
|
||||
@Resource
|
||||
@Autowired
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Override
|
||||
@@ -21,7 +22,7 @@ public class GCmp extends NodeComponent {
|
||||
|
||||
RUN_TIME_SLOT.add(this.getSlot().getRequestId());
|
||||
|
||||
System.out.println("Gcomp executed!");
|
||||
System.out.println("Gcmp executed!");
|
||||
|
||||
flowExecutor.invoke("chain4", "it's implicit subflow.", DefaultSlot.class, this.getSlotIndex());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* springboot环境下异步线程超时日志打印测试
|
||||
* spring环境下异步线程超时日志打印测试
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.4
|
||||
|
||||
@@ -20,9 +20,7 @@ public class FlowExecutorTest extends BaseTest {
|
||||
public void testMethodExecute2Resp() {
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("executor/flow.json");
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
FlowExecutor executor = new FlowExecutor(config);
|
||||
LiteflowResponse<CustomSlot> response = executor.execute2Resp("chain1", "test0", CustomSlot.class);
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("custom", response.getSlot().getName());
|
||||
@@ -32,9 +30,7 @@ public class FlowExecutorTest extends BaseTest {
|
||||
public void testMethodExecute2RespWithException() throws Exception{
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("executor/flow0.json");
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
FlowExecutor executor = new FlowExecutor(config);
|
||||
LiteflowResponse<CustomSlot> response = executor.execute2Resp("chain1", "test1", CustomSlot.class);
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
ReflectionUtils.rethrowException(response.getCause());
|
||||
@@ -44,9 +40,7 @@ public class FlowExecutorTest extends BaseTest {
|
||||
public void testMethodExecute() throws Exception {
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("executor/flow.json");
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
FlowExecutor executor = new FlowExecutor(config);
|
||||
CustomSlot slot = executor.execute("chain1", "test0", CustomSlot.class);
|
||||
Assert.assertEquals("custom", slot.getName());
|
||||
}
|
||||
@@ -55,9 +49,7 @@ public class FlowExecutorTest extends BaseTest {
|
||||
public void testMethodExecuteWithException() throws Exception {
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("executor/flow0.json");
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
executor.setLiteflowConfig(config);
|
||||
executor.init();
|
||||
FlowExecutor executor = new FlowExecutor(config);
|
||||
executor.execute("chain1", "test1", CustomSlot.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* springboot环境最普通的例子测试
|
||||
* spring环境下监控的测试
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.4
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
|
||||
/**
|
||||
* 测试springboot下混合格式规则的场景
|
||||
* 测试spring下混合格式规则的场景
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.10
|
||||
*/
|
||||
|
||||
@@ -14,14 +14,14 @@ import javax.annotation.Resource;
|
||||
|
||||
|
||||
/**
|
||||
* 测试springboot下的组件重试
|
||||
* 测试spring下的组件重试
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.10
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/nodeExecutor/application.xml")
|
||||
public class LiteflowNodeExecutorSpringbootTest extends BaseTest {
|
||||
public class LiteflowNodeExecutorSpringTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
@@ -18,11 +18,9 @@ public class LFParserJsonNoSpringTest extends BaseTest {
|
||||
//测试无spring场景的json parser
|
||||
@Test
|
||||
public void testNoSpring() {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
LiteflowConfig liteflowConfig = new LiteflowConfig();
|
||||
liteflowConfig.setRuleSource("parser/flow.json");
|
||||
executor.setLiteflowConfig(liteflowConfig);
|
||||
executor.init();
|
||||
FlowExecutor executor = new FlowExecutor(liteflowConfig);
|
||||
LiteflowResponse<DefaultSlot> response = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ public class LFParserXmlNoSpringTest extends BaseTest {
|
||||
//测试无spring场景的xml parser
|
||||
@Test
|
||||
public void testNoSpring() {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
LiteflowConfig liteflowConfig = new LiteflowConfig();
|
||||
liteflowConfig.setRuleSource("parser/flow.xml");
|
||||
executor.setLiteflowConfig(liteflowConfig);
|
||||
executor.init();
|
||||
FlowExecutor executor = new FlowExecutor(liteflowConfig);
|
||||
LiteflowResponse<DefaultSlot> response = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ public class LFParserYmlNoSpringTest extends BaseTest {
|
||||
//测试无spring场景的yml parser
|
||||
@Test
|
||||
public void testNoSpring() {
|
||||
FlowExecutor executor = new FlowExecutor();
|
||||
LiteflowConfig liteflowConfig = new LiteflowConfig();
|
||||
liteflowConfig.setRuleSource("parser/flow.yml");
|
||||
executor.setLiteflowConfig(liteflowConfig);
|
||||
executor.init();
|
||||
FlowExecutor executor = new FlowExecutor(liteflowConfig);
|
||||
LiteflowResponse<DefaultSlot> response = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* springboot环境下pre节点和finally节点的测试
|
||||
* spring环境下pre节点和finally节点的测试
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.4
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,7 @@ import javax.annotation.Resource;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* springboot环境下隐私投递的测试
|
||||
* spring环境下隐私投递的测试
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.0
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* springboot环境下重新加载规则测试
|
||||
* spring环境下重新加载规则测试
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.6.4
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yomahub.liteflow.test.reload;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* spring环境下重新加载规则测试
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/reload/application.xml")
|
||||
public class ReloadSpringTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//用reloadRule去重新加载,这里如果配置是放在本地。如果想修改,则要去修改target下面的flow.xml
|
||||
//这里的测试,手动打断点然后去修改,是ok的。但是整个测试,暂且只是为了测试这个功能是否能正常运行
|
||||
@Test
|
||||
public void testReload() throws Exception{
|
||||
flowExecutor.reloadRule();
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -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.reload.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!");
|
||||
}
|
||||
}
|
||||
@@ -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.reload.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!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.reload.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("CCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yomahub.liteflow.test.resizeSlot;
|
||||
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DataBus;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* springboot环境下slot扩容测试
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.5.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/resizeSlot/application.xml")
|
||||
public class ResizeSlotSpringTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Test
|
||||
public void testResize() throws Exception{
|
||||
ExecutorService pool = Executors.newCachedThreadPool();
|
||||
|
||||
List<Future<LiteflowResponse<DefaultSlot>>> futureList = new ArrayList<>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
Future<LiteflowResponse<DefaultSlot>> future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg"));
|
||||
futureList.add(future);
|
||||
}
|
||||
|
||||
for(Future<LiteflowResponse<DefaultSlot>> future : futureList){
|
||||
Assert.assertTrue(future.get().isSuccess());
|
||||
}
|
||||
|
||||
//取到static的对象QUEUE
|
||||
Field field = ReflectUtil.getField(DataBus.class, "QUEUE");
|
||||
ConcurrentLinkedQueue<Integer> queue = (ConcurrentLinkedQueue<Integer>) ReflectUtil.getStaticFieldValue(field);
|
||||
|
||||
//因为初始slotSize是4,按照0.75的扩容比,要满足100个线程,应该扩容5~6次,5次=65,6次=114
|
||||
//为什么不是直接114呢?
|
||||
//因为在单测中根据机器的性能,在多线程情况下,有些机器跑的慢一点,也就是说65个就足够了。有些机器跑的快一点,是能真正扩容到114个的
|
||||
Assert.assertTrue(queue.size() > 4);
|
||||
}
|
||||
}
|
||||
@@ -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.resizeSlot.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!");
|
||||
}
|
||||
}
|
||||
@@ -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.resizeSlot.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!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.resizeSlot.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("CCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.yomahub.liteflow.test.subflow;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 测试隐式调用子流程
|
||||
* 单元测试
|
||||
*
|
||||
* @author justin.xu
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/subflow/application-implicit.xml")
|
||||
public class ImplicitSubFlowTest extends BaseTest {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
public static final Set<String> RUN_TIME_SLOT = new HashSet<>();
|
||||
|
||||
//这里GCmp中隐式的调用chain4,从而执行了h,m
|
||||
@Test
|
||||
public void testImplicitSubFlow() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("f==>g==>h==>m", response.getSlot().getExecuteStepStr());
|
||||
|
||||
// 传递了slotIndex,则set的size==1
|
||||
Assert.assertEquals(1, RUN_TIME_SLOT.size());
|
||||
// set中第一次设置的requestId和response中的requestId一致
|
||||
Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.yomahub.liteflow.test.subflow;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.exception.MultipleParsersException;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 测试主流程与子流程在不同的配置文件的场景
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/subflow/application-subInDifferentConfig1.xml")
|
||||
public class SubflowInDifferentConfigTest extends BaseTest {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//是否按照流程定义配置执行
|
||||
@Test
|
||||
public void testExplicitSubFlow1() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getSlot().getExecuteStepStr());
|
||||
}
|
||||
|
||||
//主要测试有不同的配置类型后会不会报出既定的错误
|
||||
@Test(expected = MultipleParsersException.class)
|
||||
public void testExplicitSubFlow2() {
|
||||
LiteflowConfig config = LiteflowConfigGetter.get();
|
||||
config.setRuleSource("subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.yml");
|
||||
flowExecutor.init();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yomahub.liteflow.test.subflow;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 测试显示调用子流程(json)
|
||||
* 单元测试
|
||||
*
|
||||
* @author justin.xu
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/subflow/application-json.xml")
|
||||
public class SubflowJsonSpringTest extends BaseTest {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//是否按照流程定义配置执行
|
||||
@Test
|
||||
public void testExplicitSubFlow() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getSlot().getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yomahub.liteflow.test.subflow;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 测试显示调用子流程(xml)
|
||||
* 单元测试
|
||||
*
|
||||
* @author justin.xu
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/subflow/application-xml.xml")
|
||||
public class SubflowXMLSpringTest extends BaseTest {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//是否按照流程定义配置执行
|
||||
@Test
|
||||
public void testExplicitSubFlow() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getSlot().getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yomahub.liteflow.test.subflow;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 测试显示调用子流程(yml)
|
||||
* 单元测试
|
||||
*
|
||||
* @author justin.xu
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/subflow/application-yml.xml")
|
||||
public class SubflowYmlSpringTest extends BaseTest {
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//是否按照流程定义配置执行
|
||||
@Test
|
||||
public void testExplicitSubFlowYml() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "it's a request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getSlot().getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp1;
|
||||
|
||||
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("Acomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp1;
|
||||
|
||||
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("Bcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("Ccomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("d")
|
||||
public class DCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("Dcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp1;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component("e")
|
||||
public class ECmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
System.out.println("Ecomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp2;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.yomahub.liteflow.test.subflow.ImplicitSubFlowTest.RUN_TIME_SLOT;
|
||||
|
||||
|
||||
@Component("f")
|
||||
public class FCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
|
||||
RUN_TIME_SLOT.add(this.getSlot().getRequestId());
|
||||
|
||||
System.out.println("Fcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp2;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.yomahub.liteflow.test.subflow.ImplicitSubFlowTest.RUN_TIME_SLOT;
|
||||
|
||||
|
||||
@Component("g")
|
||||
public class GCmp extends NodeComponent {
|
||||
|
||||
@Autowired
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
|
||||
RUN_TIME_SLOT.add(this.getSlot().getRequestId());
|
||||
|
||||
System.out.println("Gcmp executed!");
|
||||
|
||||
flowExecutor.invoke("chain4", "it's implicit subflow.", DefaultSlot.class, this.getSlotIndex());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp2;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.yomahub.liteflow.test.subflow.ImplicitSubFlowTest.RUN_TIME_SLOT;
|
||||
|
||||
|
||||
@Component("h")
|
||||
public class HCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
|
||||
RUN_TIME_SLOT.add(this.getSlot().getRequestId());
|
||||
|
||||
System.out.println("Hcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yomahub.liteflow.test.subflow.cmp2;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.yomahub.liteflow.test.subflow.ImplicitSubFlowTest.RUN_TIME_SLOT;
|
||||
|
||||
|
||||
@Component("m")
|
||||
public class MCmp extends NodeComponent {
|
||||
@Override
|
||||
public void process() throws Exception {
|
||||
|
||||
RUN_TIME_SLOT.add(this.getSlot().getRequestId());
|
||||
|
||||
System.out.println("Mcomp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.reload.cmp" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="reload/flow.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.resizeSlot.cmp" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="resizeSlot/flow.xml"/>
|
||||
<property name="slotSize" value="4"/>
|
||||
</bean>
|
||||
|
||||
<!-- 用arg的话启动时就初始化slot,这样是严格意义上的线程安全,如果用property的话,虽然slot分配过程线程安全,但是初始化DataBus并非线程安全 -->
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<constructor-arg name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.subflow.cmp2" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="subflow/flow-implicit.xml"/>
|
||||
</bean>
|
||||
|
||||
<!-- 隐式流程的话,这里一定要用property -->
|
||||
<!-- 用 constructor-arg 的话,除了隐式流程不能用以外,其他都能用 -->
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.subflow.cmp1" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="subflow/flow.json"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.subflow.cmp1,com.yomahub.liteflow.test.subflow.cmp1" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.subflow.cmp1" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="subflow/flow.xml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.subflow.cmp1" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="subflow/flow.yml"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain3">
|
||||
<then value="f,g"/> <!-- g隐式调用chain4 -->
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
<then value="h,m"/>
|
||||
</chain>
|
||||
<!-- f,g,h,m -->
|
||||
</flow>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b"/>
|
||||
<then value="chain2"/> <!-- 测试调用c流程后是否正常调用chain2 -->
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain2">
|
||||
<then value="b,a"/>
|
||||
<then value="chain3"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain3">
|
||||
<then value="e,d"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,6 @@
|
||||
flow:
|
||||
chain:
|
||||
- name: chain3
|
||||
condition:
|
||||
- type: then
|
||||
value: 'e,d'
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"flow": {
|
||||
"chain": [
|
||||
{
|
||||
"name": "chain3",
|
||||
"condition": [
|
||||
{"type": "then", "value": "e,d"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "chain2",
|
||||
"condition": [
|
||||
{"type": "then", "value": "b,a"},
|
||||
{"type": "then", "value": "chain3"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "chain1",
|
||||
"condition": [
|
||||
{"type": "then", "value": "a,b"},
|
||||
{"type": "then", "value": "c"},
|
||||
{"type": "then", "value": "chain2"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "c",
|
||||
"condition": [
|
||||
{"type": "then", "value": "d,e"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b"/>
|
||||
<then value="c"/> <!-- 显式的调用了chain(c),当这里存在Node(c)时,测试是否为优先调用了Node(c)-->
|
||||
<then value="chain2"/> <!-- 测试调用c流程后是否正常调用chain2 -->
|
||||
</chain>
|
||||
|
||||
<chain name="c">
|
||||
<then value="d,e"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
<then value="b,a"/>
|
||||
<then value="chain3"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
<then value="e,d"/>
|
||||
</chain>
|
||||
<!-- a,b,c,b,a,e,d -->
|
||||
</flow>
|
||||
@@ -0,0 +1,24 @@
|
||||
flow:
|
||||
chain:
|
||||
- name: chain3
|
||||
condition:
|
||||
- type: then
|
||||
value: 'e,d'
|
||||
- name: chain1
|
||||
condition:
|
||||
- type: then
|
||||
value: 'a,b'
|
||||
- type: then
|
||||
value: 'c'
|
||||
- type: then
|
||||
value: 'chain2'
|
||||
- name: c
|
||||
condition:
|
||||
- type: then
|
||||
value: 'd,e'
|
||||
- name: chain2
|
||||
condition:
|
||||
- type: then
|
||||
value: 'b,a'
|
||||
- type: then
|
||||
value: 'chain3'
|
||||
Reference in New Issue
Block a user