mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-06-13 11:14:38 +08:00
单元测试-分类归纳
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package com.yomahub.liteflow.test.parsecustom;
|
||||
|
||||
import com.yomahub.liteflow.parser.ClassJsonFlowParser;
|
||||
|
||||
/**
|
||||
* 模拟用户自定义源解析
|
||||
* @author dongguo.tao
|
||||
* @date 2021/4/7
|
||||
*/
|
||||
public class CustomJsonFlowParser extends ClassJsonFlowParser {
|
||||
@Override
|
||||
public String parseCustom() {
|
||||
//模拟自定义解析结果
|
||||
String content = "{\"flow\":{\"nodes\":{\"node\":[{\"id\":\"a\",\"class\":\"com.yomahub.liteflow.test.parsecustom.cmp.ACmp\"},{\"id\":\"b\",\"class\":\"com.yomahub.liteflow.test.parsecustom.cmp.BCmp\"},{\"id\":\"c\",\"class\":\"com.yomahub.liteflow.test.parsecustom.cmp.CCmp\"},{\"id\":\"d\",\"class\":\"com.yomahub.liteflow.test.parsecustom.cmp.DCmp\"},{\"id\":\"e\",\"class\":\"com.yomahub.liteflow.test.parsecustom.cmp.ECmp\"},{\"id\":\"f\",\"class\":\"com.yomahub.liteflow.test.parsecustom.cmp.FCmp\"},{\"id\":\"g\",\"class\":\"com.yomahub.liteflow.test.parsecustom.cmp.GCmp\"}]},\"chain\":[{\"name\":\"chain2\",\"condition\":[{\"type\":\"then\",\"value\":\"c,g,f\"}]},{\"name\":\"chain1\",\"condition\":[{\"type\":\"then\",\"value\":\"a,c\"},{\"type\":\"when\",\"value\":\"b,d,e(f|g)\"},{\"type\":\"then\",\"value\":\"chain2\"}]}]}}";
|
||||
return content;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class CustomParserJsonSpringTest extends BaseTest {
|
||||
|
||||
//测试spring场景的自定义json parser
|
||||
@Test
|
||||
public void testSpringboot() throws Exception{
|
||||
public void testSpringCustomParser() throws Exception{
|
||||
LiteflowResponse<Slot> response = flowExecutor.execute("chain1", "args");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author dongguo.tao
|
||||
* @email taodongguo@foxmail.com
|
||||
* @Date 2020/4/7
|
||||
*/
|
||||
package com.yomahub.liteflow.test.parsecustom.cmp;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.exception.FlowSystemException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("a")
|
||||
public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
String str = this.getSlot().getRequestData();
|
||||
if(StrUtil.isNotBlank(str) && str.equals("exception")) {
|
||||
throw new FlowSystemException("chain execute execption");
|
||||
}
|
||||
System.out.println("ACmp executed!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author dongguo.tao
|
||||
* @email taodongguo@foxmail.com
|
||||
* @Date 2020/4/7
|
||||
*/
|
||||
package com.yomahub.liteflow.test.parsecustom.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!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author dongguo.tao
|
||||
* @email taodongguo@foxmail.com
|
||||
* @Date 2020/4/7
|
||||
*/
|
||||
package com.yomahub.liteflow.test.parsecustom.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("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 dongguo.tao
|
||||
* @email taodongguo@foxmail.com
|
||||
* @Date 2020/4/7
|
||||
*/
|
||||
package com.yomahub.liteflow.test.parsecustom.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("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 dongguo.tao
|
||||
* @email taodongguo@foxmail.com
|
||||
* @Date 2020/4/7
|
||||
*/
|
||||
package com.yomahub.liteflow.test.parsecustom.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeCondComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("e")
|
||||
public class ECmp extends NodeCondComponent {
|
||||
|
||||
@Override
|
||||
public String processCond() throws Exception {
|
||||
return "g";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author dongguo.tao
|
||||
* @email taodongguo@foxmail.com
|
||||
* @Date 2020/4/7
|
||||
*/
|
||||
package com.yomahub.liteflow.test.parsecustom.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("f")
|
||||
public class FCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("FCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @author dongguo.tao
|
||||
* @email taodongguo@foxmail.com
|
||||
* @Date 2020/4/7
|
||||
*/
|
||||
package com.yomahub.liteflow.test.parsecustom.cmp;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("g")
|
||||
public class GCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("GCmp executed!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,11 +18,4 @@
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
|
||||
<!-- <bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">-->
|
||||
<!-- <property name="rulePath">-->
|
||||
<!-- <list>-->
|
||||
<!-- <value>com.yomahub.liteflow.test.parsecustom.CustomJsonFlowParser</value>-->
|
||||
<!-- </list>-->
|
||||
<!-- </property>-->
|
||||
<!-- </bean>-->
|
||||
</beans>
|
||||
Reference in New Issue
Block a user