From 3bdbab8acefaa26525b7513c2bc57bd4868462ba Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Mon, 10 Feb 2025 17:29:09 +0800 Subject: [PATCH] =?UTF-8?q?feature=20#IBL9CK=20=E5=A2=9E=E5=8A=A0bind?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=EF=BC=8C=E8=83=BD=E5=A4=9F=E5=9C=A8?= =?UTF-8?q?=E4=BB=BB=E4=BD=95=E5=9C=B0=E6=96=B9bind=20key=E5=92=8Cvalue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/bindData/BindDataSpringbootTest.java | 11 +++++++++++ .../yomahub/liteflow/test/bindData/cmp/ACmp.java | 5 ++++- .../yomahub/liteflow/test/bindData/cmp/CCmp.java | 5 ++++- .../yomahub/liteflow/test/bindData/cmp/DCmp.java | 6 +++++- .../src/test/resources/bindData/flow.el.xml | 14 +++++++++++--- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/BindDataSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/BindDataSpringbootTest.java index 3d35ce786..fb22daec7 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/BindDataSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/BindDataSpringbootTest.java @@ -60,4 +60,15 @@ public class BindDataSpringbootTest extends BaseTest { Assertions.assertEquals("test", context.getData("y")); Assertions.assertTrue(response.isSuccess()); } + + // 测试bind关键字,对一个chain进行bind + @Test + public void testBind4() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + DefaultContext context = response.getFirstContextBean(); + Assertions.assertEquals("test2", context.getData("a")); + Assertions.assertEquals("test2", context.getData("x")); + Assertions.assertEquals("test2", context.getData("c")); + Assertions.assertTrue(response.isSuccess()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/ACmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/ACmp.java index fa717d8eb..57e07216f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/ACmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/ACmp.java @@ -7,6 +7,7 @@ */ package com.yomahub.liteflow.test.bindData.cmp; +import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @@ -18,6 +19,8 @@ public class ACmp extends NodeComponent { public void process() { DefaultContext context = this.getFirstContextBean(); String bindValue = this.getBindData("k1", String.class); - context.setData(this.getNodeId(), bindValue); + if (StrUtil.isNotBlank(bindValue)) { + context.setData(this.getNodeId(), bindValue); + } } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/CCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/CCmp.java index 6a5acc038..8488ecad2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/CCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/CCmp.java @@ -7,6 +7,7 @@ */ package com.yomahub.liteflow.test.bindData.cmp; +import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @@ -18,7 +19,9 @@ public class CCmp extends NodeComponent { public void process() { DefaultContext context = this.getFirstContextBean(); String bindValue = this.getBindData("k1", String.class); - context.setData(this.getNodeId(), bindValue); + if (StrUtil.isNotBlank(bindValue)) { + context.setData(this.getNodeId(), bindValue); + } } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/DCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/DCmp.java index 101822f8d..b169cea40 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/DCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/bindData/cmp/DCmp.java @@ -7,6 +7,7 @@ */ package com.yomahub.liteflow.test.bindData.cmp; +import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.core.NodeComponent; import com.yomahub.liteflow.slot.DefaultContext; import org.springframework.stereotype.Component; @@ -18,7 +19,10 @@ public class DCmp extends NodeComponent { public void process() { DefaultContext context = this.getFirstContextBean(); String bindValue = this.getBindData("k1", String.class); - context.setData(this.getNodeId(), bindValue); + if (StrUtil.isNotBlank(bindValue)) { + context.setData(this.getNodeId(), bindValue); + } + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/bindData/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/bindData/flow.el.xml index 11d126201..0aeacf067 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/bindData/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/bindData/flow.el.xml @@ -1,15 +1,23 @@ - + THEN(a.bind("k1", "test"), b); - + THEN(a,b).bind("k1","test"); - + THEN(SWITCH(y).TO(d,c), WHEN(a, b), IF(x, c, d)).bind("k1", "test") + + + THEN(a,IF(NOT(x), b, c)); + + + + THEN(d, sub.bind("k1", "test2")) + \ No newline at end of file