mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
enhancement #I4PJKP when标签中默认的errorResume改为false
This commit is contained in:
@@ -22,8 +22,8 @@ public class Condition {
|
||||
|
||||
private List<Executable> nodeList;
|
||||
|
||||
//只在when类型下有效,以区分当when调用链调用失败时是否继续往下执行 默认true继续执行
|
||||
private boolean errorResume = true;
|
||||
//只在when类型下有效,以区分当when调用链调用失败时是否继续往下执行 默认false不继续执行
|
||||
private boolean errorResume = false;
|
||||
|
||||
//只在when类型下有效,用于不同node进行同组合并,相同的组会进行合并,不同的组不会进行合并
|
||||
private String group = LocalDefaultFlowConstant.DEFAULT;
|
||||
|
||||
@@ -145,7 +145,7 @@ public abstract class JsonFlowParser extends FlowParser {
|
||||
group = LocalDefaultFlowConstant.DEFAULT;
|
||||
}
|
||||
if (StrUtil.isBlank(errorResume)) {
|
||||
errorResume = Boolean.TRUE.toString();
|
||||
errorResume = Boolean.FALSE.toString();
|
||||
}
|
||||
if (StrUtil.isBlank(any)){
|
||||
any = Boolean.FALSE.toString();
|
||||
@@ -175,6 +175,9 @@ public abstract class JsonFlowParser extends FlowParser {
|
||||
} else if (hasChain(flowJsonObjectList, realItem.getId())) {
|
||||
Chain chain = FlowBus.getChain(realItem.getId());
|
||||
node.setCondNode(chain.getChainName(), chain);
|
||||
} else{
|
||||
String errorMsg = StrUtil.format("executable node[{}] is not found!", realItem.getId());
|
||||
throw new ExecutableItemNotFoundException(errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,7 +189,7 @@ public abstract class JsonFlowParser extends FlowParser {
|
||||
throw new ExecutableItemNotFoundException(errorMsg);
|
||||
}
|
||||
}
|
||||
condition.setErrorResume(errorResume.equals(Boolean.TRUE.toString()));
|
||||
condition.setErrorResume(Boolean.parseBoolean(errorResume));
|
||||
condition.setGroup(group);
|
||||
condition.setAny(any.equals(Boolean.TRUE.toString()));
|
||||
condition.setConditionType(condType);
|
||||
|
||||
@@ -144,7 +144,7 @@ public abstract class XmlFlowParser extends FlowParser {
|
||||
group = LocalDefaultFlowConstant.DEFAULT;
|
||||
}
|
||||
if (StrUtil.isBlank(errorResume)) {
|
||||
errorResume = Boolean.TRUE.toString();
|
||||
errorResume = Boolean.FALSE.toString();
|
||||
}
|
||||
if (StrUtil.isBlank(any)){
|
||||
any = Boolean.FALSE.toString();
|
||||
@@ -174,6 +174,9 @@ public abstract class XmlFlowParser extends FlowParser {
|
||||
} else if (hasChain(documentList, realItem.getId())) {
|
||||
Chain chain = FlowBus.getChain(realItem.getId());
|
||||
node.setCondNode(chain.getChainName(), chain);
|
||||
} else{
|
||||
String errorMsg = StrUtil.format("executable node[{}] is not found!", realItem.getId());
|
||||
throw new ExecutableItemNotFoundException(errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,7 +188,7 @@ public abstract class XmlFlowParser extends FlowParser {
|
||||
throw new ExecutableItemNotFoundException(errorMsg);
|
||||
}
|
||||
}
|
||||
condition.setErrorResume(errorResume.equals(Boolean.TRUE.toString()));
|
||||
condition.setErrorResume(Boolean.parseBoolean(errorResume));
|
||||
condition.setGroup(group);
|
||||
condition.setAny(any.equals(Boolean.TRUE.toString()));
|
||||
condition.setConditionType(condE.getName());
|
||||
|
||||
@@ -44,6 +44,7 @@ public class AsyncNodeSpringbootTest extends BaseTest {
|
||||
System.out.println(response.getSlot().getExecuteStepStr());
|
||||
}
|
||||
|
||||
//这个和test1有点类似,只不过进一步验证了步骤
|
||||
@Test
|
||||
public void testAsyncFlow2() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "it's a base request");
|
||||
@@ -53,6 +54,21 @@ public class AsyncNodeSpringbootTest extends BaseTest {
|
||||
).contains(response.getSlot().getExecuteStepStr()));
|
||||
}
|
||||
|
||||
//测试errorResume,默认的errorResume为false,这里测试默认的
|
||||
@Test
|
||||
public void testAsyncFlow3_1() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3-1", "it's a base request");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class);
|
||||
}
|
||||
|
||||
//测试errorResume,默认的errorResume为false,这里设置为true
|
||||
@Test
|
||||
public void testAsyncFlow3_2() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3-2", "it's a base request");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
|
||||
//相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错
|
||||
@Test
|
||||
public void testAsyncFlow4() {
|
||||
|
||||
@@ -11,7 +11,17 @@
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
<when value="f,g,h"/>
|
||||
<when value="g,f,h"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain3-1">
|
||||
<when value="f,g,i" group="1"/>
|
||||
<when value="h" group="2"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain3-2">
|
||||
<when value="f,g,i" errorResume="true" group="1"/>
|
||||
<when value="h" group="2"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<when value="a,b,c"/>
|
||||
<when value="a,b,c" errorResume="true"/>
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user