From 105d1fe98f6d5ad29187c982596b21cda2653921 Mon Sep 17 00:00:00 2001 From: bryan31 Date: Tue, 9 Nov 2021 22:15:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E5=BC=82=E6=AD=A5=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BA=86=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asyncNode/AsyncNodeSpringbootTest.java | 21 +++++++++++++------ .../liteflow/test/asyncNode/cmp/GCmp.java | 1 + .../WhenTimeOutSpringbootTest.java | 3 --- .../src/test/resources/asyncNode/flow.xml | 6 ++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java index e065ec453..8a6ec6226 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/AsyncNodeSpringbootTest.java @@ -38,14 +38,14 @@ public class AsyncNodeSpringbootTest extends BaseTest { * 验证了默认参数情况下 when可以加载执行 * **/ @Test - public void testBaseConditionFlow1() { + public void testAsyncFlow1() { LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request"); Assert.assertTrue(response.isSuccess()); System.out.println(response.getSlot().printStep()); } @Test - public void testBaseConditionFlow2() { + public void testAsyncFlow2() { LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request"); Assert.assertTrue(ListUtil.toList("b==>j==>g==>f==>h","b==>j==>g==>h==>f", "b==>j==>h==>g==>f","b==>j==>h==>f==>g", @@ -55,7 +55,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错 @Test - public void testBaseErrorResumeConditionFlow4() { + public void testAsyncFlow4() { LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request"); //因为不记录错误,所以最终结果是true Assert.assertTrue(response.isSuccess()); @@ -68,7 +68,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { //相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错 @Test - public void testBaseErrorResumeConditionFlow5() throws Exception { + public void testAsyncFlow5() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request"); //整个并行组是报错的,所以最终结果是false Assert.assertFalse(response.isSuccess()); @@ -81,7 +81,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行 @Test - public void testBaseErrorResumeConditionFlow6() throws Exception { + public void testAsyncFlow6() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request"); //第一个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); @@ -94,7 +94,7 @@ public class AsyncNodeSpringbootTest extends BaseTest { //不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错 @Test - public void testBaseErrorResumeConditionFlow7() throws Exception { + public void testAsyncFlow7() throws Exception { LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request"); //第二个when会抛错,所以最终结果是false Assert.assertFalse(response.isSuccess()); @@ -104,4 +104,13 @@ public class AsyncNodeSpringbootTest extends BaseTest { //第一个when会报错,所以最终response的cause里应该会有TestException Assert.assertEquals(TestException.class, response.getCause().getClass()); } + + //d g h并行,配置了any=true,其中d耗时3秒,g耗时1秒,其他都不设耗时 + //最终执行效果应该是h先返回,然后执行abc,最后gd + //这里要注意的是,由于step是先加入,所以step的打印顺序并不是这样的。但是实际执行是正确的 + @Test + public void testAsyncFlow8() throws Exception { + LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request"); + Assert.assertTrue(response.isSuccess()); + } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java index 0660c076a..aa2a754a4 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/asyncNode/cmp/GCmp.java @@ -9,6 +9,7 @@ public class GCmp extends NodeComponent { @Override public void process() throws Exception { + Thread.sleep(1000); System.out.println("Gcomp executed!"); } } diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest.java index 66444ae55..c03db0c92 100644 --- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest.java +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/whenTimeOut/WhenTimeOutSpringbootTest.java @@ -1,11 +1,8 @@ package com.yomahub.liteflow.test.whenTimeOut; -import cn.hutool.core.io.resource.ResourceUtil; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.entity.data.DefaultSlot; import com.yomahub.liteflow.entity.data.LiteflowResponse; -import com.yomahub.liteflow.enums.FlowParserTypeEnum; -import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.test.BaseTest; import org.junit.Assert; import org.junit.Test; diff --git a/liteflow-testcase-springboot/src/test/resources/asyncNode/flow.xml b/liteflow-testcase-springboot/src/test/resources/asyncNode/flow.xml index 18924f8a0..41d31b35f 100644 --- a/liteflow-testcase-springboot/src/test/resources/asyncNode/flow.xml +++ b/liteflow-testcase-springboot/src/test/resources/asyncNode/flow.xml @@ -37,4 +37,10 @@ + + + + + + \ No newline at end of file