mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
修复回滚组件无法获得tag的问题
This commit is contained in:
@@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.rollback;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -90,4 +91,13 @@ public class RollbackELDeclMultiSpringbootTest extends BaseTest {
|
||||
Assertions.assertEquals("", response.getRollbackStepStr());
|
||||
}
|
||||
|
||||
@Test
|
||||
// 对获取数据的测试
|
||||
public void testData() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg");
|
||||
DefaultContext context = response.getFirstContextBean();
|
||||
Assertions.assertFalse(response.isSuccess());
|
||||
Assertions.assertEquals("321", context.getData("test"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ 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 com.yomahub.liteflow.slot.DefaultContext;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -20,6 +21,17 @@ public class CmpConfig {
|
||||
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.ROLLBACK, nodeId = "a")
|
||||
public void rollbackA(NodeComponent bindCmp) throws Exception {
|
||||
String testKey = "test";
|
||||
|
||||
DefaultContext context = bindCmp.getFirstContextBean();
|
||||
if (context.getData(testKey) == null) {
|
||||
context.setData(testKey, bindCmp.getTag());
|
||||
}
|
||||
else {
|
||||
String s = context.getData(testKey);
|
||||
s += bindCmp.getTag();
|
||||
context.setData(testKey, s);
|
||||
}
|
||||
System.out.println("ACmp rollback!");
|
||||
}
|
||||
|
||||
|
||||
@@ -31,4 +31,8 @@
|
||||
<chain name="chain8">
|
||||
CATCH( THEN(b, c, d) ).DO(a);
|
||||
</chain>
|
||||
|
||||
<chain name="chain9">
|
||||
THEN(a.tag("1"), a.tag("2"), a.tag("3"), d);
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.rollback;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import com.yomahub.liteflow.test.whenTimeOut.WhenTimeOutELDeclSpringbootTest1;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -92,4 +93,13 @@ public class RollbackELDeclSpringbootTest extends BaseTest {
|
||||
Assertions.assertEquals("", response.getRollbackStepStr());
|
||||
}
|
||||
|
||||
@Test
|
||||
// 对获取数据的测试
|
||||
public void testData() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg");
|
||||
DefaultContext context = response.getFirstContextBean();
|
||||
Assertions.assertFalse(response.isSuccess());
|
||||
Assertions.assertEquals("321", context.getData("test"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.yomahub.liteflow.test.rollback.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("a")
|
||||
@@ -20,6 +21,17 @@ public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void rollback() throws Exception {
|
||||
String testKey = "test";
|
||||
|
||||
DefaultContext context = this.getFirstContextBean();
|
||||
if (context.getData(testKey) == null) {
|
||||
context.setData(testKey, this.getTag());
|
||||
}
|
||||
else {
|
||||
String s = context.getData(testKey);
|
||||
s += this.getTag();
|
||||
context.setData(testKey, s);
|
||||
}
|
||||
System.out.println("ACmp rollback!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,8 @@
|
||||
<chain name="chain8">
|
||||
CATCH( THEN(b, c, d) ).DO(a);
|
||||
</chain>
|
||||
|
||||
<chain name="chain9">
|
||||
THEN(a.tag("1"), a.tag("2"), a.tag("3"), d);
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -3,7 +3,9 @@ package com.yomahub.liteflow.test.rollback;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -88,5 +90,13 @@ public class RollbackTest extends BaseTest {
|
||||
Assertions.assertEquals("", response.getRollbackStepStr());
|
||||
}
|
||||
|
||||
@Test
|
||||
// 对获取数据的测试
|
||||
public void testData() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg");
|
||||
DefaultContext context = response.getFirstContextBean();
|
||||
Assertions.assertFalse(response.isSuccess());
|
||||
Assertions.assertEquals("321", context.getData("test"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.yomahub.liteflow.test.rollback.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
|
||||
public class ACmp extends NodeComponent {
|
||||
|
||||
@@ -18,6 +19,17 @@ public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void rollback() throws Exception {
|
||||
String testKey = "test";
|
||||
|
||||
DefaultContext context = this.getFirstContextBean();
|
||||
if (context.getData(testKey) == null) {
|
||||
context.setData(testKey, this.getTag());
|
||||
}
|
||||
else {
|
||||
String s = context.getData(testKey);
|
||||
s += this.getTag();
|
||||
context.setData(testKey, s);
|
||||
}
|
||||
System.out.println("ACmp rollback!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,8 @@
|
||||
<chain name="chain8">
|
||||
CATCH( THEN(b, c, d) ).DO(a);
|
||||
</chain>
|
||||
|
||||
<chain name="chain9">
|
||||
THEN(a.tag("1"), a.tag("2"), a.tag("3"), d);
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.rollback;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -84,4 +85,13 @@ public class RollbackSpringbootTest extends BaseTest {
|
||||
Assertions.assertEquals("", response.getRollbackStepStr());
|
||||
}
|
||||
|
||||
@Test
|
||||
// 对获取数据的测试
|
||||
public void testData() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg");
|
||||
DefaultContext context = response.getFirstContextBean();
|
||||
Assertions.assertFalse(response.isSuccess());
|
||||
Assertions.assertEquals("321", context.getData("test"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.yomahub.liteflow.test.rollback.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import org.noear.solon.annotation.Component;
|
||||
|
||||
|
||||
@@ -21,6 +22,17 @@ public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void rollback() throws Exception {
|
||||
String testKey = "test";
|
||||
|
||||
DefaultContext context = this.getFirstContextBean();
|
||||
if (context.getData(testKey) == null) {
|
||||
context.setData(testKey, this.getTag());
|
||||
}
|
||||
else {
|
||||
String s = context.getData(testKey);
|
||||
s += this.getTag();
|
||||
context.setData(testKey, s);
|
||||
}
|
||||
System.out.println("ACmp rollback!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,8 @@
|
||||
<chain name="chain8">
|
||||
CATCH( THEN(b, c, d) ).DO(a);
|
||||
</chain>
|
||||
|
||||
<chain name="chain9">
|
||||
THEN(a.tag("1"), a.tag("2"), a.tag("3"), d);
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.rollback;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -87,4 +88,13 @@ public class RollbackSpringbootTest extends BaseTest {
|
||||
Assertions.assertNull(response.getCause());
|
||||
Assertions.assertEquals("", response.getRollbackStepStr());
|
||||
}
|
||||
|
||||
@Test
|
||||
// 对获取数据的测试
|
||||
public void testData() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg");
|
||||
DefaultContext context = response.getFirstContextBean();
|
||||
Assertions.assertFalse(response.isSuccess());
|
||||
Assertions.assertEquals("321", context.getData("test"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.yomahub.liteflow.test.rollback.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("a")
|
||||
@@ -20,6 +21,17 @@ public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void rollback() throws Exception {
|
||||
String testKey = "test";
|
||||
|
||||
DefaultContext context = this.getFirstContextBean();
|
||||
if (context.getData(testKey) == null) {
|
||||
context.setData(testKey, this.getTag());
|
||||
}
|
||||
else {
|
||||
String s = context.getData(testKey);
|
||||
s += this.getTag();
|
||||
context.setData(testKey, s);
|
||||
}
|
||||
System.out.println("ACmp rollback!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,8 @@
|
||||
<chain name="chain8">
|
||||
CATCH( THEN(b, c, d) ).DO(a);
|
||||
</chain>
|
||||
|
||||
<chain name="chain9">
|
||||
THEN(a.tag("1"), a.tag("2"), a.tag("3"), d);
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.rollback;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -85,5 +86,14 @@ public class RollbackSpringTest extends BaseTest {
|
||||
Assertions.assertEquals("", response.getRollbackStepStr());
|
||||
}
|
||||
|
||||
@Test
|
||||
// 对获取数据的测试
|
||||
public void testData() throws Exception {
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain9", "arg");
|
||||
DefaultContext context = response.getFirstContextBean();
|
||||
Assertions.assertFalse(response.isSuccess());
|
||||
Assertions.assertEquals("321", context.getData("test"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.yomahub.liteflow.test.rollback.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.slot.DefaultContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("a")
|
||||
@@ -20,6 +21,17 @@ public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void rollback() throws Exception {
|
||||
String testKey = "test";
|
||||
|
||||
DefaultContext context = this.getFirstContextBean();
|
||||
if (context.getData(testKey) == null) {
|
||||
context.setData(testKey, this.getTag());
|
||||
}
|
||||
else {
|
||||
String s = context.getData(testKey);
|
||||
s += this.getTag();
|
||||
context.setData(testKey, s);
|
||||
}
|
||||
System.out.println("ACmp rollback!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,8 @@
|
||||
<chain name="chain8">
|
||||
CATCH( THEN(b, c, d) ).DO(a);
|
||||
</chain>
|
||||
|
||||
<chain name="chain9">
|
||||
THEN(a.tag("1"), a.tag("2"), a.tag("3"), d);
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user