enhancement #I5O22X 增加EL解析中的报错详细信息

This commit is contained in:
everywhere.z
2022-08-25 18:06:23 +08:00
parent 7cf9b49680
commit 0c82f48233
17 changed files with 274 additions and 190 deletions

View File

@@ -62,7 +62,7 @@ public class LiteFlowChainELBuilder {
expressRunner.addFunction("PRE", new PreOperator());
expressRunner.addFunction("FINALLY", new FinallyOperator());
expressRunner.addFunction("IF", new IfOperator());
expressRunner.addFunction("ELSE", new ElseOperator());
expressRunner.addFunctionAndClassMethod("ELSE", Object.class, new ElseOperator());
expressRunner.addFunctionAndClassMethod("to", Object.class, new ToOperator());
expressRunner.addFunctionAndClassMethod("tag", Object.class, new TagOperator());
expressRunner.addFunctionAndClassMethod("any", Object.class, new AnyOperator());

View File

@@ -2,6 +2,7 @@ package com.yomahub.liteflow.builder.el.operator;
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.condition.WhenCondition;
import org.slf4j.Logger;
@@ -18,36 +19,35 @@ public class AnyOperator extends Operator {
@Override
public WhenCondition executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
if (objects.length != 2){
LOG.error("parameter error");
throw new Exception();
if (objects.length != 2) {
throw new QLException("parameter error");
}
WhenCondition whenCondition;
if (objects[0] instanceof WhenCondition){
if (objects[0] instanceof WhenCondition) {
whenCondition = (WhenCondition) objects[0];
}else{
LOG.error("The caller must be when condition item!");
throw new Exception();
} else {
throw new QLException("The caller must be when condition item");
}
boolean any = false;
if (objects[1] instanceof Boolean){
if (objects[1] instanceof Boolean) {
any = Boolean.parseBoolean(objects[1].toString());
}else{
LOG.error("the parameter must be boolean type!");
throw new Exception();
} else {
throw new QLException("the parameter must be boolean type");
}
whenCondition.setAny(any);
return whenCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -1,4 +1,54 @@
package com.yomahub.liteflow.builder.el.operator;
public class ElseOperator {
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.IfCondition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* EL规则中的ELSE的操作符
* @author Bryan.Zhang
* @since 2.8.5
*/
public class ElseOperator extends Operator {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Override
public IfCondition executeInner(Object[] objects) throws Exception {
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
//参数只能是1个但这里为什么是2个呢第一个是caller第二个才是参数
if (objects.length != 2) {
throw new QLException("parameter error");
}
IfCondition ifCondition;
if (objects[0] instanceof IfCondition) {
ifCondition = (IfCondition) objects[0];
if (ifCondition.getFalseCaseExecutableItem() != null) {
throw new QLException("The if caller already has else item");
}
} else {
throw new QLException("The caller must be IfCondition item");
}
Executable elseExecutableItem = (Executable) objects[1];
ifCondition.setFalseCaseExecutableItem(elseExecutableItem);
return ifCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}
}
}

View File

@@ -1,6 +1,7 @@
package com.yomahub.liteflow.builder.el.operator;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.FinallyCondition;
@@ -18,23 +19,23 @@ public class FinallyOperator extends Operator {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Override
public Object executeInner(Object[] objects) throws Exception {
try{
if (objects.length <= 0){
LOG.error("parameter error");
throw new Exception();
public FinallyCondition executeInner(Object[] objects) throws Exception {
try {
if (objects.length == 0) {
throw new QLException("parameter is empty");
}
FinallyCondition finallyCondition = new FinallyCondition();
for (Object obj : objects){
if (obj instanceof Executable){
finallyCondition.addExecutable((Executable)obj);
}else{
LOG.error("parameter must be executable item!");
throw new Exception();
for (Object obj : objects) {
if (obj instanceof Executable) {
finallyCondition.addExecutable((Executable) obj);
} else {
throw new QLException("parameter must be executable item!");
}
}
return finallyCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -2,6 +2,7 @@ package com.yomahub.liteflow.builder.el.operator;
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.condition.Condition;
import org.slf4j.Logger;
@@ -18,36 +19,36 @@ public class IdOperator extends Operator {
@Override
public Condition executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
if (objects.length != 2){
LOG.error("parameter error");
throw new Exception();
if (objects.length != 2) {
throw new QLException("parameter error");
}
Condition condition;
if (objects[0] instanceof Condition){
if (objects[0] instanceof Condition) {
condition = (Condition) objects[0];
}else{
LOG.error("The caller must be condition item!");
throw new Exception();
} else {
throw new QLException("The caller must be condition item");
}
String id;
if (objects[1] instanceof String){
if (objects[1] instanceof String) {
id = objects[1].toString();
}else{
} else {
LOG.error("the parameter must be String type!");
throw new Exception();
throw new QLException("the parameter must be String type");
}
condition.setId(id);
return condition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -3,6 +3,7 @@ package com.yomahub.liteflow.builder.el.operator;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Executable;
@@ -21,30 +22,27 @@ public class IfOperator extends Operator {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Override
public Object executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
public IfCondition executeInner(Object[] objects) throws Exception {
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
//参数只能是2个或者3个
if (objects.length != 2 && objects.length != 3){
LOG.error("parameter error");
throw new Exception();
if (objects.length != 2 && objects.length != 3) {
throw new QLException("parameter error");
}
//解析第一个参数
Node ifNode;
if (objects[0] instanceof Node){
if (objects[0] instanceof Node) {
ifNode = (Node) objects[0];
if(!ifNode.getType().equals(NodeTypeEnum.IF)){
LOG.error("The first parameter must be If item!");
throw new Exception();
if (!ifNode.getType().equals(NodeTypeEnum.IF)) {
throw new QLException("The first parameter must be If item");
}
}else{
LOG.error("The first parameter must be Node item!");
throw new Exception();
} else {
throw new QLException("The first parameter must be Node item");
}
//解析第二个参数
@@ -52,7 +50,7 @@ public class IfOperator extends Operator {
//解析第三个参数,如果有的话
Executable falseCaseExecutableItem = null;
if (objects.length == 3){
if (objects.length == 3) {
falseCaseExecutableItem = (Executable) objects[2];
}
@@ -61,6 +59,8 @@ public class IfOperator extends Operator {
ifCondition.setTrueCaseExecutableItem(trueCaseExecutableItem);
ifCondition.setFalseCaseExecutableItem(falseCaseExecutableItem);
return ifCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -2,6 +2,7 @@ package com.yomahub.liteflow.builder.el.operator;
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.Condition;
@@ -20,36 +21,35 @@ public class IgnoreErrorOperator extends Operator {
@Override
public Condition executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
if (objects.length != 2){
LOG.error("parameter error");
throw new Exception();
if (objects.length != 2) {
throw new QLException("parameter error");
}
WhenCondition condition;
if (objects[0] instanceof WhenCondition){
if (objects[0] instanceof WhenCondition) {
condition = (WhenCondition) objects[0];
}else{
LOG.error("The caller must be executable item!");
throw new Exception();
} else {
throw new QLException("The caller must be executable item");
}
boolean ignoreError = false;
if (objects[1] instanceof Boolean){
if (objects[1] instanceof Boolean) {
ignoreError = Boolean.parseBoolean(objects[1].toString());
}else{
LOG.error("the parameter must be boolean type!");
throw new Exception();
} else {
throw new QLException("The parameter must be boolean type");
}
condition.setErrorResume(ignoreError);
return condition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -4,6 +4,8 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.flow.element.Node;
import com.yomahub.liteflow.property.LiteflowConfig;
@@ -23,43 +25,45 @@ public class NodeOperator extends Operator {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Override
public Object executeInner(Object[] objects) throws Exception {
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
}
if (objects.length != 1){
LOG.error("parameter error");
throw new Exception();
}
String nodeId;
if (objects[0] instanceof String){
nodeId = (String) objects[0];
}else{
LOG.error("The value must be Node item!");
throw new Exception();
}
if (FlowBus.containNode(nodeId)){
return FlowBus.getNode(nodeId);
}else{
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
if (StrUtil.isNotBlank(liteflowConfig.getSubstituteCmpClass())){
Node substituteNode = FlowBus.getNodeMap().values().stream().filter(node
-> node.getInstance().getClass().getName().equals(liteflowConfig.getSubstituteCmpClass())).findFirst().orElse(null);
if (ObjectUtil.isNotNull(substituteNode)){
return substituteNode;
}else{
String error = StrUtil.format("This node[{}] cannot be found", nodeId);
LOG.error(error);
throw new Exception();
}
}else{
String error = StrUtil.format("This node[{}] cannot be found, or you can configure an substitute node", nodeId);
LOG.error(error);
throw new Exception();
public Node executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new QLException("parameter is empty");
}
if (objects.length != 1){
throw new QLException("parameter error");
}
String nodeId;
if (objects[0] instanceof String){
nodeId = (String) objects[0];
}else{
throw new QLException("The value must be Node item!");
}
if (FlowBus.containNode(nodeId)){
return FlowBus.getNode(nodeId);
}else{
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
if (StrUtil.isNotBlank(liteflowConfig.getSubstituteCmpClass())){
Node substituteNode = FlowBus.getNodeMap().values().stream().filter(node
-> node.getInstance().getClass().getName().equals(liteflowConfig.getSubstituteCmpClass())).findFirst().orElse(null);
if (ObjectUtil.isNotNull(substituteNode)){
return substituteNode;
}else{
String error = StrUtil.format("This node[{}] cannot be found", nodeId);
throw new QLException(error);
}
}else{
String error = StrUtil.format("This node[{}] cannot be found, or you can configure an substitute node", nodeId);
throw new QLException(error);
}
}
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}
}
}

View File

@@ -1,6 +1,7 @@
package com.yomahub.liteflow.builder.el.operator;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.PreCondition;
@@ -18,23 +19,23 @@ public class PreOperator extends Operator {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Override
public Object executeInner(Object[] objects) throws Exception {
try{
if (objects.length <= 0){
LOG.error("parameter error");
throw new Exception();
public PreCondition executeInner(Object[] objects) throws Exception {
try {
if (objects.length == 0) {
throw new QLException("parameter is empty");
}
PreCondition preCondition = new PreCondition();
for (Object obj : objects){
if (obj instanceof Executable){
preCondition.addExecutable((Executable)obj);
}else{
LOG.error("parameter must be executable item!");
throw new Exception();
for (Object obj : objects) {
if (obj instanceof Executable) {
preCondition.addExecutable((Executable) obj);
} else {
throw new QLException("parameter must be executable item");
}
}
return preCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -3,6 +3,7 @@ package com.yomahub.liteflow.builder.el.operator;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Node;
@@ -22,33 +23,32 @@ public class SwitchOperator extends Operator {
@Override
public SwitchCondition executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
if (objects.length != 1){
LOG.error("parameter error");
throw new Exception();
if (objects.length != 1) {
throw new QLException("parameter error");
}
Node switchNode;
if (objects[0] instanceof Node){
if (objects[0] instanceof Node) {
switchNode = (Node) objects[0];
if(!ListUtil.toList(NodeTypeEnum.SWITCH, NodeTypeEnum.SWITCH_SCRIPT).contains(switchNode.getType())){
LOG.error("The caller must be Switch item!");
throw new Exception();
if (!ListUtil.toList(NodeTypeEnum.SWITCH, NodeTypeEnum.SWITCH_SCRIPT).contains(switchNode.getType())) {
throw new QLException("The caller must be Switch item");
}
}else{
LOG.error("The caller must be Node item!");
throw new Exception();
} else {
throw new QLException("The caller must be Switch item");
}
SwitchCondition switchCondition = new SwitchCondition();
switchCondition.setSwitchNode(switchNode);
return switchCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -2,6 +2,7 @@ package com.yomahub.liteflow.builder.el.operator;
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.FlowBus;
@@ -20,30 +21,27 @@ public class TagOperator extends Operator {
@Override
public Node executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
if (objects.length != 2){
LOG.error("parameter error");
throw new Exception();
if (objects.length != 2) {
throw new QLException("parameter error");
}
Node node;
if (objects[0] instanceof Node){
if (objects[0] instanceof Node) {
node = (Node) objects[0];
}else{
LOG.error("The caller must be Node item!");
throw new Exception();
} else {
throw new QLException("The caller must be Node item");
}
String tag = null;
if (objects[1] instanceof String){
if (objects[1] instanceof String) {
tag = objects[1].toString();
}else{
LOG.error("the parameter must be String type!");
throw new Exception();
} else {
throw new QLException("the parameter must be String type");
}
//这里为什么要clone一个呢
@@ -54,6 +52,8 @@ public class TagOperator extends Operator {
return copyNode;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -1,6 +1,7 @@
package com.yomahub.liteflow.builder.el.operator;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.ThenCondition;
@@ -17,23 +18,23 @@ public class ThenOperator extends Operator {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
@Override
public Object executeInner(Object[] objects) throws Exception {
try{
if (objects.length <= 0){
LOG.error("parameter error");
throw new Exception();
public ThenCondition executeInner(Object[] objects) throws Exception {
try {
if (objects.length == 0) {
throw new QLException("parameter is empty");
}
ThenCondition thenCondition = new ThenCondition();
for (Object obj : objects){
if (obj instanceof Executable){
thenCondition.addExecutable((Executable)obj);
}else{
LOG.error("parameter must be executable item!");
throw new Exception();
for (Object obj : objects) {
if (obj instanceof Executable) {
thenCondition.addExecutable((Executable) obj);
} else {
throw new QLException("parameter must be executable item");
}
}
return thenCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -2,6 +2,7 @@ package com.yomahub.liteflow.builder.el.operator;
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.condition.WhenCondition;
import org.slf4j.Logger;
@@ -18,36 +19,35 @@ public class ThreadPoolOperator extends Operator {
@Override
public WhenCondition executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
if (objects.length != 2){
LOG.error("parameter error");
throw new Exception();
if (objects.length != 2) {
throw new QLException("parameter error");
}
WhenCondition whenCondition;
if (objects[0] instanceof WhenCondition){
if (objects[0] instanceof WhenCondition) {
whenCondition = (WhenCondition) objects[0];
}else{
LOG.error("The caller must be when condition item!");
throw new Exception();
} else {
throw new QLException("The caller must be when condition item");
}
String threadPoolClazz = null;
if (objects[1] instanceof String){
if (objects[1] instanceof String) {
threadPoolClazz = objects[1].toString();
}else{
LOG.error("the parameter must be String type!");
throw new Exception();
} else {
throw new QLException("the parameter must be String type");
}
whenCondition.setThreadExecutorClass(threadPoolClazz);
return whenCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -2,6 +2,7 @@ package com.yomahub.liteflow.builder.el.operator;
import cn.hutool.core.util.ArrayUtil;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.SwitchCondition;
@@ -19,34 +20,33 @@ public class ToOperator extends Operator {
@Override
public SwitchCondition executeInner(Object[] objects) throws Exception {
try{
if (ArrayUtil.isEmpty(objects)){
throw new Exception();
try {
if (ArrayUtil.isEmpty(objects)) {
throw new QLException("parameter is empty");
}
if (objects.length <= 1){
LOG.error("parameter error");
throw new Exception();
if (objects.length <= 1) {
throw new QLException("parameter error");
}
SwitchCondition switchCondition;
if (objects[0] instanceof SwitchCondition){
if (objects[0] instanceof SwitchCondition) {
switchCondition = (SwitchCondition) objects[0];
}else{
LOG.error("The caller must be SwitchCondition item!");
throw new Exception();
} else {
throw new QLException("The caller must be SwitchCondition item");
}
for (int i = 1; i < objects.length; i++) {
if (objects[i] instanceof Executable) {
Executable target = (Executable) objects[i];
switchCondition.addTargetItem(target);
}else {
LOG.error("The parameter must be Executable item!");
throw new Exception();
} else {
throw new QLException("The parameter must be Executable item");
}
}
return switchCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -1,6 +1,7 @@
package com.yomahub.liteflow.builder.el.operator;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.WhenCondition;
@@ -18,21 +19,22 @@ public class WhenOperator extends Operator {
@Override
public WhenCondition executeInner(Object[] objects) throws Exception {
try{
if (objects.length <= 0){
LOG.error("parameter error");
throw new Exception();
try {
if (objects.length == 0) {
throw new QLException("parameter error");
}
WhenCondition whenCondition = new WhenCondition();
for (Object obj : objects){
if (obj instanceof Executable){
whenCondition.addExecutable((Executable)obj);
}else{
throw new Exception();
for (Object obj : objects) {
if (obj instanceof Executable) {
whenCondition.addExecutable((Executable) obj);
} else {
throw new QLException("parameter error");
}
}
return whenCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}

View File

@@ -49,4 +49,18 @@ public class IfELSpringbootTest extends BaseTest {
Assert.assertTrue(response.isSuccess());
}
//IF有2个参数加上ELSE
@Test
public void testIf4() throws Exception{
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
}
//IF有2个参数ELSE里再嵌套一个IF
@Test
public void testIf5() throws Exception{
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
Assert.assertTrue(response.isSuccess());
}
}

View File

@@ -16,4 +16,14 @@
item
);
</chain>
<chain name="chain4">
IF(x1.tag("false"), THEN(a, b)).ELSE(THEN(c, d));
</chain>
<chain name="chain5">
item = IF(x1.tag("false"), a, THEN(c, c, b));
IF(x1.tag("false"), THEN(a, b)).ELSE(item);
</chain>
</flow>