增加了新的rollback测试用例
This commit is contained in:
parent
1da30a66bb
commit
05492fc198
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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!");
|
||||
}
|
||||
}
|
|
@ -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>
|
Loading…
Reference in New Issue