去除不需要的测试用例

This commit is contained in:
everywhere.z
2022-09-24 17:00:45 +08:00
parent 7c6c0bb024
commit e56c4f2717
6 changed files with 0 additions and 183 deletions

View File

@@ -1,13 +0,0 @@
package com.yomahub.liteflow.test.executor;
public class CustomContext {
private String name;
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
}

View File

@@ -1,63 +0,0 @@
package com.yomahub.liteflow.test.executor;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.slot.Slot;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.util.ReflectionUtils;
/**
* 无spring环境下FlowExecutor
* 调用方法execute、invoke单元测试
* @author zendwang
* @since 2.5.1
*/
public class FlowExecutorTest extends BaseTest {
@Test
public void testMethodExecute2Resp() {
LiteflowConfig config = new LiteflowConfig();
config.setRuleSource("executor/flow.json");
FlowExecutor executor = new FlowExecutor(config);
LiteflowResponse response = executor.execute2Resp("chain1", "test0", CustomContext.class);
CustomContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("custom", context.getName());
}
@Test(expected=RuntimeException.class)
public void testMethodExecute2RespWithException() throws Exception{
LiteflowConfig config = new LiteflowConfig();
config.setRuleSource("executor/flow0.json");
FlowExecutor executor = new FlowExecutor(config);
LiteflowResponse response = executor.execute2Resp("chain1", "test1", CustomContext.class);
CustomContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
ReflectionUtils.rethrowException(response.getCause());
}
@Test
public void testMethodExecute() throws Exception {
LiteflowConfig config = new LiteflowConfig();
config.setRuleSource("executor/flow.json");
FlowExecutor executor = new FlowExecutor(config);
LiteflowResponse response = executor.execute2Resp("chain1", "test0", CustomContext.class);
CustomContext context = response.getFirstContextBean();
Assert.assertEquals("custom", context.getName());
}
@Test(expected=RuntimeException.class)
public void testMethodExecuteWithException() throws Exception {
LiteflowConfig config = new LiteflowConfig();
config.setRuleSource("executor/flow0.json");
FlowExecutor executor = new FlowExecutor(config);
LiteflowResponse response = executor.execute2Resp("chain1", "test1", CustomContext.class);
if(!response.isSuccess()){
throw response.getCause();
}
}
}

View File

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

View File

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

View File

@@ -1,38 +0,0 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.executor.cmp;
import cn.hutool.core.util.StrUtil;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.slot.Slot;
import com.yomahub.liteflow.test.executor.CustomContext;
import org.springframework.stereotype.Component;
@Component("c")
public class CCmp extends NodeComponent {
@Override
public void process() {
Object bean = this.getFirstContextBean();
if(bean instanceof CustomContext) {
Slot slot = this.getSlot();
CustomContext context = slot.getFirstContextBean();
String str = slot.getRequestData();
if(StrUtil.isNotBlank(str) && str.equals("test0")) {
context.setName("custom");
}
if(StrUtil.isNotBlank(str) && str.equals("test1")) {
context.setName("custom");
throw new RuntimeException("customException");
}
}
System.out.println("CCmp executed!");
}
}

View File

@@ -1,28 +0,0 @@
{
"flow": {
"nodes": {
"node": [
{
"id": "a",
"class": "com.yomahub.liteflow.test.executor.cmp.ACmp"
},
{
"id": "b",
"class": "com.yomahub.liteflow.test.executor.cmp.BCmp"
},
{
"id": "c",
"class": "com.yomahub.liteflow.test.executor.cmp.CCmp"
}
]
},
"chain": [
{
"name": "chain1",
"condition": [
{"type": "then", "value": "a,b,c"}
]
}
]
}
}