Merge branch 'dev' of https://gitee.com/dromara/liteFlow into dev
This commit is contained in:
commit
d912ddcfe5
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public class LOGOPrinter {
|
|||
/**
|
||||
* LiteFlow 当前版本号
|
||||
*/
|
||||
private static final String VERSION_NO = "v2.8.1";
|
||||
private static final String VERSION_NO = "v2.8.2";
|
||||
|
||||
public static void print() {
|
||||
StringBuilder str = new StringBuilder("\n");
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.yomahub.liteflow.test;
|
||||
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
|
|
|
@ -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>
|
|
@ -2,7 +2,6 @@ package com.yomahub.liteflow.test;
|
|||
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.thread.ExecutorHelper;
|
||||
|
|
|
@ -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>
|
|
@ -1,7 +1,6 @@
|
|||
package com.yomahub.liteflow.test;
|
||||
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.yomahub.liteflow.test;
|
||||
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.yomahub.liteflow.test;
|
||||
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
|
|
|
@ -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());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package com.yomahub.liteflow.test.switchError;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.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;
|
||||
|
||||
/**
|
||||
* springboot环境EL常规的例子测试
|
||||
* @author Bryan.Zhang
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/switchError/application.properties")
|
||||
@SpringBootTest(classes = SwitchELSpringbootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.switchError.cmp"})
|
||||
public class SwitchELSpringbootTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//2022-07-12 switch 异常错误.c.y.l.builder.el.operator.ToOperator : parameter error
|
||||
//run QlExpress Exception at line 1 :
|
||||
// switch().to(): 只有一个node时出错
|
||||
@Test
|
||||
public void testSwitchError() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.switchError.cmp;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("a")
|
||||
public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("ACmp executed!");
|
||||
}
|
||||
}
|
|
@ -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.switchError.cmp;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("b")
|
||||
public class BCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("BCmp executed!");
|
||||
}
|
||||
|
||||
}
|
|
@ -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.switchError.cmp;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("c")
|
||||
public class CCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("CCmp executed!");
|
||||
}
|
||||
|
||||
}
|
|
@ -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.switchError.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("DCmp executed!");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author Bryan.Zhang
|
||||
* @email weenyc31@163.com
|
||||
* @Date 2020/4/1
|
||||
*/
|
||||
package com.yomahub.liteflow.test.switchError.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeSwitchComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("e")
|
||||
public class ESwitchCmp extends NodeSwitchComponent {
|
||||
|
||||
@Override
|
||||
public String processSwitch() throws Exception {
|
||||
return "d";
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -0,0 +1 @@
|
|||
liteflow.rule-source=switchError/flow.el.xml
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(e).to(d),
|
||||
b
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
|
@ -1,7 +1,6 @@
|
|||
package com.yomahub.liteflow.test;
|
||||
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
|
|
|
@ -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>
|
|
@ -1,7 +1,6 @@
|
|||
package com.yomahub.liteflow.test;
|
||||
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.yomahub.liteflow.test;
|
|||
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.thread.ExecutorHelper;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.yomahub.liteflow.test;
|
||||
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.yomahub.liteflow.test;
|
||||
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
|
||||
import com.yomahub.liteflow.spring.ComponentScanner;
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -39,7 +39,7 @@
|
|||
</scm>
|
||||
|
||||
<properties>
|
||||
<revision>2.8.1</revision>
|
||||
<revision>2.8.2</revision>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
|
Loading…
Reference in New Issue