From eb20a5c43c0144efcca3c2aa8444245a4cf813fe Mon Sep 17 00:00:00 2001 From: bryan31 Date: Sat, 28 May 2022 01:31:04 +0800 Subject: [PATCH] =?UTF-8?q?enhancement=20#I588BO=20=E5=AF=B9Slot=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E9=87=8D=E6=9E=84=EF=BC=8C=E5=9C=A8=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BD=BF=E7=94=A8=E4=B8=AD=E5=8E=BB=E9=99=A4Slot?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E7=9A=84=E6=A6=82=E5=BF=B5=EF=BC=8C=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E4=B8=8A=E4=B8=8B=E6=96=87=E7=9A=84=E6=A6=82=E5=BF=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/aop/ICmpAroundAspect.java | 6 +- .../yomahub/liteflow/core/FlowExecutor.java | 82 +++---- .../yomahub/liteflow/core/NodeComponent.java | 9 +- .../liteflow/flow/LiteflowResponse.java | 14 +- .../com/yomahub/liteflow/slot/AbsSlot.java | 214 ------------------ .../com/yomahub/liteflow/slot/DataBus.java | 18 +- .../yomahub/liteflow/slot/DefaultContext.java | 36 +++ .../yomahub/liteflow/slot/DefaultSlot.java | 17 -- .../java/com/yomahub/liteflow/slot/Slot.java | 199 +++++++++++++--- .../yomahub/liteflow/spi/CmpAroundAspect.java | 4 +- .../script/groovy/GroovyScriptExecutor.java | 4 +- .../qlexpress/QLExpressScriptExecutor.java | 4 +- .../spi/spring/SpringCmpAroundAspect.java | 8 +- .../AbsoluteConfigPathSpringbootTest.java | 4 +- .../test/aop/CustomAOPSpringbootTest.java | 16 +- .../test/aop/GlobalAOPSpringbootTest.java | 36 +-- .../liteflow/test/aop/aspect/CmpAspect.java | 11 +- .../test/aop/aspect/CustomAspect.java | 7 +- .../asyncNode/AsyncNodeSpringbootTest.java | 30 +-- .../liteflow/test/asyncNode/cmp/ACmp.java | 11 +- .../liteflow/test/asyncNode/cmp/BCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/CCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/DCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/GCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/HCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/ICmp.java | 11 +- .../test/base/BaseSpringbootTest.java | 4 +- .../test/builder/BuilderSpringbootTest1.java | 8 +- .../test/builder/BuilderSpringbootTest2.java | 4 +- .../cmpRetry/LiteflowRetrySpringbootTest.java | 10 +- .../component/FlowExecutorSpringbootTest.java | 16 +- .../CustomNodesSpringbootTest.java | 4 +- .../CustomWhenThreadPoolSpringbootTest.java | 14 +- .../test/customWhenThreadPool/cmp/BCmp.java | 4 +- .../test/customWhenThreadPool/cmp/CCmp.java | 4 +- .../test/customWhenThreadPool/cmp/DCmp.java | 4 +- .../test/customWhenThreadPool/cmp/ECmp.java | 4 +- .../test/customWhenThreadPool/cmp/FCmp.java | 4 +- .../exception/ExceptionSpringBootTest.java | 4 +- .../Executor2FutureSpringbootTest.java | 6 +- .../test/flowmeta/FlowMetaSpringbootTest.java | 4 +- .../test/lazy/LazySpringbootTest.java | 4 +- .../LiteflowComponentSpringbootTest.java | 4 +- .../test/monitor/MonitorSpringbootTest.java | 4 +- .../LiteflowMultipleTypeSpringbootTest.java | 4 +- .../CustomerDefaultNodeExecutor.java | 5 +- .../nodeExecutor/CustomerNodeExecutor.java | 5 +- .../CustomerNodeExecutorAndCustomRetry.java | 9 +- .../LiteflowNodeExecutorSpringbootTest.java | 16 +- .../CustomParserJsonSpringbootTest.java | 4 +- .../CustomParserXmlSpringbootTest.java | 4 +- .../test/parser/JsonParserSpringbootTest.java | 4 +- .../parser/SpringELSupportSpringbootTest.java | 4 +- .../test/parser/XmlParserSpringbootTest.java | 4 +- .../test/parser/YmlParserSpringbootTest.java | 4 +- .../PreAndFinallySpringbootTest.java | 12 +- .../test/preAndFinally/cmp/Finally3Cmp.java | 8 +- .../PrivateDeliverySpringbootTest.java | 6 +- .../test/privateDelivery/cmp/ACmp.java | 5 +- .../test/privateDelivery/cmp/BCmp.java | 4 +- .../RefreshRuleSpringbootTest.java | 6 +- .../test/reload/ReloadSpringbootTest.java | 4 +- .../resizeSlot/ResizeSlotSpringbootTest.java | 8 +- .../ImplicitSubFlowSpringbootTest.java | 4 +- ...ubflowInDifferentConfigSpringbootTest.java | 4 +- .../subflow/SubflowJsonSpringBootTest.java | 4 +- .../subflow/SubflowXMLSpringBootTest.java | 4 +- .../subflow/SubflowYmlSpringBootTest.java | 4 +- .../liteflow/test/subflow/cmp2/GCmp.java | 4 +- .../test/tag/NodeTagSpringbootJsonTest.java | 14 +- .../test/tag/NodeTagSpringbootXmlTest.java | 14 +- .../yomahub/liteflow/test/tag/cmp/ACmp.java | 11 +- .../yomahub/liteflow/test/tag/cmp/B1Cmp.java | 5 +- .../yomahub/liteflow/test/tag/cmp/BCmp.java | 5 +- .../UseTTLInWhenSpringbootTest.java | 14 +- .../liteflow/test/useTTLInWhen/cmp/BCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/CCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/DCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/ECmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/FCmp.java | 4 +- .../WhenTimeOutSpringbootTest1.java | 4 +- .../WhenTimeOutSpringbootTest2.java | 4 +- .../ZkNodeWithJsonSpringbootTest.java | 4 +- .../ZkNodeWithXmlSpringbootTest.java | 4 +- .../ZkNodeWithYmlSpringbootTest.java | 4 +- .../AbsoluteConfigPathTest.java | 4 +- .../test/asyncNode/AsyncNodeTest.java | 30 +-- .../liteflow/test/asyncNode/cmp/ACmp.java | 11 +- .../liteflow/test/asyncNode/cmp/BCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/CCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/DCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/GCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/HCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/ICmp.java | 11 +- .../liteflow/test/base/BaseCommonTest.java | 4 +- .../liteflow/test/builder/BuilderTest.java | 8 +- .../test/cmpRetry/LiteflowRetryTest.java | 10 +- .../test/component/FlowExecutorTest.java | 16 +- .../test/config/LiteflowConfigTest1.java | 4 +- .../CustomWhenThreadPoolTest.java | 14 +- .../test/customWhenThreadPool/cmp/BCmp.java | 5 +- .../test/customWhenThreadPool/cmp/CCmp.java | 5 +- .../test/customWhenThreadPool/cmp/DCmp.java | 5 +- .../test/customWhenThreadPool/cmp/ECmp.java | 4 +- .../test/customWhenThreadPool/cmp/FCmp.java | 5 +- .../test/exception/ExceptionTest.java | 4 +- .../execute2Future/Executor2FutureTest.java | 6 +- .../liteflow/test/flowmeta/FlowMetaTest.java | 4 +- .../LiteflowMultipleTypeTest.java | 4 +- .../CustomerDefaultNodeExecutor.java | 5 +- .../nodeExecutor/CustomerNodeExecutor.java | 5 +- .../CustomerNodeExecutorAndCustomRetry.java | 9 +- .../LiteflowNodeExecutorTest.java | 16 +- .../test/nullParam/NullParamTest.java | 4 +- .../parsecustom/CustomParserJsonTest.java | 4 +- .../test/parsecustom/CustomParserXmlTest.java | 4 +- .../liteflow/test/parser/JsonParserTest.java | 4 +- .../liteflow/test/parser/XmlParserTest.java | 4 +- .../liteflow/test/parser/YmlParserTest.java | 4 +- .../test/preAndFinally/PreAndFinallyTest.java | 12 +- .../test/preAndFinally/cmp/Finally3Cmp.java | 7 +- .../privateDelivery/PrivateDeliveryTest.java | 6 +- .../test/privateDelivery/cmp/ACmp.java | 5 +- .../test/privateDelivery/cmp/BCmp.java | 5 +- .../test/refreshRule/RefreshRuleTest.java | 6 +- .../liteflow/test/reload/ReloadTest.java | 4 +- .../test/removeChain/RemoveChainTest.java | 6 +- .../test/resizeSlot/ResizeSlotTest.java | 8 +- .../test/subflow/ImplicitSubFlowTest.java | 4 +- .../subflow/SubflowInDifferentConfigTest.java | 4 +- .../test/subflow/SubflowJsonTest.java | 4 +- .../liteflow/test/subflow/SubflowXMLTest.java | 4 +- .../liteflow/test/subflow/SubflowYmlTest.java | 4 +- .../liteflow/test/subflow/cmp2/GCmp.java | 5 +- .../liteflow/test/tag/NodeTagJsonTest.java | 14 +- .../liteflow/test/tag/NodeTagXmlTest.java | 14 +- .../yomahub/liteflow/test/tag/cmp/ACmp.java | 11 +- .../yomahub/liteflow/test/tag/cmp/B1Cmp.java | 5 +- .../yomahub/liteflow/test/tag/cmp/BCmp.java | 5 +- .../test/useTTLInWhen/UseTTLInWhenTest.java | 14 +- .../liteflow/test/useTTLInWhen/cmp/BCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/CCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/DCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/ECmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/FCmp.java | 4 +- .../test/whenTimeOut/WhenTimeOutTest1.java | 4 +- .../test/whenTimeOut/WhenTimeOutTest2.java | 4 +- .../test/zookeeper/ZkNodeWithJsonTest.java | 4 +- .../test/zookeeper/ZkNodeWithXmlTest.java | 4 +- .../test/zookeeper/ZkNodeWithYmlTest.java | 4 +- .../LiteFlowXmlScriptBuilderGroovyTest.java | 10 +- .../LiteflowJsonScriptFileGroovyTest.java | 14 +- .../groovy/LiteflowJsonScriptGroovyTest.java | 12 +- .../LiteflowXmlScriptFileGroovyTest.java | 14 +- .../groovy/LiteflowXmlScriptGroovyTest.java | 12 +- .../liteflow/test/script/groovy/cmp/DCmp.java | 5 +- .../src/test/resources/builder/s1.groovy | 2 +- .../src/test/resources/builder/s2.groovy | 2 +- .../test/resources/json-script-file/s1.groovy | 2 +- .../test/resources/json-script-file/s2.groovy | 2 +- .../json-script-file/s2_update.groovy | 2 +- .../test/resources/json-script-file/s3.groovy | 2 +- .../src/test/resources/json-script/flow.json | 6 +- .../resources/json-script/flow_update.json | 6 +- .../test/resources/xml-script-file/s1.groovy | 2 +- .../test/resources/xml-script-file/s2.groovy | 2 +- .../xml-script-file/s2_update.groovy | 2 +- .../test/resources/xml-script-file/s3.groovy | 2 +- .../src/test/resources/xml-script/flow.xml | 6 +- .../test/resources/xml-script/flow_update.xml | 6 +- ...LiteFlowXmlScriptBuilderQLExpressTest.java | 10 +- .../LiteflowJsonScriptFileQLExpressTest.java | 14 +- .../LiteflowJsonScriptQLExpressTest.java | 12 +- .../LiteflowXmlScriptFileQLExpressTest.java | 14 +- .../LiteflowXmlScriptQLExpressTest.java | 12 +- .../test/script/qlexpress/cmp/DCmp.java | 5 +- .../src/test/resources/builder/s1.ql | 2 +- .../src/test/resources/builder/s2.ql | 2 +- .../src/test/resources/json-script-file/s1.ql | 2 +- .../src/test/resources/json-script-file/s2.ql | 2 +- .../resources/json-script-file/s2_update.ql | 2 +- .../src/test/resources/json-script-file/s3.ql | 2 +- .../src/test/resources/json-script/flow.json | 6 +- .../resources/json-script/flow_update.json | 6 +- .../src/test/resources/xml-script-file/s1.ql | 2 +- .../src/test/resources/xml-script-file/s2.ql | 2 +- .../resources/xml-script-file/s2_update.ql | 2 +- .../src/test/resources/xml-script-file/s3.ql | 2 +- .../src/test/resources/xml-script/flow.xml | 6 +- .../test/resources/xml-script/flow_update.xml | 6 +- .../AbsoluteConfigPathSpringbootTest.java | 4 +- .../test/aop/CustomAOPSpringbootTest.java | 18 +- .../test/aop/GlobalAOPSpringbootTest.java | 36 +-- .../liteflow/test/aop/aspect/CmpAspect.java | 11 +- .../test/aop/aspect/CustomAspect.java | 7 +- .../asyncNode/AsyncNodeSpringbootTest.java | 30 +-- .../liteflow/test/asyncNode/cmp/ACmp.java | 11 +- .../liteflow/test/asyncNode/cmp/BCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/CCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/DCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/GCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/HCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/ICmp.java | 11 +- .../BannerPrintSpringbootTest.java | 4 +- .../test/base/BaseSpringbootTest.java | 4 +- .../test/builder/BuilderSpringbootTest1.java | 8 +- .../test/builder/BuilderSpringbootTest2.java | 4 +- .../cmpRetry/LiteflowRetrySpringbootTest.java | 10 +- .../component/FlowExecutorSpringbootTest.java | 16 +- .../config/LiteflowConfigSpringbootTest1.java | 4 +- .../config/LiteflowConfigSpringbootTest2.java | 6 +- .../CustomNodesSpringbootTest.java | 4 +- .../CustomWhenThreadPoolSpringbootTest.java | 14 +- .../test/customWhenThreadPool/cmp/BCmp.java | 4 +- .../test/customWhenThreadPool/cmp/CCmp.java | 4 +- .../test/customWhenThreadPool/cmp/DCmp.java | 4 +- .../test/customWhenThreadPool/cmp/ECmp.java | 4 +- .../test/customWhenThreadPool/cmp/FCmp.java | 4 +- .../DeadLoopChainSpringbootTest.java | 4 +- .../exception/ExceptionSpringBootTest.java | 4 +- .../Executor2FutureSpringbootTest.java | 6 +- .../test/flowmeta/FlowMetaSpringbootTest.java | 4 +- .../test/lazy/LazySpringbootTest.java | 4 +- .../LiteflowComponentSpringbootTest.java | 4 +- .../test/monitor/MonitorSpringbootTest.java | 4 +- .../LiteflowMultipleTypeSpringbootTest.java | 4 +- .../CustomerDefaultNodeExecutor.java | 5 +- .../nodeExecutor/CustomerNodeExecutor.java | 5 +- .../CustomerNodeExecutorAndCustomRetry.java | 9 +- .../LiteflowNodeExecutorSpringbootTest.java | 16 +- .../nullParam/NullParamSpringbootTest.java | 4 +- .../CustomParserJsonSpringbootTest.java | 4 +- .../CustomParserXmlSpringbootTest.java | 4 +- .../test/parser/JsonParserSpringbootTest.java | 4 +- .../parser/SpringELSupportSpringbootTest.java | 4 +- .../test/parser/XmlParserSpringbootTest.java | 4 +- .../test/parser/YmlParserSpringbootTest.java | 4 +- .../PreAndFinallySpringbootTest.java | 12 +- .../test/preAndFinally/cmp/Finally3Cmp.java | 8 +- .../PrivateDeliverySpringbootTest.java | 7 +- .../test/privateDelivery/cmp/ACmp.java | 5 +- .../test/privateDelivery/cmp/BCmp.java | 4 +- .../RefreshRuleSpringbootTest.java | 6 +- .../test/reload/ReloadSpringbootTest.java | 4 +- .../RemoveChainSpringbootTest.java | 6 +- .../resizeSlot/ResizeSlotSpringbootTest.java | 8 +- .../ImplicitSubFlowSpringbootTest.java | 4 +- ...ubflowInDifferentConfigSpringbootTest.java | 4 +- .../subflow/SubflowJsonSpringBootTest.java | 4 +- .../subflow/SubflowXMLSpringBootTest.java | 4 +- .../subflow/SubflowYmlSpringBootTest.java | 4 +- .../liteflow/test/subflow/cmp2/GCmp.java | 3 +- .../test/tag/NodeTagSpringbootJsonTest.java | 14 +- .../test/tag/NodeTagSpringbootXmlTest.java | 14 +- .../yomahub/liteflow/test/tag/cmp/ACmp.java | 11 +- .../yomahub/liteflow/test/tag/cmp/B1Cmp.java | 5 +- .../yomahub/liteflow/test/tag/cmp/BCmp.java | 5 +- .../UseTTLInWhenSpringbootTest.java | 14 +- .../liteflow/test/useTTLInWhen/cmp/BCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/CCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/DCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/ECmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/FCmp.java | 4 +- .../WhenTimeOutSpringbootTest1.java | 4 +- .../WhenTimeOutSpringbootTest2.java | 4 +- .../ZkNodeWithJsonSpringbootTest.java | 4 +- .../ZkNodeWithXmlSpringbootTest.java | 4 +- .../ZkNodeWithYmlSpringbootTest.java | 4 +- .../AbsoluteConfigPathSpringTest.java | 4 +- .../test/aop/CustomAOPSpringTest.java | 18 +- .../test/aop/GlobalAOPSpringTest.java | 36 +-- .../liteflow/test/aop/aspect/CmpAspect.java | 11 +- .../test/aop/aspect/CustomAspect.java | 7 +- .../test/asyncNode/AsyncNodeSpringTest.java | 30 +-- .../liteflow/test/asyncNode/cmp/ACmp.java | 11 +- .../liteflow/test/asyncNode/cmp/BCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/CCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/DCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/GCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/HCmp.java | 11 +- .../liteflow/test/asyncNode/cmp/ICmp.java | 11 +- .../test/base/BaseCommonSpringTest.java | 4 +- .../test/builder/BuilderSpringTest1.java | 8 +- .../test/builder/BuilderSpringTest2.java | 4 +- .../cmpRetry/LiteflowRetrySpringTest.java | 10 +- .../test/component/ComponentSpringTest.java | 16 +- .../test/config/LiteflowConfigSpringTest.java | 4 +- ...LocalRuleSourcePatternMatchSpringTest.java | 6 +- .../customNodes/CustomNodesSpringTest.java | 4 +- .../CustomWhenThreadPoolSpringTest.java | 14 +- .../test/customWhenThreadPool/cmp/BCmp.java | 4 +- .../test/customWhenThreadPool/cmp/CCmp.java | 4 +- .../test/customWhenThreadPool/cmp/DCmp.java | 4 +- .../test/customWhenThreadPool/cmp/ECmp.java | 4 +- .../test/customWhenThreadPool/cmp/FCmp.java | 4 +- .../test/enable/LiteflowEnableSpringTest.java | 4 +- .../test/exception/ExceptionSpringTest.java | 4 +- .../Executor2FutureSpringTest.java | 6 +- .../{CustomSlot.java => CustomContext.java} | 4 +- .../test/executor/FlowExecutorTest.java | 13 +- .../liteflow/test/executor/cmp/CCmp.java | 14 +- .../test/flowmeta/FlowMetaSpringTest.java | 4 +- .../liteflow/test/lazy/LazySpringTest.java | 4 +- .../LiteflowComponentSpringTest.java | 4 +- .../test/monitor/MonitorSpringTest.java | 4 +- .../LiteflowMultipleTypeSpringTest.java | 4 +- .../CustomerDefaultNodeExecutor.java | 5 +- .../nodeExecutor/CustomerNodeExecutor.java | 5 +- .../CustomerNodeExecutorAndCustomRetry.java | 9 +- .../LiteflowNodeExecutorSpringTest.java | 16 +- .../test/nullParam/NullParamTest.java | 4 +- .../CustomParserJsonSpringTest.java | 4 +- .../test/parser/LFParserJsonNoSpringTest.java | 4 +- .../test/parser/LFParserJsonSpringTest.java | 4 +- .../test/parser/LFParserXmlNoSpringTest.java | 4 +- .../test/parser/LFParserXmlSpringTest.java | 4 +- .../test/parser/LFParserYmlNoSpringTest.java | 4 +- .../test/parser/LFParserYmlSpringTest.java | 4 +- .../PreAndFinallySpringTest.java | 12 +- .../test/preAndFinally/cmp/Finally3Cmp.java | 8 +- .../PrivateDeliverySpringTest.java | 6 +- .../test/privateDelivery/cmp/ACmp.java | 5 +- .../test/privateDelivery/cmp/BCmp.java | 4 +- .../refreshRule/RefreshRuleSpringTest.java | 6 +- .../test/reload/ReloadSpringTest.java | 4 +- .../removeChain/RemoveChainSpringTest.java | 6 +- .../test/resizeSlot/ResizeSlotSpringTest.java | 8 +- .../subflow/ImplicitSubFlowSpringTest.java | 4 +- .../SubflowInDifferentConfigSpringTest.java | 4 +- .../test/subflow/SubflowJsonSpringTest.java | 4 +- .../test/subflow/SubflowXMLSpringTest.java | 4 +- .../test/subflow/SubflowYmlSpringTest.java | 4 +- .../liteflow/test/subflow/cmp2/GCmp.java | 3 +- .../test/tag/NodeTagSpringJsonTest.java | 14 +- .../test/tag/NodeTagSpringXmlTest.java | 14 +- .../yomahub/liteflow/test/tag/cmp/ACmp.java | 12 +- .../yomahub/liteflow/test/tag/cmp/B1Cmp.java | 5 +- .../yomahub/liteflow/test/tag/cmp/BCmp.java | 5 +- .../useTTLInWhen/UseTTLInWhenSpringTest.java | 14 +- .../liteflow/test/useTTLInWhen/cmp/BCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/CCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/DCmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/ECmp.java | 4 +- .../liteflow/test/useTTLInWhen/cmp/FCmp.java | 4 +- .../whenTimeOut/WhenTimeOutSpringTest1.java | 4 +- .../whenTimeOut/WhenTimeOutSpringTest2.java | 4 +- .../zookeeper/ZkNodeWithJsonSpringTest.java | 4 +- .../zookeeper/ZkNodeWithXmlSpringTest.java | 4 +- .../zookeeper/ZkNodeWithYmlSpringTest.java | 4 +- 349 files changed, 1541 insertions(+), 1432 deletions(-) delete mode 100644 liteflow-core/src/main/java/com/yomahub/liteflow/slot/AbsSlot.java create mode 100644 liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultContext.java delete mode 100644 liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultSlot.java rename liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/{CustomSlot.java => CustomContext.java} (71%) 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 5c2c3dce2..99c97d866 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, T contextBean); - void afterProcess(String nodeId, Slot slot); + void afterProcess(String nodeId, T contextBean); } 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 5ffa2a90f..0665899fe 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 @@ -14,8 +14,8 @@ import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; import com.google.common.collect.Lists; import com.yomahub.liteflow.slot.DataBus; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.element.Chain; import com.yomahub.liteflow.flow.element.Node; @@ -30,10 +30,7 @@ import com.yomahub.liteflow.thread.ExecutorHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.*; /** @@ -169,10 +166,6 @@ public class FlowExecutor { /** * 匹配路径配置,生成对应的解析器 - * - * @param path 配置路径 - * @param pattern 格式 - * @return */ private FlowParser matchFormatParser(String path, FlowParserTypeEnum pattern) throws ClassNotFoundException, IllegalAccessException, InstantiationException { boolean isLocalFile = isLocalConfig(path); @@ -217,9 +210,6 @@ public class FlowExecutor { /** * 判定是否为本地文件 - * - * @param path - * @return */ private boolean isLocalConfig(String path) { return ReUtil.isMatch(LOCAL_XML_CONFIG_REGEX, path) @@ -229,9 +219,6 @@ public class FlowExecutor { /** * 判定是否为自定义class配置 - * - * @param path - * @return */ private boolean isClassConfig(String path) { return ReUtil.isMatch(CLASS_CONFIG_REGEX, path); @@ -239,9 +226,6 @@ public class FlowExecutor { /** * 判定是否为zk配置 - * - * @param path - * @return */ private boolean isZKConfig(String path) { return ReUtil.isMatch(ZK_CONFIG_REGEX, path); @@ -249,9 +233,6 @@ public class FlowExecutor { /** * 匹配文本格式,支持xml,json和yml - * - * @param path - * @return */ private FlowParserTypeEnum matchFormatConfig(String path) { if (ReUtil.isMatch(LOCAL_XML_CONFIG_REGEX, path) || ReUtil.isMatch(FORMATE_XML_CONFIG_REGEX, path)) { @@ -262,7 +243,7 @@ public class FlowExecutor { return FlowParserTypeEnum.TYPE_YML; } else if (isClassConfig(path)) { try { - Class clazz = Class.forName(path); + Class clazz = Class.forName(path); if (ClassXmlFlowParser.class.isAssignableFrom(clazz)) { return FlowParserTypeEnum.TYPE_XML; } else if (ClassJsonFlowParser.class.isAssignableFrom(clazz)) { @@ -284,36 +265,35 @@ public class FlowExecutor { } //隐式流程的调用方法 - public void invoke(String chainId, Object param, Class slotClazz, - Integer slotIndex) throws Exception { - this.execute(chainId, param, slotClazz, slotIndex, true); + public void invoke(String chainId, Object param, Integer slotIndex) throws Exception { + this.execute(chainId, param, null, slotIndex, true); } - public LiteflowResponse invoke2Resp(String chainId, Object param, Class slotClazz, - Integer slotIndex){ - return this.execute2Resp(chainId, param, slotClazz, slotIndex, true); + public LiteflowResponse invoke2Resp(String chainId, Object param, Integer slotIndex){ + return this.execute2Resp(chainId, param, null, slotIndex, true); } - public void invoke(String nodeId, Integer slotIndex) throws Exception { + //单独调用某一个node + public void invoke(String nodeId, Integer slotIndex) throws Exception { Node node = FlowBus.getNode(nodeId); node.execute(slotIndex); } - public DefaultSlot execute(String chainId) throws Exception { - return this.execute(chainId, null, DefaultSlot.class, null, false); + public Slot execute(String chainId) throws Exception { + return this.execute(chainId, null, DefaultContext.class, null, false); } - public DefaultSlot execute(String chainId, Object param) throws Exception { - return this.execute(chainId, param, DefaultSlot.class, null, false); + public Slot execute(String chainId, Object param) throws Exception { + return this.execute(chainId, param, DefaultContext.class, null, false); } - public T execute(String chainId, Object param, Class slotClazz) throws Exception { - return this.execute(chainId, param, slotClazz, null, false); + public Slot execute(String chainId, Object param, Class contextBeanClazz) throws Exception { + return this.execute(chainId, param, contextBeanClazz, null, false); } - public T execute(String chainId, Object param, Class slotClazz, + public Slot execute(String chainId, Object param, Class contextBeanClazz, Integer slotIndex, boolean isInnerChain) throws Exception { - T slot = this.doExecute(chainId, param, slotClazz, slotIndex, isInnerChain); + Slot slot = this.doExecute(chainId, param, contextBeanClazz, slotIndex, isInnerChain); if (ObjectUtil.isNotNull(slot.getException())) { throw slot.getException(); } else { @@ -321,29 +301,29 @@ public class FlowExecutor { } } - public LiteflowResponse execute2Resp(String chainId) { - return this.execute2Resp(chainId, null, DefaultSlot.class); + public LiteflowResponse execute2Resp(String chainId) { + return this.execute2Resp(chainId, null, DefaultContext.class); } - public LiteflowResponse execute2Resp(String chainId, Object param) { - return this.execute2Resp(chainId, param, DefaultSlot.class); + public LiteflowResponse execute2Resp(String chainId, Object param) { + return this.execute2Resp(chainId, param, DefaultContext.class); } - public LiteflowResponse execute2Resp(String chainId, Object param, Class slotClazz) { - return this.execute2Resp(chainId, param, slotClazz, null, false); + public LiteflowResponse execute2Resp(String chainId, Object param, Class contextBeanClazz) { + return this.execute2Resp(chainId, param, contextBeanClazz, null, false); } - public Future> execute2Future(String chainId, Object param, Class slotClazz) { + public Future> execute2Future(String chainId, Object param, Class contextBeanClazz) { return ExecutorHelper.loadInstance().buildMainExecutor(liteflowConfig.getMainExecutorClass()).submit(() - -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, slotClazz, null, false)); + -> FlowExecutorHolder.loadInstance().execute2Resp(chainId, param, contextBeanClazz, null, false)); } - public LiteflowResponse execute2Resp(String chainId, Object param, Class slotClazz, Integer slotIndex, - boolean isInnerChain) { + public LiteflowResponse execute2Resp(String chainId, Object param, Class contextBeanClazz, + Integer slotIndex, boolean isInnerChain) { LiteflowResponse response = new LiteflowResponse<>(); - T slot = doExecute(chainId, param, slotClazz, slotIndex, isInnerChain); + Slot slot = doExecute(chainId, param, contextBeanClazz, slotIndex, isInnerChain); if (ObjectUtil.isNotNull(slot.getException())) { response.setSuccess(false); @@ -356,14 +336,14 @@ public class FlowExecutor { return response; } - private T doExecute(String chainId, Object param, Class slotClazz, Integer slotIndex, + private Slot doExecute(String chainId, Object param, Class contextBeanClazz, Integer slotIndex, boolean isInnerChain) { if (FlowBus.needInit()) { init(); } if (!isInnerChain && ObjectUtil.isNull(slotIndex)) { - slotIndex = DataBus.offerSlot(slotClazz); + slotIndex = DataBus.offerSlot(contextBeanClazz); LOG.info("slot[{}] offered", slotIndex); } @@ -371,7 +351,7 @@ public class FlowExecutor { throw new NoAvailableSlotException("there is no available slot"); } - T 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 0c7be34f8..e4bba1a4c 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 @@ -71,7 +71,7 @@ public abstract class NodeComponent{ } public void execute() throws Exception{ - Slot slot = this.getSlot(); + Slot slot = this.getSlot(); LOG.info("[{}]:[O]start component[{}] execution",slot.getRequestId(),this.getClass().getSimpleName()); slot.addStep(new CmpStep(nodeId, name, CmpStepTypeEnum.SINGLE)); @@ -153,10 +153,15 @@ public abstract class NodeComponent{ this.slotIndexTL.remove(); } - public T getSlot(){ + public Slot getSlot(){ return DataBus.getSlot(this.slotIndexTL.get()); } + public T getContextBean(){ + Slot slot = this.getSlot(); + return slot.getContextBean(); + } + public String getNodeId() { return nodeId; } 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 8ab2d16fd..a5f48e051 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 @@ -8,7 +8,7 @@ import java.io.Serializable; * 执行结果封装类 * @author zend.wang */ -public class LiteflowResponse implements Serializable { +public class LiteflowResponse implements Serializable { private static final long serialVersionUID = -2792556188993845048L; @@ -18,12 +18,12 @@ public class LiteflowResponse implements Serializable { private Throwable cause; - private T slot; + private Slot slot; public LiteflowResponse() { this(null); } - public LiteflowResponse(T slot) { + public LiteflowResponse(Slot slot) { this.success = true; this.message = ""; this.slot = slot; @@ -53,11 +53,15 @@ public class LiteflowResponse implements Serializable { this.cause = cause; } - public T getSlot() { + public Slot getSlot() { return slot; } - public void setSlot(final T slot) { + public void setSlot(Slot slot) { this.slot = slot; } + + public T getContextBean(){ + return getSlot().getContextBean(); + } } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/AbsSlot.java b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/AbsSlot.java deleted file mode 100644 index 4311488d3..000000000 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/AbsSlot.java +++ /dev/null @@ -1,214 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.slot; - -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -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.Queue; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * Slot的抽象类实现 - * @author Bryan.Zhang - * @author LeoLee - */ -@SuppressWarnings("unchecked") -public abstract class AbsSlot implements Slot { - - private static final Logger LOG = LoggerFactory.getLogger(Slot.class); - - private static final String REQUEST = "_request"; - - private static final String RESPONSE = "_response"; - - private static final String CHAIN_NAME = "_chain_name"; - - private static final String COND_NODE_PREFIX = "_cond_"; - - private static final String NODE_INPUT_PREFIX = "_input_"; - - private static final String NODE_OUTPUT_PREFIX = "_output_"; - - private static final String CHAIN_REQ_PREFIX = "_chain_req_"; - - private static final String REQUEST_ID = "_req_id"; - - private static final String EXCEPTION = "_exception"; - - private static final String PRIVATE_DELIVERY_PREFIX = "_private_d_"; - - private final Queue executeSteps = new ConcurrentLinkedQueue<>(); - - private String executeStepsStr; - - protected ConcurrentHashMap dataMap = new ConcurrentHashMap(); - - private void putDataMap(String key, T t) { - if (ObjectUtil.isNull(t)) { - //data slot is a ConcurrentHashMap, so null value will trigger NullPointerException - throw new NullParamException("data slot can't accept null param"); - } - dataMap.put(key, t); - } - - public T getInput(String nodeId){ - return (T)dataMap.get(NODE_INPUT_PREFIX + nodeId); - } - - public T getOutput(String nodeId){ - return (T)dataMap.get(NODE_OUTPUT_PREFIX + nodeId); - } - - public void setInput(String nodeId,T t){ - putDataMap(NODE_INPUT_PREFIX + nodeId, t); - } - - public void setOutput(String nodeId,T t){ - putDataMap(NODE_OUTPUT_PREFIX + nodeId, t); - } - - public T getRequestData(){ - return (T)dataMap.get(REQUEST); - } - - public void setRequestData(T t){ - putDataMap(REQUEST, t); - } - - public T getResponseData(){ - return (T)dataMap.get(RESPONSE); - } - - public void setResponseData(T t){ - putDataMap(RESPONSE, t); - } - - public T getChainReqData(String chainId) { - return (T)dataMap.get(CHAIN_REQ_PREFIX + chainId); - } - - public void setChainReqData(String chainId, T t) { - putDataMap(CHAIN_REQ_PREFIX + chainId, t); - } - - public boolean hasData(String key){ - return dataMap.containsKey(key); - } - - public T getData(String key){ - return (T)dataMap.get(key); - } - - public void setData(String key, T t){ - putDataMap(key, t); - } - - public void setPrivateDeliveryData(String nodeId, T t){ - String privateDKey = PRIVATE_DELIVERY_PREFIX + nodeId; - synchronized (this){ - if (dataMap.containsKey(privateDKey)){ - Queue queue = (Queue) dataMap.get(privateDKey); - queue.add(t); - }else{ - Queue queue = new ConcurrentLinkedQueue<>(); - queue.add(t); - this.setData(privateDKey, queue); - } - } - } - - public Queue getPrivateDeliveryQueue(String nodeId){ - String privateDKey = PRIVATE_DELIVERY_PREFIX + nodeId; - if(dataMap.containsKey(privateDKey)){ - return (Queue) dataMap.get(privateDKey); - }else{ - return null; - } - } - - public T getPrivateDeliveryData(String nodeId){ - String privateDKey = PRIVATE_DELIVERY_PREFIX + nodeId; - if(dataMap.containsKey(privateDKey)){ - Queue queue = (Queue) dataMap.get(privateDKey); - return queue.poll(); - }else{ - return null; - } - } - - public void setCondResult(String key, T t){ - putDataMap(COND_NODE_PREFIX + key, t); - } - - public T getCondResult(String key){ - return (T)dataMap.get(COND_NODE_PREFIX + key); - } - - public void setChainName(String chainName) { - putDataMap(CHAIN_NAME, chainName); - } - - public String getChainName() { - return (String)dataMap.get(CHAIN_NAME); - } - - public void addStep(CmpStep step){ - this.executeSteps.add(step); - } - - public String getExecuteStepStr(){ - StringBuilder str = new StringBuilder(); - CmpStep cmpStep; - for (Iterator it = executeSteps.iterator(); it.hasNext();) { - cmpStep = it.next(); - str.append(cmpStep); - if(it.hasNext()){ - str.append("==>"); - } - } - this.executeStepsStr = str.toString(); - return this.executeStepsStr; - } - - public void printStep(){ - if (ObjectUtil.isNull(this.executeStepsStr)){ - this.executeStepsStr = getExecuteStepStr(); - } - LOG.info("[{}]:CHAIN_NAME[{}]\n{}",getRequestId(),this.getChainName(), this.executeStepsStr); - } - - @Override - public void generateRequestId() { - dataMap.put(REQUEST_ID, IdUtil.fastSimpleUUID()); - } - - @Override - public String getRequestId() { - return (String)dataMap.get(REQUEST_ID); - } - - public Queue getExecuteSteps() { - return executeSteps; - } - - @Override - public Exception getException() { - return (Exception) this.dataMap.get(EXCEPTION); - } - - @Override - public void setException(Exception e) { - putDataMap(EXCEPTION, e); - } -} 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 bf8118e9d..21ee0fc81 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.slot; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ReflectUtil; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; import org.slf4j.Logger; @@ -33,7 +34,7 @@ public class DataBus { //这里为什么采用ConcurrentHashMap作为slot存放的容器? //因为ConcurrentHashMap的随机取值复杂度也和数组一样为O(1),并且没有并发问题,还有自动扩容的功能 //用数组的话,扩容涉及copy,线程安全问题还要自己处理 - private static ConcurrentHashMap SLOTS; + private static ConcurrentHashMap> SLOTS; private static ConcurrentLinkedQueue QUEUE; @@ -54,9 +55,10 @@ public class DataBus { } } - public static int offerSlot(Class slotClazz) { + public static int offerSlot(Class contextClazz) { try { - Slot slot = slotClazz.newInstance(); + T contextBean = ReflectUtil.newInstance(contextClazz); + Slot slot = new Slot<>(contextBean); //这里有没有并发问题? //没有,因为QUEUE的类型为ConcurrentLinkedQueue,并发情况下,每次取到的index不会相同 @@ -92,9 +94,13 @@ public class DataBus { return -1; } - @SuppressWarnings("unchecked") - public static T getSlot(int slotIndex){ - return (T)SLOTS.get(slotIndex); + public static Slot getSlot(int slotIndex){ + return (Slot) SLOTS.get(slotIndex); + } + + public static T getContextBean(int slotIndex){ + Slot slot = getSlot(slotIndex); + return slot.getContextBean(); } public static void releaseSlot(int slotIndex){ diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultContext.java b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultContext.java new file mode 100644 index 000000000..8827c3271 --- /dev/null +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultContext.java @@ -0,0 +1,36 @@ +package com.yomahub.liteflow.slot; + +import cn.hutool.core.util.ObjectUtil; +import com.yomahub.liteflow.exception.NullParamException; + +import java.util.concurrent.ConcurrentHashMap; + +/** + * Liteflow的默认上下文Bean + * 这个建议自己去实现一个强类型的bean,正式业务不建议用这个 + * @author Bryan.Zhang + * @since 2.7.0 + */ +public class DefaultContext { + + private final ConcurrentHashMap dataMap = new ConcurrentHashMap<>(); + + private void putDataMap(String key, T t) { + if (ObjectUtil.isNull(t)) { + throw new NullParamException("data can't accept null param"); + } + dataMap.put(key, t); + } + + public boolean hasData(String key){ + return dataMap.containsKey(key); + } + + public T getData(String key){ + return (T) dataMap.get(key); + } + + public void setData(String key, T t){ + putDataMap(key, t); + } +} diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultSlot.java b/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultSlot.java deleted file mode 100644 index 12b702382..000000000 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/slot/DefaultSlot.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.slot; - -/** - * 默认Slot的实现类 - * 不建议业务系统直接用此类,此类基于弱类型Map,应该自己去继承AbsSlot - * @author Bryan.Zhang - */ -public class DefaultSlot extends AbsSlot { - -} 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 40ba48632..02b36215f 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 @@ -7,62 +7,205 @@ */ package com.yomahub.liteflow.slot; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +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.Queue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; /** - * Slot的接口 + * Slot的抽象类实现 * @author Bryan.Zhang + * @author LeoLee */ -public interface Slot { - T getInput(String nodeId); +@SuppressWarnings("unchecked") +public class Slot{ - T getOutput(String nodeId); + private static final Logger LOG = LoggerFactory.getLogger(Slot.class); - void setInput(String nodeId,T t); + private static final String REQUEST = "_request"; - void setOutput(String nodeId,T t); + private static final String RESPONSE = "_response"; - T getRequestData(); + private static final String CHAIN_NAME = "_chain_name"; - void setRequestData(T t); + private static final String COND_NODE_PREFIX = "_cond_"; - T getResponseData(); + private static final String NODE_INPUT_PREFIX = "_input_"; - void setChainReqData(String chainId, T t); + private static final String NODE_OUTPUT_PREFIX = "_output_"; - T getChainReqData(String chainId); + private static final String CHAIN_REQ_PREFIX = "_chain_req_"; - void setResponseData(T t); + private static final String REQUEST_ID = "_req_id"; - boolean hasData(String key); + private static final String EXCEPTION = "_exception"; - T getData(String key); + private static final String PRIVATE_DELIVERY_PREFIX = "_private_d_"; - void setData(String key, T t); + private final Queue executeSteps = new ConcurrentLinkedQueue<>(); - void setCondResult(String key, T t); + private String executeStepsStr; - T getCondResult(String key); + protected ConcurrentHashMap metaDataMap = new ConcurrentHashMap<>(); - void addStep(CmpStep step); + private O contextBean; - String getExecuteStepStr(); + public Slot() { + } - void printStep(); + public Slot(O contextBean) { + this.contextBean = contextBean; + } - void generateRequestId(); + private void putMetaDataMap(String key, T t) { + if (ObjectUtil.isNull(t)) { + //data slot is a ConcurrentHashMap, so null value will trigger NullPointerException + throw new NullParamException("data slot can't accept null param"); + } + metaDataMap.put(key, t); + } - String getRequestId(); + public T getInput(String nodeId){ + return (T) metaDataMap.get(NODE_INPUT_PREFIX + nodeId); + } - void setChainName(String chainName); + public T getOutput(String nodeId){ + return (T) metaDataMap.get(NODE_OUTPUT_PREFIX + nodeId); + } - String getChainName(); + public void setInput(String nodeId,T t){ + putMetaDataMap(NODE_INPUT_PREFIX + nodeId, t); + } - void setException(Exception e); + public void setOutput(String nodeId,T t){ + putMetaDataMap(NODE_OUTPUT_PREFIX + nodeId, t); + } - Exception getException(); + public T getRequestData(){ + return (T) metaDataMap.get(REQUEST); + } - void setPrivateDeliveryData(String nodeId, T t); + public void setRequestData(T t){ + putMetaDataMap(REQUEST, t); + } - T getPrivateDeliveryData(String nodeId); + public T getResponseData(){ + return (T) metaDataMap.get(RESPONSE); + } + + public void setResponseData(T t){ + putMetaDataMap(RESPONSE, t); + } + + public T getChainReqData(String chainId) { + return (T) metaDataMap.get(CHAIN_REQ_PREFIX + chainId); + } + + public void setChainReqData(String chainId, T t) { + putMetaDataMap(CHAIN_REQ_PREFIX + chainId, t); + } + + public void setPrivateDeliveryData(String nodeId, T t){ + String privateDKey = PRIVATE_DELIVERY_PREFIX + nodeId; + synchronized (this){ + if (metaDataMap.containsKey(privateDKey)){ + Queue queue = (Queue) metaDataMap.get(privateDKey); + queue.add(t); + }else{ + Queue queue = new ConcurrentLinkedQueue<>(); + queue.add(t); + this.putMetaDataMap(privateDKey, queue); + } + } + } + + public Queue getPrivateDeliveryQueue(String nodeId){ + String privateDKey = PRIVATE_DELIVERY_PREFIX + nodeId; + if(metaDataMap.containsKey(privateDKey)){ + return (Queue) metaDataMap.get(privateDKey); + }else{ + return null; + } + } + + public T getPrivateDeliveryData(String nodeId){ + String privateDKey = PRIVATE_DELIVERY_PREFIX + nodeId; + if(metaDataMap.containsKey(privateDKey)){ + Queue queue = (Queue) metaDataMap.get(privateDKey); + return queue.poll(); + }else{ + return null; + } + } + + public void setCondResult(String key, T t){ + putMetaDataMap(COND_NODE_PREFIX + key, t); + } + + public T getCondResult(String key){ + return (T) metaDataMap.get(COND_NODE_PREFIX + key); + } + + public void setChainName(String chainName) { + putMetaDataMap(CHAIN_NAME, chainName); + } + + public String getChainName() { + return (String) metaDataMap.get(CHAIN_NAME); + } + + public void addStep(CmpStep step){ + this.executeSteps.add(step); + } + + public String getExecuteStepStr(){ + StringBuilder str = new StringBuilder(); + CmpStep cmpStep; + for (Iterator it = executeSteps.iterator(); it.hasNext();) { + cmpStep = it.next(); + str.append(cmpStep); + if(it.hasNext()){ + str.append("==>"); + } + } + this.executeStepsStr = str.toString(); + return this.executeStepsStr; + } + + public void printStep(){ + if (ObjectUtil.isNull(this.executeStepsStr)){ + this.executeStepsStr = getExecuteStepStr(); + } + LOG.info("[{}]:CHAIN_NAME[{}]\n{}",getRequestId(),this.getChainName(), this.executeStepsStr); + } + + public void generateRequestId() { + metaDataMap.put(REQUEST_ID, IdUtil.fastSimpleUUID()); + } + + public String getRequestId() { + return (String) metaDataMap.get(REQUEST_ID); + } + + public Queue getExecuteSteps() { + return executeSteps; + } + + public Exception getException() { + return (Exception) this.metaDataMap.get(EXCEPTION); + } + + public void setException(Exception e) { + putMetaDataMap(EXCEPTION, e); + } + + public O getContextBean() { + return contextBean; + } } 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 5b8d1fa46..8219c005e 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-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 74bbcca14..65fb2dd13 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 @@ -55,8 +55,8 @@ public class GroovyScriptExecutor implements ScriptExecutor { CompiledScript compiledScript = compiledScriptMap.get(nodeId); Bindings bindings = new SimpleBindings(); - Slot slot = DataBus.getSlot(slotIndex); - bindings.put("slot", slot); + Object contextBean = DataBus.getContextBean(slotIndex); + bindings.put("context", contextBean); 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 f71855648..ecccfc1f7 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,9 @@ public class QLExpressScriptExecutor implements ScriptExecutor { } InstructionSet instructionSet = compiledScriptMap.get(nodeId); - Slot slot = DataBus.getSlot(slotIndex); + Object contextBean = DataBus.getContextBean(slotIndex); DefaultContext context = new DefaultContext<>(); - context.put("slot", slot); + context.put("context", contextBean); 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 42011f2fc..bad846a60 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,16 +12,16 @@ 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); + ComponentScanner.cmpAroundAspect.beforeProcess(nodeId, slot.getContextBean()); } } @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); + ComponentScanner.cmpAroundAspect.afterProcess(nodeId, slot.getContextBean()); } } 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 e7c0c6c12..c031268f5 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 619fa4318..9cea17afa 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.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); + Assert.assertEquals("before_after", response.getContextBean.getData("a")); + Assert.assertEquals("before_after", response.getContextBean().getData("b")); + Assert.assertEquals("before_after", response.getContextBean().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.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); + Assert.assertEquals("before_after", response.getContextBean().getData("a")); + Assert.assertEquals("before_after", response.getContextBean().getData("b")); + Assert.assertEquals("before_after", response.getContextBean().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 1d39a1cc7..c38960b52 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.aop; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.aop.aspect.CmpAspect; @@ -37,35 +37,35 @@ 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"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("d")); - Assert.assertEquals("before_after", response.getSlot().getData("e")); + 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")); } //测试全局AOP,并行场景 @Test public void testGlobalAopP() { - 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.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("d")); - Assert.assertEquals("before_after", response.getSlot().getData("e")); + 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")); } @Test public void testGlobalAopException() { - LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", response.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("f")); + 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")); } @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 fdb5111b0..d4e4a0f89 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 @@ -2,16 +2,17 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; 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) { - slot.setData(nodeId, "before"); + public void beforeProcess(String nodeId, DefaultContext contextBean) { + contextBean.setData(nodeId, "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - slot.setData(nodeId, StrUtil.format("{}_{}", slot.getData(nodeId), "after")); + public void afterProcess(String nodeId, DefaultContext contextBean) { + contextBean.setData(nodeId, StrUtil.format("{}_{}", contextBean.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 718b0e02b..322038d0f 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -18,10 +19,10 @@ public class CustomAspect { @Around("cut()") public Object around(ProceedingJoinPoint jp) throws Throwable { NodeComponent cmp = (NodeComponent) jp.getThis(); - Slot slot = cmp.getSlot(); - slot.setData(cmp.getNodeId(), "before"); + DefaultContext context = cmp.getContextBean(); + context.setData(cmp.getNodeId(), "before"); Object returnObj = jp.proceed(); - slot.setData(cmp.getNodeId(), StrUtil.format("{}_{}", slot.getData(cmp.getNodeId()), "after")); + context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); return returnObj; } } 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 30a8b0717..0b6fa51d8 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.asyncNode; import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; import org.junit.Assert; @@ -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.getSlot().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,18 @@ 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.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //因为配置了不抛错,所以response里的cause应该为null Assert.assertNull(response.getCause()); @@ -85,11 +85,11 @@ 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.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //因为第一个when配置了会报错,所以response里的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -98,11 +98,11 @@ 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.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(1), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -111,11 +111,11 @@ 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.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -127,8 +127,8 @@ 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"); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("check").toString().startsWith("habc")); + Assert.assertTrue(response.getContextBean().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 0253978da..057100168 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 @@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import org.springframework.stereotype.Component; @@ -13,14 +14,14 @@ import org.springframework.stereotype.Component; public class ACmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - Slot slot = bindCmp.getSlot(); + DefaultContext context = bindCmp.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += bindCmp.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", bindCmp.getNodeId()); + context.setData("check", bindCmp.getNodeId()); } } System.out.println("Acomp executed!"); 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 be8780d74..abbc36411 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 @@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import org.springframework.stereotype.Component; @@ -13,14 +14,14 @@ import org.springframework.stereotype.Component; public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - Slot slot = bindCmp.getSlot(); + DefaultContext context = bindCmp.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += bindCmp.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", bindCmp.getNodeId()); + context.setData("check", bindCmp.getNodeId()); } } System.out.println("Bcomp executed!"); 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 60aa1b75f..3bf9a7b1c 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 @@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import org.springframework.stereotype.Component; @@ -13,14 +14,14 @@ import org.springframework.stereotype.Component; public class CCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { - Slot slot = bindCmp.getSlot(); + DefaultContext context = bindCmp.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += bindCmp.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", bindCmp.getNodeId()); + context.setData("check", bindCmp.getNodeId()); } } System.out.println("Ccomp executed!"); 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 416be39ba..f2a465f93 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 @@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import org.springframework.stereotype.Component; @@ -14,14 +15,14 @@ public class DCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { Thread.sleep(1000); - Slot slot = bindCmp.getSlot(); + DefaultContext context = bindCmp.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += bindCmp.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", bindCmp.getNodeId()); + context.setData("check", bindCmp.getNodeId()); } } System.out.println("Dcomp executed!"); 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 f422691e5..b9fa720cb 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 @@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import org.springframework.stereotype.Component; @@ -15,14 +16,14 @@ public class GCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { Thread.sleep(500); - Slot slot = bindCmp.getSlot(); + DefaultContext context = bindCmp.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += bindCmp.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", bindCmp.getNodeId()); + context.setData("check", bindCmp.getNodeId()); } } System.out.println("Gcomp executed!"); 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 f29ccde18..617d28670 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 @@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import org.springframework.stereotype.Component; @@ -14,14 +15,14 @@ public class HCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { - Slot slot = bindCmp.getSlot(); + DefaultContext context = bindCmp.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += bindCmp.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", bindCmp.getNodeId()); + context.setData("check", bindCmp.getNodeId()); } } 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 859047ab2..8315dcea3 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 @@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import com.yomahub.liteflow.test.asyncNode.exception.TestException; @@ -15,12 +16,12 @@ public class ICmp { @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception { - Slot slot = bindCmp.getSlot(); - if (slot.hasData("count")){ - Integer count = slot.getData("count"); - slot.setData("count", ++count); + DefaultContext context = bindCmp.getContextBean(); + if (context.hasData("count")){ + Integer count = context.getData("count"); + context.setData("count", ++count); } else{ - slot.setData("count", 1); + context.setData("count", 1); } System.out.println("Icomp executed! throw Exception!"); throw new TestException(); 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 eac53e574..b50e1bd4d 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 1bb2f539e..0c481ddb4 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 @@ -4,10 +4,10 @@ import com.yomahub.liteflow.builder.LiteFlowChainBuilder; import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.builder.entity.ExecutableEntity; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.NodeTypeEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.builder.cmp1.*; import org.junit.Assert; @@ -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.getSlot().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.getSlot().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.getSlot().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 d89d5fb95..a8363f88b 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 @@ -3,8 +3,8 @@ package com.yomahub.liteflow.test.builder; import com.yomahub.liteflow.builder.LiteFlowChainBuilder; import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 e5a5b190d..c13b2654e 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } 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 de1c24101..570b7e41c 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } 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 3aa0fcabb..c441b6feb 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.customNodes; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 b2dc79f9b..5a1ac1481 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.customWhenThreadPool; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -40,9 +40,9 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { */ @Test public void testGlobalThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("threadName").toString().startsWith("lf-when-thead")); + Assert.assertTrue(response.getContextBean().getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -50,9 +50,9 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { */ @Test public void testGlobalAndCustomWhenThreadPool() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(response1.getSlot().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(response1.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); } @@ -64,9 +64,9 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { // 使用when - thread1 testGlobalAndCustomWhenThreadPool(); // chain配置同一个thead1 - LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(response2.getSlot().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(response2.getContextBean().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 2a00fb1a5..b89d8a6b8 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("b") @@ -19,7 +20,8 @@ public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - bindCmp.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = bindCmp.getContextBean(); + 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 1a85ad0cb..45a9d43ac 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("c") @@ -19,7 +20,8 @@ public class CCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - bindCmp.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = bindCmp.getContextBean(); + 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 d5b9f6ce1..137239d22 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("d") @@ -19,7 +20,8 @@ public class DCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - bindCmp.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = bindCmp.getContextBean(); + 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 c9bac33b7..bc05a7e4a 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("e") @@ -19,7 +20,8 @@ public class ECmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - bindCmp.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = bindCmp.getContextBean(); + 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 552ea97a0..ed547e033 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("f") @@ -19,7 +20,8 @@ public class FCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - bindCmp.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = bindCmp.getContextBean(); + 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/exception/ExceptionSpringBootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringBootTest.java index 0765eaa03..aa70fee80 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringBootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringBootTest.java @@ -1,13 +1,13 @@ package com.yomahub.liteflow.test.exception; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.ChainNotFoundException; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.exception.FlowExecutorNotInitException; import com.yomahub.liteflow.exception.FlowSystemException; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -75,7 +75,7 @@ public class ExceptionSpringBootTest 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 ef455a466..555e2e45d 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.execute2Future; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -33,8 +33,8 @@ public class Executor2FutureSpringbootTest extends BaseTest { @Test public void testFuture() throws Exception{ - Future> future = flowExecutor.execute2Future("chain1", "arg", DefaultSlot.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/flowmeta/FlowMetaSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/flowmeta/FlowMetaSpringbootTest.java index 945719679..e8928668e 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.flowmeta; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.flowmeta.cmp2.DCmp; import org.junit.Assert; @@ -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.getSlot().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 6363d95b9..4ff8e4828 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.lazy; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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/liteflowcomponent/LiteflowComponentSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringbootTest.java index 2d7cc1e3f..2e0d64432 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringbootTest.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringbootTest.java @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.liteflowcomponent; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 7a24ca4fa..38a50f768 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.monitor; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.monitor.MonitorBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spi.holder.ContextAwareHolder; import com.yomahub.liteflow.test.BaseTest; import org.junit.AfterClass; @@ -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 422448a28..9234942fe 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 4e7423026..a5da9969f 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -11,9 +12,9 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerDefaultNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerDefaultNodeExecutor进行执行"); - slot.setData("customerDefaultNodeExecutor", this.getClass()); + 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 17d5c31be..add288d67 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -11,9 +12,9 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerNodeExecutor进行执行"); - slot.setData("customerNodeExecutor", this.getClass()); + 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 1ee6b3f2d..a6eb87d53 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -13,17 +14,17 @@ import java.util.concurrent.TimeUnit; public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); - slot.setData("customerNodeExecutorAndCustomRetry", this.getClass()); + context.setData("customerNodeExecutorAndCustomRetry", this.getClass()); super.execute(instance); } @Override protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { TimeUnit.MICROSECONDS.sleep(20L); - Slot slot = DataBus.getSlot(instance.getSlotIndex()); - slot.setData("retryLogic", this.getClass()); + DefaultContext context = instance.getContextBean(); + 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 ad5bfeb0b..33f9fe1c4 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -35,25 +35,25 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest { // 默认执行器测试 @Test public void testCustomerDefaultNodeExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); Assert.assertEquals("a", response.getSlot().getExecuteStepStr()); } //默认执行器测试+全局重试配置测试 @Test public void testDefaultExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); Assert.assertEquals("b==>b==>b", response.getSlot().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.getSlot().getExecuteStepStr()); } @@ -61,9 +61,9 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest { //自定义执行器测试+全局重试配置测试 @Test public void testCustomExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getSlot().getData("retryLogic")); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getContextBean().getData("retryLogic")); Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getSlot().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 4091d9677..acf0f397e 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 7e4521754..65795f03b 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 8d3d69a51..87cbbe648 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 165417bbd..379854374 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -26,7 +26,7 @@ public class SpringELSupportSpringbootTest extends BaseTest { //测试springEL的解析情况 @Test public void testSpringELParser() { - 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/XmlParserSpringbootTest.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java index 7ed4a14d9..63884c98f 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 4813b85ec..c7fcc74c1 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 53f04ac46..6fe7a8bc8 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.preAndFinally; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } @@ -57,8 +57,8 @@ 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"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("hasEx")); + Assert.assertTrue(response.getContextBean().getData("hasEx")); } } 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 24af8d347..cdf4e710a 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 @@ -11,6 +11,7 @@ import cn.hutool.core.util.ObjectUtil; import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; import org.springframework.stereotype.Component; @@ -21,11 +22,12 @@ public class Finally3Cmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) throws Exception{ - Slot slot = bindCmp.getSlot(); + Slot slot = bindCmp.getSlot(); + DefaultContext context = slot.getContextBean(); if (ObjectUtil.isNull(slot.getException())){ - slot.setData("hasEx", false); + context.setData("hasEx", false); }else{ - slot.setData("hasEx", true); + context.setData("hasEx", true); } System.out.println("Finally3Cmp executed!"); } 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 8fc0877d9..5fd551267 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.privateDelivery; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -33,8 +33,8 @@ public class PrivateDeliverySpringbootTest extends BaseTest { @Test public void testPrivateDelivery() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Set set = response.getSlot().getData("testSet"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Set set = response.getContextBean().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 4acc83cb3..b157b60d5 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; @@ -23,8 +24,8 @@ public class ACmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { System.out.println("ACmp executed!"); - Slot slot = bindCmp.getSlot(); - slot.setData("testSet", new HashSet<>()); + DefaultContext context = bindCmp.getContextBean(); + context.setData("testSet", new HashSet<>()); for (int i = 0; i < 100; i++) { bindCmp.sendPrivateDeliveryData("b",i+1); 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 3290d9ca2..ceaa84abc 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 @@ -12,6 +12,7 @@ import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import java.util.Set; @@ -23,7 +24,8 @@ public class BCmp{ public void process(NodeComponent bindCmp) { System.out.println("BCmp executed!"); Integer value = bindCmp.getPrivateDeliveryData(); - Set testSet = bindCmp.getSlot().getData("testSet"); + DefaultContext context = bindCmp.getContextBean(); + Set 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 7de255322..798ed4925 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.refreshRule; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 0f77e3e8f..2f5090c96 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 e80c64bca..9a9ebf2cc 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 @@ -3,8 +3,8 @@ package com.yomahub.liteflow.test.resizeSlot; import cn.hutool.core.util.ReflectUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.slot.DataBus; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 d4c334a84..b539678b2 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -37,7 +37,7 @@ 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"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("f==>g==>h==>m", response.getSlot().getExecuteStepStr()); 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 d80f99495..227df88cc 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 @@ -1,10 +1,10 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.MultipleParsersException; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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.getSlot().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 c29b70daf..f5324f056 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 218245fad..f56390faa 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 db9e2c839..70ce5f23c 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().getExecuteStepStr()); } diff --git a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java index b9de25df9..722248268 100644 --- a/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java +++ b/liteflow-testcase-declare-component/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java @@ -4,8 +4,8 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -26,6 +26,6 @@ public class GCmp{ System.out.println("Gcmp executed!"); - flowExecutor.invoke("chain4", "it's implicit subflow.", DefaultSlot.class, bindCmp.getSlotIndex()); + flowExecutor.invoke("chain4", "it's implicit subflow.", bindCmp.getSlotIndex()); } } 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 ed8f291ec..1649d2ee2 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.tag; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -33,14 +33,14 @@ public class NodeTagSpringbootJsonTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getSlot().getData("test")); + Assert.assertEquals("123",response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -50,9 +50,9 @@ 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"); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getSlot().getData("test"); + ConcurrentHashSet testSet = response.getContextBean().getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -60,7 +60,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.getSlot().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 256b4773b..f632b20c5 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.tag; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -33,14 +33,14 @@ public class NodeTagSpringbootXmlTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getSlot().getData("test")); + Assert.assertEquals("123",response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -50,9 +50,9 @@ 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"); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getSlot().getData("test"); + ConcurrentHashSet testSet = response.getContextBean().getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -60,7 +60,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.getSlot().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 2f6e77dff..8dcb55cce 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; @@ -22,13 +23,13 @@ public class ACmp{ public void process(NodeComponent bindCmp) { String testKey = "test"; - Slot slot = bindCmp.getSlot(); - if (slot.getData(testKey) == null){ - slot.setData(testKey,bindCmp.getTag()); + DefaultContext context = bindCmp.getContextBean(); + if (context.getData(testKey) == null){ + context.setData(testKey,bindCmp.getTag()); }else{ - String s = slot.getData(testKey); + String s = context.getData(testKey); s += bindCmp.getTag(); - slot.setData(testKey, s); + context.setData(testKey, s); } } } 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 af3db0d11..d28b4c007 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 @@ -12,6 +12,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; @@ -21,7 +22,7 @@ public class B1Cmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - Slot slot = bindCmp.getSlot(); - slot.setData("test",new ConcurrentHashSet()); + DefaultContext context = bindCmp.getContextBean(); + 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 3e392ae92..a0ed4476b 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 @@ -12,6 +12,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; @@ -21,8 +22,8 @@ public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { - Slot slot = bindCmp.getSlot(); - ConcurrentHashSet testSet = slot.getData("test"); + DefaultContext context = bindCmp.getContextBean(); + 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 681079806..f397e1fd3 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.useTTLInWhen; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -32,11 +32,11 @@ public class UseTTLInWhenSpringbootTest extends BaseTest { @Test public void testUseTTLInWhen() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("hello,b", response.getSlot().getData("b")); - Assert.assertEquals("hello,c", response.getSlot().getData("c")); - Assert.assertEquals("hello,d", response.getSlot().getData("d")); - Assert.assertEquals("hello,e", response.getSlot().getData("e")); - Assert.assertEquals("hello,f", response.getSlot().getData("f")); + 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")); } } 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 b2e30c9b0..61830e101 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -21,7 +22,8 @@ public class BCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - bindCmp.getSlot().setData(bindCmp.getNodeId(),value+",b"); + DefaultContext context = bindCmp.getContextBean(); + 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 429eca6d4..029abbad4 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -21,7 +22,8 @@ public class CCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - bindCmp.getSlot().setData(bindCmp.getNodeId(),value+",c"); + DefaultContext context = bindCmp.getContextBean(); + 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 a9e657f99..39b880ce4 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -21,7 +22,8 @@ public class DCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - bindCmp.getSlot().setData(bindCmp.getNodeId(),value+",d"); + DefaultContext context = bindCmp.getContextBean(); + 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 f039dbcc4..22ab46c33 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -21,7 +22,8 @@ public class ECmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - bindCmp.getSlot().setData(bindCmp.getNodeId(),value+",e"); + DefaultContext context = bindCmp.getContextBean(); + 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 2cb04f0ab..6901536b7 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 @@ -11,6 +11,7 @@ import com.yomahub.liteflow.annotation.LiteflowCmpDefine; import com.yomahub.liteflow.annotation.LiteflowMethod; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -21,7 +22,8 @@ public class FCmp{ @LiteflowMethod(LiteFlowMethodEnum.PROCESS) public void process(NodeComponent bindCmp) { String value = TestTL.get(); - bindCmp.getSlot().setData(bindCmp.getNodeId(),value+",f"); + DefaultContext context = bindCmp.getContextBean(); + 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 6643f386f..179591505 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.WhenTimeoutException; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 e3cafb3eb..1d7a1139f 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 3cefe3c4a..c6fddb4be 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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 107e13710..baec322d2 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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 5eea56f40..68503df70 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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 6cb7621f7..103860a6b 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 e3004ee36..3e7cf0b62 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 @@ -3,9 +3,9 @@ package com.yomahub.liteflow.test.asyncNode; import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; import org.junit.Assert; @@ -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.getSlot().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,18 @@ 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"); //因为不记录错误,所以最终结果是true Assert.assertTrue(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //因为配置了不抛错,所以response里的cause应该为null Assert.assertNull(response.getCause()); @@ -82,11 +82,11 @@ 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"); //整个并行组是报错的,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //因为第一个when配置了会报错,所以response里的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -95,11 +95,11 @@ 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"); //第一个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 - Integer count = response.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(1), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -108,11 +108,11 @@ 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"); //第二个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 - Integer count = response.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -124,8 +124,8 @@ 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"); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("check").toString().startsWith("habc")); + Assert.assertTrue(response.getContextBean().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 f6f5fd855..89e15af6f 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 @@ -1,20 +1,21 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class ACmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Acomp executed!"); 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 06835c7b5..868f769cd 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 @@ -1,20 +1,21 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class BCmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Bcomp executed!"); 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 bb97bfcae..5a3f2728a 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 @@ -1,20 +1,21 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class CCmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Ccomp executed!"); 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 800fa8abb..b36483053 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @@ -8,14 +9,14 @@ public class DCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(1000); - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Dcomp executed!"); 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 b8e386718..5c522118c 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @@ -9,14 +10,14 @@ public class GCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(500); - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Gcomp executed!"); 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 cd1875139..8bafdebfd 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @@ -8,14 +9,14 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } 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 bd8ed0568..f734d19c4 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.test.asyncNode.exception.TestException; @@ -9,12 +10,12 @@ public class ICmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); - if (slot.hasData("count")) { - Integer count = slot.getData("count"); - slot.setData("count", ++count); + DefaultContext context = this.getContextBean(); + if (context.hasData("count")) { + Integer count = context.getData("count"); + context.setData("count", ++count); } else { - slot.setData("count", 1); + context.setData("count", 1); } System.out.println("Icomp executed! throw Exception!"); throw new TestException(); 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 d864d166d..0c58e67f4 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 350e1f6a2..21d078f0c 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 @@ -5,11 +5,11 @@ import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.builder.entity.ExecutableEntity; import com.yomahub.liteflow.enums.NodeTypeEnum; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.builder.cmp.ACmp; import com.yomahub.liteflow.test.builder.cmp.BCmp; @@ -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.getSlot().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.getSlot().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.getSlot().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 5b834cb2b..b1e4448b2 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } 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 e953ddd76..0a5104e00 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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.getSlot().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.getSlot().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.getSlot().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 63f1134b6..301fb8c67 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.config; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 65d149376..e2db94827 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.customWhenThreadPool; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -32,9 +32,9 @@ public class CustomWhenThreadPoolTest extends BaseTest { */ @Test public void testGlobalThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("threadName").toString().startsWith("lf-when-thead")); + Assert.assertTrue(response.getContextBean().getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -42,9 +42,9 @@ public class CustomWhenThreadPoolTest extends BaseTest { */ @Test public void testGlobalAndCustomWhenThreadPool() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(response1.getSlot().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(response1.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); } @@ -56,9 +56,9 @@ public class CustomWhenThreadPoolTest extends BaseTest { // 使用when - thread1 testGlobalAndCustomWhenThreadPool(); // chain配置同一个thead1 - LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(response2.getSlot().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(response2.getContextBean().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 8a216673b..7360ebc23 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 @@ -8,12 +8,15 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.slot.Slot; public class BCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 345e817a8..43ed31b0a 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 @@ -8,12 +8,15 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.slot.Slot; public class CCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 1485a88ee..969bfbae4 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 @@ -8,12 +8,15 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.slot.Slot; public class DCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 c7655955b..d5277892d 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 @@ -8,12 +8,14 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; public class ECmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 2b5f2575d..9fb502f69 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 @@ -8,12 +8,15 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.slot.Slot; public class FCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + context.setData("threadName", Thread.currentThread().getName()); System.out.println("FCmp executed!"); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/ExceptionTest.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/ExceptionTest.java index fb89a7f25..b0fb580cc 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/ExceptionTest.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/exception/ExceptionTest.java @@ -2,13 +2,13 @@ package com.yomahub.liteflow.test.exception; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.ChainNotFoundException; import com.yomahub.liteflow.exception.FlowExecutorNotInitException; import com.yomahub.liteflow.exception.FlowSystemException; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -59,7 +59,7 @@ public class ExceptionTest 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 3609fe682..12ae0723d 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.execute2Future; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -29,8 +29,8 @@ public class Executor2FutureTest extends BaseTest { @Test public void testFuture() throws Exception{ - Future> future = flowExecutor.execute2Future("chain1", "arg", DefaultSlot.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 57ce401d9..789201bd3 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.flowmeta; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.flowmeta.cmp2.DCmp; import org.junit.Assert; @@ -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.getSlot().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 a803047a2..7c890da7a 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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.getSlot().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 4e7423026..b40a6d73c 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -11,9 +12,9 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerDefaultNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = DataBus.getContextBean(instance.getSlotIndex()); LOG.info("使用customerDefaultNodeExecutor进行执行"); - slot.setData("customerDefaultNodeExecutor", this.getClass()); + 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 17d5c31be..68651f964 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -11,9 +12,9 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = DataBus.getContextBean(instance.getSlotIndex()); LOG.info("使用customerNodeExecutor进行执行"); - slot.setData("customerNodeExecutor", this.getClass()); + 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 1ee6b3f2d..ff18dabbf 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -13,17 +14,17 @@ import java.util.concurrent.TimeUnit; public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = DataBus.getContextBean(instance.getSlotIndex()); LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); - slot.setData("customerNodeExecutorAndCustomRetry", this.getClass()); + context.setData("customerNodeExecutorAndCustomRetry", this.getClass()); super.execute(instance); } @Override protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { TimeUnit.MICROSECONDS.sleep(20L); - Slot slot = DataBus.getSlot(instance.getSlotIndex()); - slot.setData("retryLogic", this.getClass()); + DefaultContext context = DataBus.getContextBean(instance.getSlotIndex()); + 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 b574c9ad8..30e54afe1 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -33,25 +33,25 @@ public class LiteflowNodeExecutorTest extends BaseTest { // 默认执行器测试 @Test public void testCustomerDefaultNodeExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); Assert.assertEquals("a", response.getSlot().getExecuteStepStr()); } //默认执行器测试+全局重试配置测试 @Test public void testDefaultExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); Assert.assertEquals("b==>b==>b", response.getSlot().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.getSlot().getExecuteStepStr()); } @@ -59,9 +59,9 @@ public class LiteflowNodeExecutorTest extends BaseTest { //自定义执行器测试+全局重试配置测试 @Test public void testCustomExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getSlot().getData("retryLogic")); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getContextBean().getData("retryLogic")); Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getSlot().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 db97d2ad2..0c6bf84a4 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.nullParam; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -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 3979207e1..d2ef85772 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 681a6b201..84a098b16 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 f5e38696e..25d6a34e2 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 4c7015e62..5d34bd4c4 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 2f420e6fe..a50951015 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 edab3998d..b205fc606 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.preAndFinally; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } @@ -53,8 +53,8 @@ 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"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("hasEx")); + Assert.assertTrue(response.getContextBean().getData("hasEx")); } } 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 75e709a4b..9f81d2114 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 @@ -9,17 +9,18 @@ package com.yomahub.liteflow.test.preAndFinally.cmp; import cn.hutool.core.util.ObjectUtil; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class Finally3Cmp extends NodeComponent { @Override public void process() throws Exception{ - Slot slot = this.getSlot(); + Slot slot = this.getSlot(); if (ObjectUtil.isNull(slot.getException())){ - slot.setData("hasEx", false); + slot.getContextBean().setData("hasEx", false); }else{ - slot.setData("hasEx", true); + slot.getContextBean().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 98e167d59..dad2c193d 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.privateDelivery; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -29,8 +29,8 @@ public class PrivateDeliveryTest extends BaseTest { @Test public void testPrivateDelivery() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Set set = response.getSlot().getData("testSet"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Set set = response.getContextBean().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 1a0757180..9e16d3d29 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.privateDelivery.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import java.util.HashSet; @@ -17,8 +18,8 @@ public class ACmp extends NodeComponent { @Override public void process() { System.out.println("ACmp executed!"); - Slot slot = getSlot(); - slot.setData("testSet", new HashSet<>()); + DefaultContext context = this.getContextBean(); + context.setData("testSet", new HashSet<>()); for (int i = 0; i < 100; i++) { this.sendPrivateDeliveryData("b",i+1); 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 380bf8e07..e408e80ba 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 @@ -8,6 +8,8 @@ package com.yomahub.liteflow.test.privateDelivery.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.slot.Slot; import java.util.Set; @@ -15,9 +17,10 @@ public class BCmp extends NodeComponent { @Override public void process() { + DefaultContext context = this.getContextBean(); System.out.println("BCmp executed!"); Integer value = this.getPrivateDeliveryData(); - Set testSet = this.getSlot().getData("testSet"); + Set testSet = context.getData("testSet"); testSet.add(value); } } 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 a2d4bd241..6beb3e6e5 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 @@ -3,11 +3,11 @@ package com.yomahub.liteflow.test.refreshRule; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 29d35f824..8d4e68d50 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 ea4cae444..a445a0202 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.removeChain; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 f0d6835e6..dbcb1ecef 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 @@ -4,9 +4,9 @@ import cn.hutool.core.util.ReflectUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.slot.DataBus; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 7ac83c852..d75940b7b 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -34,7 +34,7 @@ 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"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("f==>g==>h==>m", response.getSlot().getExecuteStepStr()); 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 f95191c58..df275f2d9 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 @@ -2,11 +2,11 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.MultipleParsersException; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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.getSlot().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 69d9207d1..9df6b1975 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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.getSlot().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 c6af938c2..ee4b1caec 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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.getSlot().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 d95e236b9..8baa1e5ec 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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.getSlot().getExecuteStepStr()); } diff --git a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java index dc49e1e27..f4ec41aac 100644 --- a/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java +++ b/liteflow-testcase-nospring/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java @@ -3,7 +3,8 @@ package com.yomahub.liteflow.test.subflow.cmp2; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.slot.DefaultSlot; +import com.yomahub.liteflow.slot.DefaultContext; + import static com.yomahub.liteflow.test.subflow.ImplicitSubFlowTest.RUN_TIME_SLOT; @@ -18,6 +19,6 @@ public class GCmp extends NodeComponent { FlowExecutor flowExecutor = FlowExecutorHolder.loadInstance(); - flowExecutor.invoke("chain4", "it's implicit subflow.", DefaultSlot.class, this.getSlotIndex()); + flowExecutor.invoke("chain4", "it's implicit subflow.", this.getSlotIndex()); } } 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 77509643c..491a4815b 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 @@ -3,9 +3,9 @@ package com.yomahub.liteflow.test.tag; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -29,14 +29,14 @@ public class NodeTagJsonTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getSlot().getData("test")); + Assert.assertEquals("123",response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -46,9 +46,9 @@ 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"); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getSlot().getData("test"); + ConcurrentHashSet testSet = response.getContextBean().getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -56,7 +56,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.getSlot().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 c8524843d..55adbbbb7 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 @@ -3,9 +3,9 @@ package com.yomahub.liteflow.test.tag; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -29,14 +29,14 @@ public class NodeTagXmlTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getSlot().getData("test")); + Assert.assertEquals("123",response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -46,9 +46,9 @@ 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"); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getSlot().getData("test"); + ConcurrentHashSet testSet = response.getContextBean().getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -56,7 +56,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.getSlot().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 7f4dc5bbb..5052de9d1 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.tag.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class ACmp extends NodeComponent { @@ -16,13 +17,13 @@ public class ACmp extends NodeComponent { public void process() { String testKey = "test"; - Slot slot = this.getSlot(); - if (slot.getData(testKey) == null){ - slot.setData(testKey,this.getTag()); + DefaultContext context = this.getContextBean(); + if (context.getData(testKey) == null){ + context.setData(testKey,this.getTag()); }else{ - String s = slot.getData(testKey); + String s = context.getData(testKey); s += this.getTag(); - slot.setData(testKey, s); + context.setData(testKey, s); } } } 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 56b424528..4d2e6efac 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 @@ -9,13 +9,14 @@ package com.yomahub.liteflow.test.tag.cmp; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class B1Cmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); - slot.setData("test",new ConcurrentHashSet()); + DefaultContext context = this.getContextBean(); + 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 a640236ec..d12e8b1d4 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 @@ -9,14 +9,15 @@ package com.yomahub.liteflow.test.tag.cmp; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; public class BCmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); - ConcurrentHashSet testSet = slot.getData("test"); + DefaultContext context = this.getContextBean(); + 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 f09eb1b14..06f2b0169 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.useTTLInWhen; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -28,11 +28,11 @@ public class UseTTLInWhenTest extends BaseTest { @Test public void testUseTTLInWhen() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("hello,b", response.getSlot().getData("b")); - Assert.assertEquals("hello,c", response.getSlot().getData("c")); - Assert.assertEquals("hello,d", response.getSlot().getData("d")); - Assert.assertEquals("hello,e", response.getSlot().getData("e")); - Assert.assertEquals("hello,f", response.getSlot().getData("f")); + 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")); } } 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 9987e815d..7e864342c 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; public class BCmp extends NodeComponent { @@ -15,7 +16,8 @@ public class BCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",b"); + DefaultContext context = this.getContextBean(); + 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 d7a256ea8..44b016144 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; public class CCmp extends NodeComponent { @@ -15,7 +16,8 @@ public class CCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",c"); + DefaultContext context = this.getContextBean(); + 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 cfa2be8fb..e7fee79a2 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; public class DCmp extends NodeComponent { @@ -15,7 +16,8 @@ public class DCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",d"); + DefaultContext context = this.getContextBean(); + 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 17a01cea3..197f7e951 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; public class ECmp extends NodeComponent { @@ -15,7 +16,8 @@ public class ECmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",e"); + DefaultContext context = this.getContextBean(); + 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 807b39096..57ee6ce26 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; public class FCmp extends NodeComponent { @@ -15,7 +16,8 @@ public class FCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",f"); + DefaultContext context = this.getContextBean(); + 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 bc9569f24..f8bc97f91 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.WhenTimeoutException; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 149228acb..d4a739614 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 @@ -2,9 +2,9 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.BeforeClass; @@ -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 ea3bbef39..714121c02 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 @@ -3,9 +3,9 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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 1fe506efb..5c4ef92ca 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 @@ -3,9 +3,9 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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 a38d5e7a3..2db6f2f27 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 @@ -3,9 +3,9 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.FlowExecutorHolder; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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 54e37024a..876f6f7e2 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 @@ -4,9 +4,9 @@ import com.yomahub.liteflow.builder.LiteFlowChainBuilder; import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.NodeTypeEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -47,7 +47,7 @@ public class LiteFlowXmlScriptBuilderGroovyTest extends BaseTest { .setId("s1") .setName("普通脚本S1") .setType(NodeTypeEnum.SCRIPT) - .setScript("Integer a=3;Integer b=2;slot.setData(\"s1\",a*b)") + .setScript("Integer a=3;Integer b=2;context.setData(\"s1\",a*b)") .build(); LiteFlowChainBuilder.createChain().setChainName("chain1") @@ -55,9 +55,9 @@ public class LiteFlowXmlScriptBuilderGroovyTest extends BaseTest { .build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); } //测试通过builder方式运行普通script节点,以file的方式运行 @@ -89,7 +89,7 @@ public class LiteFlowXmlScriptBuilderGroovyTest 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]==>a[组件A]", response.getSlot().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 b85fc6dfb..07bdc4a3d 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.script.groovy; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -37,15 +37,15 @@ public class LiteflowJsonScriptFileGroovyTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -54,7 +54,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.getSlot().getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -63,7 +63,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.getSlot().getExecuteStepStr()); } @@ -84,7 +84,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 a8bf57847..3201a7eb0 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.script.groovy; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -37,15 +37,15 @@ public class LiteflowJsonScriptGroovyTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -54,7 +54,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.getSlot().getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -63,7 +63,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.getSlot().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 9f2276c84..e0926cb5e 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.script.groovy; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -37,15 +37,15 @@ public class LiteflowXmlScriptFileGroovyTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -54,7 +54,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.getSlot().getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -63,7 +63,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.getSlot().getExecuteStepStr()); } @@ -84,7 +84,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 bfcf75302..aac83f144 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.script.groovy; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -37,15 +37,15 @@ public class LiteflowXmlScriptGroovyTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -54,7 +54,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.getSlot().getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -63,7 +63,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.getSlot().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 0105bc21f..1246c2119 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.script.groovy.cmp; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @LiteflowComponent("d") @@ -16,8 +17,8 @@ public class DCmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); - slot.setData("count",198); + DefaultContext context = this.getContextBean(); + 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 8e6120814..e38b6957d 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 -slot.setData("s1",a*b) \ No newline at end of file +context.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 3c9bee6fa..29a8f5a0b 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 = slot.getData("count") +Integer count = context.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 8e6120814..e38b6957d 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 -slot.setData("s1",a*b) \ No newline at end of file +context.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 3c9bee6fa..29a8f5a0b 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 = slot.getData("count") +Integer count = context.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 a4b61ccfe..1d8f6dce2 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 = slot.getData("count") +Integer count = context.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 ebc6135af..d29ae4b85 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 -slot.setData("s1",a*b+c) \ No newline at end of file +context.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 c6a62b4b0..b5054329b 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;slot.setData(\"s1\",a*b);" + "value": "def a=3;def b=2;context.setData(\"s1\",a*b);" }, { "id": "s2", "name": "条件脚本", "type": "cond_script", - "value": "count = slot.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}" + "value": "count = context.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}" }, { "id": "s3", "name": "普通脚本2", "type": "script", - "value": "def a=30;def b=2;slot.setData(\"s1\",a*b);" + "value": "def a=30;def b=2;context.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 03f9d3131..a139e510a 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;slot.setData(\"s1\",a*b);" + "value": "def a=3;def b=2;context.setData(\"s1\",a*b);" }, { "id": "s2", "name": "条件脚本_改", "type": "cond_script", - "value": "count = slot.getData(\"count\");if(count > 150){return \"b\";}else{return \"a\";}" + "value": "count = context.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;slot.setData(\"s1\",a*b+c);" + "value": "def a=3;def b=2;def c=10;context.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 8e6120814..e38b6957d 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 -slot.setData("s1",a*b) \ No newline at end of file +context.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 3c9bee6fa..29a8f5a0b 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 = slot.getData("count") +Integer count = context.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 a4b61ccfe..1d8f6dce2 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 = slot.getData("count") +Integer count = context.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 1cd037347..577991b2e 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 -slot.setData("s1",a*b+c); \ No newline at end of file +context.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 62c9b3ded..5f0455b80 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 bc38a9913..fd93a289f 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; - slot.setData("s1",a*b+c); + context.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 5356bc2bd..aa8d41f21 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 @@ -4,9 +4,9 @@ import com.yomahub.liteflow.builder.LiteFlowChainBuilder; import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.NodeTypeEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -47,7 +47,7 @@ public class LiteFlowXmlScriptBuilderQLExpressTest extends BaseTest { .setId("s1") .setName("普通脚本S1") .setType(NodeTypeEnum.SCRIPT) - .setScript("a=3;b=2;slot.setData(\"s1\",a*b);") + .setScript("a=3;b=2;context.setData(\"s1\",a*b);") .build(); LiteFlowChainBuilder.createChain().setChainName("chain1") @@ -55,9 +55,9 @@ public class LiteFlowXmlScriptBuilderQLExpressTest extends BaseTest { .build(); - LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1","arg1"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().getData("s1")); } //测试通过builder方式运行普通script节点,以file的方式运行 @@ -89,7 +89,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.getSlot().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 5d3e9e3f3..765d5514e 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.script.qlexpress; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -37,15 +37,15 @@ public class LiteflowJsonScriptFileQLExpressTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -53,7 +53,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.getSlot().getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -62,7 +62,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.getSlot().getExecuteStepStr()); } @@ -83,7 +83,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 c6cb79c75..e920d741a 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.script.qlexpress; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -37,15 +37,15 @@ public class LiteflowJsonScriptQLExpressTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -53,7 +53,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.getSlot().getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -62,7 +62,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.getSlot().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 6fa3e8a04..31e9ea816 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.script.qlexpress; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -37,15 +37,15 @@ public class LiteflowXmlScriptFileQLExpressTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -53,7 +53,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.getSlot().getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -62,7 +62,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.getSlot().getExecuteStepStr()); } @@ -83,7 +83,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 3c07a53e8..62be1c773 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.script.qlexpress; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -37,15 +37,15 @@ public class LiteflowXmlScriptQLExpressTest extends BaseTest { //测试普通脚本节点 @Test public void testScript1() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(Integer.valueOf(6), response.getSlot().getData("s1")); + Assert.assertEquals(Integer.valueOf(6), response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -53,7 +53,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.getSlot().getExecuteStepStr()); //更改规则,重新加载,更改的规则内容从flow_update.xml里读取,这里只是为了模拟下获取新的内容。不一定是从文件中读取 @@ -62,7 +62,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.getSlot().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 d101337c3..56b13aca6 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.script.qlexpress.cmp; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @LiteflowComponent("d") @@ -16,8 +17,8 @@ public class DCmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); - slot.setData("count",97); + DefaultContext context = this.getContextBean(); + 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 62fc4d5cb..2d426a97a 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; -slot.setData("s1",a*b); \ No newline at end of file +context.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 bf6ec12e0..eba2b2e24 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 = slot.getData("count"); +count = context.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 62fc4d5cb..2d426a97a 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; -slot.setData("s1",a*b); \ No newline at end of file +context.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 bf6ec12e0..eba2b2e24 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 = slot.getData("count"); +count = context.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 0c647c987..7994d9427 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 = slot.getData("count"); +count = context.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 6bb24aa65..a28b66db4 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; -slot.setData("s1",a*b+c); \ No newline at end of file +context.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 f57c1e084..19f121682 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;slot.setData(\"s1\",a*b);" + "value": "a=3;b=2;context.setData(\"s1\",a*b);" }, { "id": "s2", "name": "条件脚本", "type": "cond_script", - "value": "count = slot.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}" + "value": "count = context.getData(\"count\");if(count > 100){return \"a\";}else{return \"b\";}" }, { "id": "s3", "name": "普通脚本2", "type": "script", - "value": "a=30;b=2;slot.setData(\"s1\",a*b);" + "value": "a=30;b=2;context.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 94c8c20b0..7623bf62b 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;slot.setData(\"s1\",a*b);" + "value": "a=3;b=2;context.setData(\"s1\",a*b);" }, { "id": "s2", "name": "条件脚本_改", "type": "cond_script", - "value": "count = slot.getData(\"count\");if(count > 150){return \"b\";}else{return \"a\";}" + "value": "count = context.getData(\"count\");if(count > 150){return \"b\";}else{return \"a\";}" }, { "id": "s3", "name": "普通脚本_新增", "type": "script", - "value": "a=3;b=2;c=10;slot.setData(\"s1\",a*b+c);" + "value": "a=3;b=2;c=10;context.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 62fc4d5cb..2d426a97a 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; -slot.setData("s1",a*b); \ No newline at end of file +context.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 bf6ec12e0..eba2b2e24 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 = slot.getData("count"); +count = context.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 0c647c987..7994d9427 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 = slot.getData("count"); +count = context.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 6bb24aa65..a28b66db4 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; -slot.setData("s1",a*b+c); \ No newline at end of file +context.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 35876421d..02a99d437 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 8b6d44e73..a48985af5 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; - slot.setData("s1",a*b+c); + context.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 e7c0c6c12..c031268f5 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 bddf4b75a..711222355 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.aop; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.aop.aspect.CustomAspect; import org.junit.Assert; @@ -35,20 +35,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.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); + Assert.assertEquals("before_after", response.getContextBean().getData("a")); + Assert.assertEquals("before_after", response.getContextBean().getData("b")); + Assert.assertEquals("before_after", response.getContextBean().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.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); + Assert.assertEquals("before_after", response.getContextBean().getData("a")); + Assert.assertEquals("before_after", response.getContextBean().getData("b")); + Assert.assertEquals("before_after", response.getContextBean().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 1d39a1cc7..c38960b52 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.aop; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.aop.aspect.CmpAspect; @@ -37,35 +37,35 @@ 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"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("d")); - Assert.assertEquals("before_after", response.getSlot().getData("e")); + 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")); } //测试全局AOP,并行场景 @Test public void testGlobalAopP() { - 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.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("d")); - Assert.assertEquals("before_after", response.getSlot().getData("e")); + 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")); } @Test public void testGlobalAopException() { - LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", response.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("f")); + 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")); } @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 fdb5111b0..d4e4a0f89 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 @@ -2,16 +2,17 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; 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) { - slot.setData(nodeId, "before"); + public void beforeProcess(String nodeId, DefaultContext contextBean) { + contextBean.setData(nodeId, "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - slot.setData(nodeId, StrUtil.format("{}_{}", slot.getData(nodeId), "after")); + public void afterProcess(String nodeId, DefaultContext contextBean) { + contextBean.setData(nodeId, StrUtil.format("{}_{}", contextBean.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 4ffa13d2f..673e3f7b5 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -18,10 +19,10 @@ public class CustomAspect { @Around("cut()") public Object around(ProceedingJoinPoint jp) throws Throwable { NodeComponent cmp = (NodeComponent) jp.getThis(); - Slot slot = cmp.getSlot(); - slot.setData(cmp.getNodeId(), "before"); + DefaultContext context = cmp.getContextBean(); + context.setData(cmp.getNodeId(), "before"); Object returnObj = jp.proceed(); - slot.setData(cmp.getNodeId(), StrUtil.format("{}_{}", slot.getData(cmp.getNodeId()), "after")); + context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); return returnObj; } } 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 30a8b0717..0b6fa51d8 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.asyncNode; import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; import org.junit.Assert; @@ -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.getSlot().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,18 @@ 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.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //因为配置了不抛错,所以response里的cause应该为null Assert.assertNull(response.getCause()); @@ -85,11 +85,11 @@ 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.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //因为第一个when配置了会报错,所以response里的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -98,11 +98,11 @@ 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.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(1), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -111,11 +111,11 @@ 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.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -127,8 +127,8 @@ 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"); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("check").toString().startsWith("habc")); + Assert.assertTrue(response.getContextBean().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 d208505f8..2d362f405 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -9,14 +10,14 @@ import org.springframework.stereotype.Component; public class ACmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Acomp executed!"); 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 3b9d860df..b60ed84db 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -9,14 +10,14 @@ import org.springframework.stereotype.Component; public class BCmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Bcomp executed!"); 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 0059d6fab..fc32acff6 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -9,14 +10,14 @@ import org.springframework.stereotype.Component; public class CCmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Ccomp executed!"); 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 a9c49c951..8918b783b 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -10,14 +11,14 @@ public class DCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(1000); - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Dcomp executed!"); 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 09f470bbd..dc0694664 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -11,14 +12,14 @@ public class GCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(500); - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Gcomp executed!"); 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 d2bed260f..52dfa5d85 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -10,14 +11,14 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } 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 09ec9be4d..8c5a76748 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.test.asyncNode.exception.TestException; import org.springframework.stereotype.Component; @@ -11,12 +12,12 @@ public class ICmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); - if (slot.hasData("count")){ - Integer count = slot.getData("count"); - slot.setData("count", ++count); + DefaultContext context = this.getContextBean(); + if (context.hasData("count")){ + Integer count = context.getData("count"); + context.setData("count", ++count); } else{ - slot.setData("count", 1); + context.setData("count", 1); } System.out.println("Icomp executed! throw Exception!"); throw new TestException(); 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 af6ff188d..aefe3e5c7 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.bannerPrint; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 eac53e574..b50e1bd4d 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 0083d8c2c..8c03fac97 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 @@ -4,10 +4,10 @@ import com.yomahub.liteflow.builder.LiteFlowChainBuilder; import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.builder.entity.ExecutableEntity; import com.yomahub.liteflow.enums.NodeTypeEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.builder.cmp1.ACmp; import com.yomahub.liteflow.test.builder.cmp1.BCmp; @@ -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.getSlot().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.getSlot().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.getSlot().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 d89d5fb95..a8363f88b 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 @@ -3,8 +3,8 @@ package com.yomahub.liteflow.test.builder; import com.yomahub.liteflow.builder.LiteFlowChainBuilder; import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 e5a5b190d..c13b2654e 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } 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 de1c24101..570b7e41c 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().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 68a84b8d4..9ed3f9463 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 @@ -1,10 +1,10 @@ package com.yomahub.liteflow.test.config; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 d9c771d09..d81c0bd78 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.config; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().getExecuteStepStr()); - LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertEquals("a==>c==>b==>d", response1.getSlot().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 3aa0fcabb..c441b6feb 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.customNodes; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 b2dc79f9b..5a1ac1481 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.customWhenThreadPool; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -40,9 +40,9 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { */ @Test public void testGlobalThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("threadName").toString().startsWith("lf-when-thead")); + Assert.assertTrue(response.getContextBean().getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -50,9 +50,9 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { */ @Test public void testGlobalAndCustomWhenThreadPool() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(response1.getSlot().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(response1.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); } @@ -64,9 +64,9 @@ public class CustomWhenThreadPoolSpringbootTest extends BaseTest { // 使用when - thread1 testGlobalAndCustomWhenThreadPool(); // chain配置同一个thead1 - LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(response2.getSlot().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(response2.getContextBean().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 69b1a3845..a7af6a490 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("b") @@ -15,7 +16,8 @@ public class BCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 df355c4b6..99144f623 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("c") @@ -15,7 +16,8 @@ public class CCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 a67ec4b9b..4d1c41cc4 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("d") @@ -15,7 +16,8 @@ public class DCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 929e41767..61da5bba5 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("e") @@ -15,7 +16,8 @@ public class ECmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 f4285a637..fe77d3af8 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("f") @@ -15,7 +16,8 @@ public class FCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 24cd14396..382e8f935 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.deadLoopChain; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import javax.annotation.Resource; @@ -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/exception/ExceptionSpringBootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringBootTest.java index 0765eaa03..aa70fee80 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringBootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringBootTest.java @@ -1,13 +1,13 @@ package com.yomahub.liteflow.test.exception; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.ChainNotFoundException; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.exception.FlowExecutorNotInitException; import com.yomahub.liteflow.exception.FlowSystemException; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -75,7 +75,7 @@ public class ExceptionSpringBootTest 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 ef455a466..555e2e45d 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.execute2Future; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -33,8 +33,8 @@ public class Executor2FutureSpringbootTest extends BaseTest { @Test public void testFuture() throws Exception{ - Future> future = flowExecutor.execute2Future("chain1", "arg", DefaultSlot.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 822bb3df5..ad162c083 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.flowmeta; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.flowmeta.cmp2.DCmp; import org.junit.Assert; @@ -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.getSlot().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 6363d95b9..4ff8e4828 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.lazy; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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/liteflowcomponent/LiteflowComponentSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringbootTest.java index 2d7cc1e3f..2e0d64432 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringbootTest.java @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.liteflowcomponent; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 7a24ca4fa..38a50f768 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.monitor; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.monitor.MonitorBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spi.holder.ContextAwareHolder; import com.yomahub.liteflow.test.BaseTest; import org.junit.AfterClass; @@ -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/multipleType/LiteflowMultipleTypeSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/multipleType/LiteflowMultipleTypeSpringbootTest.java index 422448a28..9234942fe 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 4e7423026..a5da9969f 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -11,9 +12,9 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerDefaultNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerDefaultNodeExecutor进行执行"); - slot.setData("customerDefaultNodeExecutor", this.getClass()); + 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 17d5c31be..add288d67 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -11,9 +12,9 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerNodeExecutor进行执行"); - slot.setData("customerNodeExecutor", this.getClass()); + 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 1ee6b3f2d..a6eb87d53 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -13,17 +14,17 @@ import java.util.concurrent.TimeUnit; public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); - slot.setData("customerNodeExecutorAndCustomRetry", this.getClass()); + context.setData("customerNodeExecutorAndCustomRetry", this.getClass()); super.execute(instance); } @Override protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { TimeUnit.MICROSECONDS.sleep(20L); - Slot slot = DataBus.getSlot(instance.getSlotIndex()); - slot.setData("retryLogic", this.getClass()); + DefaultContext context = instance.getContextBean(); + 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 ad5bfeb0b..33f9fe1c4 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -35,25 +35,25 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest { // 默认执行器测试 @Test public void testCustomerDefaultNodeExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); Assert.assertEquals("a", response.getSlot().getExecuteStepStr()); } //默认执行器测试+全局重试配置测试 @Test public void testDefaultExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); Assert.assertEquals("b==>b==>b", response.getSlot().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.getSlot().getExecuteStepStr()); } @@ -61,9 +61,9 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest { //自定义执行器测试+全局重试配置测试 @Test public void testCustomExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getSlot().getData("retryLogic")); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getContextBean().getData("retryLogic")); Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getSlot().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 d1a1b71d8..11fabcf71 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.nullParam; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -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 4091d9677..acf0f397e 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 7e4521754..65795f03b 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 8d3d69a51..87cbbe648 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 165417bbd..379854374 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -26,7 +26,7 @@ public class SpringELSupportSpringbootTest extends BaseTest { //测试springEL的解析情况 @Test public void testSpringELParser() { - 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/XmlParserSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/parser/XmlParserSpringbootTest.java index 7ed4a14d9..63884c98f 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 4813b85ec..c7fcc74c1 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 53f04ac46..6fe7a8bc8 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.preAndFinally; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } @@ -57,8 +57,8 @@ 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"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("hasEx")); + Assert.assertTrue(response.getContextBean().getData("hasEx")); } } 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 b63f8ffb3..183b199af 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.preAndFinally.cmp; import cn.hutool.core.util.ObjectUtil; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -17,11 +18,12 @@ public class Finally3Cmp extends NodeComponent { @Override public void process() throws Exception{ - Slot slot = this.getSlot(); + Slot slot = this.getSlot(); + DefaultContext context = slot.getContextBean(); if (ObjectUtil.isNull(slot.getException())){ - slot.setData("hasEx", false); + context.setData("hasEx", false); }else{ - slot.setData("hasEx", true); + context.setData("hasEx", true); } System.out.println("Finally3Cmp executed!"); } 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 8fc0877d9..09749aa33 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.privateDelivery; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -33,8 +33,9 @@ public class PrivateDeliverySpringbootTest extends BaseTest { @Test public void testPrivateDelivery() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Set set = response.getSlot().getData("testSet"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + DefaultContext context = response.getContextBean(); + Set 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 fb0626b09..ee23b7020 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.privateDelivery.cmp; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import java.util.HashSet; @@ -19,8 +20,8 @@ public class ACmp extends NodeComponent { @Override public void process() { System.out.println("ACmp executed!"); - Slot slot = getSlot(); - slot.setData("testSet", new HashSet<>()); + DefaultContext context = this.getContextBean(); + context.setData("testSet", new HashSet<>()); for (int i = 0; i < 100; i++) { this.sendPrivateDeliveryData("b",i+1); 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 b950f985b..450ad9dae 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.privateDelivery.cmp; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; import java.util.Set; @@ -20,7 +21,8 @@ public class BCmp extends NodeComponent { public void process() { System.out.println("BCmp executed!"); Integer value = this.getPrivateDeliveryData(); - Set testSet = this.getSlot().getData("testSet"); + DefaultContext context = this.getContextBean(); + Set 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 7de255322..798ed4925 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.refreshRule; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 0f77e3e8f..2f5090c96 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 04832a85d..34f70f70d 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.removeChain; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 004ead33f..525d41bb0 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 @@ -3,8 +3,8 @@ package com.yomahub.liteflow.test.resizeSlot; import cn.hutool.core.util.ReflectUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.slot.DataBus; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 d4c334a84..b539678b2 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -37,7 +37,7 @@ 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"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("f==>g==>h==>m", response.getSlot().getExecuteStepStr()); 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 d80f99495..227df88cc 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 @@ -1,10 +1,10 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.MultipleParsersException; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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.getSlot().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 c29b70daf..f5324f056 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 218245fad..f56390faa 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 db9e2c839..70ce5f23c 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().getExecuteStepStr()); } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java index d491de89e..888a33d1e 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java @@ -2,7 +2,6 @@ package com.yomahub.liteflow.test.subflow.cmp2; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.slot.DefaultSlot; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -22,6 +21,6 @@ public class GCmp extends NodeComponent { System.out.println("Gcmp executed!"); - flowExecutor.invoke("chain4", "it's implicit subflow.", DefaultSlot.class, this.getSlotIndex()); + flowExecutor.invoke("chain4", "it's implicit subflow.", this.getSlotIndex()); } } 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 ed8f291ec..1649d2ee2 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.tag; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -33,14 +33,14 @@ public class NodeTagSpringbootJsonTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getSlot().getData("test")); + Assert.assertEquals("123",response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -50,9 +50,9 @@ 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"); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getSlot().getData("test"); + ConcurrentHashSet testSet = response.getContextBean().getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -60,7 +60,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.getSlot().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 256b4773b..f632b20c5 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.tag; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -33,14 +33,14 @@ public class NodeTagSpringbootXmlTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getSlot().getData("test")); + Assert.assertEquals("123",response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -50,9 +50,9 @@ 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"); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getSlot().getData("test"); + ConcurrentHashSet testSet = response.getContextBean().getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -60,7 +60,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.getSlot().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 a9aa4dc6b..c718f989f 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.tag.cmp; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @LiteflowComponent("a") @@ -18,13 +19,13 @@ public class ACmp extends NodeComponent { public void process() { String testKey = "test"; - Slot slot = this.getSlot(); - if (slot.getData(testKey) == null){ - slot.setData(testKey,this.getTag()); + DefaultContext context = this.getContextBean(); + if (context.getData(testKey) == null){ + context.setData(testKey,this.getTag()); }else{ - String s = slot.getData(testKey); + String s = context.getData(testKey); s += this.getTag(); - slot.setData(testKey, s); + context.setData(testKey, s); } } } 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 9f548f6da..9ff1d9149 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 @@ -10,6 +10,7 @@ package com.yomahub.liteflow.test.tag.cmp; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @LiteflowComponent("b1") @@ -17,7 +18,7 @@ public class B1Cmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); - slot.setData("test",new ConcurrentHashSet()); + DefaultContext context = this.getContextBean(); + 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 7faedfc30..05c079554 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 @@ -10,6 +10,7 @@ package com.yomahub.liteflow.test.tag.cmp; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @LiteflowComponent("b") @@ -17,8 +18,8 @@ public class BCmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); - ConcurrentHashSet testSet = slot.getData("test"); + DefaultContext context = this.getContextBean(); + 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 681079806..f397e1fd3 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.useTTLInWhen; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -32,11 +32,11 @@ public class UseTTLInWhenSpringbootTest extends BaseTest { @Test public void testUseTTLInWhen() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("hello,b", response.getSlot().getData("b")); - Assert.assertEquals("hello,c", response.getSlot().getData("c")); - Assert.assertEquals("hello,d", response.getSlot().getData("d")); - Assert.assertEquals("hello,e", response.getSlot().getData("e")); - Assert.assertEquals("hello,f", response.getSlot().getData("f")); + 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")); } } 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 971883f3d..27c917c1a 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -17,7 +18,8 @@ public class BCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",b"); + DefaultContext context = this.getContextBean(); + 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 035232742..a2c404a95 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -17,7 +18,8 @@ public class CCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",c"); + DefaultContext context = this.getContextBean(); + 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 2b9d6d0f3..6419a6666 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -17,7 +18,8 @@ public class DCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",d"); + DefaultContext context = this.getContextBean(); + 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 f5af370f9..c9b97db4f 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -17,7 +18,8 @@ public class ECmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",e"); + DefaultContext context = this.getContextBean(); + 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 4ff062120..0ba2ab4f8 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -17,7 +18,8 @@ public class FCmp extends NodeComponent { @Override public void process() { String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",f"); + DefaultContext context = this.getContextBean(); + 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 6643f386f..179591505 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.WhenTimeoutException; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 e3cafb3eb..1d7a1139f 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 3cefe3c4a..c6fddb4be 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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 107e13710..baec322d2 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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 5eea56f40..68503df70 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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-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 fdf33d80e..93276d87d 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.absoluteConfigPath; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 429090b42..39aa82dd5 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.aop; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -26,20 +26,20 @@ 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"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); + Assert.assertEquals("before_after", response.getContextBean().getData("a")); + Assert.assertEquals("before_after", response.getContextBean().getData("b")); + Assert.assertEquals("before_after", response.getContextBean().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.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); + Assert.assertEquals("before_after", response.getContextBean().getData("a")); + Assert.assertEquals("before_after", response.getContextBean().getData("b")); + Assert.assertEquals("before_after", response.getContextBean().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 2759e8817..bf9a587b9 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.aop; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spring.ComponentScanner; import com.yomahub.liteflow.test.BaseTest; import org.junit.AfterClass; @@ -29,35 +29,35 @@ 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"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("before_after", response.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("d")); - Assert.assertEquals("before_after", response.getSlot().getData("e")); + 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")); } //测试全局AOP,并行场景 @Test public void testGlobalAopP() { - 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.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("d")); - Assert.assertEquals("before_after", response.getSlot().getData("e")); + 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")); } @Test public void testGlobalAopException() { - LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); + LiteflowResponse response= flowExecutor.execute2Resp("chain3", "it's a request"); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals("before_after", response.getSlot().getData("a")); - Assert.assertEquals("before_after", response.getSlot().getData("b")); - Assert.assertEquals("before_after", response.getSlot().getData("c")); - Assert.assertEquals("before_after", response.getSlot().getData("f")); + 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")); } @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 fdb5111b0..d4e4a0f89 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 @@ -2,16 +2,17 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; 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) { - slot.setData(nodeId, "before"); + public void beforeProcess(String nodeId, DefaultContext contextBean) { + contextBean.setData(nodeId, "before"); } @Override - public void afterProcess(String nodeId, Slot slot) { - slot.setData(nodeId, StrUtil.format("{}_{}", slot.getData(nodeId), "after")); + public void afterProcess(String nodeId, DefaultContext contextBean) { + contextBean.setData(nodeId, StrUtil.format("{}_{}", contextBean.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 4ffa13d2f..673e3f7b5 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.aop.aspect; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -18,10 +19,10 @@ public class CustomAspect { @Around("cut()") public Object around(ProceedingJoinPoint jp) throws Throwable { NodeComponent cmp = (NodeComponent) jp.getThis(); - Slot slot = cmp.getSlot(); - slot.setData(cmp.getNodeId(), "before"); + DefaultContext context = cmp.getContextBean(); + context.setData(cmp.getNodeId(), "before"); Object returnObj = jp.proceed(); - slot.setData(cmp.getNodeId(), StrUtil.format("{}_{}", slot.getData(cmp.getNodeId()), "after")); + context.setData(cmp.getNodeId(), StrUtil.format("{}_{}", context.getData(cmp.getNodeId()), "after")); return returnObj; } } 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 670330332..deae82126 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.asyncNode; import cn.hutool.core.collection.ListUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.asyncNode.exception.TestException; import org.junit.Assert; @@ -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.getSlot().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,18 @@ 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"); //因为不记录错误,所以最终结果是true Assert.assertTrue(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //因为配置了不抛错,所以response里的cause应该为null Assert.assertNull(response.getCause()); @@ -79,11 +79,11 @@ 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"); //整个并行组是报错的,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下 - Integer count = response.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //因为第一个when配置了会报错,所以response里的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -92,11 +92,11 @@ 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"); //第一个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); //因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍 - Integer count = response.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(1), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -105,11 +105,11 @@ 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"); //第二个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); // 传递了slotIndex,则set的size==2 - Integer count = response.getSlot().getData("count"); + Integer count = response.getContextBean().getData("count"); Assert.assertEquals(new Integer(2), count); //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); @@ -121,8 +121,8 @@ 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"); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("check").toString().startsWith("habc")); + Assert.assertTrue(response.getContextBean().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 d208505f8..2d362f405 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -9,14 +10,14 @@ import org.springframework.stereotype.Component; public class ACmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Acomp executed!"); 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 3b9d860df..b60ed84db 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -9,14 +10,14 @@ import org.springframework.stereotype.Component; public class BCmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Bcomp executed!"); 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 0059d6fab..fc32acff6 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -9,14 +10,14 @@ import org.springframework.stereotype.Component; public class CCmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Ccomp executed!"); 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 a9c49c951..8918b783b 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -10,14 +11,14 @@ public class DCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(1000); - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Dcomp executed!"); 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 09f470bbd..dc0694664 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -11,14 +12,14 @@ public class GCmp extends NodeComponent { @Override public void process() throws Exception { Thread.sleep(500); - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } System.out.println("Gcomp executed!"); 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 d2bed260f..52dfa5d85 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -10,14 +11,14 @@ public class HCmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); + DefaultContext context = this.getContextBean(); synchronized (NodeComponent.class){ - if (slot.hasData("check")){ - String str = slot.getData("check"); + if (context.hasData("check")){ + String str = context.getData("check"); str += this.getNodeId(); - slot.setData("check", str); + context.setData("check", str); }else{ - slot.setData("check", this.getNodeId()); + context.setData("check", this.getNodeId()); } } 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 09ec9be4d..8c5a76748 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 @@ -1,6 +1,7 @@ package com.yomahub.liteflow.test.asyncNode.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.test.asyncNode.exception.TestException; import org.springframework.stereotype.Component; @@ -11,12 +12,12 @@ public class ICmp extends NodeComponent { @Override public void process() throws Exception { - Slot slot = this.getSlot(); - if (slot.hasData("count")){ - Integer count = slot.getData("count"); - slot.setData("count", ++count); + DefaultContext context = this.getContextBean(); + if (context.hasData("count")){ + Integer count = context.getData("count"); + context.setData("count", ++count); } else{ - slot.setData("count", 1); + context.setData("count", 1); } System.out.println("Icomp executed! throw Exception!"); throw new TestException(); 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 2d3f964a7..25fef41cb 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.base; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 83fe86fa6..f7da0c23a 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 @@ -4,10 +4,10 @@ import com.yomahub.liteflow.builder.LiteFlowChainBuilder; import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.builder.LiteFlowNodeBuilder; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.builder.entity.ExecutableEntity; import com.yomahub.liteflow.enums.NodeTypeEnum; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.builder.cmp1.*; import org.junit.Assert; @@ -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 827ec669c..cc0ec515e 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 @@ -3,8 +3,8 @@ package com.yomahub.liteflow.test.builder; import com.yomahub.liteflow.builder.LiteFlowChainBuilder; import com.yomahub.liteflow.builder.LiteFlowConditionBuilder; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 180d7c6fc..dc99d0b39 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.cmpRetry; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } 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 93d34d7a9..aee920bbd 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.component; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().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 53d94ee45..6dd39c2a0 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.config; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 ef683a2e5..5eb6d3da5 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.config; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().getExecuteStepStr()); - LiteflowResponse response1 = executor.execute2Resp("chain3", "arg"); + LiteflowResponse response1 = executor.execute2Resp("chain3", "arg"); Assert.assertEquals("a==>c==>f==>g", response1.getSlot().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 2c9365590..61e1875ad 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.customNodes; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 ef944b91b..0f0d16224 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.customWhenThreadPool; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -34,9 +34,9 @@ public class CustomWhenThreadPoolSpringTest extends BaseTest { */ @Test public void testGlobalThreadPool() { - LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("threadName").toString().startsWith("lf-when-thead")); + Assert.assertTrue(response.getContextBean().getData("threadName").toString().startsWith("lf-when-thead")); } /** @@ -44,9 +44,9 @@ public class CustomWhenThreadPoolSpringTest extends BaseTest { */ @Test public void testGlobalAndCustomWhenThreadPool() { - LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response1.isSuccess()); - Assert.assertTrue(response1.getSlot().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(response1.getContextBean().getData("threadName").toString().startsWith("customer-when-1-thead")); } @@ -58,9 +58,9 @@ public class CustomWhenThreadPoolSpringTest extends BaseTest { // 使用when - thread1 testGlobalAndCustomWhenThreadPool(); // chain配置同一个thead1 - LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response2.isSuccess()); - Assert.assertTrue(response2.getSlot().getData("threadName").toString().startsWith("customer-when-1-thead")); + Assert.assertTrue(response2.getContextBean().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 69b1a3845..a7af6a490 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("b") @@ -15,7 +16,8 @@ public class BCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 df355c4b6..99144f623 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("c") @@ -15,7 +16,8 @@ public class CCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 a67ec4b9b..4d1c41cc4 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("d") @@ -15,7 +16,8 @@ public class DCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 929e41767..61da5bba5 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("e") @@ -15,7 +16,8 @@ public class ECmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 f4285a637..fe77d3af8 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.customWhenThreadPool.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @Component("f") @@ -15,7 +16,8 @@ public class FCmp extends NodeComponent { @Override public void process() { - this.getSlot().setData("threadName", Thread.currentThread().getName()); + DefaultContext context = this.getContextBean(); + 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 6bdb3aaa5..9b9290d4d 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 @@ -1,10 +1,10 @@ package com.yomahub.liteflow.test.enable; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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/exception/ExceptionSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringTest.java index 25969da68..0113de42f 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/exception/ExceptionSpringTest.java @@ -1,13 +1,13 @@ package com.yomahub.liteflow.test.exception; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.ChainNotFoundException; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.exception.FlowExecutorNotInitException; import com.yomahub.liteflow.exception.FlowSystemException; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -69,7 +69,7 @@ public class ExceptionSpringTest 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 7c83be435..dc501cd45 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.execute2Future; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -27,8 +27,8 @@ public class Executor2FutureSpringTest extends BaseTest { @Test public void testFuture() throws Exception{ - Future> future = flowExecutor.execute2Future("chain1", "arg", DefaultSlot.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/CustomSlot.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/CustomContext.java similarity index 71% rename from liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/CustomSlot.java rename to liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/CustomContext.java index 24a386a90..7af6b2d8b 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/CustomSlot.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/executor/CustomContext.java @@ -1,8 +1,6 @@ package com.yomahub.liteflow.test.executor; -import com.yomahub.liteflow.slot.AbsSlot; - -public class CustomSlot extends AbsSlot { +public class CustomContext { private String name; public String getName() { 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 e797aa7d3..ec613669a 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.Slot; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -21,9 +22,9 @@ 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", CustomSlot.class); + LiteflowResponse response = executor.execute2Resp("chain1", "test0", CustomContext.class); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("custom", response.getSlot().getName()); + Assert.assertEquals("custom", response.getContextBean().getName()); } @Test(expected=RuntimeException.class) @@ -31,7 +32,7 @@ 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", CustomSlot.class); + LiteflowResponse response = executor.execute2Resp("chain1", "test1", CustomContext.class); Assert.assertFalse(response.isSuccess()); ReflectionUtils.rethrowException(response.getCause()); } @@ -41,8 +42,8 @@ public class FlowExecutorTest extends BaseTest { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("executor/flow.json"); FlowExecutor executor = new FlowExecutor(config); - CustomSlot slot = executor.execute("chain1", "test0", CustomSlot.class); - Assert.assertEquals("custom", slot.getName()); + Slot slot = executor.execute("chain1", "test0", CustomContext.class); + Assert.assertEquals("custom", slot.getContextBean().getName()); } @Test(expected=RuntimeException.class) @@ -50,6 +51,6 @@ public class FlowExecutorTest extends BaseTest { LiteflowConfig config = new LiteflowConfig(); config.setRuleSource("executor/flow0.json"); FlowExecutor executor = new FlowExecutor(config); - executor.execute("chain1", "test1", CustomSlot.class); + executor.execute("chain1", "test1", CustomContext.class); } } 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 0325fcb48..4293ef371 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 @@ -9,7 +9,9 @@ package com.yomahub.liteflow.test.executor.cmp; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.test.executor.CustomSlot; +import com.yomahub.liteflow.slot.DefaultContext; +import com.yomahub.liteflow.slot.Slot; +import com.yomahub.liteflow.test.executor.CustomContext; import org.springframework.stereotype.Component; @Component("c") @@ -17,14 +19,16 @@ public class CCmp extends NodeComponent { @Override public void process() { - if(this.getSlot() instanceof CustomSlot) { - CustomSlot slot = this.getSlot(); + Object bean = this.getContextBean(); + if(bean instanceof CustomContext) { + Slot slot = this.getSlot(); + CustomContext context = slot.getContextBean(); String str = slot.getRequestData(); if(StrUtil.isNotBlank(str) && str.equals("test0")) { - slot.setName("custom"); + context.setName("custom"); } if(StrUtil.isNotBlank(str) && str.equals("test1")) { - slot.setName("custom"); + context.setName("custom"); throw new RuntimeException("customException"); } } 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 d945f7fac..b69df9a57 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.flowmeta; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import com.yomahub.liteflow.test.flowmeta.cmp2.DCmp; import org.junit.Assert; @@ -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.getSlot().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 04dece215..a141090d1 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.lazy; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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/liteflowcomponent/LiteflowComponentSpringTest.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringTest.java index db4a02458..d4a7c98d3 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringTest.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/liteflowcomponent/LiteflowComponentSpringTest.java @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.liteflowcomponent; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 a066ca369..5765b8dc6 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.monitor; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.monitor.MonitorBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.spi.holder.ContextAwareHolder; import com.yomahub.liteflow.test.BaseTest; import org.junit.AfterClass; @@ -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 c45137b8c..dd10059cf 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.multipleType; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 4e7423026..a5da9969f 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -11,9 +12,9 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerDefaultNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerDefaultNodeExecutor进行执行"); - slot.setData("customerDefaultNodeExecutor", this.getClass()); + 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 17d5c31be..add288d67 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -11,9 +12,9 @@ import com.yomahub.liteflow.flow.executor.NodeExecutor; public class CustomerNodeExecutor extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerNodeExecutor进行执行"); - slot.setData("customerNodeExecutor", this.getClass()); + 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 1ee6b3f2d..a6eb87d53 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 @@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DataBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import com.yomahub.liteflow.flow.executor.NodeExecutor; @@ -13,17 +14,17 @@ import java.util.concurrent.TimeUnit; public class CustomerNodeExecutorAndCustomRetry extends NodeExecutor { @Override public void execute(NodeComponent instance) throws Exception { - Slot slot = DataBus.getSlot(instance.getSlotIndex()); + DefaultContext context = instance.getContextBean(); LOG.info("使用customerNodeExecutorAndCustomRetry进行执行"); - slot.setData("customerNodeExecutorAndCustomRetry", this.getClass()); + context.setData("customerNodeExecutorAndCustomRetry", this.getClass()); super.execute(instance); } @Override protected void retry(NodeComponent instance, int currentRetryCount) throws Exception { TimeUnit.MICROSECONDS.sleep(20L); - Slot slot = DataBus.getSlot(instance.getSlotIndex()); - slot.setData("retryLogic", this.getClass()); + DefaultContext context = instance.getContextBean(); + 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 89d30fa5a..b2431903f 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.nodeExecutor; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -29,25 +29,25 @@ public class LiteflowNodeExecutorSpringTest extends BaseTest { // 默认执行器测试 @Test public void testCustomerDefaultNodeExecutor() { - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); Assert.assertEquals("a", response.getSlot().getExecuteStepStr()); } //默认执行器测试+全局重试配置测试 @Test public void testDefaultExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor")); + Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getContextBean().getData("customerDefaultNodeExecutor")); Assert.assertEquals("b==>b==>b", response.getSlot().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.getSlot().getExecuteStepStr()); } @@ -55,9 +55,9 @@ public class LiteflowNodeExecutorSpringTest extends BaseTest { //自定义执行器测试+全局重试配置测试 @Test public void testCustomExecutorForRetry() { - LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); Assert.assertFalse(response.isSuccess()); - Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getSlot().getData("retryLogic")); + Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, response.getContextBean().getData("retryLogic")); Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getSlot().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 a6abfb9bb..6c969455b 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.nullParam; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 ebafb9eaa..bfb1049dd 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parsecustom; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 0581ebf58..5c592215c 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 908ef5eba..eb8b4cd1e 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 6f4de293b..1a9e940d8 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 f89df4fdc..06eb320ea 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 727028a09..e0b585d91 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.property.LiteflowConfig; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 86edc7ede..45afcaa37 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.parser; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 fa3f4a18d..33f7bfbf7 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.preAndFinally; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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.getSlot().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.getSlot().getExecuteStepStr()); } @@ -51,8 +51,8 @@ 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"); Assert.assertFalse(response.isSuccess()); - Assert.assertTrue(response.getSlot().getData("hasEx")); + Assert.assertTrue(response.getContextBean().getData("hasEx")); } } 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 b63f8ffb3..183b199af 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.preAndFinally.cmp; import cn.hutool.core.util.ObjectUtil; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import org.springframework.stereotype.Component; @@ -17,11 +18,12 @@ public class Finally3Cmp extends NodeComponent { @Override public void process() throws Exception{ - Slot slot = this.getSlot(); + Slot slot = this.getSlot(); + DefaultContext context = slot.getContextBean(); if (ObjectUtil.isNull(slot.getException())){ - slot.setData("hasEx", false); + context.setData("hasEx", false); }else{ - slot.setData("hasEx", true); + context.setData("hasEx", true); } System.out.println("Finally3Cmp executed!"); } 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 91ea22dac..d74c5c426 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.privateDelivery; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -27,8 +27,8 @@ public class PrivateDeliverySpringTest extends BaseTest { @Test public void testPrivateDelivery() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Set set = response.getSlot().getData("testSet"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Set set = response.getContextBean().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 fb0626b09..ee23b7020 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.privateDelivery.cmp; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; import java.util.HashSet; @@ -19,8 +20,8 @@ public class ACmp extends NodeComponent { @Override public void process() { System.out.println("ACmp executed!"); - Slot slot = getSlot(); - slot.setData("testSet", new HashSet<>()); + DefaultContext context = this.getContextBean(); + context.setData("testSet", new HashSet<>()); for (int i = 0; i < 100; i++) { this.sendPrivateDeliveryData("b",i+1); 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 73bea692c..6bf424a4f 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.privateDelivery.cmp; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import java.util.Set; @@ -18,8 +19,9 @@ public class BCmp extends NodeComponent { @Override public void process() { System.out.println("BCmp executed!"); + DefaultContext context = this.getContextBean(); Integer value = this.getPrivateDeliveryData(); - Set testSet = this.getSlot().getData("testSet"); + Set 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 5eada401f..27061ba2e 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 @@ -2,10 +2,10 @@ package com.yomahub.liteflow.test.refreshRule; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.enums.FlowParserTypeEnum; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 94fc47644..87d14a50c 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.reload; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 7e0ba02e2..06d5e31ae 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.removeChain; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 76d86e455..1f8354608 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 @@ -3,8 +3,8 @@ package com.yomahub.liteflow.test.resizeSlot; import cn.hutool.core.util.ReflectUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.slot.DataBus; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 f4749fc0b..a93da1340 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -31,7 +31,7 @@ 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"); Assert.assertTrue(response.isSuccess()); Assert.assertEquals("f==>g==>h==>m", response.getSlot().getExecuteStepStr()); 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 e8a51fbfe..39c459b8d 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 @@ -1,11 +1,11 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.MultipleParsersException; import com.yomahub.liteflow.property.LiteflowConfig; import com.yomahub.liteflow.property.LiteflowConfigGetter; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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.getSlot().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 352bc995a..cd81249e2 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 3c9552e0f..0f6dc463d 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().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 a7a26dddd..658165c33 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.subflow; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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.getSlot().getExecuteStepStr()); } diff --git a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java index fc9ffe405..c4e9648b9 100644 --- a/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java +++ b/liteflow-testcase-springnative/src/test/java/com/yomahub/liteflow/test/subflow/cmp2/GCmp.java @@ -2,7 +2,6 @@ package com.yomahub.liteflow.test.subflow.cmp2; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.slot.DefaultSlot; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -22,6 +21,6 @@ public class GCmp extends NodeComponent { System.out.println("Gcmp executed!"); - flowExecutor.invoke("chain4", "it's implicit subflow.", DefaultSlot.class, this.getSlotIndex()); + flowExecutor.invoke("chain4", "it's implicit subflow.", this.getSlotIndex()); } } 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 2f7390b66..ce1e908bf 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.tag; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -27,14 +27,14 @@ public class NodeTagSpringJsonTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getSlot().getData("test")); + Assert.assertEquals("123",response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -44,9 +44,9 @@ 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"); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getSlot().getData("test"); + ConcurrentHashSet testSet = response.getContextBean().getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -54,7 +54,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.getSlot().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 787cad0d6..283922255 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.tag; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -27,14 +27,14 @@ public class NodeTagSpringXmlTest extends BaseTest { @Test public void testTag1() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("123",response.getSlot().getData("test")); + Assert.assertEquals("123",response.getContextBean().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.getSlot().getExecuteStepStr()); } @@ -44,9 +44,9 @@ 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"); Assert.assertTrue(response.isSuccess()); - ConcurrentHashSet testSet = response.getSlot().getData("test"); + ConcurrentHashSet testSet = response.getContextBean().getData("test"); Assert.assertEquals(3, testSet.size()); } } @@ -54,7 +54,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.getSlot().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 a9aa4dc6b..76cc7c60c 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 @@ -9,6 +9,7 @@ package com.yomahub.liteflow.test.tag.cmp; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @LiteflowComponent("a") @@ -17,14 +18,13 @@ public class ACmp extends NodeComponent { @Override public void process() { String testKey = "test"; - - Slot slot = this.getSlot(); - if (slot.getData(testKey) == null){ - slot.setData(testKey,this.getTag()); + DefaultContext context = this.getContextBean(); + if (context.getData(testKey) == null){ + context.setData(testKey,this.getTag()); }else{ - String s = slot.getData(testKey); + String s = context.getData(testKey); s += this.getTag(); - slot.setData(testKey, s); + context.setData(testKey, s); } } } 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 9f548f6da..9ff1d9149 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 @@ -10,6 +10,7 @@ package com.yomahub.liteflow.test.tag.cmp; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @LiteflowComponent("b1") @@ -17,7 +18,7 @@ public class B1Cmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); - slot.setData("test",new ConcurrentHashSet()); + DefaultContext context = this.getContextBean(); + 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 7faedfc30..05c079554 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 @@ -10,6 +10,7 @@ package com.yomahub.liteflow.test.tag.cmp; import cn.hutool.core.collection.ConcurrentHashSet; import com.yomahub.liteflow.annotation.LiteflowComponent; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.slot.Slot; @LiteflowComponent("b") @@ -17,8 +18,8 @@ public class BCmp extends NodeComponent { @Override public void process() { - Slot slot = this.getSlot(); - ConcurrentHashSet testSet = slot.getData("test"); + DefaultContext context = this.getContextBean(); + 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 c64d2bc39..7ce4bd01a 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.useTTLInWhen; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -26,11 +26,11 @@ public class UseTTLInWhenSpringTest extends BaseTest { @Test public void testUseTTLInWhen() throws Exception{ - LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); - Assert.assertEquals("hello,b", response.getSlot().getData("b")); - Assert.assertEquals("hello,c", response.getSlot().getData("c")); - Assert.assertEquals("hello,d", response.getSlot().getData("d")); - Assert.assertEquals("hello,e", response.getSlot().getData("e")); - Assert.assertEquals("hello,f", response.getSlot().getData("f")); + 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")); } } 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 971883f3d..d0e75faaa 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -16,8 +17,9 @@ public class BCmp extends NodeComponent { @Override public void process() { + DefaultContext context = this.getContextBean(); String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",b"); + 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 035232742..1701d495f 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -16,8 +17,9 @@ public class CCmp extends NodeComponent { @Override public void process() { + DefaultContext context = this.getContextBean(); String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",c"); + 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 2b9d6d0f3..6f1dace0f 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -16,8 +17,9 @@ public class DCmp extends NodeComponent { @Override public void process() { + DefaultContext context = this.getContextBean(); String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",d"); + 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 f5af370f9..91b37255b 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -16,8 +17,9 @@ public class ECmp extends NodeComponent { @Override public void process() { + DefaultContext context = this.getContextBean(); String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",e"); + 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 4ff062120..9c4e4ae3a 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 @@ -8,6 +8,7 @@ package com.yomahub.liteflow.test.useTTLInWhen.cmp; import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.useTTLInWhen.TestTL; import org.springframework.stereotype.Component; @@ -16,8 +17,9 @@ public class FCmp extends NodeComponent { @Override public void process() { + DefaultContext context = this.getContextBean(); String value = TestTL.get(); - this.getSlot().setData(this.getNodeId(),value+",f"); + 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 52e34c554..93f390538 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 @@ -1,9 +1,9 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; import com.yomahub.liteflow.exception.WhenTimeoutException; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; @@ -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 84674aeef..2a84931d4 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 @@ -1,8 +1,8 @@ package com.yomahub.liteflow.test.whenTimeOut; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; 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; @@ -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 40bced95a..da28be002 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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.getSlot().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 949c2dec3..4126a419c 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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.getSlot().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 48a560171..3e4aa04d3 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 @@ -2,8 +2,8 @@ package com.yomahub.liteflow.test.zookeeper; import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.slot.DefaultSlot; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.slot.DefaultContext; import com.yomahub.liteflow.test.BaseTest; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.exception.ZkMarshallingError; @@ -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.getSlot().getExecuteStepStr()); }