Browse Source

增加了新的rollback测试用例

rain 1 year ago
parent
commit
05492fc198
43 changed files with 1086 additions and 40 deletions
  1. 51 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/rollback/RollbackELDeclMultiSpringbootTest.java
  2. 71 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/CmpConfig.java
  3. 24 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/rollback/flow.el.xml
  4. 46 5
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/RollbackELDeclSpringbootTest.java
  5. 13 23
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java
  6. 19 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java
  7. 19 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java
  8. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java
  9. 19 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java
  10. 18 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java
  11. 22 2
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/rollback/flow.el.xml
  12. 51 2
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/RollbackTest.java
  13. 17 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java
  14. 17 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java
  15. 17 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java
  16. 21 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java
  17. 17 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java
  18. 16 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java
  19. 30 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/rollback/flow.el.xml
  20. 52 2
      liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/RollbackSpringbootTest.java
  21. 19 0
      liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java
  22. 19 0
      liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java
  23. 19 0
      liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java
  24. 23 0
      liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java
  25. 19 0
      liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java
  26. 18 0
      liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java
  27. 24 0
      liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/rollback/flow.el.xml
  28. 50 2
      liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/RollbackSpringbootTest.java
  29. 19 0
      liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java
  30. 19 0
      liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java
  31. 19 0
      liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java
  32. 23 0
      liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java
  33. 19 0
      liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java
  34. 18 0
      liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java
  35. 24 0
      liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/rollback/flow.el.xml
  36. 51 2
      liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/RollbackSpringTest.java
  37. 19 0
      liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java
  38. 19 0
      liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java
  39. 19 0
      liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java
  40. 23 0
      liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java
  41. 19 0
      liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java
  42. 18 0
      liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java
  43. 23 0
      liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/rollback/flow.el.xml

+ 51 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/rollback/RollbackELDeclMultiSpringbootTest.java

@@ -33,12 +33,61 @@ public class RollbackELDeclMultiSpringbootTest extends BaseTest {
 		Assertions.assertEquals("", response.getRollbackStepStr());
 	}
 
-	// 测试产生异常之后的回滚顺序
+	// 对串行编排与并行编排语法的测试
 	@Test
-	public void testRollbackStep() throws Exception {
+	public void testWhenAndThen() throws Exception {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
 		Assertions.assertFalse(response.isSuccess());
 		Assertions.assertEquals("d==>b==>a", response.getRollbackStepStr());
 	}
 
+	// 对条件编排语法的测试
+	@Test
+	public void testIf() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>x", response.getRollbackStepStr());
+	}
+
+	// 对选择编排语法的测试
+	@Test
+	public void testSwitch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>f", response.getRollbackStepStr());
+	}
+
+	// 对FOR循环编排语法的测试
+	@Test
+	public void testFor() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("h==>b==>g", response.getRollbackStepStr());
+	}
+
+	// 对WHILE循环编排语法的测试
+	@Test
+	public void testWhile() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>w", response.getRollbackStepStr());
+	}
+
+	// 对ITERATOR迭代循环编排语法的测试
+	@Test
+	public void testIterator() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>i", response.getRollbackStepStr());
+	}
+
+	@Test
+	// 对捕获异常表达式的测试
+	public void testCatch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg");
+		Assertions.assertTrue(response.isSuccess());
+		Assertions.assertNull(response.getCause());
+		Assertions.assertEquals("", response.getRollbackStepStr());
+	}
+
 }

+ 71 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/CmpConfig.java

@@ -1,9 +1,14 @@
 package com.yomahub.liteflow.test.rollback.cmp;
 
+import cn.hutool.core.collection.ListUtil;
 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.Iterator;
