feature #I4CRSY 在一个流程中的同名组件无法传递不同的参数

This commit is contained in:
bryan31
2021-10-12 18:58:12 +08:00
parent 00c8ffb600
commit 0600100029
18 changed files with 356 additions and 59 deletions

View File

@@ -0,0 +1,47 @@
package com.yomahub.liteflow.test.tag;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.entity.data.DefaultSlot;
import com.yomahub.liteflow.entity.data.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Set;
/**
* springboot环境下隐私投递的测试
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@TestPropertySource(value = "classpath:/tag/application.properties")
@SpringBootTest(classes = NodeTagSpringbootTest.class)
@EnableAutoConfiguration
@ComponentScan({"com.yomahub.liteflow.test.tag.cmp"})
public class NodeTagSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
@Test
public void testTag1() throws Exception{
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("123",response.getSlot().getData("test"));
}
@Test
public void testTag2() throws Exception{
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>a==>a==>c==>e", response.getSlot().printStep());
}
}

View File

@@ -0,0 +1,32 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.tag.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.entity.data.Slot;
import java.util.HashSet;
@LiteflowComponent("a")
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());
}else{
String s = slot.getData(testKey);
s += this.getTag();
slot.setData(testKey, s);
}
}
}

View File

@@ -0,0 +1,22 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.tag.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import java.util.Set;
@LiteflowComponent("b")
public class BCmp extends NodeComponent {
@Override
public void process() {
System.out.println(this.getTag());
}
}

View File

@@ -0,0 +1,25 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.tag.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.core.NodeCondComponent;
@LiteflowComponent("c")
public class CCmp extends NodeCondComponent {
@Override
public String processCond() throws Exception {
if(this.getTag().equals("2")){
return "e";
}else{
return "d";
}
}
}

View File

@@ -0,0 +1,21 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.tag.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("d")
public class DCmp extends NodeComponent {
@Override
public void process() {
System.out.println(this.getTag());
System.out.println("DCmp executed!");
}
}

View File

@@ -0,0 +1,21 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.tag.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
@LiteflowComponent("e")
public class ECmp extends NodeComponent {
@Override
public void process() {
System.out.println(this.getTag());
System.out.println("ECmp executed!");
}
}

View File

@@ -0,0 +1 @@
liteflow.rule-source=tag/flow.xml

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
<then value="a[1],a[2],a[3]"/>
</chain>
<chain name="chain2">
<then value="a[1],a[2],a[3],c[2](d[5]|e[6])"/>
</chain>
</flow>