mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
enhancement #I5GD1G 在CmpStep中增加tag的属性
This commit is contained in:
@@ -76,6 +76,7 @@ public abstract class NodeComponent{
|
||||
|
||||
//在元数据里加入step信息
|
||||
CmpStep cmpStep = new CmpStep(nodeId, name, CmpStepTypeEnum.SINGLE);
|
||||
cmpStep.setTag(tagTL.get());
|
||||
slot.addStep(cmpStep);
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
@@ -22,6 +22,8 @@ public class CmpStep {
|
||||
|
||||
private String nodeName;
|
||||
|
||||
private String tag;
|
||||
|
||||
private CmpStepTypeEnum stepType;
|
||||
|
||||
//消耗的时间,毫秒为单位
|
||||
@@ -138,4 +140,12 @@ public class CmpStep {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.cmpStep;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -13,6 +14,10 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* springboot环境最普通的例子测试
|
||||
@@ -48,4 +53,22 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStep3() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Map<String, CmpStep> stepMap = response.getExecuteSteps();
|
||||
Assert.assertEquals(2, stepMap.size());
|
||||
Queue<CmpStep> queue = response.getExecuteStepQueue();
|
||||
Assert.assertEquals(5, queue.size());
|
||||
|
||||
Set<String> tagSet = new HashSet<>();
|
||||
response.getExecuteStepQueue().stream().filter(
|
||||
cmpStep -> cmpStep.getNodeId().equals("a")
|
||||
).forEach(cmpStep -> tagSet.add(cmpStep.getTag()));
|
||||
|
||||
Assert.assertEquals(3, tagSet.size());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
THEN(a, b, WHEN(c, d));
|
||||
THEN(a.tag("A"), b.tag("B"), WHEN(c.tag("C"), d.tag("D")));
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
THEN(WHEN(e, a).any(true), b);
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
THEN(a.tag("a1"), b, a.tag("a2"), a.tag("a3"), b);
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -3,12 +3,18 @@ package com.yomahub.liteflow.test.cmpStep;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
public class CmpStepTest extends BaseTest{
|
||||
|
||||
private static FlowExecutor flowExecutor;
|
||||
@@ -39,4 +45,22 @@ public class CmpStepTest extends BaseTest{
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStep3() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Map<String, CmpStep> stepMap = response.getExecuteSteps();
|
||||
Assert.assertEquals(2, stepMap.size());
|
||||
Queue<CmpStep> queue = response.getExecuteStepQueue();
|
||||
Assert.assertEquals(5, queue.size());
|
||||
|
||||
Set<String> tagSet = new HashSet<>();
|
||||
response.getExecuteStepQueue().stream().filter(
|
||||
cmpStep -> cmpStep.getNodeId().equals("a")
|
||||
).forEach(cmpStep -> tagSet.add(cmpStep.getTag()));
|
||||
|
||||
Assert.assertEquals(3, tagSet.size());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,14 @@
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
THEN(a, b, WHEN(c, d));
|
||||
THEN(a.tag("A"), b.tag("B"), WHEN(c.tag("C"), d.tag("D")));
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
THEN(WHEN(e, a).any(true), b);
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
THEN(a.tag("a1"), b, a.tag("a2"), a.tag("a3"), b);
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -14,8 +14,12 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* springboot环境step的测试例子
|
||||
@@ -62,6 +66,14 @@ public class CmpStepELSpringbootTest extends BaseTest {
|
||||
Assert.assertEquals(2, stepMap.size());
|
||||
Queue<CmpStep> queue = response.getExecuteStepQueue();
|
||||
Assert.assertEquals(5, queue.size());
|
||||
|
||||
Set<String> tagSet = new HashSet<>();
|
||||
response.getExecuteStepQueue().stream().filter(
|
||||
cmpStep -> cmpStep.getNodeId().equals("a")
|
||||
).forEach(cmpStep -> tagSet.add(cmpStep.getTag()));
|
||||
|
||||
Assert.assertEquals(3, tagSet.size());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
THEN(a, b, WHEN(c, d));
|
||||
THEN(a.tag("A"), b.tag("B"), WHEN(c.tag("C"), d.tag("D")));
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
@@ -9,6 +9,6 @@
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
THEN(a, b, a, a, b);
|
||||
THEN(a.tag("a1"), b, a.tag("a2"), a.tag("a3"), b);
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.cmpStep;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -10,6 +11,10 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration("classpath:/cmpStep/application.xml")
|
||||
@@ -37,4 +42,22 @@ public class CmpStepELSpringTest extends BaseTest {
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStep3() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Map<String, CmpStep> stepMap = response.getExecuteSteps();
|
||||
Assert.assertEquals(2, stepMap.size());
|
||||
Queue<CmpStep> queue = response.getExecuteStepQueue();
|
||||
Assert.assertEquals(5, queue.size());
|
||||
|
||||
Set<String> tagSet = new HashSet<>();
|
||||
response.getExecuteStepQueue().stream().filter(
|
||||
cmpStep -> cmpStep.getNodeId().equals("a")
|
||||
).forEach(cmpStep -> tagSet.add(cmpStep.getTag()));
|
||||
|
||||
Assert.assertEquals(3, tagSet.size());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
THEN(a, b, WHEN(c, d));
|
||||
THEN(a.tag("A"), b.tag("B"), WHEN(c.tag("C"), d.tag("D")));
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
THEN(WHEN(e, a).any(true), b);
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
THEN(a.tag("a1"), b, a.tag("a2"), a.tag("a3"), b);
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user