diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/aop/ICmpAroundAspect.java b/liteflow-core/src/main/java/com/yomahub/liteflow/aop/ICmpAroundAspect.java index d9b5852cd..5c2c3dce2 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/aop/ICmpAroundAspect.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/aop/ICmpAroundAspect.java @@ -14,9 +14,9 @@ import com.yomahub.liteflow.slot.Slot; * 实现这个接口并注入到spring上下文即可 * @author Bryan.Zhang */ -public interface ICmpAroundAspect { +public interface ICmpAroundAspect { - void beforeProcess(String nodeId, Slot slot); + void beforeProcess(String nodeId, Slot slot); - void afterProcess(String nodeId, Slot slot); + void afterProcess(String nodeId, Slot slot); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java index a64731828..2939616d7 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java @@ -9,10 +9,7 @@ package com.yomahub.liteflow.core; import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.BooleanUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.ReUtil; -import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.*; import com.google.common.collect.Lists; import com.yomahub.liteflow.slot.DataBus; import com.yomahub.liteflow.flow.LiteflowResponse; @@ -270,10 +267,13 @@ public class FlowExecutor { //隐式流程的调用方法 public void invoke(String chainId, Object param, Integer slotIndex) throws Exception { - this.execute(chainId, param, null, slotIndex, true); + LiteflowResponse response = this.execute2Resp(chainId, param, null, slotIndex, true); + if (!response.isSuccess()){ + throw response.getCause(); + } } - public LiteflowResponse invoke2Resp(String chainId, Object param, Integer slotIndex) { + public LiteflowResponse invoke2Resp(String chainId, Object param, Integer slotIndex) { return this.execute2Resp(chainId, param, null, slotIndex, true); } @@ -283,51 +283,42 @@ public class FlowExecutor { node.execute(slotIndex); } - public DefaultContext execute(String chainId) throws Exception { - return this.execute(chainId, null, DefaultContext.class, null, false); - } - - public DefaultContext execute(String chainId, Object param) throws Exception { - return this.execute(chainId, param, DefaultContext.class, null, false); - } - - public T execute(String chainId, Object param, Class contextBeanClazz) throws Exception { - return this.execute(chainId, param, contextBeanClazz, null, false); - } - - private T execute(String chainId, Object param, Class contextBeanClazz, - Integer slotIndex, boolean isInnerChain) throws Exception { - Slot slot = this.doExecute(chainId, param, contextBeanClazz, slotIndex, isInnerChain); - if (ObjectUtil.isNotNull(slot.getException())) { - throw slot.getException(); - } else { - return slot.getContextBean(); - } - } - - public LiteflowResponse execute2Resp(String chainId) { + //调用一个流程并返回LiteflowResponse,上下文为默认的DefaultContext,初始参数为null + public LiteflowResponse execute2Resp(String chainId) { return this.execute2Resp(chainId, null, DefaultContext.class); } - public LiteflowResponse execute2Resp(String chainId, Object param) { + //调用一个流程并返回LiteflowResponse,上下文为默认的DefaultContext + public LiteflowResponse execute2Resp(String chainId, Object param) { return this.execute2Resp(chainId, param, DefaultContext.class); } - public LiteflowResponse execute2Resp(String chainId, Object param, Class contextBeanClazz) { - return this.execute2Resp(chainId, param, contextBeanClazz, null, false); + //调用一个流程并返回LiteflowResponse,允许多上下文的传入 + public LiteflowResponse execute2Resp(String chainId, Object param, Class... contextBeanClazzArray) { + return this.execute2Resp(chainId, param, contextBeanClazzArray, null, false); } - public Future> execute2Future(String chainId, Object param, Class contextBeanClazz) { + //调用一个流程并返回Future,允许多上下文的传入 + public Future execute2Future(String chainId, Object param, Class... contextBeanClazzArray) { return ExecutorHelper.loadInstance().buildMainExecutor(liteflowConfig.getMainExecutorClass()).submit(() - -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, contextBeanClazz, null, false)); - + -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, contextBeanClazzArray, null, false)); } - public LiteflowResponse execute2Resp(String chainId, Object param, Class contextBeanClazz, - Integer slotIndex, boolean isInnerChain) { - LiteflowResponse response = new LiteflowResponse<>(); + //调用一个流程,返回默认的上下文,适用于简单的调用 + public DefaultContext execute(String chainId, Object param) throws Exception{ + LiteflowResponse response = this.execute2Resp(chainId, param, DefaultContext.class); + if (!response.isSuccess()){ + throw response.getCause(); + }else{ + return response.getFirstContextBean(); + } + } - Slot slot = doExecute(chainId, param, contextBeanClazz, slotIndex, isInnerChain); + private LiteflowResponse execute2Resp(String chainId, Object param, Class[] contextBeanClazzArray, + Integer slotIndex, boolean isInnerChain) { + LiteflowResponse response = new LiteflowResponse(); + + Slot slot = doExecute(chainId, param, contextBeanClazzArray, slotIndex, isInnerChain); if (ObjectUtil.isNotNull(slot.getException())) { response.setSuccess(false); @@ -340,14 +331,14 @@ public class FlowExecutor { return response; } - private Slot doExecute(String chainId, Object param, Class contextBeanClazz, Integer slotIndex, + private Slot doExecute(String chainId, Object param, Class[] contextBeanClazzArray, Integer slotIndex, boolean isInnerChain) { if (FlowBus.needInit()) { init(); } if (!isInnerChain && ObjectUtil.isNull(slotIndex)) { - slotIndex = DataBus.offerSlot(contextBeanClazz); + slotIndex = DataBus.offerSlot(ListUtil.toList(contextBeanClazzArray)); if (BooleanUtil.isTrue(liteflowConfig.getPrintExecutionLog())) { LOG.info("slot[{}] offered", slotIndex); } @@ -357,7 +348,7 @@ public class FlowExecutor { throw new NoAvailableSlotException("there is no available slot"); } - Slot slot = DataBus.getSlot(slotIndex); + Slot slot = DataBus.getSlot(slotIndex); if (ObjectUtil.isNull(slot)) { throw new NoAvailableSlotException(StrUtil.format("the slot[{}] is not exist", slotIndex)); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java index 46571ebcb..27f4643b0 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/NodeComponent.java @@ -70,7 +70,7 @@ public abstract class NodeComponent{ } public void execute() throws Exception{ - Slot slot = this.getSlot(); + Slot slot = this.getSlot(); //在元数据里加入step信息 CmpStep cmpStep = new CmpStep(nodeId, name, CmpStepTypeEnum.SINGLE); @@ -137,7 +137,7 @@ public abstract class NodeComponent{ } - public void beforeProcess(String nodeId, Slot slot){ + public void beforeProcess(String nodeId, Slot slot){ //全局切面只在spring体系下生效,这里用了spi机制取到相应环境下的实现类 //非spring环境下,全局切面为空实现 CmpAroundAspectHolder.loadCmpAroundAspect().beforeProcess(nodeId, slot); @@ -153,7 +153,7 @@ public abstract class NodeComponent{ //如果需要在抛错后回调某一段逻辑,请覆盖这个方法 } - public void afterProcess(String nodeId, Slot slot){ + public void afterProcess(String nodeId, Slot slot){ CmpAroundAspectHolder.loadCmpAroundAspect().afterProcess(nodeId, slot); } @@ -199,13 +199,16 @@ public abstract class NodeComponent{ this.slotIndexTL.remove(); } - public Slot getSlot(){ + public Slot getSlot(){ return DataBus.getSlot(this.slotIndexTL.get()); } - public T getContextBean(){ - Slot slot = this.getSlot(); - return slot.getContextBean(); + public T getFirstContextBean(){ + return this.getSlot().getFirstContextBean(); + } + + public T getContextBean(Class contextBeanClazz){ + return this.getSlot().getContextBean(contextBeanClazz); } public String getNodeId() { diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainDuplicateException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainDuplicateException.java index e458fd55d..6cf101e05 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainDuplicateException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainDuplicateException.java @@ -18,6 +18,7 @@ public class ChainDuplicateException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainEndException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainEndException.java index cf8eb3704..42a9cf3f6 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainEndException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainEndException.java @@ -12,6 +12,7 @@ public class ChainEndException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainNotFoundException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainNotFoundException.java index 06d87be48..7e08373eb 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainNotFoundException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ChainNotFoundException.java @@ -11,6 +11,7 @@ public class ChainNotFoundException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentCannotRegisterException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentCannotRegisterException.java index 7f955ca5d..b9d0e3370 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentCannotRegisterException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentCannotRegisterException.java @@ -17,6 +17,7 @@ public class ComponentCannotRegisterException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentMethodDefineErrorException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentMethodDefineErrorException.java index 9e8beb8ac..520b29d76 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentMethodDefineErrorException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentMethodDefineErrorException.java @@ -12,6 +12,7 @@ public class ComponentMethodDefineErrorException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentNotAccessException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentNotAccessException.java index d7d6c8836..1ad1db869 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentNotAccessException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentNotAccessException.java @@ -11,6 +11,7 @@ public class ComponentNotAccessException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentProxyErrorException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentProxyErrorException.java index 4b04c29b3..d8177be53 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentProxyErrorException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ComponentProxyErrorException.java @@ -12,6 +12,7 @@ public class ComponentProxyErrorException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ConfigErrorException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ConfigErrorException.java index c8e4d6d3f..7ff1a6e65 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ConfigErrorException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ConfigErrorException.java @@ -11,6 +11,7 @@ public class ConfigErrorException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/CyclicDependencyException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/CyclicDependencyException.java index 95a6e676d..700aef088 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/CyclicDependencyException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/CyclicDependencyException.java @@ -12,6 +12,7 @@ public class CyclicDependencyException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/EmptyConditionValueException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/EmptyConditionValueException.java index 0331091e4..76614442b 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/EmptyConditionValueException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/EmptyConditionValueException.java @@ -11,6 +11,7 @@ public class EmptyConditionValueException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ErrorSupportPathException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ErrorSupportPathException.java index 65e3e58ce..dcc4d782f 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ErrorSupportPathException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ErrorSupportPathException.java @@ -11,6 +11,7 @@ public class ErrorSupportPathException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ExecutableItemNotFoundException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ExecutableItemNotFoundException.java index cd2cf8d15..3cb6eba13 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ExecutableItemNotFoundException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ExecutableItemNotFoundException.java @@ -21,6 +21,7 @@ public class ExecutableItemNotFoundException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/FlowExecutorNotInitException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/FlowExecutorNotInitException.java index 24c1dbcf5..3b0ceb0df 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/FlowExecutorNotInitException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/FlowExecutorNotInitException.java @@ -11,6 +11,7 @@ public class FlowExecutorNotInitException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/FlowSystemException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/FlowSystemException.java index 400e0c5d5..5ce4647d4 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/FlowSystemException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/FlowSystemException.java @@ -11,6 +11,7 @@ public class FlowSystemException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/MultipleParsersException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/MultipleParsersException.java index 354aface3..2f960e06d 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/MultipleParsersException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/MultipleParsersException.java @@ -11,6 +11,7 @@ public class MultipleParsersException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NoAvailableSlotException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NoAvailableSlotException.java index a4ae9162e..998ceeb50 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NoAvailableSlotException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NoAvailableSlotException.java @@ -11,6 +11,7 @@ public class NoAvailableSlotException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NoSuchContextBeanException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NoSuchContextBeanException.java new file mode 100644 index 000000000..b209a0b20 --- /dev/null +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NoSuchContextBeanException.java @@ -0,0 +1,30 @@ +package com.yomahub.liteflow.exception; + +/** + * Chain 重复异常 + * + * @author tangkc + */ +public class NoSuchContextBeanException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * 异常信息 + */ + private String message; + + public NoSuchContextBeanException(String message) { + this.message = message; + } + + @Override + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NodeBuildException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NodeBuildException.java index d3f397a49..f53277169 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NodeBuildException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NodeBuildException.java @@ -11,6 +11,7 @@ public class NodeBuildException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NodeTypeNotSupportException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NodeTypeNotSupportException.java index 78083e1ca..933ace6c1 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NodeTypeNotSupportException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NodeTypeNotSupportException.java @@ -17,6 +17,7 @@ public class NodeTypeNotSupportException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NotSupportConditionException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NotSupportConditionException.java index 4a7d4f27f..89ef7d76b 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NotSupportConditionException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/NotSupportConditionException.java @@ -11,6 +11,7 @@ public class NotSupportConditionException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ParseException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ParseException.java index f0b2ac3c6..b91a6e5fb 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ParseException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ParseException.java @@ -11,6 +11,7 @@ public class ParseException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ThreadExecutorServiceCreateException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ThreadExecutorServiceCreateException.java index 6c3442231..4fdba3670 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ThreadExecutorServiceCreateException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/ThreadExecutorServiceCreateException.java @@ -15,6 +15,7 @@ public class ThreadExecutorServiceCreateException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/WhenExecuteException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/WhenExecuteException.java index ebe3f8662..fff2b0d96 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/WhenExecuteException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/WhenExecuteException.java @@ -11,6 +11,7 @@ public class WhenExecuteException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/WhenTimeoutException.java b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/WhenTimeoutException.java index 71f139165..6c7d9e025 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/exception/WhenTimeoutException.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/exception/WhenTimeoutException.java @@ -11,6 +11,7 @@ public class WhenTimeoutException extends RuntimeException { this.message = message; } + @Override public String getMessage() { return message; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java index fa3d6e4c1..4f5acf4d7 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/LiteflowResponse.java @@ -13,7 +13,7 @@ import java.util.stream.Collectors; * 执行结果封装类 * @author zend.wang */ -public class LiteflowResponse implements Serializable { +public class LiteflowResponse implements Serializable { private static final long serialVersionUID = -2792556188993845048L; @@ -21,14 +21,14 @@ public class LiteflowResponse implements Serializable { private String message; - private Throwable cause; + private Exception cause; - private Slot slot; + private Slot slot; public LiteflowResponse() { this(null); } - public LiteflowResponse(Slot slot) { + public LiteflowResponse(Slot slot) { this.success = true; this.message = ""; this.slot = slot; @@ -50,35 +50,39 @@ public class LiteflowResponse implements Serializable { this.message = message; } - public Throwable getCause() { + public Exception getCause() { return cause; } - public void setCause(final Throwable cause) { + public void setCause(final Exception cause) { this.cause = cause; } - public Slot getSlot() { + public Slot getSlot() { return slot; } - public void setSlot(Slot slot) { + public void setSlot(Slot slot) { this.slot = slot; } - public T getContextBean(){ - return getSlot().getContextBean(); + public T getFirstContextBean(){ + return this.getSlot().getFirstContextBean(); + } + + public T getContextBean(Class contextBeanClazz){ + return this.getSlot().getContextBean(contextBeanClazz); } public Map getExecuteSteps(){ - return getSlot().getExecuteSteps().stream().collect(Collectors.toMap(CmpStep::getNodeId, cmpStep -> cmpStep)); + return this.getSlot().getExecuteSteps().stream().collect(Collectors.toMap(CmpStep::getNodeId, cmpStep -> cmpStep)); } public String getExecuteStepStr(){ - return getSlot().getExecuteStepStr(); + return this.getSlot().getExecuteStepStr(); } public String getExecuteStepStrWithoutTime(){ - return getSlot().getExecuteStepStr(false); + return this.getSlot().getExecuteStepStr(false); } } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java index fa022eeab..790f8bc6d 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java @@ -72,7 +72,7 @@ public class Chain implements Executable { if (CollUtil.isEmpty(conditionList)) { throw new FlowSystemException("no conditionList in this chain[" + chainName + "]"); } - Slot slot = DataBus.getSlot(slotIndex); + Slot slot = DataBus.getSlot(slotIndex); try { //在子流程或者隐式流程里,slot需要取到的chainName是当前流程,所以这不再是set,而是push //其底层结构是一个stack diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java index 2c7975b5a..5019bfbca 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Node.java @@ -112,7 +112,7 @@ public class Node implements Executable,Cloneable{ throw new FlowSystemException("there is no instance for node id " + id); } instance.setSlotIndex(slotIndex); - Slot slot = DataBus.getSlot(slotIndex); + Slot slot = DataBus.getSlot(slotIndex); try { //把tag和condNodeMap赋给NodeComponent diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhenCondition.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhenCondition.java index ec0660a5e..7a9eff81a 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhenCondition.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhenCondition.java @@ -49,7 +49,7 @@ public class WhenCondition extends Condition { //使用线程池执行when并发流程 //这块涉及到挺多的多线程逻辑,所以注释比较详细,看到这里的童鞋可以仔细阅读 private void executeAsyncCondition(Integer slotIndex) throws Exception{ - Slot slot = DataBus.getSlot(slotIndex); + Slot slot = DataBus.getSlot(slotIndex); //此方法其实只会初始化一次Executor,不会每次都会初始化。Executor是唯一的 ExecutorService parallelExecutor = ExecutorHelper.loadInstance().buildWhenExecutor(this.getThreadExecutorClass()); diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java index 9475b7789..e10905c98 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DataBus.java @@ -16,9 +16,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -35,7 +37,7 @@ public class DataBus { //这里为什么采用ConcurrentHashMap作为slot存放的容器? //因为ConcurrentHashMap的随机取值复杂度也和数组一样为O(1),并且没有并发问题,还有自动扩容的功能 //用数组的话,扩容涉及copy,线程安全问题还要自己处理 - private static ConcurrentHashMap> SLOTS; + private static ConcurrentHashMap SLOTS; private static ConcurrentLinkedQueue QUEUE; @@ -56,11 +58,14 @@ public class DataBus { } } - public static int offerSlot(Class contextClazz) { + public static int offerSlot(List> contextClazzList) { try { - //这里用这个方法,是为了兼容当没有无参构造方法所报的错 - T contextBean = ReflectUtil.newInstanceIfPossible(contextClazz); - Slot slot = new Slot<>(contextBean); + //把classList通过反射初始化成对象列表 + //这里用newInstanceIfPossible这个方法,是为了兼容当没有无参构造方法所报的错 + List contextBeanList = contextClazzList.stream() + .map((Function, Object>) ReflectUtil::newInstanceIfPossible).collect(Collectors.toList()); + + Slot slot = new Slot(contextBeanList); //这里有没有并发问题? //没有,因为QUEUE的类型为ConcurrentLinkedQueue,并发情况下,每次取到的index不会相同 @@ -96,13 +101,13 @@ public class DataBus { return -1; } - public static Slot getSlot(int slotIndex){ - return (Slot) SLOTS.get(slotIndex); + public static Slot getSlot(int slotIndex){ + return SLOTS.get(slotIndex); } - public static T getContextBean(int slotIndex){ - Slot slot = getSlot(slotIndex); - return slot.getContextBean(); + public static List getContextBeanList(int slotIndex){ + Slot slot = getSlot(slotIndex); + return slot.getContextBeanList(); } public static void releaseSlot(int slotIndex){ diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/Slot.java b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/Slot.java index f0bdc1a98..6e12d6a67 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/Slot.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/Slot.java @@ -9,15 +9,18 @@ package com.yomahub.liteflow.slot; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; +import com.yomahub.liteflow.exception.NoSuchContextBeanException; import com.yomahub.liteflow.exception.NullParamException; import com.yomahub.liteflow.flow.entity.CmpStep; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Iterator; +import java.util.List; import java.util.Queue; import java.util.Stack; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.function.Predicate; /** * Slot的抽象类实现 @@ -25,7 +28,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; * @author LeoLee */ @SuppressWarnings("unchecked") -public class Slot{ +public class Slot{ private static final Logger LOG = LoggerFactory.getLogger(Slot.class); @@ -55,13 +58,13 @@ public class Slot{ protected ConcurrentHashMap metaDataMap = new ConcurrentHashMap<>(); - private O contextBean; + private List contextBeanList; public Slot() { } - public Slot(O contextBean) { - this.contextBean = contextBean; + public Slot(List contextBeanList) { + this.contextBeanList = contextBeanList; } private boolean hasMetaData(String key){ @@ -239,7 +242,20 @@ public class Slot{ putMetaDataMap(EXCEPTION, e); } - public O getContextBean() { - return contextBean; + public List getContextBeanList(){ + return this.contextBeanList; + } + + public T getContextBean(Class contextBeanClazz) { + T t = (T)contextBeanList.stream().filter(o -> o.getClass().equals(contextBeanClazz)).findFirst().orElse(null); + if (t == null){ + throw new NoSuchContextBeanException("this type is not in the context type passed in"); + } + return t; + } + + public T getFirstContextBean(){ + Class firstContextBeanClazz = (Class) this.getContextBeanList().get(0).getClass(); + return this.getContextBean(firstContextBeanClazz); } } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/CmpAroundAspect.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/CmpAroundAspect.java index 8219c005e..5b8d1fa46 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/CmpAroundAspect.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/CmpAroundAspect.java @@ -9,7 +9,7 @@ import com.yomahub.liteflow.slot.Slot; */ public interface CmpAroundAspect extends SpiPriority { - void beforeProcess(String nodeId, Slot slot); + void beforeProcess(String nodeId, Slot slot); - void afterProcess(String nodeId, Slot slot); + void afterProcess(String nodeId, Slot slot); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalCmpAroundAspect.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalCmpAroundAspect.java index 0adf0afac..cdc879bbe 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalCmpAroundAspect.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalCmpAroundAspect.java @@ -11,12 +11,12 @@ import com.yomahub.liteflow.spi.CmpAroundAspect; */ public class LocalCmpAroundAspect implements CmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { + public void beforeProcess(String nodeId, Slot slot) { //无spring环境下为空实现 } @Override - public void afterProcess(String nodeId, Slot slot) { + public void afterProcess(String nodeId, Slot slot) { //无spring环境下为空实现 } diff --git a/liteflow-script-groovy/src/main/java/com/yomahub/liteflow/script/groovy/GroovyScriptExecutor.java b/liteflow-script-groovy/src/main/java/com/yomahub/liteflow/script/groovy/GroovyScriptExecutor.java index 65fb2dd13..c497dba0c 100644 --- a/liteflow-script-groovy/src/main/java/com/yomahub/liteflow/script/groovy/GroovyScriptExecutor.java +++ b/liteflow-script-groovy/src/main/java/com/yomahub/liteflow/script/groovy/GroovyScriptExecutor.java @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; import javax.script.*; import java.util.Map; +import java.util.function.Consumer; /** * Groovy脚本语言的执行器实现 @@ -55,8 +56,15 @@ public class GroovyScriptExecutor implements ScriptExecutor { CompiledScript compiledScript = compiledScriptMap.get(nodeId); Bindings bindings = new SimpleBindings(); - Object contextBean = DataBus.getContextBean(slotIndex); - bindings.put("context", contextBean); + + //往脚本语言绑定表里循环增加绑定上下文的key + //key的规则为自定义上下文的simpleName + //比如你的自定义上下文为AbcContext,那么key就为:abcContext + //这里不统一放一个map的原因是考虑到有些用户会调用上下文里的方法,而不是参数,所以脚本语言的绑定表里也是放多个上下文 + DataBus.getContextBeanList(slotIndex).forEach(o -> { + String key = StrUtil.lowerFirst(o.getClass().getSimpleName()); + bindings.put(key, o); + }); return compiledScript.eval(bindings); }catch (Exception e){ log.error(e.getMessage(), e); diff --git a/liteflow-script-qlexpress/src/main/java/com/yomahub/liteflow/script/qlexpress/QLExpressScriptExecutor.java b/liteflow-script-qlexpress/src/main/java/com/yomahub/liteflow/script/qlexpress/QLExpressScriptExecutor.java index ecccfc1f7..682f89c59 100644 --- a/liteflow-script-qlexpress/src/main/java/com/yomahub/liteflow/script/qlexpress/QLExpressScriptExecutor.java +++ b/liteflow-script-qlexpress/src/main/java/com/yomahub/liteflow/script/qlexpress/QLExpressScriptExecutor.java @@ -59,9 +59,17 @@ public class QLExpressScriptExecutor implements ScriptExecutor { } InstructionSet instructionSet = compiledScriptMap.get(nodeId); - Object contextBean = DataBus.getContextBean(slotIndex); DefaultContext context = new DefaultContext<>(); - context.put("context", contextBean); + + //往脚本语言绑定表里循环增加绑定上下文的key + //key的规则为自定义上下文的simpleName + //比如你的自定义上下文为AbcContext,那么key就为:abcContext + //这里不统一放一个map的原因是考虑到有些用户会调用上下文里的方法,而不是参数,所以脚本语言的绑定表里也是放多个上下文 + DataBus.getContextBeanList(slotIndex).forEach(o -> { + String key = StrUtil.lowerFirst(o.getClass().getSimpleName()); + context.put(key, o); + }); + return expressRunner.execute(instructionSet, context, errorList, true, false, null); }catch (Exception e){ for (String scriptErrorMsg : errorList){ diff --git a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringCmpAroundAspect.java b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringCmpAroundAspect.java index b34d04e72..42011f2fc 100644 --- a/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringCmpAroundAspect.java +++ b/liteflow-spring/src/main/java/com/yomahub/liteflow/spi/spring/SpringCmpAroundAspect.java @@ -12,14 +12,14 @@ import com.yomahub.liteflow.spring.ComponentScanner; */ public class SpringCmpAroundAspect implements CmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { + public void beforeProcess(String nodeId, Slot slot) { if (ObjectUtil.isNotNull(ComponentScanner.cmpAroundAspect)) { ComponentScanner.cmpAroundAspect.beforeProcess(nodeId, slot); } } @Override - public void afterProcess(String nodeId, Slot slot) { + public void afterProcess(String nodeId, Slot slot) { if (ObjectUtil.isNotNull(ComponentScanner.cmpAroundAspect)) { ComponentScanner.cmpAroundAspect.afterProcess(nodeId, slot); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java index c031268f5..02913478c 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java @@ -36,7 +36,7 @@ public class AbsoluteConfigPathSpringbootTest extends BaseTest { @Test public void testAbsoluteConfig() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringbootTest.java index 9cea17afa..6ebacfc7d 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringbootTest.java @@ -22,20 +22,20 @@ public class CustomAOPSpringbootTest extends BaseTest { //测试自定义AOP,串行场景 @Test public void testCustomAopS() { - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("before_after", response.getContextBean.getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); } //测试自定义AOP,并行场景 @Test public void testCustomAopP() { - LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); }*/ } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringbootTest.java index c38960b52..04bcbc997 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringbootTest.java @@ -37,35 +37,38 @@ public class GlobalAOPSpringbootTest extends BaseTest { //测试全局AOP,串行场景 @Test public void testGlobalAopS() { - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("d")); - Assert.assertEquals("before_after", response.getContextBean().getData("e")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("d")); + Assert.assertEquals("before_after", context.getData("e")); } //测试全局AOP,并行场景 @Test public void testGlobalAopP() { - LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("d")); - Assert.assertEquals("before_after", response.getContextBean().getData("e")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("d")); + Assert.assertEquals("before_after", context.getData("e")); } @Test public void testGlobalAopException() { - LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("f")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("f")); } @AfterClass diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java index 785578fda..3704a146d 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java @@ -5,16 +5,16 @@ import com.yomahub.liteflow.aop.ICmpAroundAspect; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; -public class CmpAspect implements ICmpAroundAspect { +public class CmpAspect implements ICmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getContextBean(); + public void beforeProcess(String nodeId, Slot slot) { + DefaultContext context = slot.getFirstContextBean(); context.setData(nodeId, "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getContextBean(); + public void afterProcess(String nodeId, Slot slot) { + DefaultContext context = slot.getFirstContextBean(); context.setData(nodeId, StrUtil.format("{}_{}", context.getData(nodeId), "after")); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java index 322038d0f..dd2e61453 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java @@ -19,7 +19,7 @@ public class CustomAspect { @Around("cut()") public Object around(ProceedingJoinPoint jp) throws Throwable { NodeComponent cmp = (NodeComponent) jp.getThis(); - DefaultContext context = cmp.getContextBean(); + DefaultContext context = cmp.getFirstContextBean(); context.setData(cmp.getNodeId(), "before"); Object returnObj = jp.proceed(); context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java index 9c2e18928..71264d840 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java @@ -39,7 +39,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { * **/ @Test public void testAsyncFlow1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); Assert.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -47,7 +47,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { //这个和test1有点类似,只不过进一步验证了步骤 @Test public void testAsyncFlow2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); Assert.assertTrue(ListUtil.toList("b==>j==>g==>f==>h","b==>j==>g==>h==>f", "b==>j==>h==>g==>f","b==>j==>h==>f==>g", "b==>j==>f==>h==>g","b==>j==>f==>g==>h" @@ -57,7 +57,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { //测试errorResume,默认的errorResume为false,这里测试默认的 @Test public void testAsyncFlow3_1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); } @@ -65,18 +65,19 @@ public class AsyncNodeSpringbootTest extends BaseTest { //测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); Assert.assertTrue(response.isSuccess()); } //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @Test public void testAsyncFlow4() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //因为不记录错误,所以最终结果是true Assert.assertTrue(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //因为配置了不抛错,所以response里的cause应该为null Assert.assertNull(response.getCause()); @@ -85,11 +86,12 @@ public class AsyncNodeSpringbootTest extends BaseTest { //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @Test public void testAsyncFlow5() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //整个并行组是报错的,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //因为第一个when配置了会报错,所以response里的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -98,11 +100,12 @@ public class AsyncNodeSpringbootTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @Test public void testAsyncFlow6() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //第一个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(1), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -111,11 +114,12 @@ public class AsyncNodeSpringbootTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @Test public void testAsyncFlow7() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //第二个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -127,8 +131,9 @@ public class AsyncNodeSpringbootTest extends BaseTest { //这里要注意的是,由于step是先加入,所以step的打印顺序并不是这样的。但是实际执行是正确的 @Test public void testAsyncFlow8() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("check").toString().startsWith("habc")); + Assert.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java index 057100168..043d58eda 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; public class ACmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java index abbc36411..94e0eac96 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java index 3bf9a7b1c..64e3a43c3 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; public class CCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java index f2a465f93..16398b8de 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java @@ -15,7 +15,7 @@ public class DCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { Thread.sleep(1000); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java index b9fa720cb..b835cfb4d 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java @@ -16,7 +16,7 @@ public class GCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { Thread.sleep(500); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java index 617d28670..00aec49ef 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java @@ -15,7 +15,7 @@ public class HCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java index 8315dcea3..a61784129 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java @@ -16,7 +16,7 @@ public class ICmp { @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); if (context.hasData("count")){ Integer count = context.getData("count"); context.setData("count", ++count); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/base/BaseSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/base/BaseSpringbootTest.java index b50e1bd4d..608e90986 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/base/BaseSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/base/BaseSpringbootTest.java @@ -32,7 +32,7 @@ public class BaseSpringbootTest extends BaseTest { @Test public void testBase() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest1.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest1.java index 0bbf7fc63..1e830db3f 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest1.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest1.java @@ -83,7 +83,7 @@ public class BuilderSpringbootTest1 extends BaseTest { .setValue("e(f|g|chain2)").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @@ -141,7 +141,7 @@ public class BuilderSpringbootTest1 extends BaseTest { .setValue("e(f|g|chain2)").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @@ -210,7 +210,7 @@ public class BuilderSpringbootTest1 extends BaseTest { )).build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest2.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest2.java index 8906dc70e..fc8d67074 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest2.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest2.java @@ -34,7 +34,7 @@ public class BuilderSpringbootTest2 extends BaseTest { LiteFlowConditionBuilder.createThenCondition().setValue("h,i,j").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("h==>i==>j", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringbootTest.java index 30770cfde..bae024e7f 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringbootTest.java @@ -34,7 +34,7 @@ public class LiteflowRetrySpringbootTest extends BaseTest { //全局重试配置测试 @Test public void testRetry1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } @@ -42,7 +42,7 @@ public class LiteflowRetrySpringbootTest extends BaseTest { //单个组件重试配置测试 @Test public void testRetry2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } @@ -50,14 +50,14 @@ public class LiteflowRetrySpringbootTest extends BaseTest { //单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertFalse(response.isSuccess()); } //单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringbootTest.java index 1ba23fe02..b96d94d55 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringbootTest.java @@ -32,7 +32,7 @@ public class CmpStepSpringbootTest extends BaseTest { @Test public void testStep() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); @@ -45,7 +45,7 @@ public class CmpStepSpringbootTest extends BaseTest { @Test public void testStep2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorSpringbootTest.java index f3833fd26..5bc400e2b 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorSpringbootTest.java @@ -38,7 +38,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //isAccess方法的功能测试 @Test public void testIsAccess() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); Assert.assertTrue(response.isSuccess()); Assert.assertNotNull(response.getSlot().getResponseData()); } @@ -46,7 +46,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //组件抛错的功能点测试 @Test(expected = ArithmeticException.class) public void testComponentException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("/ by zero", response.getMessage()); ReflectionUtils.rethrowException(response.getCause()); @@ -55,7 +55,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); Assert.assertTrue(response.isSuccess()); Assert.assertNull(response.getCause()); } @@ -63,7 +63,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d",response.getExecuteStepStr()); } @@ -71,7 +71,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("e",response.getExecuteStepStr()); } @@ -79,14 +79,14 @@ public class FlowExecutorSpringbootTest extends BaseTest { //条件组件的功能点测试 @Test public void testNodeCondComponent() { - LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); Assert.assertTrue(response.isSuccess()); } //测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g",response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameSpringbootTest.java index 1c1e046ef..3f1d970ff 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customMethodName/CustomMethodNameSpringbootTest.java @@ -32,7 +32,7 @@ public class CustomMethodNameSpringbootTest extends BaseTest { @Test public void testCustomMethodName() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customMethodName/cmp/ACmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customMethodName/cmp/ACmp.java index 3fded6e00..890d0b5b5 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customMethodName/cmp/ACmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customMethodName/cmp/ACmp.java @@ -30,12 +30,12 @@ public class ACmp{ } @LiteflowMethod(LiteFlowMethodEnum.BEFORE_PROCESS) - public void beforeAcmp(String nodeId, Slot slot){ + public void beforeAcmp(String nodeId, Slot slot){ System.out.println("before A"); } @LiteflowMethod(LiteFlowMethodEnum.AFTER_PROCESS) - public void afterAcmp(String nodeId, Slot slot){ + public void afterAcmp(String nodeId, Slot slot){ System.out.println("after A"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringbootTest.java index c441b6feb..6437c5640 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringbootTest.java @@ -37,7 +37,7 @@ public class CustomNodesSpringbootTest extends BaseTest { @Test public void testCustomNodes() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringbootTest.java index 5a1ac1481..766ed3165 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringbootTest.java @@ -40,9 +40,10 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { */ @Test public void testGlobalThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("threadName").toString().startsWith("lf-when-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -50,9 +51,10 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { */ @Test public void testGlobalAndCustomWhenThreadPool() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response1.getFirstContextBean(); Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(response1.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } @@ -64,9 +66,10 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { // 使用when - thread1 testGlobalAndCustomWhenThreadPool(); // chain配置同一个thead1 - LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response2.getFirstContextBean(); Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(response2.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java index b89d8a6b8..7f506aa29 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java @@ -20,7 +20,7 @@ public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("BCmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java index 45a9d43ac..39a1213fb 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java @@ -20,7 +20,7 @@ public class CCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("CCmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java index 137239d22..e06ad1efa 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java @@ -20,7 +20,7 @@ public class DCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java index bc05a7e4a..983cfbf8d 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java @@ -20,7 +20,7 @@ public class ECmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("ECmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java index ed547e033..ddb239028 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java @@ -20,7 +20,7 @@ public class FCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java index a62883a92..0bcf48b1f 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java @@ -33,29 +33,32 @@ public class EventSpringbootTest extends BaseTest { //测试组件成功事件 @Test public void testEvent1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", response.getContextBean().getData("test")); + Assert.assertEquals("abc", context.getData("test")); } //测试组件失败事件 @Test public void testEvent2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", response.getContextBean().getData("test")); - Assert.assertEquals("error:d", response.getContextBean().getData("error")); + Assert.assertEquals("ab", context.getData("test")); + Assert.assertEquals("error:d", context.getData("error")); } //测试组件失败事件本身抛出异常 @Test public void testEvent3() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", response.getContextBean().getData("test")); - Assert.assertEquals("error:e", response.getContextBean().getData("error")); + Assert.assertEquals("a", context.getData("test")); + Assert.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java index 36c678ca1..a21f927d6 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java @@ -20,14 +20,14 @@ public class ACmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("test",""); System.out.println("ACmp executed!"); } @LiteflowMethod(LiteFlowMethodEnum.ON_SUCCESS) public void onSuccess(NodeComponent bindCmp) throws Exception { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); String str = context.getData("test"); str += bindCmp.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java index 8875137c1..07985de02 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java @@ -25,7 +25,7 @@ public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.ON_SUCCESS) public void onSuccess(NodeComponent bindCmp) throws Exception { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); String str = context.getData("test"); str += bindCmp.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java index 2380dc512..4b1328852 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java @@ -25,7 +25,7 @@ public class CCmp{ @LiteflowMethod(LiteFlowMethodEnum.ON_SUCCESS) public void onSuccess(NodeComponent bindCmp) throws Exception { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); String str = context.getData("test"); str += bindCmp.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index a6bb546f3..282f18539 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -26,7 +26,7 @@ public class DCmp{ @LiteflowMethod(LiteFlowMethodEnum.ON_ERROR) public void onError(NodeComponent bindCmp) throws Exception { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("error","error:"+bindCmp.getNodeId()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index c18ee294e..01ae0c0c9 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -26,7 +26,7 @@ public class ECmp{ @LiteflowMethod(LiteFlowMethodEnum.ON_ERROR) public void onError(NodeComponent bindCmp) throws Exception { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("error","error:"+bindCmp.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringBootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringBootTest.java index 4f68c6dec..9702452d3 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringBootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringBootTest.java @@ -59,7 +59,7 @@ public class Exception2SpringBootTest extends BaseTest { @Test public void testGetSlotFromResponseWhenException() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); Assert.assertFalse(response.isSuccess()); Assert.assertNotNull(response.getCause()); Assert.assertNotNull(response.getSlot()); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringbootTest.java index 555e2e45d..7327cc568 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringbootTest.java @@ -33,8 +33,8 @@ public class Executor2FutureSpringbootTest extends BaseTest { @Test public void testFuture() throws Exception{ - Future> future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); - LiteflowResponse response = future.get(); + Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); + LiteflowResponse response = future.get(); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendSpringbootTest.java index f13627bd7..5363b5c9a 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/extend/CmpExtendSpringbootTest.java @@ -32,7 +32,7 @@ public class CmpExtendSpringbootTest extends BaseTest { @Test public void testExtend() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java index eed3cd4cf..06e826e75 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java @@ -31,7 +31,7 @@ public class FlowMetaSpringbootTest extends BaseTest { @Test public void testFlowMeta() { FlowBus.addCommonNode("d", "d组件", DCmp.class.getName()); - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>d[d组件]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java index 4ff8e4828..e656a9029 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java @@ -27,7 +27,7 @@ public class LazySpringbootTest extends BaseTest { @Test public void testLazy() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringbootTest.java index 43fa6a188..c47a29a2b 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringbootTest.java @@ -32,7 +32,7 @@ public class LiteflowComponentSpringbootTest extends BaseTest { @Test public void testConfig() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java index 38a50f768..c151cbaa3 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java @@ -35,7 +35,7 @@ public class MonitorSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Thread.sleep(10000); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java index 2ce1f1c4e..74659c688 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java @@ -32,7 +32,7 @@ public class LiteflowMultipleTypeSpringbootTest extends BaseTest { @Test public void testMultipleType() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java index a5da9969f..0ced9da9f 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerDefaultNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerDefaultNodeExecutor进行执行"); context.setData("customerDefaultNodeExecutor", this.getClass()); super.execute(instance); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java index add288d67..5a9f2e58d 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerNodeExecutor进行执行"); context.setData("customerNodeExecutor", this.getClass()); super.execute(instance); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java index a6eb87d53..003d33319 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); context.setData("customerNodeExecutorAndCustomRetry", this.getClass()); super.execute(instance); @@ -23,7 +23,7 @@ public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { TimeUnit.MICROSECONDS.sleep(20L); - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); context.setData("retryLogic", this.getClass()); super.retry(instance, currentRetryCount); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java index bc6871a74..45baf6bae 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java @@ -35,25 +35,27 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest { // 默认执行器测试 @Test public void testCustomerDefaultNodeExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); Assert.assertEquals("a", response.getExecuteStepStr()); } //默认执行器测试+全局重试配置测试 @Test public void testDefaultExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); } //自定义执行器测试 @Test public void testCustomerExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("c", response.getExecuteStepStr()); } @@ -61,9 +63,10 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest { //自定义执行器测试+全局重试配置测试 @Test public void testCustomExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getContextBean().getData("retryLogic")); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java index acf0f397e..dd2b055e3 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java @@ -33,7 +33,7 @@ public class CustomParserJsonSpringbootTest extends BaseTest { //测试springboot场景的自定义json parser @Test public void testJsonCustomParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java index 65795f03b..47e80dee4 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java @@ -34,7 +34,7 @@ public class CustomParserXmlSpringbootTest extends BaseTest { //测试springboot场景的自定义json parser @Test public void testXmlCustomParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/JsonParserSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/JsonParserSpringbootTest.java index 87cbbe648..04707d903 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/JsonParserSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/JsonParserSpringbootTest.java @@ -31,7 +31,7 @@ public class JsonParserSpringbootTest extends BaseTest { //测试spring场景的json parser @Test public void testJsonParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportSpringbootTest.java index 7837ffa6a..5234ab72d 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportSpringbootTest.java @@ -26,7 +26,7 @@ public class SpringELSupportSpringbootTest extends BaseTest { //测试springEL的解析情况 @Test public void testSpringELParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java index 63884c98f..2e52acc18 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java @@ -31,7 +31,7 @@ public class XmlParserSpringbootTest extends BaseTest { //测试无springboot场景的xml parser @Test public void testXmlParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/YmlParserSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/YmlParserSpringbootTest.java index c7fcc74c1..d64698267 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/YmlParserSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/YmlParserSpringbootTest.java @@ -31,7 +31,7 @@ public class YmlParserSpringbootTest extends BaseTest { //测试无springboot场景的yml parser @Test public void testYmlParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringbootTest.java index 35b109f2a..17c499c98 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringbootTest.java @@ -33,7 +33,7 @@ public class PreAndFinallySpringbootTest extends BaseTest { //测试普通的pre和finally节点 @Test public void testPreAndFinally1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getExecuteStepStr()); } @@ -41,7 +41,7 @@ public class PreAndFinallySpringbootTest extends BaseTest { //测试pre和finally节点不放在开头和结尾的情况 @Test public void testPreAndFinally2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getExecuteStepStr()); } @@ -49,7 +49,7 @@ public class PreAndFinallySpringbootTest extends BaseTest { //测试有节点报错是否还执行finally节点的情况,其中d节点会报错,但依旧执行f1,f2节点 @Test public void testPreAndFinally3() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } @@ -57,14 +57,15 @@ public class PreAndFinallySpringbootTest extends BaseTest { //测试在finally节点里是否能获取exception @Test public void testPreAndFinally4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("hasEx")); + Assert.assertTrue(context.getData("hasEx")); } @Test public void testPreAndFinally5() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java index cdf4e710a..ca929402c 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java @@ -22,8 +22,8 @@ public class Finally3Cmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception{ - Slot slot = bindCmp.getSlot(); - DefaultContext context = slot.getContextBean(); + Slot slot = bindCmp.getSlot(); + DefaultContext context = slot.getFirstContextBean(); if (ObjectUtil.isNull(slot.getException())){ context.setData("hasEx", false); }else{ diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java index bb03ce012..67c630f1f 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java @@ -34,8 +34,9 @@ public class PrivateDeliverySpringbootTest extends BaseTest { @Test public void testPrivateDelivery() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - ConcurrentHashSet set = response.getContextBean().getData("testSet"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); + ConcurrentHashSet set = context.getData("testSet"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals(100, set.size()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java index 19d5108d5..5d0f91861 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java @@ -25,7 +25,7 @@ public class ACmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { System.out.println("ACmp executed!"); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("testSet", new ConcurrentHashSet<>()); for (int i = 0; i < 100; i++) { diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java index e920b0808..5186d922a 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java @@ -25,7 +25,7 @@ public class BCmp{ public void process(NodeComponent bindCmp) { System.out.println("BCmp executed!"); Integer value = bindCmp.getPrivateDeliveryData(); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); ConcurrentHashSet testSet = context.getData("testSet"); testSet.add(value); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringbootTest.java index 798ed4925..f631f2c67 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringbootTest.java @@ -38,7 +38,7 @@ public class RefreshRuleSpringbootTest extends BaseTest { public void testRefresh1() throws Exception{ String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, content); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } @@ -57,7 +57,7 @@ public class RefreshRuleSpringbootTest extends BaseTest { }).start(); for (int i = 0; i < 500; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); try { Thread.sleep(10L); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java index 2f5090c96..f18a20c2b 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java @@ -35,7 +35,7 @@ public class ReloadSpringbootTest extends BaseTest { @Test public void testReload() throws Exception{ flowExecutor.reloadRule(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java index 9a9ebf2cc..ba04dcde8 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java @@ -43,13 +43,13 @@ public class ResizeSlotSpringbootTest extends BaseTest { public void testResize() throws Exception{ ExecutorService pool = Executors.newCachedThreadPool(); - List>> futureList = new ArrayList<>(); + List> futureList = new ArrayList<>(); for (int i = 0; i < 100; i++) { - Future> future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg")); + Future future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg")); futureList.add(future); } - for(Future> future : futureList){ + for(Future future : futureList){ Assert.assertTrue(future.get().isSuccess()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringbootTest.java index fa014d723..15591e164 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringbootTest.java @@ -37,7 +37,8 @@ public class ImplicitSubFlowSpringbootTest extends BaseTest { //这里GCmp中隐式的调用chain4,从而执行了h,m @Test public void testImplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); @@ -46,6 +47,6 @@ public class ImplicitSubFlowSpringbootTest extends BaseTest { // set中第一次设置的requestId和response中的requestId一致 Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); //requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", response.getContextBean().getData("innerRequest")); + Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringbootTest.java index 2e67e1f29..3eb708eda 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringbootTest.java @@ -36,7 +36,7 @@ public class SubflowInDifferentConfigSpringbootTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringBootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringBootTest.java index e44a7d12d..80b24197f 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringBootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringBootTest.java @@ -33,7 +33,7 @@ public class SubflowJsonSpringBootTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringBootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringBootTest.java index a3dafab98..700d05a5e 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringBootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringBootTest.java @@ -33,7 +33,7 @@ public class SubflowXMLSpringBootTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringBootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringBootTest.java index d4c5b6b7a..283c0d7cd 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringBootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringBootTest.java @@ -33,7 +33,7 @@ public class SubflowYmlSpringBootTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlowYml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java index 7f2f79b5a..03c9b0d8f 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java @@ -16,7 +16,7 @@ public class HCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { String requestData = bindCmp.getSubChainReqData(); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("innerRequest", requestData); RUN_TIME_SLOT.add(bindCmp.getSlot().getRequestId()); diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootJsonTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootJsonTest.java index ded006a83..31fb76114 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootJsonTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootJsonTest.java @@ -33,14 +33,15 @@ public class NodeTagSpringbootJsonTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getContextBean().getData("test")); + Assert.assertEquals("123",context.getData("test")); } @Test public void testTag2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } @@ -50,9 +51,10 @@ public class NodeTagSpringbootJsonTest extends BaseTest { @Test public void testTag3() throws Exception{ for (int i = 0; i < 50; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getContextBean().getData("test"); + ConcurrentHashSet testSet = context.getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -60,7 +62,7 @@ public class NodeTagSpringbootJsonTest extends BaseTest { //测试tag是否能在isAccess中起效 @Test public void testTag4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootXmlTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootXmlTest.java index b9769eed0..e7e0b58fd 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootXmlTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootXmlTest.java @@ -33,14 +33,15 @@ public class NodeTagSpringbootXmlTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getContextBean().getData("test")); + Assert.assertEquals("123",context.getData("test")); } @Test public void testTag2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } @@ -50,9 +51,10 @@ public class NodeTagSpringbootXmlTest extends BaseTest { @Test public void testTag3() throws Exception{ for (int i = 0; i < 50; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getContextBean().getData("test"); + ConcurrentHashSet testSet = context.getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -60,7 +62,7 @@ public class NodeTagSpringbootXmlTest extends BaseTest { //测试tag是否能在isAccess中起效 @Test public void testTag4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java index 8dcb55cce..926ee6459 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java @@ -23,7 +23,7 @@ public class ACmp{ public void process(NodeComponent bindCmp) { String testKey = "test"; - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); if (context.getData(testKey) == null){ context.setData(testKey,bindCmp.getTag()); }else{ diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java index d28b4c007..edbe8d3d3 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java @@ -22,7 +22,7 @@ public class B1Cmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData("test",new ConcurrentHashSet()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java index a0ed4476b..48284946f 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java @@ -22,7 +22,7 @@ public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); ConcurrentHashSet testSet = context.getData("test"); testSet.add(bindCmp.getTag()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringbootTest.java index f397e1fd3..dbfecb808 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringbootTest.java @@ -32,11 +32,12 @@ public class UseTTLInWhenSpringbootTest extends BaseTest { @Test public void testUseTTLInWhen() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("hello,b", response.getContextBean().getData("b")); - Assert.assertEquals("hello,c", response.getContextBean().getData("c")); - Assert.assertEquals("hello,d", response.getContextBean().getData("d")); - Assert.assertEquals("hello,e", response.getContextBean().getData("e")); - Assert.assertEquals("hello,f", response.getContextBean().getData("f")); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); + Assert.assertEquals("hello,b", context.getData("b")); + Assert.assertEquals("hello,c", context.getData("c")); + Assert.assertEquals("hello,d", context.getData("d")); + Assert.assertEquals("hello,e", context.getData("e")); + Assert.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java index 61830e101..5bcddcd45 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java @@ -22,7 +22,7 @@ public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData(bindCmp.getNodeId(),value+",b"); System.out.println("BCmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java index 029abbad4..0a03ff778 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java @@ -22,7 +22,7 @@ public class CCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData(bindCmp.getNodeId(),value+",c"); System.out.println("CCmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java index 39b880ce4..f4337516d 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java @@ -22,7 +22,7 @@ public class DCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData(bindCmp.getNodeId(),value+",d"); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java index 22ab46c33..cf2be2733 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java @@ -22,7 +22,7 @@ public class ECmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData(bindCmp.getNodeId(),value+",e"); System.out.println("ECmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java index 6901536b7..c4c63861e 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java @@ -22,7 +22,7 @@ public class FCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - DefaultContext context = bindCmp.getContextBean(); + DefaultContext context = bindCmp.getFirstContextBean(); context.setData(bindCmp.getNodeId(),value+",f"); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest1.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest1.java index 179591505..c85ea7521 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest1.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest1.java @@ -38,7 +38,7 @@ public class WhenTimeOutSpringbootTest1 extends BaseTest { //其中b和c在when情况下超时,所以抛出了WhenTimeoutException这个错 @Test public void testWhenTimeOut() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest2.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest2.java index 1d7a1139f..e3377ef0a 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest2.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest2.java @@ -37,7 +37,7 @@ public class WhenTimeOutSpringbootTest2 extends BaseTest { //其中d,e,f都sleep 4秒,其中def是不同的组,超时设置5秒 @Test public void testWhenTimeOut() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java index c6fddb4be..109648467 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java @@ -72,7 +72,7 @@ public class ZkNodeWithJsonSpringbootTest extends BaseTest { @Test public void testZkNodeWithJson() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java index baec322d2..373db08cc 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java @@ -72,7 +72,7 @@ public class ZkNodeWithXmlSpringbootTest extends BaseTest { @Test public void testZkNodeWithXml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java index 68503df70..21a754f19 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java @@ -72,7 +72,7 @@ public class ZkNodeWithYmlSpringbootTest extends BaseTest { @Test public void testZkNodeWithYml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java index 103860a6b..ed4593916 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathTest.java @@ -28,7 +28,7 @@ public class AbsoluteConfigPathTest extends BaseTest { @Test public void testAbsoluteConfig() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeTest.java index 17dd22488..bd2354567 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeTest.java @@ -36,7 +36,7 @@ public class AsyncNodeTest extends BaseTest { * **/ @Test public void testAsyncFlow1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); Assert.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -44,7 +44,7 @@ public class AsyncNodeTest extends BaseTest { //这个和test1有点类似,只不过进一步验证了步骤 @Test public void testAsyncFlow2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); Assert.assertTrue(ListUtil.toList("b==>j==>g==>f==>h","b==>j==>g==>h==>f", "b==>j==>h==>g==>f","b==>j==>h==>f==>g", "b==>j==>f==>h==>g","b==>j==>f==>g==>h" @@ -54,7 +54,7 @@ public class AsyncNodeTest extends BaseTest { //测试errorResume,默认的errorResume为false,这里测试默认的 @Test public void testAsyncFlow3_1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); } @@ -62,18 +62,19 @@ public class AsyncNodeTest extends BaseTest { //测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); Assert.assertTrue(response.isSuccess()); } //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @Test public void testAsyncFlow4() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //因为不记录错误,所以最终结果是true Assert.assertTrue(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //因为配置了不抛错,所以response里的cause应该为null Assert.assertNull(response.getCause()); @@ -82,11 +83,12 @@ public class AsyncNodeTest extends BaseTest { //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @Test public void testAsyncFlow5() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //整个并行组是报错的,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //因为第一个when配置了会报错,所以response里的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -95,11 +97,12 @@ public class AsyncNodeTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @Test public void testAsyncFlow6() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //第一个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(1), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -108,11 +111,12 @@ public class AsyncNodeTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @Test public void testAsyncFlow7() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //第二个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -124,8 +128,9 @@ public class AsyncNodeTest extends BaseTest { //这里要注意的是,由于step是先加入,所以step的打印顺序并不是这样的。但是实际执行是正确的 @Test public void testAsyncFlow8() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("check").toString().startsWith("habc")); + Assert.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java index 89e15af6f..67eb36cf2 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java @@ -8,7 +8,7 @@ import com.yomahub.liteflow.slot.Slot; public class ACmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java index 868f769cd..d369d1904 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java @@ -8,7 +8,7 @@ import com.yomahub.liteflow.slot.Slot; public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java index 5a3f2728a..01acb9075 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java @@ -8,7 +8,7 @@ import com.yomahub.liteflow.slot.Slot; public class CCmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java index b36483053..1b7534316 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java @@ -9,7 +9,7 @@ public class DCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(1000); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java index 5c522118c..8d2db9082 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java @@ -10,7 +10,7 @@ public class GCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(500); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java index 8bafdebfd..1bdad12fa 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java @@ -9,7 +9,7 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java index f734d19c4..e3422fcf8 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java @@ -10,7 +10,7 @@ public class ICmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); if (context.hasData("count")) { Integer count = context.getData("count"); context.setData("count", ++count); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/base/BaseCommonTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/base/BaseCommonTest.java index 0c58e67f4..a88b8ce3b 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/base/BaseCommonTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/base/BaseCommonTest.java @@ -23,7 +23,7 @@ public class BaseCommonTest extends BaseTest{ @Test public void testBase(){ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "test0"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "test0"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/builder/BuilderTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/builder/BuilderTest.java index ae000fff7..6b78275ce 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/builder/BuilderTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/builder/BuilderTest.java @@ -85,7 +85,7 @@ public class BuilderTest extends BaseTest { .setValue("e(f|g|chain2)").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @@ -142,7 +142,7 @@ public class BuilderTest extends BaseTest { .setValue("e(f|g|chain2)").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @@ -210,7 +210,7 @@ public class BuilderTest extends BaseTest { )).build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryTest.java index 6243f6c42..5e3f69c2e 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetryTest.java @@ -32,7 +32,7 @@ public class LiteflowRetryTest extends BaseTest { //全局重试配置测试 @Test public void testRetry1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } @@ -40,7 +40,7 @@ public class LiteflowRetryTest extends BaseTest { //单个组件重试配置测试 @Test public void testRetry2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } @@ -48,14 +48,14 @@ public class LiteflowRetryTest extends BaseTest { //单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertFalse(response.isSuccess()); } //单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java index a45c9fd4d..cc23d43be 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepTest.java @@ -23,7 +23,7 @@ public class CmpStepTest extends BaseTest{ @Test public void testStep1(){ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); @@ -36,7 +36,7 @@ public class CmpStepTest extends BaseTest{ @Test public void testStep2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java index e180fe894..366fdd50e 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorTest.java @@ -30,7 +30,7 @@ public class FlowExecutorTest extends BaseTest { //isAccess方法的功能测试 @Test public void testIsAccess() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); Assert.assertTrue(response.isSuccess()); Assert.assertNotNull(response.getSlot().getResponseData()); } @@ -38,7 +38,7 @@ public class FlowExecutorTest extends BaseTest { //组件抛错的功能点测试 @Test(expected = ArithmeticException.class) public void testComponentException() throws Throwable { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("/ by zero", response.getMessage()); throw response.getCause(); @@ -47,7 +47,7 @@ public class FlowExecutorTest extends BaseTest { //isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Throwable { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); Assert.assertTrue(response.isSuccess()); Assert.assertNull(response.getCause()); } @@ -55,7 +55,7 @@ public class FlowExecutorTest extends BaseTest { //isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d",response.getExecuteStepStr()); } @@ -63,7 +63,7 @@ public class FlowExecutorTest extends BaseTest { //setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("e",response.getExecuteStepStr()); } @@ -71,14 +71,14 @@ public class FlowExecutorTest extends BaseTest { //条件组件的功能点测试 @Test public void testNodeCondComponent() { - LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); Assert.assertTrue(response.isSuccess()); } //测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g",response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigTest1.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigTest1.java index 301fb8c67..e367af9a4 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigTest1.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigTest1.java @@ -30,7 +30,7 @@ public class LiteflowConfigTest1 extends BaseTest { @Test public void testConfig() { LiteflowConfig config = LiteflowConfigGetter.get(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("config/flow.xml", config.getRuleSource()); Assert.assertEquals(15, config.getWhenMaxWaitSeconds().intValue()); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolTest.java index e2db94827..0d2574b1a 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolTest.java @@ -32,9 +32,10 @@ public class CustomWhenThreadPoolTest extends BaseTest { */ @Test public void testGlobalThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("threadName").toString().startsWith("lf-when-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -42,9 +43,10 @@ public class CustomWhenThreadPoolTest extends BaseTest { */ @Test public void testGlobalAndCustomWhenThreadPool() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response1.getFirstContextBean(); Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(response1.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } @@ -56,9 +58,10 @@ public class CustomWhenThreadPoolTest extends BaseTest { // 使用when - thread1 testGlobalAndCustomWhenThreadPool(); // chain配置同一个thead1 - LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response2.getFirstContextBean(); Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(response2.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java index 7360ebc23..97b99f08f 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java @@ -15,7 +15,7 @@ public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("BCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java index 43ed31b0a..fe8f9d849 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java @@ -15,7 +15,7 @@ public class CCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("CCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java index 969bfbae4..5d96e447d 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java @@ -15,7 +15,7 @@ public class DCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java index d5277892d..3ce1d86cb 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java @@ -14,7 +14,7 @@ public class ECmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("ECmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java index 9fb502f69..d0bcd868f 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java @@ -15,7 +15,7 @@ public class FCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java index 06eaa5aad..b26f0f900 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/EventTest.java @@ -24,28 +24,31 @@ public class EventTest extends BaseTest{ //测试组件成功事件 @Test public void testEvent1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", response.getContextBean().getData("test")); + Assert.assertEquals("abc", context.getData("test")); } //测试组件失败事件 @Test public void testEvent2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", response.getContextBean().getData("test")); - Assert.assertEquals("error:d", response.getContextBean().getData("error")); + Assert.assertEquals("ab", context.getData("test")); + Assert.assertEquals("error:d", context.getData("error")); } //测试组件失败事件本身抛出异常 @Test public void testEvent3() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", response.getContextBean().getData("test")); - Assert.assertEquals("error:e", response.getContextBean().getData("error")); + Assert.assertEquals("a", context.getData("test")); + Assert.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java index b7e25db2b..d4c72e051 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java @@ -14,14 +14,14 @@ public class ACmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("test",""); System.out.println("ACmp executed!"); } @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java index cfa388e24..b3328cd94 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java @@ -19,7 +19,7 @@ public class BCmp extends NodeComponent { @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java index 560c36d0d..6815efbbb 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java @@ -19,7 +19,7 @@ public class CCmp extends NodeComponent { @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index 6c920bbe1..502b4e39d 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -20,7 +20,7 @@ public class DCmp extends NodeComponent { @Override public void onError() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("error","error:"+this.getNodeId()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index 0f1821c5e..6bc89b13a 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -20,7 +20,7 @@ public class ECmp extends NodeComponent { @Override public void onError() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("error","error:"+this.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception2Test.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception2Test.java index 2706b4d65..98040456d 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception2Test.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/Exception2Test.java @@ -51,7 +51,7 @@ public class Exception2Test extends BaseTest { @Test public void testGetSlotFromResponseWhenException() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); Assert.assertFalse(response.isSuccess()); Assert.assertNotNull(response.getCause()); Assert.assertNotNull(response.getSlot()); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureTest.java index 12ae0723d..941351aa5 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureTest.java @@ -29,8 +29,8 @@ public class Executor2FutureTest extends BaseTest { @Test public void testFuture() throws Exception{ - Future> future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); - LiteflowResponse response = future.get(); + Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); + LiteflowResponse response = future.get(); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaTest.java index f3a5a4b4c..3a2550e77 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaTest.java @@ -28,7 +28,7 @@ public class FlowMetaTest extends BaseTest { @Test public void testFlowMeta() { FlowBus.addCommonNode("d", "d组件", DCmp.class); - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>d[d组件]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeTest.java index 255245800..df6b12ec3 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeTest.java @@ -29,7 +29,7 @@ public class LiteflowMultipleTypeTest extends BaseTest { @Test public void testMultipleType() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java index b40a6d73c..0ced9da9f 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerDefaultNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = DataBus.getContextBean(instance.getSlotIndex()); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerDefaultNodeExecutor进行执行"); context.setData("customerDefaultNodeExecutor", this.getClass()); super.execute(instance); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java index 68651f964..5a9f2e58d 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = DataBus.getContextBean(instance.getSlotIndex()); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerNodeExecutor进行执行"); context.setData("customerNodeExecutor", this.getClass()); super.execute(instance); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java index ff18dabbf..003d33319 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = DataBus.getContextBean(instance.getSlotIndex()); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); context.setData("customerNodeExecutorAndCustomRetry", this.getClass()); super.execute(instance); @@ -23,7 +23,7 @@ public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { TimeUnit.MICROSECONDS.sleep(20L); - DefaultContext context = DataBus.getContextBean(instance.getSlotIndex()); + DefaultContext context = instance.getFirstContextBean(); context.setData("retryLogic", this.getClass()); super.retry(instance, currentRetryCount); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorTest.java index d771fbf9f..eaf99576c 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorTest.java @@ -33,25 +33,27 @@ public class LiteflowNodeExecutorTest extends BaseTest { // 默认执行器测试 @Test public void testCustomerDefaultNodeExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); Assert.assertEquals("a", response.getExecuteStepStr()); } //默认执行器测试+全局重试配置测试 @Test public void testDefaultExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); } //自定义执行器测试 @Test public void testCustomerExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("c", response.getExecuteStepStr()); } @@ -59,9 +61,10 @@ public class LiteflowNodeExecutorTest extends BaseTest { //自定义执行器测试+全局重试配置测试 @Test public void testCustomExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getContextBean().getData("retryLogic")); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java index 0c6bf84a4..cf1f6c6f7 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java @@ -31,7 +31,7 @@ public class NullParamTest { */ @Test public void testNullParam() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonTest.java index d2ef85772..24b855433 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonTest.java @@ -29,7 +29,7 @@ public class CustomParserJsonTest extends BaseTest { //测试非spring场景的自定义json parser @Test public void testJsonCustomParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlTest.java index 84a098b16..eb1c0ba09 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlTest.java @@ -29,7 +29,7 @@ public class CustomParserXmlTest extends BaseTest { //测试非spring场景的自定义json parser @Test public void testXmlCustomParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/JsonParserTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/JsonParserTest.java index 25d6a34e2..f390e3b97 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/JsonParserTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/JsonParserTest.java @@ -29,7 +29,7 @@ public class JsonParserTest extends BaseTest { //测试spring场景的json parser @Test public void testJsonParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/XmlParserTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/XmlParserTest.java index 5d34bd4c4..07f13e50f 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/XmlParserTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/XmlParserTest.java @@ -29,7 +29,7 @@ public class XmlParserTest extends BaseTest { //测试无spring场景的xml parser @Test public void testXmlParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/YmlParserTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/YmlParserTest.java index a50951015..cc744c045 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/YmlParserTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/parser/YmlParserTest.java @@ -29,7 +29,7 @@ public class YmlParserTest extends BaseTest { //测试无spring场景的yml parser @Test public void testYmlParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyTest.java index 8f3794068..95f3a71bf 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallyTest.java @@ -29,7 +29,7 @@ public class PreAndFinallyTest extends BaseTest { //测试普通的pre和finally节点 @Test public void testPreAndFinally1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getExecuteStepStr()); } @@ -37,7 +37,7 @@ public class PreAndFinallyTest extends BaseTest { //测试pre和finally节点不放在开头和结尾的情况 @Test public void testPreAndFinally2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getExecuteStepStr()); } @@ -45,7 +45,7 @@ public class PreAndFinallyTest extends BaseTest { //测试有节点报错是否还执行finally节点的情况,其中d节点会报错,但依旧执行f1,f2节点 @Test public void testPreAndFinally3() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } @@ -53,14 +53,15 @@ public class PreAndFinallyTest extends BaseTest { //测试在finally节点里是否能获取exception @Test public void testPreAndFinally4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("hasEx")); + Assert.assertTrue(context.getData("hasEx")); } @Test public void testPreAndFinally5() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java index 9f81d2114..8777c80b7 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java @@ -16,11 +16,12 @@ public class Finally3Cmp extends NodeComponent { @Override public void process() throws Exception{ - Slot slot = this.getSlot(); + Slot slot = this.getSlot(); + DefaultContext context = slot.getFirstContextBean(); if (ObjectUtil.isNull(slot.getException())){ - slot.getContextBean().setData("hasEx", false); + context.setData("hasEx", false); }else{ - slot.getContextBean().setData("hasEx", true); + context.setData("hasEx", true); } System.out.println("Finally3Cmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryTest.java index 04804522d..671e0b333 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliveryTest.java @@ -30,8 +30,9 @@ public class PrivateDeliveryTest extends BaseTest { @Test public void testPrivateDelivery() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - ConcurrentHashSet set = response.getContextBean().getData("testSet"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); + ConcurrentHashSet set = context.getData("testSet"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals(100, set.size()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java index fb040841b..17227a258 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java @@ -19,7 +19,7 @@ public class ACmp extends NodeComponent { @Override public void process() { System.out.println("ACmp executed!"); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("testSet", new ConcurrentHashSet<>()); for (int i = 0; i < 100; i++) { diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java index 106ae1b87..fe0edd88d 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java @@ -18,7 +18,7 @@ public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); System.out.println("BCmp executed!"); Integer value = this.getPrivateDeliveryData(); ConcurrentHashSet testSet = context.getData("testSet"); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleTest.java index 6beb3e6e5..3eacfe864 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleTest.java @@ -34,7 +34,7 @@ public class RefreshRuleTest extends BaseTest { public void testRefresh1() throws Exception{ String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, content); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } @@ -53,7 +53,7 @@ public class RefreshRuleTest extends BaseTest { }).start(); for (int i = 0; i < 500; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); try { Thread.sleep(10L); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/reload/ReloadTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/reload/ReloadTest.java index 8d4e68d50..cbb54758c 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/reload/ReloadTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/reload/ReloadTest.java @@ -31,7 +31,7 @@ public class ReloadTest extends BaseTest { @Test public void testReload() throws Exception{ flowExecutor.reloadRule(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainTest.java index a445a0202..8fc9ce58d 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainTest.java @@ -24,10 +24,10 @@ public class RemoveChainTest extends BaseTest{ @Test public void testRemoveChain(){ - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response1.isSuccess()); FlowBus.removeChain("chain1"); - LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response2.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotTest.java index dbcb1ecef..c844dc2cb 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotTest.java @@ -41,13 +41,13 @@ public class ResizeSlotTest extends BaseTest { try{ ExecutorService pool = Executors.newCachedThreadPool(); - List>> futureList = new ArrayList<>(); + List> futureList = new ArrayList<>(); for (int i = 0; i < 100; i++) { - Future> future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg")); + Future future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg")); futureList.add(future); } - for(Future> future : futureList){ + for(Future future : futureList){ Assert.assertTrue(future.get().isSuccess()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowTest.java index e633a0f74..85ee4cbbb 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowTest.java @@ -34,7 +34,8 @@ public class ImplicitSubFlowTest extends BaseTest { //这里GCmp中隐式的调用chain4,从而执行了h,m @Test public void testImplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); @@ -43,6 +44,6 @@ public class ImplicitSubFlowTest extends BaseTest { // set中第一次设置的requestId和response中的requestId一致 Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); //requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", response.getContextBean().getData("innerRequest")); + Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigTest.java index 81f61cabc..e1dd0cf46 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigTest.java @@ -31,7 +31,7 @@ public class SubflowInDifferentConfigTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonTest.java index 360985937..27ee26a7e 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonTest.java @@ -30,7 +30,7 @@ public class SubflowJsonTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLTest.java index 9f5fbe96b..b8a0a2ca9 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLTest.java @@ -30,7 +30,7 @@ public class SubflowXMLTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlTest.java index 6cb70df68..12bb28aae 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlTest.java @@ -30,7 +30,7 @@ public class SubflowYmlTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlowYml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java index 68926cd43..2a727d471 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java @@ -10,7 +10,7 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { String requestData = this.getSubChainReqData(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("innerRequest", requestData); RUN_TIME_SLOT.add(this.getSlot().getRequestId()); diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagJsonTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagJsonTest.java index 883892c19..18b101e34 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagJsonTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagJsonTest.java @@ -29,14 +29,15 @@ public class NodeTagJsonTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getContextBean().getData("test")); + Assert.assertEquals("123",context.getData("test")); } @Test public void testTag2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } @@ -46,9 +47,10 @@ public class NodeTagJsonTest extends BaseTest { @Test public void testTag3() throws Exception{ for (int i = 0; i < 50; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getContextBean().getData("test"); + ConcurrentHashSet testSet = context.getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -56,7 +58,7 @@ public class NodeTagJsonTest extends BaseTest { //测试tag是否能在isAccess中起效 @Test public void testTag4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagXmlTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagXmlTest.java index 3fa737313..cf05b118b 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagXmlTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/NodeTagXmlTest.java @@ -29,14 +29,15 @@ public class NodeTagXmlTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getContextBean().getData("test")); + Assert.assertEquals("123",context.getData("test")); } @Test public void testTag2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } @@ -46,9 +47,10 @@ public class NodeTagXmlTest extends BaseTest { @Test public void testTag3() throws Exception{ for (int i = 0; i < 50; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getContextBean().getData("test"); + ConcurrentHashSet testSet = context.getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -56,7 +58,7 @@ public class NodeTagXmlTest extends BaseTest { //测试tag是否能在isAccess中起效 @Test public void testTag4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java index 5052de9d1..8d12933e2 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java @@ -17,7 +17,7 @@ public class ACmp extends NodeComponent { public void process() { String testKey = "test"; - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); if (context.getData(testKey) == null){ context.setData(testKey,this.getTag()); }else{ diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java index 4d2e6efac..11c13b00f 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java @@ -16,7 +16,7 @@ public class B1Cmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("test",new ConcurrentHashSet()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java index d12e8b1d4..ba93a3abd 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java @@ -16,7 +16,7 @@ public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); ConcurrentHashSet testSet = context.getData("test"); testSet.add(this.getTag()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenTest.java index 06f2b0169..beff5c6e4 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenTest.java @@ -28,11 +28,12 @@ public class UseTTLInWhenTest extends BaseTest { @Test public void testUseTTLInWhen() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("hello,b", response.getContextBean().getData("b")); - Assert.assertEquals("hello,c", response.getContextBean().getData("c")); - Assert.assertEquals("hello,d", response.getContextBean().getData("d")); - Assert.assertEquals("hello,e", response.getContextBean().getData("e")); - Assert.assertEquals("hello,f", response.getContextBean().getData("f")); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); + Assert.assertEquals("hello,b", context.getData("b")); + Assert.assertEquals("hello,c", context.getData("c")); + Assert.assertEquals("hello,d", context.getData("d")); + Assert.assertEquals("hello,e", context.getData("e")); + Assert.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java index 7e864342c..8737920c4 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java @@ -16,7 +16,7 @@ public class BCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",b"); System.out.println("BCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java index 44b016144..f0022bee2 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java @@ -16,7 +16,7 @@ public class CCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",c"); System.out.println("CCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java index e7fee79a2..9f99e1330 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java @@ -16,7 +16,7 @@ public class DCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",d"); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java index 197f7e951..0d98daae4 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java @@ -16,7 +16,7 @@ public class ECmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",e"); System.out.println("ECmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java index 57ee6ce26..325a7a2ea 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java @@ -16,7 +16,7 @@ public class FCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",f"); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest1.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest1.java index f8bc97f91..fe3dcdfd6 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest1.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest1.java @@ -31,7 +31,7 @@ public class WhenTimeOutTest1 extends BaseTest { //其中b和c在when情况下超时,所以抛出了WhenTimeoutException这个错 @Test public void testWhenTimeOut() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest2.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest2.java index d4a739614..95b64ff81 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest2.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutTest2.java @@ -30,7 +30,7 @@ public class WhenTimeOutTest2 extends BaseTest { //其中d,e,f都sleep 4秒,其中def是不同的组,超时设置5秒 @Test public void testWhenTimeOut() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonTest.java index 714121c02..376d00aa0 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonTest.java @@ -64,7 +64,7 @@ public class ZkNodeWithJsonTest extends BaseTest { @Test public void testZkNodeWithJson() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlTest.java index 5c4ef92ca..3698bbaad 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlTest.java @@ -64,7 +64,7 @@ public class ZkNodeWithXmlTest extends BaseTest { @Test public void testZkNodeWithXml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlTest.java index 2db6f2f27..56d28ba55 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlTest.java @@ -64,7 +64,7 @@ public class ZkNodeWithYmlTest extends BaseTest { @Test public void testZkNodeWithYml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteFlowXmlScriptBuilderGroovyTest.java b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteFlowXmlScriptBuilderGroovyTest.java index ace7db6c8..11be163f4 100644 --- a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteFlowXmlScriptBuilderGroovyTest.java +++ b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteFlowXmlScriptBuilderGroovyTest.java @@ -47,7 +47,7 @@ public class LiteFlowXmlScriptBuilderGroovyTest extends BaseTest { .setId("s1") .setName("普通脚本S1") .setType(NodeTypeEnum.SCRIPT) - .setScript("Integer a=3;Integer b=2;context.setData(\"s1\",a*b)") + .setScript("Integer a=3;Integer b=2;defaultContext.setData(\"s1\",a*b)") .build(); LiteFlowChainBuilder.createChain().setChainName("chain1") @@ -55,9 +55,10 @@ public class LiteFlowXmlScriptBuilderGroovyTest extends BaseTest { .build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试通过builder方式运行普通script节点,以file的方式运行 @@ -89,7 +90,8 @@ public class LiteFlowXmlScriptBuilderGroovyTest extends BaseTest { .build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain2","arg1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2","arg1"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d[组件D]==>s2[条件脚本S2]==>a[组件A]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptFileGroovyTest.java b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptFileGroovyTest.java index 7717a4883..639a7d796 100644 --- a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptFileGroovyTest.java +++ b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptFileGroovyTest.java @@ -37,15 +37,16 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试条件脚本节点 @Test public void testScript2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); } @@ -54,7 +55,7 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest { @Test public void testScript3() throws Exception{ //根据配置,加载的应该是flow.xml,执行原来的规则 - LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseOld.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -63,7 +64,7 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest { FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_JSON, newContent); //重新执行chain2这个链路,结果会变 - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } @@ -84,7 +85,7 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest { }).start(); for (int i = 0; i < 300; i++) { - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Thread.sleep(10L); } diff --git a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptGroovyTest.java b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptGroovyTest.java index c97ff7ca2..af87ccd79 100644 --- a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptGroovyTest.java +++ b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowJsonScriptGroovyTest.java @@ -37,15 +37,16 @@ public class LiteflowJsonScriptGroovyTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试条件脚本节点 @Test public void testScript2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); } @@ -54,7 +55,7 @@ public class LiteflowJsonScriptGroovyTest extends BaseTest { @Test public void testScript3() throws Exception{ //根据配置,加载的应该是flow.xml,执行原来的规则 - LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseOld.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -63,7 +64,7 @@ public class LiteflowJsonScriptGroovyTest extends BaseTest { FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_JSON, newContent); //重新执行chain2这个链路,结果会变 - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } diff --git a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptFileGroovyTest.java b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptFileGroovyTest.java index a375541de..4fca9bcb9 100644 --- a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptFileGroovyTest.java +++ b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptFileGroovyTest.java @@ -37,15 +37,16 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试条件脚本节点 @Test public void testScript2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); } @@ -54,7 +55,7 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest { @Test public void testScript3() throws Exception{ //根据配置,加载的应该是flow.xml,执行原来的规则 - LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseOld.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -63,7 +64,7 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest { FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, newContent); //重新执行chain2这个链路,结果会变 - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } @@ -84,7 +85,7 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest { }).start(); for (int i = 0; i < 300; i++) { - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Thread.sleep(10L); } diff --git a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptGroovyTest.java b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptGroovyTest.java index bcec4aece..a8b3c15ed 100644 --- a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptGroovyTest.java +++ b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/LiteflowXmlScriptGroovyTest.java @@ -37,15 +37,16 @@ public class LiteflowXmlScriptGroovyTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试条件脚本节点 @Test public void testScript2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>a", response.getExecuteStepStr()); } @@ -54,7 +55,7 @@ public class LiteflowXmlScriptGroovyTest extends BaseTest { @Test public void testScript3() throws Exception{ //根据配置,加载的应该是flow.xml,执行原来的规则 - LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseOld.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>a", responseOld.getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -63,7 +64,7 @@ public class LiteflowXmlScriptGroovyTest extends BaseTest { FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, newContent); //重新执行chain2这个链路,结果会变 - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Assert.assertEquals("d==>s2[条件脚本_改]==>b==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } diff --git a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/cmp/DCmp.java b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/cmp/DCmp.java index 1246c2119..54dee3bab 100644 --- a/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/cmp/DCmp.java +++ b/liteflow-testcase-script-groovy/src/test/java/com/yomahub/liteflow/test/script/groovy/cmp/DCmp.java @@ -17,7 +17,7 @@ public class DCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("count",198); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-script-groovy/src/test/resources/builder/s1.groovy b/liteflow-testcase-script-groovy/src/test/resources/builder/s1.groovy index e38b6957d..02ae4756f 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/builder/s1.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/builder/s1.groovy @@ -1,3 +1,3 @@ Integer a=3 Integer b=2 -context.setData("s1",a*b) \ No newline at end of file +defaultContext.setData("s1",a*b) \ No newline at end of file diff --git a/liteflow-testcase-script-groovy/src/test/resources/builder/s2.groovy b/liteflow-testcase-script-groovy/src/test/resources/builder/s2.groovy index 29a8f5a0b..dc9199dee 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/builder/s2.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/builder/s2.groovy @@ -1,4 +1,4 @@ -Integer count = context.getData("count") +Integer count = defaultContext.getData("count") if(count > 100){ return "a" }else{ diff --git a/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s1.groovy b/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s1.groovy index e38b6957d..02ae4756f 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s1.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s1.groovy @@ -1,3 +1,3 @@ Integer a=3 Integer b=2 -context.setData("s1",a*b) \ No newline at end of file +defaultContext.setData("s1",a*b) \ No newline at end of file diff --git a/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s2.groovy b/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s2.groovy index 29a8f5a0b..dc9199dee 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s2.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s2.groovy @@ -1,4 +1,4 @@ -Integer count = context.getData("count") +Integer count = defaultContext.getData("count") if(count > 100){ return "a" }else{ diff --git a/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s2_update.groovy b/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s2_update.groovy index 1d8f6dce2..287b639d2 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s2_update.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s2_update.groovy @@ -1,4 +1,4 @@ -Integer count = context.getData("count") +Integer count = defaultContext.getData("count") if(count > 150){ return "b" }else{ diff --git a/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s3.groovy b/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s3.groovy index d29ae4b85..144001ec7 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s3.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/json-script-file/s3.groovy @@ -1,4 +1,4 @@ Integer a=3 Integer b=2 Integer c=10 -context.setData("s1",a*b+c) \ No newline at end of file +defaultContext.setData("s1",a*b+c) \ No newline at end of file diff --git a/liteflow-testcase-script-groovy/src/test/resources/json-script/flow.json b/liteflow-testcase-script-groovy/src/test/resources/json-script/flow.json index b5054329b..8ec234c83 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/json-script/flow.json +++ b/liteflow-testcase-script-groovy/src/test/resources/json-script/flow.json @@ -6,19 +6,19 @@ "id": "s1", "name": "普通脚本", "type": "script", - "value": "def a=3;def b=2;context.setData(\"s1\",a*b);" + "value": "def a=3;def b=2;defaultContext.setData(\"s1\",a*b);" }, { "id": "s2", "name": "条件脚本", "type": "cond_script", - "value": "count = context.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}" + "value": "count = defaultContext.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}" }, { "id": "s3", "name": "普通脚本2", "type": "script", - "value": "def a=30;def b=2;context.setData(\"s1\",a*b);" + "value": "def a=30;def b=2;defaultContext.setData(\"s1\",a*b);" } ] }, diff --git a/liteflow-testcase-script-groovy/src/test/resources/json-script/flow_update.json b/liteflow-testcase-script-groovy/src/test/resources/json-script/flow_update.json index a139e510a..f827c5b0e 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/json-script/flow_update.json +++ b/liteflow-testcase-script-groovy/src/test/resources/json-script/flow_update.json @@ -6,19 +6,19 @@ "id": "s1", "name": "普通脚本", "type": "script", - "value": "def a=3;def b=2;context.setData(\"s1\",a*b);" + "value": "def a=3;def b=2;defaultContext.setData(\"s1\",a*b);" }, { "id": "s2", "name": "条件脚本_改", "type": "cond_script", - "value": "count = context.getData(\"count\");if(count > 150){return \"b\";}else{return \"a\";}" + "value": "count = defaultContext.getData(\"count\");if(count > 150){return \"b\";}else{return \"a\";}" }, { "id": "s3", "name": "普通脚本_新增", "type": "script", - "value": "def a=3;def b=2;def c=10;context.setData(\"s1\",a*b+c);" + "value": "def a=3;def b=2;def c=10;defaultContext.setData(\"s1\",a*b+c);" } ] }, diff --git a/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s1.groovy b/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s1.groovy index e38b6957d..02ae4756f 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s1.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s1.groovy @@ -1,3 +1,3 @@ Integer a=3 Integer b=2 -context.setData("s1",a*b) \ No newline at end of file +defaultContext.setData("s1",a*b) \ No newline at end of file diff --git a/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s2.groovy b/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s2.groovy index 29a8f5a0b..dc9199dee 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s2.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s2.groovy @@ -1,4 +1,4 @@ -Integer count = context.getData("count") +Integer count = defaultContext.getData("count") if(count > 100){ return "a" }else{ diff --git a/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s2_update.groovy b/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s2_update.groovy index 1d8f6dce2..287b639d2 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s2_update.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s2_update.groovy @@ -1,4 +1,4 @@ -Integer count = context.getData("count") +Integer count = defaultContext.getData("count") if(count > 150){ return "b" }else{ diff --git a/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s3.groovy b/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s3.groovy index 577991b2e..39a48f4cd 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s3.groovy +++ b/liteflow-testcase-script-groovy/src/test/resources/xml-script-file/s3.groovy @@ -1,4 +1,4 @@ Integer a=3 Integer b=2 Integer c=10 -context.setData("s1",a*b+c); \ No newline at end of file +defaultContext.setData("s1",a*b+c); \ No newline at end of file diff --git a/liteflow-testcase-script-groovy/src/test/resources/xml-script/flow.xml b/liteflow-testcase-script-groovy/src/test/resources/xml-script/flow.xml index 5f0455b80..26a29d3bc 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/xml-script/flow.xml +++ b/liteflow-testcase-script-groovy/src/test/resources/xml-script/flow.xml @@ -5,13 +5,13 @@ 100){ return "a"; }else{ @@ -25,7 +25,7 @@ diff --git a/liteflow-testcase-script-groovy/src/test/resources/xml-script/flow_update.xml b/liteflow-testcase-script-groovy/src/test/resources/xml-script/flow_update.xml index fd93a289f..07481369e 100644 --- a/liteflow-testcase-script-groovy/src/test/resources/xml-script/flow_update.xml +++ b/liteflow-testcase-script-groovy/src/test/resources/xml-script/flow_update.xml @@ -5,13 +5,13 @@ 150){ return "b"; }else{ @@ -25,7 +25,7 @@ def a=3; def b=2; def c=10; - context.setData("s1",a*b+c); + defaultContext.setData("s1",a*b+c); ]]> diff --git a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptBuilderQLExpressTest.java b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptBuilderQLExpressTest.java index 4c3e8c881..2e70c4a9f 100644 --- a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptBuilderQLExpressTest.java +++ b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteFlowXmlScriptBuilderQLExpressTest.java @@ -47,7 +47,7 @@ public class LiteFlowXmlScriptBuilderQLExpressTest extends BaseTest { .setId("s1") .setName("普通脚本S1") .setType(NodeTypeEnum.SCRIPT) - .setScript("a=3;b=2;context.setData(\"s1\",a*b);") + .setScript("a=3;b=2;defaultContext.setData(\"s1\",a*b);") .build(); LiteFlowChainBuilder.createChain().setChainName("chain1") @@ -55,9 +55,10 @@ public class LiteFlowXmlScriptBuilderQLExpressTest extends BaseTest { .build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试通过builder方式运行普通script节点,以file的方式运行 @@ -89,7 +90,7 @@ public class LiteFlowXmlScriptBuilderQLExpressTest extends BaseTest { .build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain2","arg1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2","arg1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d[组件D]==>s2[条件脚本S2]==>b[组件B]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressTest.java b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressTest.java index 38341701e..69b81a266 100644 --- a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressTest.java +++ b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptFileQLExpressTest.java @@ -37,15 +37,16 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试条件脚本节点 @Test public void testScript2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); } @@ -53,7 +54,7 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest { @Test public void testScript3() throws Exception{ //根据配置,加载的应该是flow.xml,执行原来的规则 - LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseOld.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -62,7 +63,7 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest { FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_JSON, newContent); //重新执行chain2这个链路,结果会变 - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } @@ -83,7 +84,7 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest { }).start(); for (int i = 0; i < 300; i++) { - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Thread.sleep(10L); } diff --git a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptQLExpressTest.java b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptQLExpressTest.java index 17af9021d..f8321769c 100644 --- a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptQLExpressTest.java +++ b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowJsonScriptQLExpressTest.java @@ -37,15 +37,16 @@ public class LiteflowJsonScriptQLExpressTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试条件脚本节点 @Test public void testScript2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); } @@ -53,7 +54,7 @@ public class LiteflowJsonScriptQLExpressTest extends BaseTest { @Test public void testScript3() throws Exception{ //根据配置,加载的应该是flow.xml,执行原来的规则 - LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseOld.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -62,7 +63,7 @@ public class LiteflowJsonScriptQLExpressTest extends BaseTest { FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_JSON, newContent); //重新执行chain2这个链路,结果会变 - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } diff --git a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressTest.java b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressTest.java index db7895dc9..af745da03 100644 --- a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressTest.java +++ b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptFileQLExpressTest.java @@ -37,15 +37,16 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试条件脚本节点 @Test public void testScript2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); } @@ -53,7 +54,7 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest { @Test public void testScript3() throws Exception{ //根据配置,加载的应该是flow.xml,执行原来的规则 - LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseOld.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -62,7 +63,7 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest { FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, newContent); //重新执行chain2这个链路,结果会变 - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } @@ -83,7 +84,7 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest { }).start(); for (int i = 0; i < 300; i++) { - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Thread.sleep(10L); } diff --git a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptQLExpressTest.java b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptQLExpressTest.java index cceacf9a5..ba4680a76 100644 --- a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptQLExpressTest.java +++ b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/LiteflowXmlScriptQLExpressTest.java @@ -37,15 +37,16 @@ public class LiteflowXmlScriptQLExpressTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), context.getData("s1")); } //测试条件脚本节点 @Test public void testScript2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>b", response.getExecuteStepStr()); } @@ -53,7 +54,7 @@ public class LiteflowXmlScriptQLExpressTest extends BaseTest { @Test public void testScript3() throws Exception{ //根据配置,加载的应该是flow.xml,执行原来的规则 - LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseOld = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseOld.isSuccess()); Assert.assertEquals("d==>s2[条件脚本]==>b", responseOld.getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -62,7 +63,7 @@ public class LiteflowXmlScriptQLExpressTest extends BaseTest { FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, newContent); //重新执行chain2这个链路,结果会变 - LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse responseNew = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(responseNew.isSuccess()); Assert.assertEquals("d==>s2[条件脚本_改]==>a==>s3[普通脚本_新增]", responseNew.getExecuteStepStr()); } diff --git a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/cmp/DCmp.java b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/cmp/DCmp.java index 56b13aca6..ecc648de5 100644 --- a/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/cmp/DCmp.java +++ b/liteflow-testcase-script-qlexpress/src/test/java/com/yomahub/liteflow/test/script/qlexpress/cmp/DCmp.java @@ -17,7 +17,7 @@ public class DCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("count",97); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/builder/s1.ql b/liteflow-testcase-script-qlexpress/src/test/resources/builder/s1.ql index 2d426a97a..560850daf 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/builder/s1.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/builder/s1.ql @@ -1,3 +1,3 @@ a=3; b=2; -context.setData("s1",a*b); \ No newline at end of file +defaultContext.setData("s1",a*b); \ No newline at end of file diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/builder/s2.ql b/liteflow-testcase-script-qlexpress/src/test/resources/builder/s2.ql index eba2b2e24..e27901531 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/builder/s2.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/builder/s2.ql @@ -1,4 +1,4 @@ -count = context.getData("count"); +count = defaultContext.getData("count"); if(count > 100){ return "a"; }else{ diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s1.ql b/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s1.ql index 2d426a97a..560850daf 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s1.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s1.ql @@ -1,3 +1,3 @@ a=3; b=2; -context.setData("s1",a*b); \ No newline at end of file +defaultContext.setData("s1",a*b); \ No newline at end of file diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s2.ql b/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s2.ql index eba2b2e24..e27901531 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s2.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s2.ql @@ -1,4 +1,4 @@ -count = context.getData("count"); +count = defaultContext.getData("count"); if(count > 100){ return "a"; }else{ diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s2_update.ql b/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s2_update.ql index 7994d9427..ebfa25e4c 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s2_update.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s2_update.ql @@ -1,4 +1,4 @@ -count = context.getData("count"); +count = defaultContext.getData("count"); if(count > 150){ return "b"; }else{ diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s3.ql b/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s3.ql index a28b66db4..f7285edbf 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s3.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/json-script-file/s3.ql @@ -1,4 +1,4 @@ a=3; b=2; c=10; -context.setData("s1",a*b+c); \ No newline at end of file +defaultContext.setData("s1",a*b+c); \ No newline at end of file diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/json-script/flow.json b/liteflow-testcase-script-qlexpress/src/test/resources/json-script/flow.json index 19f121682..001936edd 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/json-script/flow.json +++ b/liteflow-testcase-script-qlexpress/src/test/resources/json-script/flow.json @@ -6,19 +6,19 @@ "id": "s1", "name": "普通脚本", "type": "script", - "value": "a=3;b=2;context.setData(\"s1\",a*b);" + "value": "a=3;b=2;defaultContext.setData(\"s1\",a*b);" }, { "id": "s2", "name": "条件脚本", "type": "cond_script", - "value": "count = context.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}" + "value": "count = defaultContext.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}" }, { "id": "s3", "name": "普通脚本2", "type": "script", - "value": "a=30;b=2;context.setData(\"s1\",a*b);" + "value": "a=30;b=2;defaultContext.setData(\"s1\",a*b);" } ] }, diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/json-script/flow_update.json b/liteflow-testcase-script-qlexpress/src/test/resources/json-script/flow_update.json index 7623bf62b..4fa838181 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/json-script/flow_update.json +++ b/liteflow-testcase-script-qlexpress/src/test/resources/json-script/flow_update.json @@ -6,19 +6,19 @@ "id": "s1", "name": "普通脚本", "type": "script", - "value": "a=3;b=2;context.setData(\"s1\",a*b);" + "value": "a=3;b=2;defaultContext.setData(\"s1\",a*b);" }, { "id": "s2", "name": "条件脚本_改", "type": "cond_script", - "value": "count = context.getData(\"count\");if(count > 150){return \"b\";}else{return \"a\";}" + "value": "count = defaultContext.getData(\"count\");if(count > 150){return \"b\";}else{return \"a\";}" }, { "id": "s3", "name": "普通脚本_新增", "type": "script", - "value": "a=3;b=2;c=10;context.setData(\"s1\",a*b+c);" + "value": "a=3;b=2;c=10;defaultContext.setData(\"s1\",a*b+c);" } ] }, diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s1.ql b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s1.ql index 2d426a97a..560850daf 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s1.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s1.ql @@ -1,3 +1,3 @@ a=3; b=2; -context.setData("s1",a*b); \ No newline at end of file +defaultContext.setData("s1",a*b); \ No newline at end of file diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s2.ql b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s2.ql index eba2b2e24..e27901531 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s2.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s2.ql @@ -1,4 +1,4 @@ -count = context.getData("count"); +count = defaultContext.getData("count"); if(count > 100){ return "a"; }else{ diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s2_update.ql b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s2_update.ql index 7994d9427..ebfa25e4c 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s2_update.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s2_update.ql @@ -1,4 +1,4 @@ -count = context.getData("count"); +count = defaultContext.getData("count"); if(count > 150){ return "b"; }else{ diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s3.ql b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s3.ql index a28b66db4..f7285edbf 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s3.ql +++ b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script-file/s3.ql @@ -1,4 +1,4 @@ a=3; b=2; c=10; -context.setData("s1",a*b+c); \ No newline at end of file +defaultContext.setData("s1",a*b+c); \ No newline at end of file diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script/flow.xml b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script/flow.xml index 02a99d437..4ba49a042 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script/flow.xml +++ b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script/flow.xml @@ -5,13 +5,13 @@ 100){ return "a"; }else{ @@ -25,7 +25,7 @@ diff --git a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script/flow_update.xml b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script/flow_update.xml index a48985af5..bcea8e6ce 100644 --- a/liteflow-testcase-script-qlexpress/src/test/resources/xml-script/flow_update.xml +++ b/liteflow-testcase-script-qlexpress/src/test/resources/xml-script/flow_update.xml @@ -5,13 +5,13 @@ 150){ return "b"; }else{ @@ -25,7 +25,7 @@ a=3; b=2; c=10; - context.setData("s1",a*b+c); + defaultContext.setData("s1",a*b+c); ]]> diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java index c031268f5..02913478c 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java @@ -36,7 +36,7 @@ public class AbsoluteConfigPathSpringbootTest extends BaseTest { @Test public void testAbsoluteConfig() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringbootTest.java index 711222355..5eeda18ae 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringbootTest.java @@ -35,20 +35,22 @@ public class CustomAOPSpringbootTest extends BaseTest { //测试自定义AOP,串行场景 @Test public void testCustomAopS() { - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); } //测试自定义AOP,并行场景 @Test public void testCustomAopP() { - LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringbootTest.java index c38960b52..04bcbc997 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringbootTest.java @@ -37,35 +37,38 @@ public class GlobalAOPSpringbootTest extends BaseTest { //测试全局AOP,串行场景 @Test public void testGlobalAopS() { - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("d")); - Assert.assertEquals("before_after", response.getContextBean().getData("e")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("d")); + Assert.assertEquals("before_after", context.getData("e")); } //测试全局AOP,并行场景 @Test public void testGlobalAopP() { - LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("d")); - Assert.assertEquals("before_after", response.getContextBean().getData("e")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("d")); + Assert.assertEquals("before_after", context.getData("e")); } @Test public void testGlobalAopException() { - LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("f")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("f")); } @AfterClass diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java index 785578fda..3704a146d 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java @@ -5,16 +5,16 @@ import com.yomahub.liteflow.aop.ICmpAroundAspect; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; -public class CmpAspect implements ICmpAroundAspect { +public class CmpAspect implements ICmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getContextBean(); + public void beforeProcess(String nodeId, Slot slot) { + DefaultContext context = slot.getFirstContextBean(); context.setData(nodeId, "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getContextBean(); + public void afterProcess(String nodeId, Slot slot) { + DefaultContext context = slot.getFirstContextBean(); context.setData(nodeId, StrUtil.format("{}_{}", context.getData(nodeId), "after")); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java index 673e3f7b5..b2fc0f86a 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java @@ -19,7 +19,7 @@ public class CustomAspect { @Around("cut()") public Object around(ProceedingJoinPoint jp) throws Throwable { NodeComponent cmp = (NodeComponent) jp.getThis(); - DefaultContext context = cmp.getContextBean(); + DefaultContext context = cmp.getFirstContextBean(); context.setData(cmp.getNodeId(), "before"); Object returnObj = jp.proceed(); context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java index 9c2e18928..7a3c636cf 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java @@ -39,7 +39,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { * **/ @Test public void testAsyncFlow1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); Assert.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -47,7 +47,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { //这个和test1有点类似,只不过进一步验证了步骤 @Test public void testAsyncFlow2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); Assert.assertTrue(ListUtil.toList("b==>j==>g==>f==>h","b==>j==>g==>h==>f", "b==>j==>h==>g==>f","b==>j==>h==>f==>g", "b==>j==>f==>h==>g","b==>j==>f==>g==>h" @@ -57,7 +57,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { //测试errorResume,默认的errorResume为false,这里测试默认的 @Test public void testAsyncFlow3_1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); } @@ -65,18 +65,19 @@ public class AsyncNodeSpringbootTest extends BaseTest { //测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); Assert.assertTrue(response.isSuccess()); } //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @Test public void testAsyncFlow4() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); //因为不记录错误,所以最终结果是true Assert.assertTrue(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getContextBean().getData("count"); + DefaultContext context = response.getFirstContextBean(); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //因为配置了不抛错,所以response里的cause应该为null Assert.assertNull(response.getCause()); @@ -85,11 +86,12 @@ public class AsyncNodeSpringbootTest extends BaseTest { //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @Test public void testAsyncFlow5() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); //整个并行组是报错的,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getContextBean().getData("count"); + DefaultContext context = response.getFirstContextBean(); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //因为第一个when配置了会报错,所以response里的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -98,11 +100,12 @@ public class AsyncNodeSpringbootTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @Test public void testAsyncFlow6() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); //第一个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 - Integer count = response.getContextBean().getData("count"); + DefaultContext context = response.getFirstContextBean(); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(1), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -111,11 +114,12 @@ public class AsyncNodeSpringbootTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @Test public void testAsyncFlow7() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); //第二个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 - Integer count = response.getContextBean().getData("count"); + DefaultContext context = response.getFirstContextBean(); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -127,8 +131,9 @@ public class AsyncNodeSpringbootTest extends BaseTest { //这里要注意的是,由于step是先加入,所以step的打印顺序并不是这样的。但是实际执行是正确的 @Test public void testAsyncFlow8() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("check").toString().startsWith("habc")); + Assert.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java index 2d362f405..01afc5856 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; public class ACmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java index b60ed84db..73c27c742 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java index fc32acff6..253447f81 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; public class CCmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java index 8918b783b..6203d92da 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java @@ -11,7 +11,7 @@ public class DCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(1000); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java index dc0694664..66fd659cc 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java @@ -12,7 +12,7 @@ public class GCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(500); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java index 52dfa5d85..dd211dfa3 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java @@ -11,7 +11,7 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java index 8c5a76748..d3789bb8b 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java @@ -12,7 +12,7 @@ public class ICmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); if (context.hasData("count")){ Integer count = context.getData("count"); context.setData("count", ++count); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/bannerPrint/BannerPrintSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/bannerPrint/BannerPrintSpringbootTest.java index aefe3e5c7..972b0e25b 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/bannerPrint/BannerPrintSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/bannerPrint/BannerPrintSpringbootTest.java @@ -32,7 +32,7 @@ public class BannerPrintSpringbootTest extends BaseTest { @Test public void testRefresh() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseSpringbootTest.java index b50e1bd4d..608e90986 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/base/BaseSpringbootTest.java @@ -32,7 +32,7 @@ public class BaseSpringbootTest extends BaseTest { @Test public void testBase() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest1.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest1.java index a46bcaf10..5f0b18c3f 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest1.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest1.java @@ -89,7 +89,7 @@ public class BuilderSpringbootTest1 extends BaseTest { .setValue("e(f|g|chain2)").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @@ -147,7 +147,7 @@ public class BuilderSpringbootTest1 extends BaseTest { .setValue("e(f|g|chain2)").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } @@ -216,7 +216,7 @@ public class BuilderSpringbootTest1 extends BaseTest { )).build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest2.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest2.java index 8906dc70e..fc8d67074 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest2.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringbootTest2.java @@ -34,7 +34,7 @@ public class BuilderSpringbootTest2 extends BaseTest { LiteFlowConditionBuilder.createThenCondition().setValue("h,i,j").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("h==>i==>j", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringbootTest.java index 30770cfde..bae024e7f 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringbootTest.java @@ -34,7 +34,7 @@ public class LiteflowRetrySpringbootTest extends BaseTest { //全局重试配置测试 @Test public void testRetry1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } @@ -42,7 +42,7 @@ public class LiteflowRetrySpringbootTest extends BaseTest { //单个组件重试配置测试 @Test public void testRetry2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } @@ -50,14 +50,14 @@ public class LiteflowRetrySpringbootTest extends BaseTest { //单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertFalse(response.isSuccess()); } //单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringbootTest.java index 577de812a..0c9817345 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringbootTest.java @@ -34,7 +34,7 @@ public class CmpStepSpringbootTest extends BaseTest { //cd并行,都抛错,其中c耗时2秒 @Test public void testStep1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); @@ -47,7 +47,7 @@ public class CmpStepSpringbootTest extends BaseTest { @Test public void testStep2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorSpringbootTest.java index f3833fd26..5bc400e2b 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/component/FlowExecutorSpringbootTest.java @@ -38,7 +38,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //isAccess方法的功能测试 @Test public void testIsAccess() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); Assert.assertTrue(response.isSuccess()); Assert.assertNotNull(response.getSlot().getResponseData()); } @@ -46,7 +46,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //组件抛错的功能点测试 @Test(expected = ArithmeticException.class) public void testComponentException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("/ by zero", response.getMessage()); ReflectionUtils.rethrowException(response.getCause()); @@ -55,7 +55,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); Assert.assertTrue(response.isSuccess()); Assert.assertNull(response.getCause()); } @@ -63,7 +63,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d",response.getExecuteStepStr()); } @@ -71,7 +71,7 @@ public class FlowExecutorSpringbootTest extends BaseTest { //setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("e",response.getExecuteStepStr()); } @@ -79,14 +79,14 @@ public class FlowExecutorSpringbootTest extends BaseTest { //条件组件的功能点测试 @Test public void testNodeCondComponent() { - LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); Assert.assertTrue(response.isSuccess()); } //测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g",response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringbootTest1.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringbootTest1.java index 9ed3f9463..2f510da1a 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringbootTest1.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringbootTest1.java @@ -34,7 +34,7 @@ public class LiteflowConfigSpringbootTest1 extends BaseTest { @Test public void testConfig() { LiteflowConfig config = LiteflowConfigGetter.get(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("config/flow.yml", config.getRuleSource()); Assert.assertEquals(15, config.getWhenMaxWaitSeconds().intValue()); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringbootTest2.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringbootTest2.java index 9ad8769d3..ae90bd391 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringbootTest2.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringbootTest2.java @@ -32,10 +32,10 @@ public class LiteflowConfigSpringbootTest2 extends BaseTest { //测试通配符 @Test public void testRuleSourceMatch() { - LiteflowResponse response0 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response0 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertEquals("a==>b==>c", response0.getExecuteStepStr()); - LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertEquals("a==>c==>b==>d", response1.getExecuteStepStr()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringbootTest.java index c441b6feb..6437c5640 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringbootTest.java @@ -37,7 +37,7 @@ public class CustomNodesSpringbootTest extends BaseTest { @Test public void testCustomNodes() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringbootTest.java index 5a1ac1481..766ed3165 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringbootTest.java @@ -40,9 +40,10 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { */ @Test public void testGlobalThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("threadName").toString().startsWith("lf-when-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -50,9 +51,10 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { */ @Test public void testGlobalAndCustomWhenThreadPool() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response1.getFirstContextBean(); Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(response1.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } @@ -64,9 +66,10 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { // 使用when - thread1 testGlobalAndCustomWhenThreadPool(); // chain配置同一个thead1 - LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response2.getFirstContextBean(); Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(response2.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java index a7af6a490..66bc03a45 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java @@ -16,7 +16,7 @@ public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("BCmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java index 99144f623..809d4429a 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java @@ -16,7 +16,7 @@ public class CCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("CCmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java index 4d1c41cc4..07d5a53dd 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java @@ -16,7 +16,7 @@ public class DCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java index 61da5bba5..6e96482bf 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java @@ -16,7 +16,7 @@ public class ECmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("ECmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java index fe77d3af8..7091b7316 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java @@ -16,7 +16,7 @@ public class FCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/deadLoopChain/DeadLoopChainSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/deadLoopChain/DeadLoopChainSpringbootTest.java index 382e8f935..ad2f4bd01 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/deadLoopChain/DeadLoopChainSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/deadLoopChain/DeadLoopChainSpringbootTest.java @@ -30,6 +30,6 @@ public class DeadLoopChainSpringbootTest extends BaseTest { //为什么不删除呢?是因为如果用户不自己判断退出的条件。会报出栈溢出。以后希望liteflow自己能抛出相关的错。而不是抛出JDK的异常。所以暂时留着。 //@Test(expected = CyclicDependencyException.class) public void testDeadLoopChain() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java index 84699debf..31e6d65f7 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/EventSpringbootTest.java @@ -33,29 +33,32 @@ public class EventSpringbootTest extends BaseTest { //测试组件成功事件 @Test public void testEvent1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", response.getContextBean().getData("test")); + Assert.assertEquals("abc", context.getData("test")); } //测试组件失败事件 @Test public void testEvent2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", response.getContextBean().getData("test")); - Assert.assertEquals("error:d", response.getContextBean().getData("error")); + Assert.assertEquals("ab", context.getData("test")); + Assert.assertEquals("error:d", context.getData("error")); } //测试组件失败事件本身抛出异常 @Test public void testEvent3() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", response.getContextBean().getData("test")); - Assert.assertEquals("error:e", response.getContextBean().getData("error")); + Assert.assertEquals("a", context.getData("test")); + Assert.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java index b50a41cb4..11c7509ba 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java @@ -16,14 +16,14 @@ public class ACmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("test",""); System.out.println("ACmp executed!"); } @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java index 40d237fa1..7fc1b3538 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java @@ -21,7 +21,7 @@ public class BCmp extends NodeComponent { @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java index 9173f1f50..f87eeed18 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java @@ -21,7 +21,7 @@ public class CCmp extends NodeComponent { @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index 862352aab..1865b83ed 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -22,7 +22,7 @@ public class DCmp extends NodeComponent { @Override public void onError() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("error","error:"+this.getNodeId()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index 1a7156aeb..600f16321 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -22,7 +22,7 @@ public class ECmp extends NodeComponent { @Override public void onError() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("error","error:"+this.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringBootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringBootTest.java index 6ce4da90d..5512e2916 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringBootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringBootTest.java @@ -62,7 +62,7 @@ public class Exception2SpringBootTest extends BaseTest { @Test public void testGetSlotFromResponseWhenException() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); Assert.assertFalse(response.isSuccess()); Assert.assertNotNull(response.getCause()); Assert.assertNotNull(response.getSlot()); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringbootTest.java index 555e2e45d..7327cc568 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringbootTest.java @@ -33,8 +33,8 @@ public class Executor2FutureSpringbootTest extends BaseTest { @Test public void testFuture() throws Exception{ - Future> future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); - LiteflowResponse response = future.get(); + Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); + LiteflowResponse response = future.get(); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java index 7f9d2f2ca..8e0eaebd0 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java @@ -31,7 +31,7 @@ public class FlowMetaSpringbootTest extends BaseTest { @Test public void testFlowMeta() { FlowBus.addCommonNode("d", "d组件", DCmp.class); - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>d[d组件]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java index 4ff8e4828..e656a9029 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java @@ -27,7 +27,7 @@ public class LazySpringbootTest extends BaseTest { @Test public void testLazy() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringbootTest.java index 43fa6a188..c47a29a2b 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringbootTest.java @@ -32,7 +32,7 @@ public class LiteflowComponentSpringbootTest extends BaseTest { @Test public void testConfig() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java index 38a50f768..c151cbaa3 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringbootTest.java @@ -35,7 +35,7 @@ public class MonitorSpringbootTest extends BaseTest { @Test public void testMonitor() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Thread.sleep(10000); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/CheckContext.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/CheckContext.java new file mode 100644 index 000000000..af8bfad4a --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/CheckContext.java @@ -0,0 +1,24 @@ +package com.yomahub.liteflow.test.multiContext; + +public class CheckContext { + + private String sign; + + private int randomId; + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public int getRandomId() { + return randomId; + } + + public void setRandomId(int randomId) { + this.randomId = randomId; + } +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextSpringbootTest.java new file mode 100644 index 000000000..da7b98eb5 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/MultiContextSpringbootTest.java @@ -0,0 +1,55 @@ +package com.yomahub.liteflow.test.multiContext; + +import cn.hutool.core.date.DateUtil; +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.exception.ChainNotFoundException; +import com.yomahub.liteflow.exception.NoSuchContextBeanException; +import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.test.BaseTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + +/** + * springboot环境最普通的例子测试 + * @author Bryan.Zhang + * @since 2.6.4 + */ +@RunWith(SpringRunner.class) +@TestPropertySource(value = "classpath:/multiContext/application.properties") +@SpringBootTest(classes = MultiContextSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.multiContext.cmp"}) +public class MultiContextSpringbootTest extends BaseTest { + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testMultiContext1() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); + OrderContext orderContext = response.getContextBean(OrderContext.class); + CheckContext checkContext = response.getContextBean(CheckContext.class); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("987XYZ", checkContext.getSign()); + Assert.assertEquals(95, checkContext.getRandomId()); + Assert.assertEquals("SO12345", orderContext.getOrderNo()); + Assert.assertEquals(2, orderContext.getOrderType()); + Assert.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime()); + } + + @Test(expected = NoSuchContextBeanException.class) + public void testMultiContext2() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class); + DefaultContext context = response.getContextBean(DefaultContext.class); + } + +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/OrderContext.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/OrderContext.java new file mode 100644 index 000000000..c477108b3 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/OrderContext.java @@ -0,0 +1,36 @@ +package com.yomahub.liteflow.test.multiContext; + +import java.util.Date; + +public class OrderContext { + + private String orderNo; + + private int orderType; + + private Date createTime; + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public int getOrderType() { + return orderType; + } + + public void setOrderType(int orderType) { + this.orderType = orderType; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/ACmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/ACmp.java new file mode 100644 index 000000000..b8e5b6757 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/ACmp.java @@ -0,0 +1,24 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.multiContext.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.test.multiContext.CheckContext; +import org.springframework.stereotype.Component; + +@Component("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + CheckContext checkContext = this.getContextBean(CheckContext.class); + checkContext.setSign("987XYZ"); + checkContext.setRandomId(95); + System.out.println("ACmp executed!"); + } +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/BCmp.java new file mode 100644 index 000000000..c5a13ddba --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/BCmp.java @@ -0,0 +1,25 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.multiContext.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.test.multiContext.OrderContext; +import org.springframework.stereotype.Component; + +@Component("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + //getContextBean无参方法是获取到第一个上下文 + OrderContext orderContext = this.getFirstContextBean(); + orderContext.setOrderNo("SO12345"); + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/CCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/CCmp.java new file mode 100644 index 000000000..027de6f98 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/CCmp.java @@ -0,0 +1,24 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.multiContext.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.test.multiContext.OrderContext; +import org.springframework.stereotype.Component; + +@Component("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + OrderContext orderContext = this.getContextBean(OrderContext.class); + orderContext.setOrderType(2); + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/DCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/DCmp.java new file mode 100644 index 000000000..1ebfd536a --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multiContext/cmp/DCmp.java @@ -0,0 +1,25 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.multiContext.cmp; + +import cn.hutool.core.date.DateUtil; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.test.multiContext.OrderContext; +import org.springframework.stereotype.Component; + +@Component("d") +public class DCmp extends NodeComponent { + + @Override + public void process() { + OrderContext orderContext = this.getContextBean(OrderContext.class); + orderContext.setCreateTime(DateUtil.parseDate("2022-06-15")); + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java index 2ce1f1c4e..74659c688 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java @@ -32,7 +32,7 @@ public class LiteflowMultipleTypeSpringbootTest extends BaseTest { @Test public void testMultipleType() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java index a5da9969f..0ced9da9f 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerDefaultNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerDefaultNodeExecutor进行执行"); context.setData("customerDefaultNodeExecutor", this.getClass()); super.execute(instance); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java index add288d67..5a9f2e58d 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerNodeExecutor进行执行"); context.setData("customerNodeExecutor", this.getClass()); super.execute(instance); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java index a6eb87d53..003d33319 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); context.setData("customerNodeExecutorAndCustomRetry", this.getClass()); super.execute(instance); @@ -23,7 +23,7 @@ public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { TimeUnit.MICROSECONDS.sleep(20L); - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); context.setData("retryLogic", this.getClass()); super.retry(instance, currentRetryCount); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java index bc6871a74..45baf6bae 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java @@ -35,25 +35,27 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest { // 默认执行器测试 @Test public void testCustomerDefaultNodeExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); Assert.assertEquals("a", response.getExecuteStepStr()); } //默认执行器测试+全局重试配置测试 @Test public void testDefaultExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); } //自定义执行器测试 @Test public void testCustomerExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("c", response.getExecuteStepStr()); } @@ -61,9 +63,10 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest { //自定义执行器测试+全局重试配置测试 @Test public void testCustomExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getContextBean().getData("retryLogic")); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamSpringbootTest.java index 11fabcf71..b7d5eda9e 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamSpringbootTest.java @@ -34,7 +34,7 @@ public class NullParamSpringbootTest { */ @Test public void testNullParam() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java index acf0f397e..dd2b055e3 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringbootTest.java @@ -33,7 +33,7 @@ public class CustomParserJsonSpringbootTest extends BaseTest { //测试springboot场景的自定义json parser @Test public void testJsonCustomParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java index 65795f03b..47e80dee4 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserXmlSpringbootTest.java @@ -34,7 +34,7 @@ public class CustomParserXmlSpringbootTest extends BaseTest { //测试springboot场景的自定义json parser @Test public void testXmlCustomParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserSpringbootTest.java index 87cbbe648..04707d903 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/JsonParserSpringbootTest.java @@ -31,7 +31,7 @@ public class JsonParserSpringbootTest extends BaseTest { //测试spring场景的json parser @Test public void testJsonParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportSpringbootTest.java index 7837ffa6a..5234ab72d 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/SpringELSupportSpringbootTest.java @@ -26,7 +26,7 @@ public class SpringELSupportSpringbootTest extends BaseTest { //测试springEL的解析情况 @Test public void testSpringELParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java index 63884c98f..2e52acc18 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java @@ -31,7 +31,7 @@ public class XmlParserSpringbootTest extends BaseTest { //测试无springboot场景的xml parser @Test public void testXmlParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserSpringbootTest.java index c7fcc74c1..d64698267 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/YmlParserSpringbootTest.java @@ -31,7 +31,7 @@ public class YmlParserSpringbootTest extends BaseTest { //测试无springboot场景的yml parser @Test public void testYmlParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringbootTest.java index 579b41dfc..8887ad1aa 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringbootTest.java @@ -33,7 +33,7 @@ public class PreAndFinallySpringbootTest extends BaseTest { //测试普通的pre和finally节点 @Test public void testPreAndFinally1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getExecuteStepStr()); } @@ -41,7 +41,7 @@ public class PreAndFinallySpringbootTest extends BaseTest { //测试pre和finally节点不放在开头和结尾的情况 @Test public void testPreAndFinally2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getExecuteStepStr()); } @@ -49,7 +49,7 @@ public class PreAndFinallySpringbootTest extends BaseTest { //测试有节点报错是否还执行finally节点的情况,其中d节点会报错,但依旧执行f1,f2节点 @Test public void testPreAndFinally3() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } @@ -57,15 +57,16 @@ public class PreAndFinallySpringbootTest extends BaseTest { //测试在finally节点里是否能获取exception @Test public void testPreAndFinally4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("hasEx")); + Assert.assertTrue(context.getData("hasEx")); } //测试嵌套结构pre和finally是否在各自的chain里打出 @Test public void testPreAndFinally5() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java index 183b199af..22c4d1d2e 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java @@ -18,8 +18,8 @@ public class Finally3Cmp extends NodeComponent { @Override public void process() throws Exception{ - Slot slot = this.getSlot(); - DefaultContext context = slot.getContextBean(); + Slot slot = this.getSlot(); + DefaultContext context = slot.getFirstContextBean(); if (ObjectUtil.isNull(slot.getException())){ context.setData("hasEx", false); }else{ diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java index 60ffcf9ca..67c630f1f 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringbootTest.java @@ -34,8 +34,8 @@ public class PrivateDeliverySpringbootTest extends BaseTest { @Test public void testPrivateDelivery() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - DefaultContext context = response.getContextBean(); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); ConcurrentHashSet set = context.getData("testSet"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals(100, set.size()); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java index e3d65e4c7..253901045 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java @@ -21,7 +21,7 @@ public class ACmp extends NodeComponent { @Override public void process() { System.out.println("ACmp executed!"); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("testSet", new ConcurrentHashSet<>()); for (int i = 0; i < 100; i++) { diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java index 721ff92a1..ab5de1a08 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java @@ -22,7 +22,7 @@ public class BCmp extends NodeComponent { public void process() { System.out.println("BCmp executed!"); Integer value = this.getPrivateDeliveryData(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); ConcurrentHashSet testSet = context.getData("testSet"); testSet.add(value); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringbootTest.java index 798ed4925..f631f2c67 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringbootTest.java @@ -38,7 +38,7 @@ public class RefreshRuleSpringbootTest extends BaseTest { public void testRefresh1() throws Exception{ String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, content); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } @@ -57,7 +57,7 @@ public class RefreshRuleSpringbootTest extends BaseTest { }).start(); for (int i = 0; i < 500; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); try { Thread.sleep(10L); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java index 2f5090c96..f18a20c2b 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringbootTest.java @@ -35,7 +35,7 @@ public class ReloadSpringbootTest extends BaseTest { @Test public void testReload() throws Exception{ flowExecutor.reloadRule(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainSpringbootTest.java index 34f70f70d..13da53ec2 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainSpringbootTest.java @@ -33,10 +33,10 @@ public class RemoveChainSpringbootTest extends BaseTest { @Test public void testRemoveChain() throws Exception{ - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response1.isSuccess()); FlowBus.removeChain("chain1"); - LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response2.isSuccess()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java index 525d41bb0..1f973aa07 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringbootTest.java @@ -40,13 +40,13 @@ public class ResizeSlotSpringbootTest extends BaseTest { public void testResize() throws Exception{ ExecutorService pool = Executors.newCachedThreadPool(); - List>> futureList = new ArrayList<>(); + List> futureList = new ArrayList<>(); for (int i = 0; i < 100; i++) { - Future> future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg")); + Future future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg")); futureList.add(future); } - for(Future> future : futureList){ + for(Future future : futureList){ Assert.assertTrue(future.get().isSuccess()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringbootTest.java index fa014d723..15591e164 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringbootTest.java @@ -37,7 +37,8 @@ public class ImplicitSubFlowSpringbootTest extends BaseTest { //这里GCmp中隐式的调用chain4,从而执行了h,m @Test public void testImplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); @@ -46,6 +47,6 @@ public class ImplicitSubFlowSpringbootTest extends BaseTest { // set中第一次设置的requestId和response中的requestId一致 Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); //requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", response.getContextBean().getData("innerRequest")); + Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringbootTest.java index 2e67e1f29..3eb708eda 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringbootTest.java @@ -36,7 +36,7 @@ public class SubflowInDifferentConfigSpringbootTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringBootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringBootTest.java index e44a7d12d..80b24197f 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringBootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringBootTest.java @@ -33,7 +33,7 @@ public class SubflowJsonSpringBootTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringBootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringBootTest.java index a3dafab98..700d05a5e 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringBootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringBootTest.java @@ -33,7 +33,7 @@ public class SubflowXMLSpringBootTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringBootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringBootTest.java index d4c5b6b7a..283c0d7cd 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringBootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringBootTest.java @@ -33,7 +33,7 @@ public class SubflowYmlSpringBootTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlowYml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/FCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/FCmp.java index 6caa2613c..cd352edd3 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/FCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/FCmp.java @@ -14,7 +14,7 @@ public class FCmp extends NodeComponent { RUN_TIME_SLOT.add(this.getSlot().getRequestId()); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("innerRequestData", "inner request"); System.out.println("Fcomp executed!"); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java index 292ccd825..e594daf37 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java @@ -12,7 +12,7 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { String requestData = this.getSubChainReqData(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("innerRequest", requestData); RUN_TIME_SLOT.add(this.getSlot().getRequestId()); diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootJsonTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootJsonTest.java index ded006a83..31fb76114 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootJsonTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootJsonTest.java @@ -33,14 +33,15 @@ public class NodeTagSpringbootJsonTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getContextBean().getData("test")); + Assert.assertEquals("123",context.getData("test")); } @Test public void testTag2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } @@ -50,9 +51,10 @@ public class NodeTagSpringbootJsonTest extends BaseTest { @Test public void testTag3() throws Exception{ for (int i = 0; i < 50; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getContextBean().getData("test"); + ConcurrentHashSet testSet = context.getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -60,7 +62,7 @@ public class NodeTagSpringbootJsonTest extends BaseTest { //测试tag是否能在isAccess中起效 @Test public void testTag4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootXmlTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootXmlTest.java index b9769eed0..e7e0b58fd 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootXmlTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringbootXmlTest.java @@ -33,14 +33,15 @@ public class NodeTagSpringbootXmlTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getContextBean().getData("test")); + Assert.assertEquals("123",context.getData("test")); } @Test public void testTag2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } @@ -50,9 +51,10 @@ public class NodeTagSpringbootXmlTest extends BaseTest { @Test public void testTag3() throws Exception{ for (int i = 0; i < 50; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getContextBean().getData("test"); + ConcurrentHashSet testSet = context.getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -60,7 +62,7 @@ public class NodeTagSpringbootXmlTest extends BaseTest { //测试tag是否能在isAccess中起效 @Test public void testTag4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java index c718f989f..6e2a73ffd 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java @@ -19,7 +19,7 @@ public class ACmp extends NodeComponent { public void process() { String testKey = "test"; - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); if (context.getData(testKey) == null){ context.setData(testKey,this.getTag()); }else{ diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java index 9ff1d9149..de3d6aba5 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java @@ -18,7 +18,7 @@ public class B1Cmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("test",new ConcurrentHashSet()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java index 05c079554..58841874b 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java @@ -18,7 +18,7 @@ public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); ConcurrentHashSet testSet = context.getData("test"); testSet.add(this.getTag()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringbootTest.java index f397e1fd3..dbfecb808 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringbootTest.java @@ -32,11 +32,12 @@ public class UseTTLInWhenSpringbootTest extends BaseTest { @Test public void testUseTTLInWhen() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("hello,b", response.getContextBean().getData("b")); - Assert.assertEquals("hello,c", response.getContextBean().getData("c")); - Assert.assertEquals("hello,d", response.getContextBean().getData("d")); - Assert.assertEquals("hello,e", response.getContextBean().getData("e")); - Assert.assertEquals("hello,f", response.getContextBean().getData("f")); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); + Assert.assertEquals("hello,b", context.getData("b")); + Assert.assertEquals("hello,c", context.getData("c")); + Assert.assertEquals("hello,d", context.getData("d")); + Assert.assertEquals("hello,e", context.getData("e")); + Assert.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java index 27c917c1a..7597ad59c 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java @@ -18,7 +18,7 @@ public class BCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",b"); System.out.println("BCmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java index a2c404a95..bc5c7ca69 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java @@ -18,7 +18,7 @@ public class CCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",c"); System.out.println("CCmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java index 6419a6666..1410921d8 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java @@ -18,7 +18,7 @@ public class DCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",d"); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java index c9b97db4f..6217dd6a9 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java @@ -18,7 +18,7 @@ public class ECmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",e"); System.out.println("ECmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java index 0ba2ab4f8..06380e58c 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java @@ -18,7 +18,7 @@ public class FCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData(this.getNodeId(),value+",f"); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest1.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest1.java index 179591505..c85ea7521 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest1.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest1.java @@ -38,7 +38,7 @@ public class WhenTimeOutSpringbootTest1 extends BaseTest { //其中b和c在when情况下超时,所以抛出了WhenTimeoutException这个错 @Test public void testWhenTimeOut() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest2.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest2.java index 1d7a1139f..e3377ef0a 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest2.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest2.java @@ -37,7 +37,7 @@ public class WhenTimeOutSpringbootTest2 extends BaseTest { //其中d,e,f都sleep 4秒,其中def是不同的组,超时设置5秒 @Test public void testWhenTimeOut() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java index c6fddb4be..109648467 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringbootTest.java @@ -72,7 +72,7 @@ public class ZkNodeWithJsonSpringbootTest extends BaseTest { @Test public void testZkNodeWithJson() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java index baec322d2..373db08cc 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringbootTest.java @@ -72,7 +72,7 @@ public class ZkNodeWithXmlSpringbootTest extends BaseTest { @Test public void testZkNodeWithXml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java index 68503df70..21a754f19 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringbootTest.java @@ -72,7 +72,7 @@ public class ZkNodeWithYmlSpringbootTest extends BaseTest { @Test public void testZkNodeWithYml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-springboot/src/test/resources/multiContext/application.properties b/liteflow-testcase-springboot/src/test/resources/multiContext/application.properties new file mode 100644 index 000000000..195b78559 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/resources/multiContext/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=multiContext/flow.xml \ No newline at end of file diff --git a/liteflow-testcase-springboot/src/test/resources/multiContext/flow.xml b/liteflow-testcase-springboot/src/test/resources/multiContext/flow.xml new file mode 100644 index 000000000..7068d6cee --- /dev/null +++ b/liteflow-testcase-springboot/src/test/resources/multiContext/flow.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringTest.java index 93276d87d..d02f37c91 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringTest.java @@ -21,7 +21,7 @@ public class AbsoluteConfigPathSpringTest extends BaseTest { @Test public void testAbsoluteConfig(){ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringTest.java index 39aa82dd5..170dd88aa 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/CustomAOPSpringTest.java @@ -26,20 +26,22 @@ public class CustomAOPSpringTest extends BaseTest { //测试自定义AOP,串行场景 @Test public void testCustomAopS() { - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); } //测试自定义AOP,并行场景 @Test public void testCustomAopP() { - LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringTest.java index bf9a587b9..5493621eb 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/GlobalAOPSpringTest.java @@ -29,35 +29,38 @@ public class GlobalAOPSpringTest extends BaseTest { //测试全局AOP,串行场景 @Test public void testGlobalAopS() { - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("d")); - Assert.assertEquals("before_after", response.getContextBean().getData("e")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("d")); + Assert.assertEquals("before_after", context.getData("e")); } //测试全局AOP,并行场景 @Test public void testGlobalAopP() { - LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain2", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("d")); - Assert.assertEquals("before_after", response.getContextBean().getData("e")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("d")); + Assert.assertEquals("before_after", context.getData("e")); } @Test public void testGlobalAopException() { - LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", response.getContextBean().getData("a")); - Assert.assertEquals("before_after", response.getContextBean().getData("b")); - Assert.assertEquals("before_after", response.getContextBean().getData("c")); - Assert.assertEquals("before_after", response.getContextBean().getData("f")); + Assert.assertEquals("before_after", context.getData("a")); + Assert.assertEquals("before_after", context.getData("b")); + Assert.assertEquals("before_after", context.getData("c")); + Assert.assertEquals("before_after", context.getData("f")); } @AfterClass diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java index 785578fda..3704a146d 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CmpAspect.java @@ -5,16 +5,16 @@ import com.yomahub.liteflow.aop.ICmpAroundAspect; import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; -public class CmpAspect implements ICmpAroundAspect { +public class CmpAspect implements ICmpAroundAspect { @Override - public void beforeProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getContextBean(); + public void beforeProcess(String nodeId, Slot slot) { + DefaultContext context = slot.getFirstContextBean(); context.setData(nodeId, "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - DefaultContext context = slot.getContextBean(); + public void afterProcess(String nodeId, Slot slot) { + DefaultContext context = slot.getFirstContextBean(); context.setData(nodeId, StrUtil.format("{}_{}", context.getData(nodeId), "after")); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java index 673e3f7b5..b2fc0f86a 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/aop/aspect/CustomAspect.java @@ -19,7 +19,7 @@ public class CustomAspect { @Around("cut()") public Object around(ProceedingJoinPoint jp) throws Throwable { NodeComponent cmp = (NodeComponent) jp.getThis(); - DefaultContext context = cmp.getContextBean(); + DefaultContext context = cmp.getFirstContextBean(); context.setData(cmp.getNodeId(), "before"); Object returnObj = jp.proceed(); context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringTest.java index 30eb622a2..a5231d06e 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringTest.java @@ -33,7 +33,7 @@ public class AsyncNodeSpringTest extends BaseTest { * **/ @Test public void testAsyncFlow1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); Assert.assertTrue(response.isSuccess()); System.out.println(response.getExecuteStepStr()); } @@ -41,7 +41,7 @@ public class AsyncNodeSpringTest extends BaseTest { //这个和test1有点类似,只不过进一步验证了步骤 @Test public void testAsyncFlow2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); Assert.assertTrue(ListUtil.toList("b==>j==>g==>f==>h","b==>j==>g==>h==>f", "b==>j==>h==>g==>f","b==>j==>h==>f==>g", "b==>j==>f==>h==>g","b==>j==>f==>g==>h" @@ -51,7 +51,7 @@ public class AsyncNodeSpringTest extends BaseTest { //测试errorResume,默认的errorResume为false,这里测试默认的 @Test public void testAsyncFlow3_1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class); } @@ -59,18 +59,19 @@ public class AsyncNodeSpringTest extends BaseTest { //测试errorResume,默认的errorResume为false,这里设置为true @Test public void testAsyncFlow3_2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request"); Assert.assertTrue(response.isSuccess()); } //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @Test public void testAsyncFlow4() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //因为不记录错误,所以最终结果是true Assert.assertTrue(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //因为配置了不抛错,所以response里的cause应该为null Assert.assertNull(response.getCause()); @@ -79,11 +80,12 @@ public class AsyncNodeSpringTest extends BaseTest { //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @Test public void testAsyncFlow5() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //整个并行组是报错的,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //因为第一个when配置了会报错,所以response里的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -92,11 +94,12 @@ public class AsyncNodeSpringTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @Test public void testAsyncFlow6() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //第一个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(1), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -105,11 +108,12 @@ public class AsyncNodeSpringTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @Test public void testAsyncFlow7() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); //第二个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 - Integer count = response.getContextBean().getData("count"); + Integer count = context.getData("count"); Assert.assertEquals(new Integer(2), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -121,8 +125,9 @@ public class AsyncNodeSpringTest extends BaseTest { //这里要注意的是,由于step是先加入,所以step的打印顺序并不是这样的。但是实际执行是正确的 @Test public void testAsyncFlow8() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("check").toString().startsWith("habc")); + Assert.assertTrue(context.getData("check").toString().startsWith("habc")); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java index 2d362f405..01afc5856 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ACmp.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; public class ACmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java index b60ed84db..73c27c742 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/BCmp.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java index fc32acff6..253447f81 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/CCmp.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; public class CCmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java index 8918b783b..6203d92da 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/DCmp.java @@ -11,7 +11,7 @@ public class DCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(1000); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java index dc0694664..66fd659cc 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java @@ -12,7 +12,7 @@ public class GCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(500); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java index 52dfa5d85..dd211dfa3 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/HCmp.java @@ -11,7 +11,7 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); synchronized (NodeComponent.class){ if (context.hasData("check")){ String str = context.getData("check"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java index 8c5a76748..d3789bb8b 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/ICmp.java @@ -12,7 +12,7 @@ public class ICmp extends NodeComponent { @Override public void process() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); if (context.hasData("count")){ Integer count = context.getData("count"); context.setData("count", ++count); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/base/BaseCommonSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/base/BaseCommonSpringTest.java index 8c98130d2..e30b14758 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/base/BaseCommonSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/base/BaseCommonSpringTest.java @@ -21,7 +21,7 @@ public class BaseCommonSpringTest extends BaseTest { @Test public void testBaseCommon(){ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringTest1.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringTest1.java index f7da0c23a..41ac849ee 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringTest1.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringTest1.java @@ -80,7 +80,7 @@ public class BuilderSpringTest1 extends BaseTest { .setValue("e(f|g|chain2)").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); } @@ -138,7 +138,7 @@ public class BuilderSpringTest1 extends BaseTest { .setValue("e(f|g|chain2)").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); } @@ -205,7 +205,7 @@ public class BuilderSpringTest1 extends BaseTest { )).build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringTest2.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringTest2.java index 59c14736e..f80d4a559 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringTest2.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/builder/BuilderSpringTest2.java @@ -30,7 +30,7 @@ public class BuilderSpringTest2 extends BaseTest { LiteFlowConditionBuilder.createThenCondition().setValue("h,i,j").build() ).build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("h==>i==>j", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringTest.java index f65fb094e..a68df34ad 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/cmpRetry/LiteflowRetrySpringTest.java @@ -30,7 +30,7 @@ public class LiteflowRetrySpringTest extends BaseTest { //全局重试配置测试 @Test public void testRetry1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr()); } @@ -38,7 +38,7 @@ public class LiteflowRetrySpringTest extends BaseTest { //单个组件重试配置测试 @Test public void testRetry2() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr()); } @@ -46,14 +46,14 @@ public class LiteflowRetrySpringTest extends BaseTest { //单个组件指定异常,但抛出的并不是指定异常的场景测试 @Test public void testRetry3() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertFalse(response.isSuccess()); } //单个组件指定异常重试,抛出的是指定异常或者 @Test public void testRetry4() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringTest.java index 003ee0a9e..21e19828f 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/cmpStep/CmpStepSpringTest.java @@ -21,7 +21,7 @@ public class CmpStepSpringTest extends BaseTest { @Test public void testStep1(){ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertTrue(response.getExecuteSteps().get("a").isSuccess()); Assert.assertTrue(response.getExecuteSteps().get("b").isSuccess()); @@ -34,7 +34,7 @@ public class CmpStepSpringTest extends BaseTest { @Test public void testStep2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/component/ComponentSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/component/ComponentSpringTest.java index 2446dc22c..eb89da349 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/component/ComponentSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/component/ComponentSpringTest.java @@ -32,7 +32,7 @@ public class ComponentSpringTest extends BaseTest { //isAccess方法的功能测试 @Test public void testIsAccess() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101); Assert.assertTrue(response.isSuccess()); Assert.assertNotNull(response.getSlot().getResponseData()); } @@ -40,7 +40,7 @@ public class ComponentSpringTest extends BaseTest { //组件抛错的功能点测试 @Test(expected = ArithmeticException.class) public void testComponentException() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("/ by zero", response.getMessage()); ReflectionUtils.rethrowException(response.getCause()); @@ -49,7 +49,7 @@ public class ComponentSpringTest extends BaseTest { //isContinueOnError方法的功能点测试 @Test public void testIsContinueOnError() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0); Assert.assertTrue(response.isSuccess()); Assert.assertNull(response.getCause()); } @@ -57,7 +57,7 @@ public class ComponentSpringTest extends BaseTest { //isEnd方法的功能点测试 @Test public void testIsEnd() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("d",response.getExecuteStepStr()); } @@ -65,7 +65,7 @@ public class ComponentSpringTest extends BaseTest { //setIsEnd方法的功能点测试 @Test public void testSetIsEnd1() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("e",response.getExecuteStepStr()); } @@ -73,14 +73,14 @@ public class ComponentSpringTest extends BaseTest { //条件组件的功能点测试 @Test public void testNodeCondComponent() { - LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); + LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0); Assert.assertTrue(response.isSuccess()); } //测试setIsEnd如果为true,continueError也为true,那不应该continue了 @Test public void testSetIsEnd2() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); + LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g",response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringTest.java index 92d8c5924..ad6730eae 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigSpringTest.java @@ -32,7 +32,7 @@ public class LiteflowConfigSpringTest extends BaseTest { @Test public void testConfig() throws Exception { LiteflowConfig config = context.getBean(LiteflowConfig.class); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("config/flow.json", config.getRuleSource()); Assert.assertEquals(15, config.getWhenMaxWaitSeconds().intValue()); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchSpringTest.java index b307988ac..af8017823 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchSpringTest.java @@ -31,9 +31,9 @@ public class LocalRuleSourcePatternMatchSpringTest extends BaseTest { */ @Test public void testLocalJsonRuleSourcePatternMatch() { - LiteflowResponse response0 = executor.execute2Resp("chain1", "arg"); + LiteflowResponse response0 = executor.execute2Resp("chain1", "arg"); Assert.assertEquals("a==>b==>c", response0.getExecuteStepStr()); - LiteflowResponse response1 = executor.execute2Resp("chain3", "arg"); + LiteflowResponse response1 = executor.execute2Resp("chain3", "arg"); Assert.assertEquals("a==>c==>f==>g", response1.getExecuteStepStr()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringTest.java index 61e1875ad..678191fc0 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customNodes/CustomNodesSpringTest.java @@ -30,7 +30,7 @@ public class CustomNodesSpringTest extends BaseTest { @Test public void testCustomNodes() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringTest.java index 0f0d16224..f00691452 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolSpringTest.java @@ -34,9 +34,10 @@ public class CustomWhenThreadPoolSpringTest extends BaseTest { */ @Test public void testGlobalThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("threadName").toString().startsWith("lf-when-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -44,9 +45,10 @@ public class CustomWhenThreadPoolSpringTest extends BaseTest { */ @Test public void testGlobalAndCustomWhenThreadPool() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response1.getFirstContextBean(); Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(response1.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } @@ -58,9 +60,10 @@ public class CustomWhenThreadPoolSpringTest extends BaseTest { // 使用when - thread1 testGlobalAndCustomWhenThreadPool(); // chain配置同一个thead1 - LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response2.getFirstContextBean(); Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(response2.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead")); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java index a7af6a490..66bc03a45 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/BCmp.java @@ -16,7 +16,7 @@ public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("BCmp executed!"); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java index 99144f623..809d4429a 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/CCmp.java @@ -16,7 +16,7 @@ public class CCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("CCmp executed!"); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java index 4d1c41cc4..07d5a53dd 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/DCmp.java @@ -16,7 +16,7 @@ public class DCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("DCmp executed!"); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java index 61da5bba5..6e96482bf 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/ECmp.java @@ -16,7 +16,7 @@ public class ECmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("ECmp executed!"); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java index fe77d3af8..7091b7316 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/cmp/FCmp.java @@ -16,7 +16,7 @@ public class FCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("threadName", Thread.currentThread().getName()); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringTest.java index 9b9290d4d..c840cf4e0 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/enable/LiteflowEnableSpringTest.java @@ -31,7 +31,7 @@ public class LiteflowEnableSpringTest extends BaseTest { LiteflowConfig config = LiteflowConfigGetter.get(); Boolean enable = config.getEnable(); if (enable) { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); return; } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/EventSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/EventSpringTest.java index fb1810775..f09d215c7 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/EventSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/EventSpringTest.java @@ -22,28 +22,31 @@ public class EventSpringTest extends BaseTest { //测试组件成功事件 @Test public void testEvent1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("abc", response.getContextBean().getData("test")); + Assert.assertEquals("abc", context.getData("test")); } //测试组件失败事件 @Test public void testEvent2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("ab", response.getContextBean().getData("test")); - Assert.assertEquals("error:d", response.getContextBean().getData("error")); + Assert.assertEquals("ab", context.getData("test")); + Assert.assertEquals("error:d", context.getData("error")); } //测试组件失败事件本身抛出异常 @Test public void testEvent3() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(NullPointerException.class, response.getCause().getClass()); - Assert.assertEquals("a", response.getContextBean().getData("test")); - Assert.assertEquals("error:e", response.getContextBean().getData("error")); + Assert.assertEquals("a", context.getData("test")); + Assert.assertEquals("error:e", context.getData("error")); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java index b50a41cb4..11c7509ba 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ACmp.java @@ -16,14 +16,14 @@ public class ACmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("test",""); System.out.println("ACmp executed!"); } @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java index 40d237fa1..7fc1b3538 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/BCmp.java @@ -21,7 +21,7 @@ public class BCmp extends NodeComponent { @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java index 9173f1f50..f87eeed18 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/CCmp.java @@ -21,7 +21,7 @@ public class CCmp extends NodeComponent { @Override public void onSuccess() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String str = context.getData("test"); str += this.getNodeId(); context.setData("test", str); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java index 862352aab..1865b83ed 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/DCmp.java @@ -22,7 +22,7 @@ public class DCmp extends NodeComponent { @Override public void onError() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("error","error:"+this.getNodeId()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java index 1a7156aeb..600f16321 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/event/cmp/ECmp.java @@ -22,7 +22,7 @@ public class ECmp extends NodeComponent { @Override public void onError() throws Exception { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("error","error:"+this.getNodeId()); throw new IllegalAccessException("错误事件回调本身抛出异常"); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringTest.java index b6679b18a..1fcdf011a 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/Exception2SpringTest.java @@ -48,7 +48,7 @@ public class Exception2SpringTest extends BaseTest { @Test public void testGetSlotFromResponseWhenException() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test"); Assert.assertFalse(response.isSuccess()); Assert.assertNotNull(response.getCause()); Assert.assertNotNull(response.getSlot()); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringTest.java index dc501cd45..50c8b9310 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/execute2Future/Executor2FutureSpringTest.java @@ -27,8 +27,8 @@ public class Executor2FutureSpringTest extends BaseTest { @Test public void testFuture() throws Exception{ - Future> future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); - LiteflowResponse response = future.get(); + Future future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class); + LiteflowResponse response = future.get(); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/FlowExecutorTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/FlowExecutorTest.java index 01cd56364..1014abc09 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/FlowExecutorTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/FlowExecutorTest.java @@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.executor; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; @@ -22,9 +23,10 @@ public class FlowExecutorTest extends BaseTest { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("executor/flow.json"); FlowExecutor executor = new FlowExecutor(config); - LiteflowResponse response = executor.execute2Resp("chain1", "test0", CustomContext.class); + LiteflowResponse response = executor.execute2Resp("chain1", "test0", CustomContext.class); + CustomContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("custom", response.getContextBean().getName()); + Assert.assertEquals("custom", context.getName()); } @Test(expected=RuntimeException.class) @@ -32,7 +34,8 @@ public class FlowExecutorTest extends BaseTest { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("executor/flow0.json"); FlowExecutor executor = new FlowExecutor(config); - LiteflowResponse response = executor.execute2Resp("chain1", "test1", CustomContext.class); + LiteflowResponse response = executor.execute2Resp("chain1", "test1", CustomContext.class); + CustomContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); ReflectionUtils.rethrowException(response.getCause()); } @@ -42,7 +45,8 @@ public class FlowExecutorTest extends BaseTest { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("executor/flow.json"); FlowExecutor executor = new FlowExecutor(config); - CustomContext context = executor.execute("chain1", "test0", CustomContext.class); + LiteflowResponse response = executor.execute2Resp("chain1", "test0", CustomContext.class); + CustomContext context = response.getFirstContextBean(); Assert.assertEquals("custom", context.getName()); } @@ -51,6 +55,9 @@ public class FlowExecutorTest extends BaseTest { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("executor/flow0.json"); FlowExecutor executor = new FlowExecutor(config); - executor.execute("chain1", "test1", CustomContext.class); + LiteflowResponse response = executor.execute2Resp("chain1", "test1", CustomContext.class); + if(!response.isSuccess()){ + throw response.getCause(); + } } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/cmp/CCmp.java index 4293ef371..dfc6ecf04 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/cmp/CCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/cmp/CCmp.java @@ -19,10 +19,10 @@ public class CCmp extends NodeComponent { @Override public void process() { - Object bean = this.getContextBean(); + Object bean = this.getFirstContextBean(); if(bean instanceof CustomContext) { - Slot slot = this.getSlot(); - CustomContext context = slot.getContextBean(); + Slot slot = this.getSlot(); + CustomContext context = slot.getFirstContextBean(); String str = slot.getRequestData(); if(StrUtil.isNotBlank(str) && str.equals("test0")) { context.setName("custom"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringTest.java index bbeb223d1..8be9d8618 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringTest.java @@ -25,7 +25,7 @@ public class FlowMetaSpringTest extends BaseTest { @Test public void testFlowMeta() { FlowBus.addCommonNode("d", "d组件", DCmp.class); - LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>d[d组件]", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringTest.java index a141090d1..7c1350c06 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringTest.java @@ -21,7 +21,7 @@ public class LazySpringTest extends BaseTest { @Test public void testLazy() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringTest.java index fab5b4758..4d8aa54ce 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/lfCmpAnno/LiteflowComponentSpringTest.java @@ -26,7 +26,7 @@ public class LiteflowComponentSpringTest extends BaseTest { @Test public void testConfig() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringTest.java index 5765b8dc6..585fd6323 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/monitor/MonitorSpringTest.java @@ -29,7 +29,7 @@ public class MonitorSpringTest extends BaseTest { @Test public void testMonitor() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Thread.sleep(10000); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringTest.java index b378c3886..98964374d 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringTest.java @@ -26,7 +26,7 @@ public class LiteflowMultipleTypeSpringTest extends BaseTest { @Test public void testMultipleType() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr()); response = flowExecutor.execute2Resp("chain3", "arg"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java index a5da9969f..0ced9da9f 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerDefaultNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerDefaultNodeExecutor进行执行"); context.setData("customerDefaultNodeExecutor", this.getClass()); super.execute(instance); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java index add288d67..5a9f2e58d 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutor.java @@ -12,7 +12,7 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerNodeExecutor进行执行"); context.setData("customerNodeExecutor", this.getClass()); super.execute(instance); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java index a6eb87d53..003d33319 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerNodeExecutorAndCustomRetry.java @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); context.setData("customerNodeExecutorAndCustomRetry", this.getClass()); super.execute(instance); @@ -23,7 +23,7 @@ public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { TimeUnit.MICROSECONDS.sleep(20L); - DefaultContext context = instance.getContextBean(); + DefaultContext context = instance.getFirstContextBean(); context.setData("retryLogic", this.getClass()); super.retry(instance, currentRetryCount); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringTest.java index 4f9a555ed..68afc4cd4 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringTest.java @@ -29,25 +29,27 @@ public class LiteflowNodeExecutorSpringTest extends BaseTest { // 默认执行器测试 @Test public void testCustomerDefaultNodeExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); Assert.assertEquals("a", response.getExecuteStepStr()); } //默认执行器测试+全局重试配置测试 @Test public void testDefaultExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor")); Assert.assertEquals("b==>b==>b", response.getExecuteStepStr()); } //自定义执行器测试 @Test public void testCustomerExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("c", response.getExecuteStepStr()); } @@ -55,9 +57,10 @@ public class LiteflowNodeExecutorSpringTest extends BaseTest { //自定义执行器测试+全局重试配置测试 @Test public void testCustomExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getContextBean().getData("retryLogic")); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic")); Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java index 6c969455b..05a6b3524 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/nullParam/NullParamTest.java @@ -29,7 +29,7 @@ public class NullParamTest extends BaseTest { */ @Test public void testNullParam() throws Exception { - LiteflowResponse response = flowExecutor.execute2Resp("chain1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java index bfb1049dd..d2344bf88 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java @@ -27,7 +27,7 @@ public class CustomParserJsonSpringTest extends BaseTest { //测试spring场景的自定义json parser @Test public void testJsonCustomParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonNoSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonNoSpringTest.java index 5c592215c..36d554e7a 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonNoSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonNoSpringTest.java @@ -21,7 +21,7 @@ public class LFParserJsonNoSpringTest extends BaseTest { LiteflowConfig liteflowConfig = new LiteflowConfig(); liteflowConfig.setRuleSource("parser/flow.json"); FlowExecutor executor = new FlowExecutor(liteflowConfig); - LiteflowResponse response = executor.execute2Resp("chain1", "arg"); + LiteflowResponse response = executor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonSpringTest.java index eb8b4cd1e..6e724a374 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserJsonSpringTest.java @@ -27,7 +27,7 @@ public class LFParserJsonSpringTest extends BaseTest { //测试spring场景的xml parser @Test public void testJsonParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlNoSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlNoSpringTest.java index 1a9e940d8..8220d6397 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlNoSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlNoSpringTest.java @@ -21,7 +21,7 @@ public class LFParserXmlNoSpringTest extends BaseTest { LiteflowConfig liteflowConfig = new LiteflowConfig(); liteflowConfig.setRuleSource("parser/flow.xml"); FlowExecutor executor = new FlowExecutor(liteflowConfig); - LiteflowResponse response = executor.execute2Resp("chain1", "arg"); + LiteflowResponse response = executor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlSpringTest.java index 06eb320ea..0b72d2681 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserXmlSpringTest.java @@ -27,7 +27,7 @@ public class LFParserXmlSpringTest extends BaseTest { //测试spring场景的xml parser @Test public void testXmlParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlNoSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlNoSpringTest.java index e0b585d91..79d7d858c 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlNoSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlNoSpringTest.java @@ -21,7 +21,7 @@ public class LFParserYmlNoSpringTest extends BaseTest { LiteflowConfig liteflowConfig = new LiteflowConfig(); liteflowConfig.setRuleSource("parser/flow.yml"); FlowExecutor executor = new FlowExecutor(liteflowConfig); - LiteflowResponse response = executor.execute2Resp("chain1", "arg"); + LiteflowResponse response = executor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlSpringTest.java index 45afcaa37..d60c99699 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/parser/LFParserYmlSpringTest.java @@ -27,7 +27,7 @@ public class LFParserYmlSpringTest extends BaseTest { //测试spring场景的xml parser @Test public void testYmlParser() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringTest.java index a60abf765..7a2566b70 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/PreAndFinallySpringTest.java @@ -27,7 +27,7 @@ public class PreAndFinallySpringTest extends BaseTest { //测试普通的pre和finally节点 @Test public void testPreAndFinally1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getExecuteStepStr()); } @@ -35,7 +35,7 @@ public class PreAndFinallySpringTest extends BaseTest { //测试pre和finally节点不放在开头和结尾的情况 @Test public void testPreAndFinally2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2",response.getExecuteStepStr()); } @@ -43,7 +43,7 @@ public class PreAndFinallySpringTest extends BaseTest { //测试有节点报错是否还执行finally节点的情况,其中d节点会报错,但依旧执行f1,f2节点 @Test public void testPreAndFinally3() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr()); } @@ -51,15 +51,16 @@ public class PreAndFinallySpringTest extends BaseTest { //测试在finally节点里是否能获取exception @Test public void testPreAndFinally4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getContextBean().getData("hasEx")); + Assert.assertTrue(context.getData("hasEx")); } //测试嵌套结构pre和finally是否在各自的chain里打出 @Test public void testPreAndFinally5() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java index 183b199af..22c4d1d2e 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/preAndFinally/cmp/Finally3Cmp.java @@ -18,8 +18,8 @@ public class Finally3Cmp extends NodeComponent { @Override public void process() throws Exception{ - Slot slot = this.getSlot(); - DefaultContext context = slot.getContextBean(); + Slot slot = this.getSlot(); + DefaultContext context = slot.getFirstContextBean(); if (ObjectUtil.isNull(slot.getException())){ context.setData("hasEx", false); }else{ diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringTest.java index 8f15d1b37..866a58691 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/PrivateDeliverySpringTest.java @@ -28,8 +28,9 @@ public class PrivateDeliverySpringTest extends BaseTest { @Test public void testPrivateDelivery() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - ConcurrentHashSet set = response.getContextBean().getData("testSet"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); + ConcurrentHashSet set = context.getData("testSet"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals(100, set.size()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java index e3d65e4c7..253901045 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/ACmp.java @@ -21,7 +21,7 @@ public class ACmp extends NodeComponent { @Override public void process() { System.out.println("ACmp executed!"); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("testSet", new ConcurrentHashSet<>()); for (int i = 0; i < 100; i++) { diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java index ce77027a5..2bd78c299 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/privateDelivery/cmp/BCmp.java @@ -20,7 +20,7 @@ public class BCmp extends NodeComponent { @Override public void process() { System.out.println("BCmp executed!"); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); Integer value = this.getPrivateDeliveryData(); ConcurrentHashSet testSet = context.getData("testSet"); testSet.add(value); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringTest.java index 27061ba2e..015012282 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/refreshRule/RefreshRuleSpringTest.java @@ -32,7 +32,7 @@ public class RefreshRuleSpringTest extends BaseTest { public void testRefresh1() throws Exception{ String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.xml"); FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, content); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } @@ -51,7 +51,7 @@ public class RefreshRuleSpringTest extends BaseTest { }).start(); for (int i = 0; i < 500; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); try { Thread.sleep(10L); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringTest.java index 87d14a50c..c05b09dae 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/reload/ReloadSpringTest.java @@ -29,7 +29,7 @@ public class ReloadSpringTest extends BaseTest { @Test public void testReload() throws Exception{ flowExecutor.reloadRule(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainSpringTest.java index 06d5e31ae..77dfe5279 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/removeChain/RemoveChainSpringTest.java @@ -22,10 +22,10 @@ public class RemoveChainSpringTest extends BaseTest { @Test public void testRemoveChain(){ - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response1.isSuccess()); FlowBus.removeChain("chain1"); - LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response2.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringTest.java index 1f8354608..ccfeb93ca 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/resizeSlot/ResizeSlotSpringTest.java @@ -37,13 +37,13 @@ public class ResizeSlotSpringTest extends BaseTest { public void testResize() throws Exception{ ExecutorService pool = Executors.newCachedThreadPool(); - List>> futureList = new ArrayList<>(); + List> futureList = new ArrayList<>(); for (int i = 0; i < 100; i++) { - Future> future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg")); + Future future = pool.submit(() -> flowExecutor.execute2Resp("chain1", "arg")); futureList.add(future); } - for(Future> future : futureList){ + for(Future future : futureList){ Assert.assertTrue(future.get().isSuccess()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringTest.java index 7889d7cb2..20c8b7f0f 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/ImplicitSubFlowSpringTest.java @@ -31,7 +31,8 @@ public class ImplicitSubFlowSpringTest extends BaseTest { //这里GCmp中隐式的调用chain4,从而执行了h,m @Test public void testImplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr()); @@ -40,6 +41,6 @@ public class ImplicitSubFlowSpringTest extends BaseTest { // set中第一次设置的requestId和response中的requestId一致 Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId())); //requestData的取值正确 - Assert.assertEquals("it's implicit subflow.", response.getContextBean().getData("innerRequest")); + Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest")); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringTest.java index 8e4afd691..20db8947f 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowInDifferentConfigSpringTest.java @@ -29,7 +29,7 @@ public class SubflowInDifferentConfigSpringTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringTest.java index 244770ee0..d858befa4 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowJsonSpringTest.java @@ -27,7 +27,7 @@ public class SubflowJsonSpringTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringTest.java index e8d6f4678..3bcf02975 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowXMLSpringTest.java @@ -27,7 +27,7 @@ public class SubflowXMLSpringTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlow() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringTest.java index a05ba2755..2df39e9e1 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/SubflowYmlSpringTest.java @@ -27,7 +27,7 @@ public class SubflowYmlSpringTest extends BaseTest { //是否按照流程定义配置执行 @Test public void testExplicitSubFlowYml() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java index 1d05d7501..f21e2db88 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/HCmp.java @@ -12,7 +12,7 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { String requestData = this.getSubChainReqData(); - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("innerRequest", requestData); RUN_TIME_SLOT.add(this.getSlot().getRequestId()); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringJsonTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringJsonTest.java index 16d6871de..e1a644b30 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringJsonTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringJsonTest.java @@ -27,14 +27,15 @@ public class NodeTagSpringJsonTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getContextBean().getData("test")); + Assert.assertEquals("123",context.getData("test")); } @Test public void testTag2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } @@ -44,9 +45,10 @@ public class NodeTagSpringJsonTest extends BaseTest { @Test public void testTag3() throws Exception{ for (int i = 0; i < 50; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getContextBean().getData("test"); + ConcurrentHashSet testSet = context.getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -54,7 +56,7 @@ public class NodeTagSpringJsonTest extends BaseTest { //测试tag是否能在isAccess中起效 @Test public void testTag4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringXmlTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringXmlTest.java index 4b6b840cc..75cc97811 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringXmlTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/NodeTagSpringXmlTest.java @@ -27,14 +27,15 @@ public class NodeTagSpringXmlTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getContextBean().getData("test")); + Assert.assertEquals("123",context.getData("test")); } @Test public void testTag2() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr()); } @@ -44,9 +45,10 @@ public class NodeTagSpringXmlTest extends BaseTest { @Test public void testTag3() throws Exception{ for (int i = 0; i < 50; i++) { - LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg"); + DefaultContext context = response.getFirstContextBean(); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getContextBean().getData("test"); + ConcurrentHashSet testSet = context.getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -54,7 +56,7 @@ public class NodeTagSpringXmlTest extends BaseTest { //测试tag是否能在isAccess中起效 @Test public void testTag4() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("g", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java index 76cc7c60c..57868b288 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/ACmp.java @@ -18,7 +18,7 @@ public class ACmp extends NodeComponent { @Override public void process() { String testKey = "test"; - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); if (context.getData(testKey) == null){ context.setData(testKey,this.getTag()); }else{ diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java index 9ff1d9149..de3d6aba5 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/B1Cmp.java @@ -18,7 +18,7 @@ public class B1Cmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); context.setData("test",new ConcurrentHashSet()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java index 05c079554..58841874b 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/tag/cmp/BCmp.java @@ -18,7 +18,7 @@ public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); ConcurrentHashSet testSet = context.getData("test"); testSet.add(this.getTag()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringTest.java index 7ce4bd01a..be06ec9d2 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/UseTTLInWhenSpringTest.java @@ -26,11 +26,12 @@ public class UseTTLInWhenSpringTest extends BaseTest { @Test public void testUseTTLInWhen() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("hello,b", response.getContextBean().getData("b")); - Assert.assertEquals("hello,c", response.getContextBean().getData("c")); - Assert.assertEquals("hello,d", response.getContextBean().getData("d")); - Assert.assertEquals("hello,e", response.getContextBean().getData("e")); - Assert.assertEquals("hello,f", response.getContextBean().getData("f")); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getFirstContextBean(); + Assert.assertEquals("hello,b", context.getData("b")); + Assert.assertEquals("hello,c", context.getData("c")); + Assert.assertEquals("hello,d", context.getData("d")); + Assert.assertEquals("hello,e", context.getData("e")); + Assert.assertEquals("hello,f", context.getData("f")); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java index d0e75faaa..b0e7b15f6 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/BCmp.java @@ -17,7 +17,7 @@ public class BCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String value = TestTL.get(); context.setData(this.getNodeId(),value+",b"); System.out.println("BCmp executed!"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java index 1701d495f..90a294748 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/CCmp.java @@ -17,7 +17,7 @@ public class CCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String value = TestTL.get(); context.setData(this.getNodeId(),value+",c"); System.out.println("CCmp executed!"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java index 6f1dace0f..c81a734af 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/DCmp.java @@ -17,7 +17,7 @@ public class DCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String value = TestTL.get(); context.setData(this.getNodeId(),value+",d"); System.out.println("DCmp executed!"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java index 91b37255b..7384747fc 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/ECmp.java @@ -17,7 +17,7 @@ public class ECmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String value = TestTL.get(); context.setData(this.getNodeId(),value+",e"); System.out.println("ECmp executed!"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java index 9c4e4ae3a..0fb50eff3 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/useTTLInWhen/cmp/FCmp.java @@ -17,7 +17,7 @@ public class FCmp extends NodeComponent { @Override public void process() { - DefaultContext context = this.getContextBean(); + DefaultContext context = this.getFirstContextBean(); String value = TestTL.get(); context.setData(this.getNodeId(),value+",f"); System.out.println("FCmp executed!"); diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringTest1.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringTest1.java index 93f390538..e82ae842f 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringTest1.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringTest1.java @@ -32,7 +32,7 @@ public class WhenTimeOutSpringTest1 extends BaseTest { //其中b和c在when情况下超时,所以抛出了WhenTimeoutException这个错 @Test public void testWhenTimeOut() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertFalse(response.isSuccess()); Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringTest2.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringTest2.java index 2a84931d4..70fdddb63 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringTest2.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringTest2.java @@ -31,7 +31,7 @@ public class WhenTimeOutSpringTest2 extends BaseTest { //其中d,e,f都sleep 4秒,其中def是不同的组,超时设置5秒 @Test public void testWhenTimeOut() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); } } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringTest.java index 02cca5ccc..604619231 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithJsonSpringTest.java @@ -66,7 +66,7 @@ public class ZkNodeWithJsonSpringTest extends BaseTest { @Test public void test() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringTest.java index ac00d8a2d..cdbdc4ec8 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithXmlSpringTest.java @@ -66,7 +66,7 @@ public class ZkNodeWithXmlSpringTest extends BaseTest { @Test public void test() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringTest.java index 263beabf0..0d994c94b 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/zookeeper/ZkNodeWithYmlSpringTest.java @@ -66,7 +66,7 @@ public class ZkNodeWithYmlSpringTest extends BaseTest { @Test public void test() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>b==>c", response.getExecuteStepStr()); }