enhancement #I8SMQB BREAK、IF、WHILE组件统一变成布尔组件

This commit is contained in:
everywhere.z 2024-04-03 19:00:58 +08:00
parent 671762face
commit 80606c63f9
47 changed files with 229 additions and 1077 deletions

View File

@ -1,225 +0,0 @@
package com.yomahub.liteflow.test.fallback;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
/**
* SpringBoot 降级组件测试
*
* @author DaleLee
* @since 2.11.1
*/
@TestPropertySource(value = "classpath:/fallback/application.properties")
@SpringBootTest(classes = FallbackELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ComponentScan({"com.yomahub.liteflow.test.fallback.cmp"})
public class FallbackELDeclSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
@Test
public void testThen1() {
LiteflowResponse response = flowExecutor.execute2Resp("then1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>c", response.getExecuteStepStrWithoutTime());
}
@Test
public void testThen2() {
LiteflowResponse response = flowExecutor.execute2Resp("then2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("c==>c==>c", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhen1() {
LiteflowResponse response = flowExecutor.execute2Resp("when1", "arg");
Assertions.assertTrue(response.isSuccess());
String executeStepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("b==>c".equals(executeStepStr) || "c==>b".equals(executeStepStr));
}
@Test
public void testIf1() {
LiteflowResponse response = flowExecutor.execute2Resp("if1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIf2() {
LiteflowResponse response = flowExecutor.execute2Resp("if2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn1==>c", response.getExecuteStepStrWithoutTime());
}
@Test
public void testFor1() {
LiteflowResponse response = flowExecutor.execute2Resp("for1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("for1==>a==>a==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testFor2() {
LiteflowResponse response = flowExecutor.execute2Resp("for2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_3==>c==>c==>c", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhile1() {
LiteflowResponse response = flowExecutor.execute2Resp("while1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhile2() {
LiteflowResponse response = flowExecutor.execute2Resp("while2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn1==>c==>wn1==>c==>wn1==>c==>wn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIterator1() {
LiteflowResponse response = flowExecutor.execute2Resp("iterator1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIterator2() {
LiteflowResponse response = flowExecutor.execute2Resp("iterator2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn1==>c==>c==>c", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak1() {
LiteflowResponse response = flowExecutor.execute2Resp("break1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_3==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak2() {
LiteflowResponse response = flowExecutor.execute2Resp("break2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn1==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak3() {
LiteflowResponse response = flowExecutor.execute2Resp("break3", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn1==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testSwitch1() {
LiteflowResponse response = flowExecutor.execute2Resp("switch1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("swn2==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testSwitch2() {
LiteflowResponse response = flowExecutor.execute2Resp("switch2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("swn1==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testAnd1() {
LiteflowResponse response = flowExecutor.execute2Resp("and1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testOr1() {
LiteflowResponse response = flowExecutor.execute2Resp("or1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>ifn1==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testNot1() {
LiteflowResponse response = flowExecutor.execute2Resp("not1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testCatch1() {
LiteflowResponse response = flowExecutor.execute2Resp("catch1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>d==>c", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti1() {
LiteflowResponse response = flowExecutor.execute2Resp("multi1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>c==>ifn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti2() {
LiteflowResponse response = flowExecutor.execute2Resp("multi2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>ifn1==>a==>c", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti3() {
LiteflowResponse response = flowExecutor.execute2Resp("multi3", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("for1==>b==>c==>b==>c==>b==>c", response.getExecuteStepStrWithoutTime());
}
@Test
public void testConcurrent1() {
LiteflowResponse response = flowExecutor.execute2Resp("concurrent1", "arg");
Assertions.assertTrue(response.isSuccess());
String stepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr) || "ifn2==>c".equals(stepStr));
}
@Test
public void testConcurrent2() {
LiteflowResponse response = flowExecutor.execute2Resp("concurrent2", "arg");
Assertions.assertTrue(response.isSuccess());
String stepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr) || "ifn2==>c".equals(stepStr));
}
@Test
public void testConcurrent3() throws ExecutionException, InterruptedException {
// 执行多条 chain
Future<LiteflowResponse> future1 = flowExecutor.execute2Future("concurrent1", "arg", new Object());
Future<LiteflowResponse> future2 = flowExecutor.execute2Future("concurrent2", "arg", new Object());
Thread.sleep(1000);
LiteflowResponse response1 = future1.get();
LiteflowResponse response2 = future2.get();
Assertions.assertTrue(response1.isSuccess());
String stepStr1 = response1.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr1) || "ifn2==>c".equals(stepStr1));
Assertions.assertTrue(response2.isSuccess());
String stepStr2 = response2.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr2) || "ifn2==>c".equals(stepStr2));
}
}

View File

@ -1,16 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
@LiteflowComponent("a")
public class ACmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("ACmp executed!");
}
}

View File

@ -1,16 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
@LiteflowComponent("b")
public class BCmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("BCmp executed!");
}
}

View File

@ -1,20 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
@LiteflowComponent("bn1")
@LiteflowCmpDefine(NodeTypeEnum.BOOLEAN)
@FallbackCmp
public class BreakCmp {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN)
public boolean processBreak(NodeComponent bindCmp) throws Exception {
return true;
}
}

View File

@ -1,18 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
@LiteflowComponent("c")
@FallbackCmp
public class CCmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) {
System.out.println("CCmp executed!");
}
}

View File

@ -1,15 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
@LiteflowComponent("d")
public class DCmp {
@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
public void process(NodeComponent bindCmp) throws Exception {
throw new RuntimeException("component[d]");
}
}

View File

@ -1,20 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
@LiteflowComponent("for1")
@LiteflowCmpDefine(NodeTypeEnum.FOR)
@FallbackCmp
public class ForCmp {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_FOR)
public int processFor(NodeComponent bindCmp) throws Exception {
return 3;
}
}

View File

@ -1,18 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
@LiteflowComponent("ifn1")
@LiteflowCmpDefine(NodeTypeEnum.BOOLEAN)
public class IfCmp1 {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN)
public boolean processIf(NodeComponent bindCmp) throws Exception {
return true;
}
}

View File

@ -1,20 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
@LiteflowComponent("ifn2")
@LiteflowCmpDefine(NodeTypeEnum.BOOLEAN)
@FallbackCmp
public class IfCmp2 {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN)
public boolean processIf(NodeComponent bindCmp) throws Exception {
return false;
}
}

View File

@ -1,21 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import java.util.Arrays;
import java.util.Iterator;
@LiteflowComponent("itn1")
@LiteflowCmpDefine(NodeTypeEnum.ITERATOR)
public class IteratorCmp1 {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_ITERATOR)
public Iterator<?> processIterator(NodeComponent bindCmp) throws Exception {
return Arrays.asList("a", "b", "c").iterator();
}
}

View File

@ -1,23 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import java.util.Collections;
import java.util.Iterator;
@LiteflowComponent("itn2")
@LiteflowCmpDefine(NodeTypeEnum.ITERATOR)
@FallbackCmp
public class IteratorCmp2 {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_ITERATOR)
public Iterator<?> processIterator(NodeComponent bindCmp) throws Exception {
return Collections.emptyIterator();
}
}

View File

@ -1,18 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
@LiteflowComponent("swn1")
@LiteflowCmpDefine(NodeTypeEnum.SWITCH)
public class SwitchCmp1 {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH)
public String processSwitch(NodeComponent bindCmp) throws Exception {
return "a";
}
}

View File

@ -1,20 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
@LiteflowComponent("swn2")
@LiteflowCmpDefine(NodeTypeEnum.SWITCH)
@FallbackCmp
public class SwitchCmp2 {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH)
public String processSwitch(NodeComponent bindCmp) throws Exception {
return "b";
}
}

View File

@ -1,31 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import java.util.HashSet;
import java.util.Set;
@LiteflowComponent("wn1")
@LiteflowCmpDefine(NodeTypeEnum.BOOLEAN)
public class WhileCmp1 {
private int count = 0;
// 执行过的 chain
Set<String> executedChain = new HashSet<>();
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN)
public boolean processWhile(NodeComponent bindCmp) throws Exception {
// 判断是否切换了 chain
if (!executedChain.contains(bindCmp.getCurrChainId())) {
count = 0;
executedChain.add(bindCmp.getCurrChainId());
}
count++;
return count <= 3;
}
}

View File

@ -1,20 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
@LiteflowComponent("wn2")
@LiteflowCmpDefine(NodeTypeEnum.BOOLEAN)
@FallbackCmp
public class WhileCmp2 {
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN)
public boolean processWhile(NodeComponent bindCmp) throws Exception {
return false;
}
}

View File

@ -1,2 +0,0 @@
liteflow.rule-source=fallback/flow.el.xml
liteflow.fallback-cmp-enable=true

View File

@ -1,136 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<!-- THEN 普通组件降级 -->
<chain name="then1">
THEN(a, node("x"));
</chain>
<chain name="then2">
THEN(PRE(node("x1")), node("x2"), FINALLY(node("x3")));
</chain>
<!-- WHEN 普通组件降级 -->
<chain name="when1">
WHEN(b, node("x"));
</chain>
<!-- IF 条件组件降级 -->
<chain name="if1">
IF(node("x"), a)
</chain>
<!-- IF 普通组件降级 -->
<chain name="if2">
IF(ifn1, node("x"))
</chain>
<!-- FOR 次数循环组件降级 -->
<chain name="for1">
FOR(node("x")).DO(a);
</chain>
<!-- FOR 普通组件降级 -->
<chain name="for2">
FOR(3).DO(node("x"));
</chain>
<!-- WHILE 条件循环组件降级 -->
<chain name="while1">
WHILE(node("x")).DO(a)
</chain>
<!-- WHILE 普通组件降级 -->
<chain name="while2">
WHILE(wn1).DO(node("x"))
</chain>
<!-- ITERATOR 迭代组件降级 -->
<chain name="iterator1">
ITERATOR(node("x")).DO(a)
</chain>
<!-- ITERATOR 普通组件降级 -->
<chain name="iterator2">
ITERATOR(itn1).DO(node("x"))
</chain>
<!-- BREAK 退出循环组件降级 -->
<chain name="break1">
FOR(3).DO(a).BREAK(node("x"));
</chain>
<chain name="break2">
WHILE(wn1).DO(a).BREAK(node("x"));
</chain>
<chain name="break3">
ITERATOR(itn1).DO(a).BREAK(node("x"));
</chain>
<!-- SWITCH 选择组件降级 -->
<chain name="switch1">
SWITCH(node("x")).to(a,b);
</chain>
<!-- SWITCH 普通组件降级 -->
<chain name="switch2">
SWITCH(swn1).to(node("x"),a);
</chain>
<!-- AND 条件组件降级 -->
<chain name="and1">
IF(AND(node("x"),ifn1), a);
</chain>
<!-- OR 条件组件降级 -->
<chain name="or1">
IF(OR(node("x"),ifn1), a);
</chain>
<!-- NOT 条件组件降级 -->
<chain name="not1">
IF(NOT(node("x")), a);
</chain>
<!-- CATCH 普通组件降级 -->
<chain name="catch1">
CATCH(THEN(a, d)).DO(node("x"))
</chain>
<!-- 多个组件降级 -->
<chain name="multi1">
THEN(
a,
node("x1"),
IF(node("x2"), b)
);
</chain>
<chain name="multi2">
IF(
OR(node("x1"), ifn1),
THEN(a, node("x2"))
);
</chain>
<chain name="multi3">
FOR(node("x1")).DO(
THEN(b, node("x2"))
);
</chain>
<!-- 并发降级测试 -->
<chain name="concurrent1">
WHEN(
THEN(node("x1")),
IF(node("x2"), b)
).maxWaitSeconds(10000);
</chain>
<chain name="concurrent2">
WHEN(
node("x1"),
IF(node("x2"), b)
).maxWaitSeconds(10000);
</chain>
</flow>

View File

@ -19,6 +19,11 @@
<artifactId>liteflow-core</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-el-builder</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>

View File

@ -1,5 +1,8 @@
package com.yomahub.liteflow.test.fallback;
import com.yomahub.liteflow.builder.el.ELBus;
import com.yomahub.liteflow.builder.el.ELWrapper;
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.core.FlowExecutorHolder;
import com.yomahub.liteflow.flow.LiteflowResponse;
@ -33,14 +36,14 @@ public class FallbackTest extends BaseTest {
public void testThen1() {
LiteflowResponse response = flowExecutor.execute2Resp("then1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testThen2() {
LiteflowResponse response = flowExecutor.execute2Resp("then2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_comm_cmp==>fb_comm_cmp==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
@ -48,147 +51,112 @@ public class FallbackTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("when1", "arg");
Assertions.assertTrue(response.isSuccess());
String executeStepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("b==>c".equals(executeStepStr) || "c==>b".equals(executeStepStr));
Assertions.assertTrue("b==>fb_comm_cmp".equals(executeStepStr) || "fb_comm_cmp==>b".equals(executeStepStr));
}
@Test
public void testIf1() {
LiteflowResponse response = flowExecutor.execute2Resp("if1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIf2() {
LiteflowResponse response = flowExecutor.execute2Resp("if2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn1==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("ifn1==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testFor1() {
LiteflowResponse response = flowExecutor.execute2Resp("for1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("for1==>a==>a==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_for_cmp==>a==>a==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testFor2() {
LiteflowResponse response = flowExecutor.execute2Resp("for2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_3==>c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("LOOP_3==>fb_comm_cmp==>fb_comm_cmp==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhile1() {
LiteflowResponse response = flowExecutor.execute2Resp("while1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhile2() {
LiteflowResponse response = flowExecutor.execute2Resp("while2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn1==>c==>wn1==>c==>wn1==>c==>wn1", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIterator1() {
LiteflowResponse response = flowExecutor.execute2Resp("iterator1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIterator2() {
LiteflowResponse response = flowExecutor.execute2Resp("iterator2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn1==>c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_iter_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak1() {
LiteflowResponse response = flowExecutor.execute2Resp("break1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_3==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak2() {
LiteflowResponse response = flowExecutor.execute2Resp("break2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn1==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak3() {
LiteflowResponse response = flowExecutor.execute2Resp("break3", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn1==>a==>bn1", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("LOOP_3==>a==>fb_bool_cmp==>a==>fb_bool_cmp==>a==>fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testSwitch1() {
LiteflowResponse response = flowExecutor.execute2Resp("switch1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("swn2==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testSwitch2() {
LiteflowResponse response = flowExecutor.execute2Resp("switch2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("swn1==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_sw_cmp==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testAnd1() {
LiteflowResponse response = flowExecutor.execute2Resp("and1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testOr1() {
LiteflowResponse response = flowExecutor.execute2Resp("or1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>ifn1==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>ifn1==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testNot1() {
LiteflowResponse response = flowExecutor.execute2Resp("not1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testCatch1() {
LiteflowResponse response = flowExecutor.execute2Resp("catch1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>d==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>d==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti1() {
LiteflowResponse response = flowExecutor.execute2Resp("multi1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>c==>ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>fb_comm_cmp==>fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti2() {
LiteflowResponse response = flowExecutor.execute2Resp("multi2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>ifn1==>a==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>ifn1==>a==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti3() {
LiteflowResponse response = flowExecutor.execute2Resp("multi3", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("for1==>b==>c==>b==>c==>b==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_for_cmp==>b==>fb_comm_cmp==>b==>fb_comm_cmp==>b==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
@ -196,7 +164,7 @@ public class FallbackTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("concurrent1", "arg");
Assertions.assertTrue(response.isSuccess());
String stepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr) || "ifn2==>c".equals(stepStr));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr));
}
@Test
@ -204,7 +172,7 @@ public class FallbackTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("concurrent2", "arg");
Assertions.assertTrue(response.isSuccess());
String stepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr) || "ifn2==>c".equals(stepStr));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr) || "ifn2==>c".equals(stepStr));
}
@Test
@ -217,9 +185,18 @@ public class FallbackTest extends BaseTest {
LiteflowResponse response2 = future2.get();
Assertions.assertTrue(response1.isSuccess());
String stepStr1 = response1.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr1) || "ifn2==>c".equals(stepStr1));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr1) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr1));
Assertions.assertTrue(response2.isSuccess());
String stepStr2 = response2.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr2) || "ifn2==>c".equals(stepStr2));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr2) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr2));
}
@Test
public void testWithElBuild(){
ELWrapper el = ELBus.then("a", "b", "az");
LiteFlowChainELBuilder.createChain().setChainId("elBuilder").setEL(el.toEL()).build();
LiteflowResponse response = flowExecutor.execute2Resp("elBuilder");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
}

View File

@ -4,7 +4,7 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@FallbackCmp
public class IfCmp2 extends NodeBooleanComponent {
public class BooleanFBCmp extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {

View File

@ -1,13 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@FallbackCmp
public class BreakCmp extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {
return true;
}
}

View File

@ -4,7 +4,7 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.core.NodeComponent;
@FallbackCmp
public class CCmp extends NodeComponent {
public class CommonFBCmp extends NodeComponent {
@Override
public void process() {

View File

@ -4,7 +4,7 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.core.NodeForComponent;
@FallbackCmp
public class ForCmp extends NodeForComponent {
public class ForFBCmp extends NodeForComponent {
@Override
public int processFor() throws Exception {

View File

@ -7,7 +7,7 @@ import java.util.Collections;
import java.util.Iterator;
@FallbackCmp
public class IteratorCmp2 extends NodeIteratorComponent {
public class IterFBCmp extends NodeIteratorComponent {
@Override
public Iterator<?> processIterator() throws Exception {

View File

@ -4,7 +4,7 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.core.NodeSwitchComponent;
@FallbackCmp
public class SwitchCmp2 extends NodeSwitchComponent {
public class SwFBCmp extends NodeSwitchComponent {
@Override
public String processSwitch() throws Exception {

View File

@ -1,13 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@FallbackCmp
public class WhileCmp2 extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {
return false;
}
}

View File

@ -3,25 +3,23 @@
<nodes>
<node id = "a" class="com.yomahub.liteflow.test.fallback.cmp.ACmp"/>
<node id = "b" class="com.yomahub.liteflow.test.fallback.cmp.BCmp"/>
<node id = "c" class="com.yomahub.liteflow.test.fallback.cmp.CCmp"/>
<node id = "d" class="com.yomahub.liteflow.test.fallback.cmp.DCmp"/>
<node id = "fb_bool_cmp" class="com.yomahub.liteflow.test.fallback.cmp.BooleanFBCmp"/>
<node id = "fb_comm_cmp" class="com.yomahub.liteflow.test.fallback.cmp.CommonFBCmp"/>
<node id = "fb_for_cmp" class="com.yomahub.liteflow.test.fallback.cmp.ForFBCmp"/>
<node id = "ifn1" class="com.yomahub.liteflow.test.fallback.cmp.IfCmp1"/>
<node id = "ifn2" class="com.yomahub.liteflow.test.fallback.cmp.IfCmp2"/>
<node id = "swn1" class="com.yomahub.liteflow.test.fallback.cmp.SwitchCmp1"/>
<node id = "swn2" class="com.yomahub.liteflow.test.fallback.cmp.SwitchCmp2"/>
<node id = "for1" class="com.yomahub.liteflow.test.fallback.cmp.ForCmp"/>
<node id = "wn1" class="com.yomahub.liteflow.test.fallback.cmp.WhileCmp1"/>
<node id = "wn2" class="com.yomahub.liteflow.test.fallback.cmp.WhileCmp2"/>
<node id = "itn1" class="com.yomahub.liteflow.test.fallback.cmp.IteratorCmp1"/>
<node id = "itn2" class="com.yomahub.liteflow.test.fallback.cmp.IteratorCmp2"/>
<node id = "bn1" class="com.yomahub.liteflow.test.fallback.cmp.BreakCmp"/>
<node id = "fb_iter_cmp" class="com.yomahub.liteflow.test.fallback.cmp.IterFBCmp"/>
<node id = "fb_sw_cmp" class="com.yomahub.liteflow.test.fallback.cmp.SwFBCmp"/>
<node id = "swn1" class="com.yomahub.liteflow.test.fallback.cmp.SwitchCmp1"/>
<node id = "wn1" class="com.yomahub.liteflow.test.fallback.cmp.WhileCmp1"/>
</nodes>
<!-- THEN 普通组件降级 -->
<chain name="then1">
THEN(a, node("x"));
</chain>
<chain name="then2">
THEN(PRE(node("x1")), node("x2"), FINALLY(node("x3")));
</chain>
@ -35,119 +33,96 @@
<chain name="if1">
IF(node("x"), a)
</chain>
<!-- IF 普通组件降级 -->
<chain name="if2">
IF(ifn1, node("x"))
</chain>
<!-- FOR 次数循环组件降级 -->
<chain name="for1">
FOR(node("x")).DO(a);
</chain>
<!-- FOR 普通组件降级 -->
<chain name="for2">
FOR(3).DO(node("x"));
</chain>
<!-- WHILE 条件循环组件降级 -->
<chain name="while1">
WHILE(node("x")).DO(a)
</chain>
<!-- WHILE 普通组件降级 -->
<chain name="while2">
WHILE(wn1).DO(node("x"))
</chain>
<!-- ITERATOR 迭代组件降级 -->
<chain name="iterator1">
ITERATOR(node("x")).DO(a)
</chain>
<!-- ITERATOR 普通组件降级 -->
<chain name="iterator2">
ITERATOR(itn1).DO(node("x"))
</chain>
<!-- BREAK 退出循环组件降级 -->
<chain name="break1">
FOR(3).DO(a).BREAK(node("x"));
</chain>
<chain name="break2">
WHILE(wn1).DO(a).BREAK(node("x"));
</chain>
<chain name="break3">
ITERATOR(itn1).DO(a).BREAK(node("x"));
</chain>
<!-- SWITCH 选择组件降级 -->
<chain name="switch1">
SWITCH(node("x")).to(a,b);
</chain>
<!-- SWITCH 普通组件降级 -->
<chain name="switch2">
SWITCH(swn1).to(node("x"),a);
</chain>
<!-- AND 条件组件降级 -->
<chain name="and1">
IF(AND(node("x"),ifn1), a);
</chain>
<!-- OR 条件组件降级 -->
<chain name="or1">
IF(OR(node("x"),ifn1), a);
</chain>
<!-- NOT 条件组件降级 -->
<chain name="not1">
IF(NOT(node("x")), a);
</chain>
<!-- CATCH 普通组件降级 -->
<chain name="catch1">
CATCH(THEN(a, d)).DO(node("x"))
CATCH(THEN(a, d)).DO(node("x"))
</chain>
<!-- 多个组件降级 -->
<chain name="multi1">
THEN(
a,
node("x1"),
IF(node("x2"), b)
a,
node("x1"),
IF(node("x2"), b)
);
</chain>
<chain name="multi2">
IF(
OR(node("x1"), ifn1),
THEN(a, node("x2"))
OR(node("x1"), ifn1),
THEN(a, node("x2"))
);
</chain>
<chain name="multi3">
FOR(node("x1")).DO(
THEN(b, node("x2"))
THEN(b, node("x2"))
);
</chain>
<!-- 并发降级测试 -->
<chain name="concurrent1">
WHEN(
THEN(node("x1")),
IF(node("x2"), b)
THEN(node("x1")),
IF(node("x2"), b)
).maxWaitSeconds(10000);
</chain>
<chain name="concurrent2">
WHEN(
node("x1"),
IF(node("x2"), b)
node("x1"),
IF(node("x2"), b)
).maxWaitSeconds(10000);
</chain>
</flow>

View File

@ -19,6 +19,12 @@
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-el-builder</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-test-junit5</artifactId>

View File

@ -1,5 +1,8 @@
package com.yomahub.liteflow.test.fallback;
import com.yomahub.liteflow.builder.el.ELBus;
import com.yomahub.liteflow.builder.el.ELWrapper;
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;
@ -30,14 +33,14 @@ public class FallbackELSolonTest extends BaseTest {
public void testThen1() {
LiteflowResponse response = flowExecutor.execute2Resp("then1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testThen2() {
LiteflowResponse response = flowExecutor.execute2Resp("then2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_comm_cmp==>fb_comm_cmp==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
@ -45,147 +48,112 @@ public class FallbackELSolonTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("when1", "arg");
Assertions.assertTrue(response.isSuccess());
String executeStepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("b==>c".equals(executeStepStr) || "c==>b".equals(executeStepStr));
Assertions.assertTrue("b==>fb_comm_cmp".equals(executeStepStr) || "fb_comm_cmp==>b".equals(executeStepStr));
}
@Test
public void testIf1() {
LiteflowResponse response = flowExecutor.execute2Resp("if1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIf2() {
LiteflowResponse response = flowExecutor.execute2Resp("if2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn1==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("ifn1==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testFor1() {
LiteflowResponse response = flowExecutor.execute2Resp("for1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("for1==>a==>a==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_for_cmp==>a==>a==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testFor2() {
LiteflowResponse response = flowExecutor.execute2Resp("for2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_3==>c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("LOOP_3==>fb_comm_cmp==>fb_comm_cmp==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhile1() {
LiteflowResponse response = flowExecutor.execute2Resp("while1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhile2() {
LiteflowResponse response = flowExecutor.execute2Resp("while2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn1==>c==>wn1==>c==>wn1==>c==>wn1", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIterator1() {
LiteflowResponse response = flowExecutor.execute2Resp("iterator1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIterator2() {
LiteflowResponse response = flowExecutor.execute2Resp("iterator2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn1==>c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_iter_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak1() {
LiteflowResponse response = flowExecutor.execute2Resp("break1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_3==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak2() {
LiteflowResponse response = flowExecutor.execute2Resp("break2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn1==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak3() {
LiteflowResponse response = flowExecutor.execute2Resp("break3", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn1==>a==>bn1", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("LOOP_3==>a==>fb_bool_cmp==>a==>fb_bool_cmp==>a==>fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testSwitch1() {
LiteflowResponse response = flowExecutor.execute2Resp("switch1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("swn2==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testSwitch2() {
LiteflowResponse response = flowExecutor.execute2Resp("switch2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("swn1==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_sw_cmp==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testAnd1() {
LiteflowResponse response = flowExecutor.execute2Resp("and1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testOr1() {
LiteflowResponse response = flowExecutor.execute2Resp("or1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>ifn1==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>ifn1==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testNot1() {
LiteflowResponse response = flowExecutor.execute2Resp("not1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testCatch1() {
LiteflowResponse response = flowExecutor.execute2Resp("catch1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>d==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>d==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti1() {
LiteflowResponse response = flowExecutor.execute2Resp("multi1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>c==>ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>fb_comm_cmp==>fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti2() {
LiteflowResponse response = flowExecutor.execute2Resp("multi2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>ifn1==>a==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>ifn1==>a==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti3() {
LiteflowResponse response = flowExecutor.execute2Resp("multi3", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("for1==>b==>c==>b==>c==>b==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_for_cmp==>b==>fb_comm_cmp==>b==>fb_comm_cmp==>b==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
@ -193,7 +161,7 @@ public class FallbackELSolonTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("concurrent1", "arg");
Assertions.assertTrue(response.isSuccess());
String stepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr) || "ifn2==>c".equals(stepStr));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr));
}
@Test
@ -201,7 +169,7 @@ public class FallbackELSolonTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("concurrent2", "arg");
Assertions.assertTrue(response.isSuccess());
String stepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr) || "ifn2==>c".equals(stepStr));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr) || "ifn2==>c".equals(stepStr));
}
@Test
@ -214,9 +182,18 @@ public class FallbackELSolonTest extends BaseTest {
LiteflowResponse response2 = future2.get();
Assertions.assertTrue(response1.isSuccess());
String stepStr1 = response1.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr1) || "ifn2==>c".equals(stepStr1));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr1) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr1));
Assertions.assertTrue(response2.isSuccess());
String stepStr2 = response2.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr2) || "ifn2==>c".equals(stepStr2));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr2) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr2));
}
@Test
public void testWithElBuild(){
ELWrapper el = ELBus.then("a", "b", "az");
LiteFlowChainELBuilder.createChain().setChainId("elBuilder").setEL(el.toEL()).build();
LiteflowResponse response = flowExecutor.execute2Resp("elBuilder");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
}

View File

@ -4,9 +4,9 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@LiteflowComponent("ifn2")
@LiteflowComponent("fb_bool_cmp")
@FallbackCmp
public class IfCmp2 extends NodeBooleanComponent {
public class BooleanFBCmp extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {

View File

@ -1,15 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@LiteflowComponent("bn1")
@FallbackCmp
public class BreakCmp extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {
return true;
}
}

View File

@ -4,9 +4,9 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("c")
@LiteflowComponent("fb_comm_cmp")
@FallbackCmp
public class CCmp extends NodeComponent {
public class CommonFBCmp extends NodeComponent {
@Override
public void process() {

View File

@ -4,9 +4,9 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeForComponent;
@LiteflowComponent("for1")
@LiteflowComponent("fb_for_cmp")
@FallbackCmp
public class ForCmp extends NodeForComponent {
public class ForFBCmp extends NodeForComponent {
@Override
public int processFor() throws Exception {

View File

@ -7,9 +7,9 @@ import com.yomahub.liteflow.core.NodeIteratorComponent;
import java.util.Collections;
import java.util.Iterator;
@LiteflowComponent("itn2")
@LiteflowComponent("fb_iter_cmp")
@FallbackCmp
public class IteratorCmp2 extends NodeIteratorComponent {
public class IterFBCmp extends NodeIteratorComponent {
@Override
public Iterator<?> processIterator() throws Exception {

View File

@ -4,9 +4,9 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeSwitchComponent;
@LiteflowComponent("swn2")
@LiteflowComponent("fb_sw_cmp")
@FallbackCmp
public class SwitchCmp2 extends NodeSwitchComponent {
public class SwFBCmp extends NodeSwitchComponent {
@Override
public String processSwitch() throws Exception {

View File

@ -1,15 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@LiteflowComponent("wn2")
@FallbackCmp
public class WhileCmp2 extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {
return false;
}
}

View File

@ -4,7 +4,7 @@
<chain name="then1">
THEN(a, node("x"));
</chain>
<chain name="then2">
THEN(PRE(node("x1")), node("x2"), FINALLY(node("x3")));
</chain>
@ -18,119 +18,96 @@
<chain name="if1">
IF(node("x"), a)
</chain>
<!-- IF 普通组件降级 -->
<chain name="if2">
IF(ifn1, node("x"))
</chain>
<!-- FOR 次数循环组件降级 -->
<chain name="for1">
FOR(node("x")).DO(a);
</chain>
<!-- FOR 普通组件降级 -->
<chain name="for2">
FOR(3).DO(node("x"));
</chain>
<!-- WHILE 条件循环组件降级 -->
<chain name="while1">
WHILE(node("x")).DO(a)
</chain>
<!-- WHILE 普通组件降级 -->
<chain name="while2">
WHILE(wn1).DO(node("x"))
</chain>
<!-- ITERATOR 迭代组件降级 -->
<chain name="iterator1">
ITERATOR(node("x")).DO(a)
</chain>
<!-- ITERATOR 普通组件降级 -->
<chain name="iterator2">
ITERATOR(itn1).DO(node("x"))
</chain>
<!-- BREAK 退出循环组件降级 -->
<chain name="break1">
FOR(3).DO(a).BREAK(node("x"));
</chain>
<chain name="break2">
WHILE(wn1).DO(a).BREAK(node("x"));
</chain>
<chain name="break3">
ITERATOR(itn1).DO(a).BREAK(node("x"));
</chain>
<!-- SWITCH 选择组件降级 -->
<chain name="switch1">
SWITCH(node("x")).to(a,b);
</chain>
<!-- SWITCH 普通组件降级 -->
<chain name="switch2">
SWITCH(swn1).to(node("x"),a);
</chain>
<!-- AND 条件组件降级 -->
<chain name="and1">
IF(AND(node("x"),ifn1), a);
</chain>
<!-- OR 条件组件降级 -->
<chain name="or1">
IF(OR(node("x"),ifn1), a);
</chain>
<!-- NOT 条件组件降级 -->
<chain name="not1">
IF(NOT(node("x")), a);
</chain>
<!-- CATCH 普通组件降级 -->
<chain name="catch1">
CATCH(THEN(a, d)).DO(node("x"))
CATCH(THEN(a, d)).DO(node("x"))
</chain>
<!-- 多个组件降级 -->
<chain name="multi1">
THEN(
a,
node("x1"),
IF(node("x2"), b)
a,
node("x1"),
IF(node("x2"), b)
);
</chain>
<chain name="multi2">
IF(
OR(node("x1"), ifn1),
THEN(a, node("x2"))
OR(node("x1"), ifn1),
THEN(a, node("x2"))
);
</chain>
<chain name="multi3">
FOR(node("x1")).DO(
THEN(b, node("x2"))
THEN(b, node("x2"))
);
</chain>
<!-- 并发降级测试 -->
<chain name="concurrent1">
WHEN(
THEN(node("x1")),
IF(node("x2"), b)
THEN(node("x1")),
IF(node("x2"), b)
).maxWaitSeconds(10000);
</chain>
<chain name="concurrent2">
WHEN(
node("x1"),
IF(node("x2"), b)
node("x1"),
IF(node("x2"), b)
).maxWaitSeconds(10000);
</chain>
</flow>

View File

@ -19,6 +19,12 @@
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-el-builder</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>

View File

@ -1,5 +1,8 @@
package com.yomahub.liteflow.test.fallback;
import com.yomahub.liteflow.builder.el.ELBus;
import com.yomahub.liteflow.builder.el.ELWrapper;
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;
@ -29,14 +32,14 @@ public class FallbackELSpringTest extends BaseTest {
public void testThen1() {
LiteflowResponse response = flowExecutor.execute2Resp("then1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testThen2() {
LiteflowResponse response = flowExecutor.execute2Resp("then2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_comm_cmp==>fb_comm_cmp==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
@ -44,147 +47,112 @@ public class FallbackELSpringTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("when1", "arg");
Assertions.assertTrue(response.isSuccess());
String executeStepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("b==>c".equals(executeStepStr) || "c==>b".equals(executeStepStr));
Assertions.assertTrue("b==>fb_comm_cmp".equals(executeStepStr) || "fb_comm_cmp==>b".equals(executeStepStr));
}
@Test
public void testIf1() {
LiteflowResponse response = flowExecutor.execute2Resp("if1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIf2() {
LiteflowResponse response = flowExecutor.execute2Resp("if2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn1==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("ifn1==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testFor1() {
LiteflowResponse response = flowExecutor.execute2Resp("for1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("for1==>a==>a==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_for_cmp==>a==>a==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testFor2() {
LiteflowResponse response = flowExecutor.execute2Resp("for2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_3==>c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("LOOP_3==>fb_comm_cmp==>fb_comm_cmp==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhile1() {
LiteflowResponse response = flowExecutor.execute2Resp("while1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testWhile2() {
LiteflowResponse response = flowExecutor.execute2Resp("while2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn1==>c==>wn1==>c==>wn1==>c==>wn1", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIterator1() {
LiteflowResponse response = flowExecutor.execute2Resp("iterator1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn2", response.getExecuteStepStrWithoutTime());
}
@Test
public void testIterator2() {
LiteflowResponse response = flowExecutor.execute2Resp("iterator2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn1==>c==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_iter_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak1() {
LiteflowResponse response = flowExecutor.execute2Resp("break1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_3==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak2() {
LiteflowResponse response = flowExecutor.execute2Resp("break2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("wn1==>a==>bn1", response.getExecuteStepStrWithoutTime());
}
@Test
public void testBreak3() {
LiteflowResponse response = flowExecutor.execute2Resp("break3", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("itn1==>a==>bn1", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("LOOP_3==>a==>fb_bool_cmp==>a==>fb_bool_cmp==>a==>fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testSwitch1() {
LiteflowResponse response = flowExecutor.execute2Resp("switch1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("swn2==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testSwitch2() {
LiteflowResponse response = flowExecutor.execute2Resp("switch2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("swn1==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_sw_cmp==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testAnd1() {
LiteflowResponse response = flowExecutor.execute2Resp("and1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testOr1() {
LiteflowResponse response = flowExecutor.execute2Resp("or1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>ifn1==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>ifn1==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testNot1() {
LiteflowResponse response = flowExecutor.execute2Resp("not1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>a", response.getExecuteStepStrWithoutTime());
}
@Test
public void testCatch1() {
LiteflowResponse response = flowExecutor.execute2Resp("catch1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>d==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>d==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti1() {
LiteflowResponse response = flowExecutor.execute2Resp("multi1", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>c==>ifn2", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>fb_comm_cmp==>fb_bool_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti2() {
LiteflowResponse response = flowExecutor.execute2Resp("multi2", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("ifn2==>ifn1==>a==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_bool_cmp==>ifn1==>a==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
public void testMulti3() {
LiteflowResponse response = flowExecutor.execute2Resp("multi3", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("for1==>b==>c==>b==>c==>b==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("fb_for_cmp==>b==>fb_comm_cmp==>b==>fb_comm_cmp==>b==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
@Test
@ -192,7 +160,7 @@ public class FallbackELSpringTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("concurrent1", "arg");
Assertions.assertTrue(response.isSuccess());
String stepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr) || "ifn2==>c".equals(stepStr));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr));
}
@Test
@ -200,7 +168,7 @@ public class FallbackELSpringTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("concurrent2", "arg");
Assertions.assertTrue(response.isSuccess());
String stepStr = response.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr) || "ifn2==>c".equals(stepStr));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr) || "ifn2==>c".equals(stepStr));
}
@Test
@ -213,9 +181,18 @@ public class FallbackELSpringTest extends BaseTest {
LiteflowResponse response2 = future2.get();
Assertions.assertTrue(response1.isSuccess());
String stepStr1 = response1.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr1) || "ifn2==>c".equals(stepStr1));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr1) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr1));
Assertions.assertTrue(response2.isSuccess());
String stepStr2 = response2.getExecuteStepStrWithoutTime();
Assertions.assertTrue("c==>ifn2".equals(stepStr2) || "ifn2==>c".equals(stepStr2));
Assertions.assertTrue("fb_comm_cmp==>fb_bool_cmp".equals(stepStr2) || "fb_bool_cmp==>fb_comm_cmp".equals(stepStr2));
}
@Test
public void testWithElBuild(){
ELWrapper el = ELBus.then("a", "b", "az");
LiteFlowChainELBuilder.createChain().setChainId("elBuilder").setEL(el.toEL()).build();
LiteflowResponse response = flowExecutor.execute2Resp("elBuilder");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>fb_comm_cmp", response.getExecuteStepStrWithoutTime());
}
}

View File

@ -4,9 +4,9 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@LiteflowComponent("ifn2")
@LiteflowComponent("fb_bool_cmp")
@FallbackCmp
public class IfCmp2 extends NodeBooleanComponent {
public class BooleanFBCmp extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {

View File

@ -1,15 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@LiteflowComponent("bn1")
@FallbackCmp
public class BreakCmp extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {
return true;
}
}

View File

@ -4,9 +4,9 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("c")
@LiteflowComponent("fb_comm_cmp")
@FallbackCmp
public class CCmp extends NodeComponent {
public class CommonFBCmp extends NodeComponent {
@Override
public void process() {

View File

@ -4,9 +4,9 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeForComponent;
@LiteflowComponent("for1")
@LiteflowComponent("fb_for_cmp")
@FallbackCmp
public class ForCmp extends NodeForComponent {
public class ForFBCmp extends NodeForComponent {
@Override
public int processFor() throws Exception {

View File

@ -7,9 +7,9 @@ import com.yomahub.liteflow.core.NodeIteratorComponent;
import java.util.Collections;
import java.util.Iterator;
@LiteflowComponent("itn2")
@LiteflowComponent("fb_iter_cmp")
@FallbackCmp
public class IteratorCmp2 extends NodeIteratorComponent {
public class IterFBCmp extends NodeIteratorComponent {
@Override
public Iterator<?> processIterator() throws Exception {

View File

@ -4,9 +4,9 @@ import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeSwitchComponent;
@LiteflowComponent("swn2")
@LiteflowComponent("fb_sw_cmp")
@FallbackCmp
public class SwitchCmp2 extends NodeSwitchComponent {
public class SwFBCmp extends NodeSwitchComponent {
@Override
public String processSwitch() throws Exception {

View File

@ -1,15 +0,0 @@
package com.yomahub.liteflow.test.fallback.cmp;
import com.yomahub.liteflow.annotation.FallbackCmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeBooleanComponent;
@LiteflowComponent("wn2")
@FallbackCmp
public class WhileCmp2 extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {
return false;
}
}

View File

@ -4,7 +4,7 @@
<chain name="then1">
THEN(a, node("x"));
</chain>
<chain name="then2">
THEN(PRE(node("x1")), node("x2"), FINALLY(node("x3")));
</chain>
@ -18,119 +18,96 @@
<chain name="if1">
IF(node("x"), a)
</chain>
<!-- IF 普通组件降级 -->
<chain name="if2">
IF(ifn1, node("x"))
</chain>
<!-- FOR 次数循环组件降级 -->
<chain name="for1">
FOR(node("x")).DO(a);
</chain>
<!-- FOR 普通组件降级 -->
<chain name="for2">
FOR(3).DO(node("x"));
</chain>
<!-- WHILE 条件循环组件降级 -->
<chain name="while1">
WHILE(node("x")).DO(a)
</chain>
<!-- WHILE 普通组件降级 -->
<chain name="while2">
WHILE(wn1).DO(node("x"))
</chain>
<!-- ITERATOR 迭代组件降级 -->
<chain name="iterator1">
ITERATOR(node("x")).DO(a)
</chain>
<!-- ITERATOR 普通组件降级 -->
<chain name="iterator2">
ITERATOR(itn1).DO(node("x"))
</chain>
<!-- BREAK 退出循环组件降级 -->
<chain name="break1">
FOR(3).DO(a).BREAK(node("x"));
</chain>
<chain name="break2">
WHILE(wn1).DO(a).BREAK(node("x"));
</chain>
<chain name="break3">
ITERATOR(itn1).DO(a).BREAK(node("x"));
</chain>
<!-- SWITCH 选择组件降级 -->
<chain name="switch1">
SWITCH(node("x")).to(a,b);
</chain>
<!-- SWITCH 普通组件降级 -->
<chain name="switch2">
SWITCH(swn1).to(node("x"),a);
</chain>
<!-- AND 条件组件降级 -->
<chain name="and1">
IF(AND(node("x"),ifn1), a);
</chain>
<!-- OR 条件组件降级 -->
<chain name="or1">
IF(OR(node("x"),ifn1), a);
</chain>
<!-- NOT 条件组件降级 -->
<chain name="not1">
IF(NOT(node("x")), a);
</chain>
<!-- CATCH 普通组件降级 -->
<chain name="catch1">
CATCH(THEN(a, d)).DO(node("x"))
CATCH(THEN(a, d)).DO(node("x"))
</chain>
<!-- 多个组件降级 -->
<chain name="multi1">
THEN(
a,
node("x1"),
IF(node("x2"), b)
a,
node("x1"),
IF(node("x2"), b)
);
</chain>
<chain name="multi2">
IF(
OR(node("x1"), ifn1),
THEN(a, node("x2"))
OR(node("x1"), ifn1),
THEN(a, node("x2"))
);
</chain>
<chain name="multi3">
FOR(node("x1")).DO(
THEN(b, node("x2"))
THEN(b, node("x2"))
);
</chain>
<!-- 并发降级测试 -->
<chain name="concurrent1">
WHEN(
THEN(node("x1")),
IF(node("x2"), b)
THEN(node("x1")),
IF(node("x2"), b)
).maxWaitSeconds(10000);
</chain>
<chain name="concurrent2">
WHEN(
node("x1"),
IF(node("x2"), b)
node("x1"),
IF(node("x2"), b)
).maxWaitSeconds(10000);
</chain>
</flow>