mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-24 09:48:09 +08:00
补充测试用例
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
package com.yomahub.liteflow.test.privateDelivery;
|
||||||
|
|
||||||
|
import com.yomahub.liteflow.core.FlowExecutor;
|
||||||
|
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||||
|
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||||
|
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.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 非spring环境下隐私投递的测试
|
||||||
|
* @author Bryan.Zhang
|
||||||
|
* @since 2.5.0
|
||||||
|
*/
|
||||||
|
public class PrivateDeliveryTest extends BaseTest {
|
||||||
|
|
||||||
|
private static FlowExecutor flowExecutor;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void init(){
|
||||||
|
LiteflowConfig config = new LiteflowConfig();
|
||||||
|
config.setRuleSource("privateDelivery/flow.xml");
|
||||||
|
flowExecutor = FlowExecutor.loadInstance(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPrivateDelivery() throws Exception{
|
||||||
|
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||||
|
Set<Integer> set = response.getSlot().getData("testSet");
|
||||||
|
Assert.assertTrue(response.isSuccess());
|
||||||
|
Assert.assertEquals(100, set.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* <p>Title: liteflow</p>
|
||||||
|
* <p>Description: 轻量级的组件式流程框架</p>
|
||||||
|
* @author Bryan.Zhang
|
||||||
|
* @email weenyc31@163.com
|
||||||
|
* @Date 2020/4/1
|
||||||
|
*/
|
||||||
|
package com.yomahub.liteflow.test.privateDelivery.cmp;
|
||||||
|
|
||||||
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
|
import com.yomahub.liteflow.entity.data.Slot;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class ACmp extends NodeComponent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process() {
|
||||||
|
System.out.println("ACmp executed!");
|
||||||
|
Slot slot = getSlot();
|
||||||
|
slot.setData("testSet", new HashSet<>());
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
this.sendPrivateDeliveryData("b",i+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* <p>Title: liteflow</p>
|
||||||
|
* <p>Description: 轻量级的组件式流程框架</p>
|
||||||
|
* @author Bryan.Zhang
|
||||||
|
* @email weenyc31@163.com
|
||||||
|
* @Date 2020/4/1
|
||||||
|
*/
|
||||||
|
package com.yomahub.liteflow.test.privateDelivery.cmp;
|
||||||
|
|
||||||
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class BCmp extends NodeComponent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process() {
|
||||||
|
System.out.println("BCmp executed!");
|
||||||
|
Integer value = this.getPrivateDeliveryData();
|
||||||
|
Set<Integer> testSet = this.getSlot().getData("testSet");
|
||||||
|
testSet.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* <p>Title: liteflow</p>
|
||||||
|
* <p>Description: 轻量级的组件式流程框架</p>
|
||||||
|
* @author Bryan.Zhang
|
||||||
|
* @email weenyc31@163.com
|
||||||
|
* @Date 2020/4/1
|
||||||
|
*/
|
||||||
|
package com.yomahub.liteflow.test.privateDelivery.cmp;
|
||||||
|
|
||||||
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
|
|
||||||
|
public class CCmp extends NodeComponent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process() {
|
||||||
|
System.out.println("CCmp executed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* <p>Title: liteflow</p>
|
||||||
|
* <p>Description: 轻量级的组件式流程框架</p>
|
||||||
|
* @author Bryan.Zhang
|
||||||
|
* @email weenyc31@163.com
|
||||||
|
* @Date 2020/4/1
|
||||||
|
*/
|
||||||
|
package com.yomahub.liteflow.test.privateDelivery.cmp;
|
||||||
|
|
||||||
|
import com.yomahub.liteflow.core.NodeComponent;
|
||||||
|
|
||||||
|
public class DCmp extends NodeComponent {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process() {
|
||||||
|
System.out.println("CCmp executed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<flow>
|
||||||
|
<nodes>
|
||||||
|
<node id="a" class="com.yomahub.liteflow.test.privateDelivery.cmp.ACmp"/>
|
||||||
|
<node id="b" class="com.yomahub.liteflow.test.privateDelivery.cmp.BCmp"/>
|
||||||
|
<node id="c" class="com.yomahub.liteflow.test.privateDelivery.cmp.CCmp"/>
|
||||||
|
<node id="d" class="com.yomahub.liteflow.test.privateDelivery.cmp.DCmp"/>
|
||||||
|
</nodes>
|
||||||
|
|
||||||
|
<chain name="chain1">
|
||||||
|
<then value="a"/>
|
||||||
|
<!-- 100个b组件并发 -->
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<when value="b,b,b,b,b,b,b,b,b,b"/>
|
||||||
|
<then value="c"/>
|
||||||
|
</chain>
|
||||||
|
</flow>
|
||||||
Reference in New Issue
Block a user