diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomJsonFlowParser.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomJsonFlowParser.java new file mode 100644 index 000000000..a08e8cf98 --- /dev/null +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomJsonFlowParser.java @@ -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; + } +} diff --git a/liteflow-spring-boot-starter/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java similarity index 94% rename from liteflow-spring-boot-starter/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java rename to liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java index f08974c1e..8db731961 100644 --- a/liteflow-spring-boot-starter/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/CustomParserJsonSpringTest.java @@ -26,7 +26,7 @@ public class CustomParserJsonSpringTest extends BaseTest { //测试spring场景的自定义json parser @Test - public void testSpringboot() throws Exception{ + public void testSpringCustomParser() throws Exception{ LiteflowResponse response = flowExecutor.execute("chain1", "args"); Assert.assertTrue(response.isSuccess()); } diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/ACmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/ACmp.java new file mode 100644 index 000000000..4be3f1d52 --- /dev/null +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/ACmp.java @@ -0,0 +1,26 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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!"); + } +} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/BCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/BCmp.java new file mode 100644 index 000000000..5ab76db33 --- /dev/null +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/BCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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!"); + } + +} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/CCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/CCmp.java new file mode 100644 index 000000000..58e9c86ee --- /dev/null +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/CCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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!"); + } + +} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/DCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/DCmp.java new file mode 100644 index 000000000..c7e7a6355 --- /dev/null +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/DCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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!"); + } + +} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/ECmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/ECmp.java new file mode 100644 index 000000000..76af9f013 --- /dev/null +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/ECmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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"; + } +} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/FCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/FCmp.java new file mode 100644 index 000000000..84444012b --- /dev/null +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/FCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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!"); + } + +} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/GCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/GCmp.java new file mode 100644 index 000000000..510e9932e --- /dev/null +++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/parsecustom/cmp/GCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @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!"); + } + +} diff --git a/liteflow-spring-boot-starter/src/test/resources/parsecustom/application.xml b/liteflow-core/src/test/resources/parsecustom/application.xml similarity index 74% rename from liteflow-spring-boot-starter/src/test/resources/parsecustom/application.xml rename to liteflow-core/src/test/resources/parsecustom/application.xml index 904c8c80b..10b5ec593 100644 --- a/liteflow-spring-boot-starter/src/test/resources/parsecustom/application.xml +++ b/liteflow-core/src/test/resources/parsecustom/application.xml @@ -18,11 +18,4 @@ - - - - - - - \ No newline at end of file