From 225d3f12b759711c599565786b83d367a2011cbb Mon Sep 17 00:00:00 2001 From: bryan31 Date: Tue, 30 Mar 2021 02:21:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yomahub/liteflow/core/FlowExecutor.java | 6 +- liteflow-test/pom.xml | 67 +++++++++++++++++++ .../liteflow/test/aop/LiteflowAOPTest.java | 25 +++++++ .../yomahub/liteflow/test/aop/TestRunner.java | 16 +++++ .../yomahub/liteflow/test/aop/cmp1/AComp.java | 21 ++++++ .../yomahub/liteflow/test/aop/cmp1/BComp.java | 21 ++++++ .../yomahub/liteflow/test/aop/cmp1/CComp.java | 21 ++++++ .../yomahub/liteflow/test/aop/cmp2/DComp.java | 21 ++++++ .../yomahub/liteflow/test/aop/cmp2/EComp.java | 21 ++++++ liteflow-test/src/test/resources/aop/flow.xml | 11 +++ .../src/test/resources/application.properties | 1 + pom.xml | 1 + 12 files changed, 229 insertions(+), 3 deletions(-) create mode 100644 liteflow-test/pom.xml create mode 100644 liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/LiteflowAOPTest.java create mode 100644 liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/TestRunner.java create mode 100644 liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/AComp.java create mode 100644 liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/BComp.java create mode 100644 liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/CComp.java create mode 100644 liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp2/DComp.java create mode 100644 liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp2/EComp.java create mode 100644 liteflow-test/src/test/resources/aop/flow.xml create mode 100644 liteflow-test/src/test/resources/application.properties diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java index 84b20153b..fe2a83c8a 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java @@ -101,15 +101,15 @@ public class FlowExecutor { execute(chainId, param, slotClazz, slotIndex,true); } - public LiteflowResponse execute(String chainId, Object param) throws Exception { + public LiteflowResponse execute(String chainId, Object param) throws Exception { return execute(chainId, param, DefaultSlot.class, null, false); } - public LiteflowResponse execute(String chainId, Object param, Class slotClazz) throws Exception { + public LiteflowResponse execute(String chainId, Object param, Class slotClazz) throws Exception { return execute(chainId, param, slotClazz,null,false); } - public LiteflowResponse execute(String chainId, Object param, Class slotClazz, Integer slotIndex, + public LiteflowResponse execute(String chainId, Object param, Class slotClazz, Integer slotIndex, boolean isInnerChain) throws Exception { Slot slot = null; diff --git a/liteflow-test/pom.xml b/liteflow-test/pom.xml new file mode 100644 index 000000000..9b535dc19 --- /dev/null +++ b/liteflow-test/pom.xml @@ -0,0 +1,67 @@ + + + + liteflow + com.yomahub + 2.5.0-SNAPSHOT + + 4.0.0 + + liteflow-test + + + + + + org.springframework.boot + spring-boot-dependencies + 2.0.5.RELEASE + pom + import + + + + + + + org.springframework.boot + spring-boot-starter + + + + com.yomahub + liteflow-spring-boot-starter + ${project.parent.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + maven-deploy-plugin + + true + + + + + + \ No newline at end of file diff --git a/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/LiteflowAOPTest.java b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/LiteflowAOPTest.java new file mode 100644 index 000000000..b75988948 --- /dev/null +++ b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/LiteflowAOPTest.java @@ -0,0 +1,25 @@ +package com.yomahub.liteflow.test.aop; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.entity.data.LiteflowResponse; +import com.yomahub.liteflow.entity.data.Slot; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestRunner.class) +public class LiteflowAOPTest { + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testAop() throws Exception{ + LiteflowResponse response= flowExecutor.execute("chain2", "it's a request"); + System.out.println(response); + } +} diff --git a/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/TestRunner.java b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/TestRunner.java new file mode 100644 index 000000000..a8cea9995 --- /dev/null +++ b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/TestRunner.java @@ -0,0 +1,16 @@ +package com.yomahub.liteflow.test.aop; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class TestRunner { + public static void main(String[] args) { + try{ + SpringApplication.run(TestRunner.class, args); + System.exit(0); + }catch (Throwable t){ + t.printStackTrace(); + } + } +} diff --git a/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/AComp.java b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/AComp.java new file mode 100644 index 000000000..5e1716956 --- /dev/null +++ b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/AComp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.aop.cmp1; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("a") +public class AComp extends NodeComponent { + + @Override + public void process() { + System.out.println("Acomp executed!"); + } + +} diff --git a/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/BComp.java b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/BComp.java new file mode 100644 index 000000000..3e42b4ce4 --- /dev/null +++ b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/BComp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.aop.cmp1; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("b") +public class BComp extends NodeComponent { + + @Override + public void process() { + System.out.println("Bcomp executed!"); + } + +} diff --git a/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/CComp.java b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/CComp.java new file mode 100644 index 000000000..63a6d37f5 --- /dev/null +++ b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp1/CComp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.aop.cmp1; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("c") +public class CComp extends NodeComponent { + + @Override + public void process() { + System.out.println("Ccomp executed!"); + } + +} diff --git a/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp2/DComp.java b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp2/DComp.java new file mode 100644 index 000000000..e10c6b155 --- /dev/null +++ b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp2/DComp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.aop.cmp2; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("d") +public class DComp extends NodeComponent { + + @Override + public void process() { + System.out.println("Dcomp executed!"); + } + +} diff --git a/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp2/EComp.java b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp2/EComp.java new file mode 100644 index 000000000..dca2147a5 --- /dev/null +++ b/liteflow-test/src/test/java/com/yomahub/liteflow/test/aop/cmp2/EComp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

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

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.aop.cmp2; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("e") +public class EComp extends NodeComponent { + + @Override + public void process() { + System.out.println("Ecomp executed!"); + } + +} diff --git a/liteflow-test/src/test/resources/aop/flow.xml b/liteflow-test/src/test/resources/aop/flow.xml new file mode 100644 index 000000000..fcbc8b715 --- /dev/null +++ b/liteflow-test/src/test/resources/aop/flow.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/liteflow-test/src/test/resources/application.properties b/liteflow-test/src/test/resources/application.properties new file mode 100644 index 000000000..f9075d1c6 --- /dev/null +++ b/liteflow-test/src/test/resources/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=aop/flow.xml \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9ab409d0e..1b3458fd3 100644 --- a/pom.xml +++ b/pom.xml @@ -210,6 +210,7 @@ liteflow-core liteflow-spring-boot-starter + liteflow-test liteflow-test-springboot liteflow-test-spring