diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/CustomSlot.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/CustomSlot.java deleted file mode 100644 index 8763463e5..000000000 --- a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/CustomSlot.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.yomahub.liteflow.test.flow; - -import com.yomahub.liteflow.entity.data.AbsSlot; - -public class CustomSlot extends AbsSlot { - private String name; - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } -} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/FlowExecutorTest.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/FlowExecutorTest.java deleted file mode 100644 index 35b9967fc..000000000 --- a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/FlowExecutorTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.yomahub.liteflow.test.flow; - -import com.yomahub.liteflow.core.FlowExecutor; -import com.yomahub.liteflow.entity.data.LiteflowResponse; -import com.yomahub.liteflow.entity.data.Slot; -import com.yomahub.liteflow.property.LiteflowConfig; -import org.junit.Assert; -import org.junit.Test; -import org.springframework.util.ReflectionUtils; - -public class FlowExecutorTest { - - @Test - public void testMethodExecute() { - LiteflowConfig config = new LiteflowConfig(); - config.setRuleSource("flow/flow.json"); - FlowExecutor executor = new FlowExecutor(); - executor.setLiteflowConfig(config); - executor.init(); - LiteflowResponse response = executor.execute("chain1", "test0", CustomSlot.class); - Assert.assertTrue(response.isSuccess()); - Assert.assertEquals("custom", response.getSlot().getName()); - } - - @Test(expected=RuntimeException.class) - public void testMethodExecuteWithException() throws Exception{ - LiteflowConfig config = new LiteflowConfig(); - config.setRuleSource("flow/flow.json"); - FlowExecutor executor = new FlowExecutor(); - executor.setLiteflowConfig(config); - executor.init(); - LiteflowResponse response = executor.execute("chain1", "test1", CustomSlot.class); - Assert.assertFalse(response.isSuccess()); - ReflectionUtils.rethrowException(response.getCause()); - } - - @Test - public void testMethodInvoke() throws Exception { - LiteflowConfig config = new LiteflowConfig(); - config.setRuleSource("flow/flow.json"); - FlowExecutor executor = new FlowExecutor(); - executor.setLiteflowConfig(config); - executor.init(); - CustomSlot slot = executor.invoke("chain1", "test0", CustomSlot.class); - Assert.assertEquals("custom", slot.getName()); - } - - @Test(expected=RuntimeException.class) - public void testMethodInvokeWithException() throws Exception { - LiteflowConfig config = new LiteflowConfig(); - config.setRuleSource("flow/flow.json"); - FlowExecutor executor = new FlowExecutor(); - executor.setLiteflowConfig(config); - executor.init(); - Slot slot = executor.invoke("chain1", "test1", CustomSlot.class); - - } -} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/cmp/ACmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/cmp/ACmp.java deleted file mode 100644 index c2a71036e..000000000 --- a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/cmp/ACmp.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.flow.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!"); - } -} diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/cmp/BCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/cmp/BCmp.java deleted file mode 100644 index e60604409..000000000 --- a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/cmp/BCmp.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.flow.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/flow/cmp/CCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/cmp/CCmp.java deleted file mode 100644 index a1881ba2e..000000000 --- a/liteflow-core/src/test/java/com/yomahub/liteflow/test/flow/cmp/CCmp.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - *

Title: liteflow

- *

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

- * @author Bryan.Zhang - * @email weenyc31@163.com - * @Date 2020/4/1 - */ -package com.yomahub.liteflow.test.flow.cmp; - -import cn.hutool.core.util.StrUtil; -import com.yomahub.liteflow.core.NodeComponent; -import com.yomahub.liteflow.test.flow.CustomSlot; -import org.springframework.stereotype.Component; - -@Component("c") -public class CCmp extends NodeComponent { - - @Override - public void process() { - if(this.getSlot() instanceof CustomSlot) { - CustomSlot slot = this.getSlot(); - String str = slot.getRequestData(); - if(StrUtil.isNotBlank(str) && str.equals("test0")) { - slot.setName("custom"); - } - if(StrUtil.isNotBlank(str) && str.equals("test1")) { - slot.setName("custom"); - throw new RuntimeException("customException"); - } - } - System.out.println("CCmp executed!"); - } - -} diff --git a/liteflow-core/src/test/resources/flow/flow.json b/liteflow-core/src/test/resources/flow/flow.json deleted file mode 100644 index aa62d7082..000000000 --- a/liteflow-core/src/test/resources/flow/flow.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "flow": { - "nodes": { - "node": [ - { - "id": "a", - "class": "com.yomahub.liteflow.test.flow.cmp.ACmp" - }, - { - "id": "b", - "class": "com.yomahub.liteflow.test.flow.cmp.BCmp" - }, - { - "id": "c", - "class": "com.yomahub.liteflow.test.flow.cmp.CCmp" - } - ] - }, - "chain": [ - { - "name": "chain1", - "condition": [ - {"type": "then", "value": "a,b,c"} - ] - } - ] - } -} \ No newline at end of file