+import java.util.List;
 
 @LiteflowComponent
 public class CmpConfig {
@@ -62,4 +67,70 @@ public class CmpConfig {
         System.out.println("ECmp rollback!");
     }
 
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH, nodeId = "f", nodeType = NodeTypeEnum.SWITCH)
+    public String processF(NodeComponent bindCmp) {
+        System.out.println("FCmp executed!");
+        return "abc";
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.ROLLBACK, nodeId = "f", nodeType = NodeTypeEnum.SWITCH)
+    public void rollbackF() throws Exception {
+        System.out.println("FCmp rollback!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_FOR, nodeId = "g", nodeType = NodeTypeEnum.FOR)
+    public int processG(NodeComponent bindCmp) {
+        System.out.println("GCmp executed!");
+        return 3;
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.ROLLBACK, nodeId = "g", nodeType = NodeTypeEnum.FOR)
+    public void rollbackG() throws Exception {
+        System.out.println("GCmp rollback!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BREAK, nodeId = "h", nodeType = NodeTypeEnum.BREAK)
+    public int processH(NodeComponent bindCmp) {
+        System.out.println("HCmp executed!");
+        throw new RuntimeException();
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.ROLLBACK, nodeId = "h", nodeType = NodeTypeEnum.BREAK)
+    public void rollbackH() throws Exception {
+        System.out.println("HCmp rollback!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_ITERATOR, nodeId = "i", nodeType = NodeTypeEnum.ITERATOR)
+    public Iterator<?> processI(NodeComponent bindCmp) {
+        List<String> list = ListUtil.toList("jack", "mary", "tom");
+        return list.iterator();
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.ROLLBACK, nodeId = "i", nodeType = NodeTypeEnum.ITERATOR)
+    public void rollbackI() throws Exception {
+        System.out.println("ICmp rollback!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_WHILE, nodeId = "w", nodeType = NodeTypeEnum.WHILE)
+    public boolean processW(NodeComponent bindCmp) {
+        System.out.println("WCmp executed!");
+        return true;
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.ROLLBACK, nodeId = "w", nodeType = NodeTypeEnum.WHILE)
+    public void rollbackW() throws Exception {
+        System.out.println("WCmp rollback!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_IF, nodeId = "x", nodeType = NodeTypeEnum.IF)
+    public boolean processX(NodeComponent bindCmp) {
+        System.out.println("XCmp executed!");
+        return true;
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.ROLLBACK, nodeId = "x", nodeType = NodeTypeEnum.IF)
+    public void rollbackX() throws Exception {
+        System.out.println("XCmp rollback!");
+    }
+
 }

+ 24 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/rollback/flow.el.xml

@@ -7,4 +7,28 @@
     <chain name="chain2">
         THEN( a, b, WHEN(c, d) );
     </chain>
+
+    <chain name="chain3">
+        THEN( IF(x, d, a), CATCH(IF(x, d, a)) );
+    </chain>
+
+    <chain name="chain4">
+        SWITCH(f).TO(a, b).DEFAULT(d);
+    </chain>
+
+    <chain name="chain5">
+        FOR(g).DO(THEN(b, c)).BREAK(h);
+    </chain>
+
+    <chain name="chain6">
+        WHILE(w).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain7">
+        ITERATOR(i).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain8">
+        CATCH( THEN(b, c, d) ).DO(a);
+    </chain>
 </flow>

+ 46 - 5
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/RollbackELDeclSpringbootTest.java

@@ -35,20 +35,61 @@ public class RollbackELDeclSpringbootTest extends BaseTest {
 		Assertions.assertEquals("", response.getRollbackStepStr());
 	}
 
-	// 测试产生异常之后的回滚顺序
+	// 对串行编排与并行编排语法的测试
 	@Test
-	public void testRollbackStep() throws Exception {
+	public void testWhenAndThen() throws Exception {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
 		Assertions.assertFalse(response.isSuccess());
 		Assertions.assertEquals("d==>b==>a", response.getRollbackStepStr());
 	}
 
-	// 声明式组件测试
+	// 对条件编排语法的测试
 	@Test
-	public void testRollbackComponent() throws Exception {
+	public void testIf() throws Exception {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
 		Assertions.assertFalse(response.isSuccess());
-		Assertions.assertEquals("e==>a", response.getRollbackStepStr());
+		Assertions.assertEquals("d==>x", response.getRollbackStepStr());
+	}
+
+	// 对选择编排语法的测试
+	@Test
+	public void testSwitch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>f", response.getRollbackStepStr());
+	}
+
+	// 对FOR循环编排语法的测试
+	@Test
+	public void testFor() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("h==>b==>g", response.getRollbackStepStr());
+	}
+
+	// 对WHILE循环编排语法的测试
+	@Test
+	public void testWhile() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>w", response.getRollbackStepStr());
+	}
+
+	// 对ITERATOR迭代循环编排语法的测试
+	@Test
+	public void testIterator() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>i", response.getRollbackStepStr());
+	}
+
+	@Test
+	// 对捕获异常表达式的测试
+	public void testCatch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg");
+		Assertions.assertTrue(response.isSuccess());
+		Assertions.assertNull(response.getCause());
+		Assertions.assertEquals("", response.getRollbackStepStr());
 	}
 
 }

+ 13 - 23
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java

@@ -1,29 +1,19 @@
-/**
- * <p>Title: liteflow</p>
- * <p>Description: 轻量级的组件式流程框架</p>
- * @author Bryan.Zhang
- * @email weenyc31@163.com
- * @Date 2020/4/1
- */
 package com.yomahub.liteflow.test.rollback.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.core.NodeSwitchComponent;
+import org.springframework.stereotype.Component;
 
-@LiteflowComponent("f")
-@LiteflowCmpDefine
-public class FCmp {
+@Component("f")
+public class FCmp extends NodeSwitchComponent {
 
-	@LiteflowMethod(LiteFlowMethodEnum.PROCESS)
-	public void process(NodeComponent bindCmp) {
-		System.out.println("FCmp executed!");
-	}
+    @Override
+    public String processSwitch() {
+        System.out.println("FCmp executed!");
+        return "abc";
+    }
 
-	@LiteflowMethod(LiteFlowMethodEnum.ROLLBACK)
-	public void rollback(NodeComponent bindCmp) {
-		System.out.println("FCmp rollback!");
-	}
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("FCmp rollback!");
+    }
 }

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeForComponent;
+import org.springframework.stereotype.Component;
+
+@Component("g")
+public class GCmp extends NodeForComponent {
+
+    @Override
+    public int processFor() throws Exception {
+        System.out.println("GCmp executed!");
+        return 3;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("GCmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeBreakComponent;
+import org.springframework.stereotype.Component;
+
+@Component("h")
+public class HCmp extends NodeBreakComponent {
+
+    @Override
+    public boolean processBreak() throws Exception {
+        System.out.println("HCmp executed!");
+        throw new RuntimeException();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("HCmp rollback!");
+    }
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.NodeIteratorComponent;
+import org.springframework.stereotype.Component;
+
+import java.util.Iterator;
+import java.util.List;
+
+@Component("i")
+public class ICmp extends NodeIteratorComponent {
+
+    @Override
+    public Iterator<?> processIterator() throws Exception {
+        List<String> list = ListUtil.toList("jack", "mary", "tom");
+        return list.iterator();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("ICmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeWhileComponent;
+import org.springframework.stereotype.Component;
+
+@Component("w")
+public class WCmp extends NodeWhileComponent {
+
+    @Override
+    public boolean processWhile() throws Exception {
+        System.out.println("WCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("WCmp rollback!");
+    }
+}

+ 18 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java

@@ -0,0 +1,18 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeIfComponent;
+import org.springframework.stereotype.Component;
+
+@Component("x")
+public class XCmp extends NodeIfComponent {
+    @Override
+    public boolean processIf() throws Exception {
+        System.out.println("XCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("XCmp rollback!");
+    }
+}

+ 22 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/rollback/flow.el.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <flow>
     <chain name="chain1">
-        THEN( a, b, WHEN(c, d).ignoreError(true), CATCH(e), f );
+        THEN( a, b, WHEN(c, d).ignoreError(true), CATCH(e) );
     </chain>
 
     <chain name="chain2">
@@ -9,6 +9,26 @@
     </chain>
 
     <chain name="chain3">
-        THEN( a, e, f );
+        THEN( IF(x, d, a), CATCH(IF(x, d, a)) );
+    </chain>
+
+    <chain name="chain4">
+        SWITCH(f).TO(a, b).DEFAULT(d);
+    </chain>
+
+    <chain name="chain5">
+        FOR(g).DO(THEN(b, c)).BREAK(h);;
+    </chain>
+
+    <chain name="chain6">
+        WHILE(w).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain7">
+        ITERATOR(i).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain8">
+        CATCH( THEN(b, c, d) ).DO(a);
     </chain>
 </flow>

+ 51 - 2
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/RollbackTest.java

@@ -31,13 +31,62 @@ public class RollbackTest extends BaseTest {
 		Assertions.assertEquals("", response.getRollbackStepStr());
 	}
 
-	// 测试产生异常之后的回滚顺序
+	// 对串行编排与并行编排语法的测试
 	@Test
-	public void testRollbackStep() throws Exception {
+	public void testWhenAndThen() throws Exception {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
 		Assertions.assertFalse(response.isSuccess());
 		Assertions.assertEquals("d==>b==>a", response.getRollbackStepStr());
 	}
 
+	// 对条件编排语法的测试
+	@Test
+	public void testIf() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>x", response.getRollbackStepStr());
+	}
+
+	// 对选择编排语法的测试
+	@Test
+	public void testSwitch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>f", response.getRollbackStepStr());
+	}
+
+	// 对FOR循环编排语法的测试
+	@Test
+	public void testFor() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("h==>b==>g", response.getRollbackStepStr());
+	}
+
+	// 对WHILE循环编排语法的测试
+	@Test
+	public void testWhile() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>w", response.getRollbackStepStr());
+	}
+
+	// 对ITERATOR迭代循环编排语法的测试
+	@Test
+	public void testIterator() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>i", response.getRollbackStepStr());
+	}
+
+	@Test
+	// 对捕获异常表达式的测试
+	public void testCatch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg");
+		Assertions.assertTrue(response.isSuccess());
+		Assertions.assertNull(response.getCause());
+		Assertions.assertEquals("", response.getRollbackStepStr());
+	}
+
 
 }

+ 17 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java

@@ -0,0 +1,17 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeSwitchComponent;
+
+public class FCmp extends NodeSwitchComponent {
+
+    @Override
+    public String processSwitch() {
+        System.out.println("FCmp executed!");
+        return "abc";
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("FCmp rollback!");
+    }
+}

+ 17 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java

@@ -0,0 +1,17 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeForComponent;
+
+public class GCmp extends NodeForComponent {
+
+    @Override
+    public int processFor() throws Exception {
+        System.out.println("GCmp executed!");
+        return 3;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("GCmp rollback!");
+    }
+}

+ 17 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java

@@ -0,0 +1,17 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeBreakComponent;
+
+public class HCmp extends NodeBreakComponent {
+
+    @Override
+    public boolean processBreak() throws Exception {
+        System.out.println("HCmp executed!");
+        throw new RuntimeException();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("HCmp rollback!");
+    }
+}

+ 21 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java

@@ -0,0 +1,21 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.NodeIteratorComponent;
+
+import java.util.Iterator;
+import java.util.List;
+
+public class ICmp extends NodeIteratorComponent {
+
+    @Override
+    public Iterator<?> processIterator() throws Exception {
+        List<String> list = ListUtil.toList("jack", "mary", "tom");
+        return list.iterator();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("ICmp rollback!");
+    }
+}

+ 17 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java

@@ -0,0 +1,17 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeWhileComponent;
+
+public class WCmp extends NodeWhileComponent {
+
+    @Override
+    public boolean processWhile() throws Exception {
+        System.out.println("WCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("WCmp rollback!");
+    }
+}

+ 16 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java

@@ -0,0 +1,16 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeIfComponent;
+
+public class XCmp extends NodeIfComponent {
+    @Override
+    public boolean processIf() throws Exception {
+        System.out.println("XCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("XCmp rollback!");
+    }
+}

+ 30 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/rollback/flow.el.xml

@@ -6,6 +6,12 @@
         <node id="c" class="com.yomahub.liteflow.test.rollback.cmp.CCmp"/>
         <node id="d" class="com.yomahub.liteflow.test.rollback.cmp.DCmp"/>
         <node id="e" class="com.yomahub.liteflow.test.rollback.cmp.ECmp"/>
+        <node id="f" class="com.yomahub.liteflow.test.rollback.cmp.FCmp"/>
+        <node id="g" class="com.yomahub.liteflow.test.rollback.cmp.GCmp"/>
+        <node id="h" class="com.yomahub.liteflow.test.rollback.cmp.HCmp"/>
+        <node id="i" class="com.yomahub.liteflow.test.rollback.cmp.ICmp"/>
+        <node id="w" class="com.yomahub.liteflow.test.rollback.cmp.WCmp"/>
+        <node id="x" class="com.yomahub.liteflow.test.rollback.cmp.XCmp"/>
     </nodes>
     <chain name="chain1">
         THEN( a, b, WHEN(c, d).ignoreError(true), CATCH(e) );
@@ -14,4 +20,28 @@
     <chain name="chain2">
         THEN( a, b, WHEN(c, d) );
     </chain>
+
+    <chain name="chain3">
+        THEN( IF(x, d, a), CATCH(IF(x, d, a)) );
+    </chain>
+
+    <chain name="chain4">
+        SWITCH(f).TO(a, b).DEFAULT(d);
+    </chain>
+
+    <chain name="chain5">
+        FOR(g).DO(THEN(b, c)).BREAK(h);;
+    </chain>
+
+    <chain name="chain6">
+        WHILE(w).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain7">
+        ITERATOR(i).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain8">
+        CATCH( THEN(b, c, d) ).DO(a);
+    </chain>
 </flow>

+ 52 - 2
liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/RollbackSpringbootTest.java

@@ -10,6 +10,7 @@ import org.noear.solon.annotation.Inject;
 import org.noear.solon.test.SolonJUnit5Extension;
 import org.noear.solon.test.annotation.TestPropertySource;
 
+
 @ExtendWith(SolonJUnit5Extension.class)
 @TestPropertySource("classpath:/rollback/application.properties")
 public class RollbackSpringbootTest extends BaseTest {
@@ -26,12 +27,61 @@ public class RollbackSpringbootTest extends BaseTest {
 		Assertions.assertEquals("", response.getRollbackStepStr());
 	}
 
-	// 测试产生异常之后的回滚顺序
+	// 对串行编排与并行编排语法的测试
 	@Test
-	public void testRollbackStep() throws Exception {
+	public void testWhenAndThen() throws Exception {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
 		Assertions.assertFalse(response.isSuccess());
 		Assertions.assertEquals("d==>b==>a", response.getRollbackStepStr());
 	}
 
+	// 对条件编排语法的测试
+	@Test
+	public void testIf() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>x", response.getRollbackStepStr());
+	}
+
+	// 对选择编排语法的测试
+	@Test
+	public void testSwitch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>f", response.getRollbackStepStr());
+	}
+
+	// 对FOR循环编排语法的测试
+	@Test
+	public void testFor() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("h==>b==>g", response.getRollbackStepStr());
+	}
+
+	// 对WHILE循环编排语法的测试
+	@Test
+	public void testWhile() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>w", response.getRollbackStepStr());
+	}
+
+	// 对ITERATOR迭代循环编排语法的测试
+	@Test
+	public void testIterator() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>i", response.getRollbackStepStr());
+	}
+
+	@Test
+	// 对捕获异常表达式的测试
+	public void testCatch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg");
+		Assertions.assertTrue(response.isSuccess());
+		Assertions.assertNull(response.getCause());
+		Assertions.assertEquals("", response.getRollbackStepStr());
+	}
+
 }

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeSwitchComponent;
+import org.noear.solon.annotation.Component;
+
+@Component("f")
+public class FCmp extends NodeSwitchComponent {
+
+    @Override
+    public String processSwitch() {
+        System.out.println("FCmp executed!");
+        return "abc";
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("FCmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeForComponent;
+import org.noear.solon.annotation.Component;
+
+@Component("g")
+public class GCmp extends NodeForComponent {
+
+    @Override
+    public int processFor() throws Exception {
+        System.out.println("GCmp executed!");
+        return 3;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("GCmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeBreakComponent;
+import org.noear.solon.annotation.Component;
+
+@Component("h")
+public class HCmp extends NodeBreakComponent {
+
+    @Override
+    public boolean processBreak() throws Exception {
+        System.out.println("HCmp executed!");
+        throw new RuntimeException();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("HCmp rollback!");
+    }
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.NodeIteratorComponent;
+import org.noear.solon.annotation.Component;
+
+import java.util.Iterator;
+import java.util.List;
+
+@Component("i")
+public class ICmp extends NodeIteratorComponent {
+
+    @Override
+    public Iterator<?> processIterator() throws Exception {
+        List<String> list = ListUtil.toList("jack", "mary", "tom");
+        return list.iterator();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("ICmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeWhileComponent;
+import org.noear.solon.annotation.Component;
+
+@Component("w")
+public class WCmp extends NodeWhileComponent {
+
+    @Override
+    public boolean processWhile() throws Exception {
+        System.out.println("WCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("WCmp rollback!");
+    }
+}

+ 18 - 0
liteflow-testcase-el/liteflow-testcase-el-solon/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java

@@ -0,0 +1,18 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeIfComponent;
+import org.noear.solon.annotation.Component;;
+
+@Component("x")
+public class XCmp extends NodeIfComponent {
+    @Override
+    public boolean processIf() throws Exception {
+        System.out.println("XCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("XCmp rollback!");
+    }
+}

+ 24 - 0
liteflow-testcase-el/liteflow-testcase-el-solon/src/test/resources/rollback/flow.el.xml

@@ -7,4 +7,28 @@
     <chain name="chain2">
         THEN( a, b, WHEN(c, d) );
     </chain>
+
+    <chain name="chain3">
+        THEN( IF(x, d, a), CATCH(IF(x, d, a)) );
+    </chain>
+
+    <chain name="chain4">
+        SWITCH(f).TO(a, b).DEFAULT(d);
+    </chain>
+
+    <chain name="chain5">
+        FOR(g).DO(THEN(b, c)).BREAK(h);;
+    </chain>
+
+    <chain name="chain6">
+        WHILE(w).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain7">
+        ITERATOR(i).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain8">
+        CATCH( THEN(b, c, d) ).DO(a);
+    </chain>
 </flow>

+ 50 - 2
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/RollbackSpringbootTest.java

@@ -31,12 +31,60 @@ public class RollbackSpringbootTest extends BaseTest {
 		Assertions.assertEquals("", response.getRollbackStepStr());
 	}
 
-	// 测试产生异常之后的回滚顺序
+	// 对串行编排与并行编排语法的测试
 	@Test
-	public void testRollbackStep() throws Exception {
+	public void testWhenAndThen() throws Exception {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
 		Assertions.assertFalse(response.isSuccess());
 		Assertions.assertEquals("d==>b==>a", response.getRollbackStepStr());
 	}
 
+	// 对条件编排语法的测试
+	@Test
+	public void testIf() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>x", response.getRollbackStepStr());
+	}
+
+	// 对选择编排语法的测试
+	@Test
+	public void testSwitch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>f", response.getRollbackStepStr());
+	}
+
+	// 对FOR循环编排语法的测试
+	@Test
+	public void testFor() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("h==>b==>g", response.getRollbackStepStr());
+	}
+
+	// 对WHILE循环编排语法的测试
+	@Test
+	public void testWhile() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>w", response.getRollbackStepStr());
+	}
+
+	// 对ITERATOR迭代循环编排语法的测试
+	@Test
+	public void testIterator() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>i", response.getRollbackStepStr());
+	}
+
+	@Test
+	// 对捕获异常表达式的测试
+	public void testCatch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg");
+		Assertions.assertTrue(response.isSuccess());
+		Assertions.assertNull(response.getCause());
+		Assertions.assertEquals("", response.getRollbackStepStr());
+	}
 }

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeSwitchComponent;
+import org.springframework.stereotype.Component;
+
+@Component("f")
+public class FCmp extends NodeSwitchComponent {
+
+    @Override
+    public String processSwitch() {
+        System.out.println("FCmp executed!");
+        return "abc";
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("FCmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeForComponent;
+import org.springframework.stereotype.Component;
+
+@Component("g")
+public class GCmp extends NodeForComponent {
+
+    @Override
+    public int processFor() throws Exception {
+        System.out.println("GCmp executed!");
+        return 3;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("GCmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeBreakComponent;
+import org.springframework.stereotype.Component;
+
+@Component("h")
+public class HCmp extends NodeBreakComponent {
+
+    @Override
+    public boolean processBreak() throws Exception {
+        System.out.println("HCmp executed!");
+        throw new RuntimeException();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("HCmp rollback!");
+    }
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.NodeIteratorComponent;
+import org.springframework.stereotype.Component;
+
+import java.util.Iterator;
+import java.util.List;
+
+@Component("i")
+public class ICmp extends NodeIteratorComponent {
+
+    @Override
+    public Iterator<?> processIterator() throws Exception {
+        List<String> list = ListUtil.toList("jack", "mary", "tom");
+        return list.iterator();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("ICmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeWhileComponent;
+import org.springframework.stereotype.Component;
+
+@Component("w")
+public class WCmp extends NodeWhileComponent {
+
+    @Override
+    public boolean processWhile() throws Exception {
+        System.out.println("WCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("WCmp rollback!");
+    }
+}

+ 18 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java

@@ -0,0 +1,18 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeIfComponent;
+import org.springframework.stereotype.Component;
+
+@Component("x")
+public class XCmp extends NodeIfComponent {
+    @Override
+    public boolean processIf() throws Exception {
+        System.out.println("XCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("XCmp rollback!");
+    }
+}

+ 24 - 0
liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/rollback/flow.el.xml

@@ -7,4 +7,28 @@
     <chain name="chain2">
         THEN( a, b, WHEN(c, d) );
     </chain>
+
+    <chain name="chain3">
+        THEN( IF(x, d, a), CATCH(IF(x, d, a)) );
+    </chain>
+
+    <chain name="chain4">
+        SWITCH(f).TO(a, b).DEFAULT(d);
+    </chain>
+
+    <chain name="chain5">
+        FOR(g).DO(THEN(b, c)).BREAK(h);;
+    </chain>
+
+    <chain name="chain6">
+        WHILE(w).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain7">
+        ITERATOR(i).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain8">
+        CATCH( THEN(b, c, d) ).DO(a);
+    </chain>
 </flow>

+ 51 - 2
liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/RollbackSpringTest.java

@@ -28,13 +28,62 @@ public class RollbackSpringTest extends BaseTest {
 		Assertions.assertEquals("", response.getRollbackStepStr());
 	}
 
-	// 测试产生异常之后的回滚顺序
+	// 对串行编排与并行编排语法的测试
 	@Test
-	public void testRollbackStep() throws Exception {
+	public void testWhenAndThen() throws Exception {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
 		Assertions.assertFalse(response.isSuccess());
 		Assertions.assertEquals("d==>b==>a", response.getRollbackStepStr());
 	}
 
+	// 对条件编排语法的测试
+	@Test
+	public void testIf() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>x", response.getRollbackStepStr());
+	}
+
+	// 对选择编排语法的测试
+	@Test
+	public void testSwitch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>f", response.getRollbackStepStr());
+	}
+
+	// 对FOR循环编排语法的测试
+	@Test
+	public void testFor() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("h==>b==>g", response.getRollbackStepStr());
+	}
+
+	// 对WHILE循环编排语法的测试
+	@Test
+	public void testWhile() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>w", response.getRollbackStepStr());
+	}
+
+	// 对ITERATOR迭代循环编排语法的测试
+	@Test
+	public void testIterator() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
+		Assertions.assertFalse(response.isSuccess());
+		Assertions.assertEquals("d==>b==>a==>i", response.getRollbackStepStr());
+	}
+
+	@Test
+	// 对捕获异常表达式的测试
+	public void testCatch() throws Exception {
+		LiteflowResponse response = flowExecutor.execute2Resp("chain8", "arg");
+		Assertions.assertTrue(response.isSuccess());
+		Assertions.assertNull(response.getCause());
+		Assertions.assertEquals("", response.getRollbackStepStr());
+	}
+
 
 }

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/FCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeSwitchComponent;
+import org.springframework.stereotype.Component;
+
+@Component("f")
+public class FCmp extends NodeSwitchComponent {
+
+    @Override
+    public String processSwitch() {
+        System.out.println("FCmp executed!");
+        return "abc";
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("FCmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/GCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeForComponent;
+import org.springframework.stereotype.Component;
+
+@Component("g")
+public class GCmp extends NodeForComponent {
+
+    @Override
+    public int processFor() throws Exception {
+        System.out.println("GCmp executed!");
+        return 3;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("GCmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/HCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeBreakComponent;
+import org.springframework.stereotype.Component;
+
+@Component("h")
+public class HCmp extends NodeBreakComponent {
+
+    @Override
+    public boolean processBreak() throws Exception {
+        System.out.println("HCmp executed!");
+        throw new RuntimeException();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("HCmp rollback!");
+    }
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/ICmp.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.NodeIteratorComponent;
+import org.springframework.stereotype.Component;
+
+import java.util.Iterator;
+import java.util.List;
+
+@Component("i")
+public class ICmp extends NodeIteratorComponent {
+
+    @Override
+    public Iterator<?> processIterator() throws Exception {
+        List<String> list = ListUtil.toList("jack", "mary", "tom");
+        return list.iterator();
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("ICmp rollback!");
+    }
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/WCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeWhileComponent;
+import org.springframework.stereotype.Component;
+
+@Component("w")
+public class WCmp extends NodeWhileComponent {
+
+    @Override
+    public boolean processWhile() throws Exception {
+        System.out.println("WCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("WCmp rollback!");
+    }
+}

+ 18 - 0
liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/rollback/cmp/XCmp.java

@@ -0,0 +1,18 @@
+package com.yomahub.liteflow.test.rollback.cmp;
+
+import com.yomahub.liteflow.core.NodeIfComponent;
+import org.springframework.stereotype.Component;
+
+@Component("x")
+public class XCmp extends NodeIfComponent {
+    @Override
+    public boolean processIf() throws Exception {
+        System.out.println("XCmp executed!");
+        return true;
+    }
+
+    @Override
+    public void rollback() throws Exception {
+        System.out.println("XCmp rollback!");
+    }
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/rollback/flow.el.xml

@@ -8,4 +8,27 @@
         THEN( a, b, WHEN(c, d) );
     </chain>
 
+    <chain name="chain3">
+        THEN( IF(x, d, a), CATCH(IF(x, d, a)) );
+    </chain>
+
+    <chain name="chain4">
+        SWITCH(f).TO(a, b).DEFAULT(d);
+    </chain>
+
+    <chain name="chain5">
+        FOR(g).DO(THEN(b, c)).BREAK(h);;
+    </chain>
+
+    <chain name="chain6">
+        WHILE(w).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain7">
+        ITERATOR(i).DO(THEN(a, b, d));
+    </chain>
+
+    <chain name="chain8">
+        CATCH( THEN(b, c, d) ).DO(a);
+    </chain>
 </flow>