补充测试用例

This commit is contained in:
bryan31
2022-03-05 21:50:27 +08:00
parent b7aed717d8
commit ccabf0ce02
6 changed files with 116 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package com.yomahub.liteflow.test.multipleType;
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;
/**
* 测试springboot下混合格式规则的场景
* @author Bryan.Zhang
* @since 2.5.10
*/
public class LiteflowMultipleTypeTest extends BaseTest {
private static FlowExecutor flowExecutor;
@BeforeClass
public static void init(){
LiteflowConfig config = new LiteflowConfig();
config.setRuleSource("multipleType/flow.xml,multipleType/flow.yml");
config.setSupportMultipleType(true);
flowExecutor = FlowExecutor.loadInstance(config);
}
@Test
public void testConfig() {
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c==>b==>a", response.getSlot().getExecuteStepStr());
response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c", response.getSlot().getExecuteStepStr());
}
}

View File

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

View File

@@ -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.multipleType.cmp;
import com.yomahub.liteflow.core.NodeComponent;
public class BCmp extends NodeComponent {
@Override
public void process() {
System.out.println("BCmp executed!");
}
}

View File

@@ -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.multipleType.cmp;
import com.yomahub.liteflow.core.NodeComponent;
public class CCmp extends NodeComponent {
@Override
public void process() {
System.out.println("CCmp executed!");
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<nodes>
<node id="a" class="com.yomahub.liteflow.test.multipleType.cmp.ACmp"/>
<node id="b" class="com.yomahub.liteflow.test.multipleType.cmp.BCmp"/>
<node id="c" class="com.yomahub.liteflow.test.multipleType.cmp.CCmp"/>
</nodes>
<chain name="chain1">
<then value="a,b,chain2"/>
</chain>
<chain name="chain2">
<then value="c,b,a"/>
</chain>
</flow>

View File

@@ -0,0 +1,6 @@
flow:
chain:
- name: chain3
condition:
- type: then
value: 'a,b,c'