mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-06-10 03:07:32 +08:00
feature #IBL9CK 增加bind关键字,能够在任何地方bind key和value
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE flow PUBLIC "liteflow" "liteflow.dtd">
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<chain id="chain1">
|
||||
THEN(a.bind("k1", "test"), b);
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
<chain id="chain2">
|
||||
THEN(a,b).bind("k1","test");
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
<chain id="chain3">
|
||||
THEN(SWITCH(y).TO(d,c), WHEN(a, b), IF(x, c, d)).bind("k1", "test")
|
||||
</chain>
|
||||
|
||||
<chain id="sub">
|
||||
THEN(a,IF(NOT(x), b, c));
|
||||
</chain>
|
||||
|
||||
<chain id="chain4">
|
||||
THEN(d, sub.bind("k1", "test2"))
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user