|
@@ -6,9 +6,10 @@ import com.yomahub.liteflow.flow.LiteflowResponse;
|
|
|
import com.yomahub.liteflow.slot.DefaultContext;
|
|
|
import com.yomahub.liteflow.test.BaseTest;
|
|
|
import com.yomahub.liteflow.test.asyncNode.exception.TestException;
|
|
|
-import org.junit.Assert;
|
|
|
-import org.junit.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
+import org.junit.jupiter.api.Assertions;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
+import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
@@ -22,7 +23,7 @@ import javax.annotation.Resource;
|
|
|
*
|
|
|
* @author ssss
|
|
|
*/
|
|
|
-@RunWith(SpringRunner.class)
|
|
|
+@ExtendWith(SpringExtension.class)
|
|
|
@TestPropertySource(value = "classpath:/asyncNode/application.properties")
|
|
|
@SpringBootTest(classes = AsyncNodeELDeclSpringbootTest.class)
|
|
|
@EnableAutoConfiguration
|
|
@@ -38,7 +39,7 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest {
|
|
|
@Test
|
|
|
public void testAsyncFlow1() {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request");
|
|
|
- Assert.assertTrue(response.isSuccess());
|
|
|
+ Assertions.assertTrue(response.isSuccess());
|
|
|
System.out.println(response.getExecuteStepStr());
|
|
|
}
|
|
|
|
|
@@ -46,7 +47,7 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest {
|
|
|
@Test
|
|
|
public void testAsyncFlow2() {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a base request");
|
|
|
- Assert.assertTrue(
|
|
|
+ Assertions.assertTrue(
|
|
|
ListUtil
|
|
|
.toList("b==>j==>g==>f==>h", "b==>j==>g==>h==>f", "b==>j==>h==>g==>f", "b==>j==>h==>f==>g",
|
|
|
"b==>j==>f==>h==>g", "b==>j==>f==>g==>h")
|
|
@@ -57,15 +58,15 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest {
|
|
|
@Test
|
|
|
public void testAsyncFlow3_1() {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain3-1", "it's a base request");
|
|
|
- Assert.assertFalse(response.isSuccess());
|
|
|
- Assert.assertEquals(response.getSlot().getException().getClass(), TestException.class);
|
|
|
+ Assertions.assertFalse(response.isSuccess());
|
|
|
+ Assertions.assertEquals(response.getSlot().getException().getClass(), TestException.class);
|
|
|
}
|
|
|
|
|
|
// 测试errorResume,默认的errorResume为false,这里设置为true
|
|
|
@Test
|
|
|
public void testAsyncFlow3_2() {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain3-2", "it's a base request");
|
|
|
- Assert.assertTrue(response.isSuccess());
|
|
|
+ Assertions.assertTrue(response.isSuccess());
|
|
|
}
|
|
|
|
|
|
// 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了不抛错
|
|
@@ -74,12 +75,12 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "it's a base request");
|
|
|
DefaultContext context = response.getFirstContextBean();
|
|
|
// 因为不记录错误,所以最终结果是true
|
|
|
- Assert.assertTrue(response.isSuccess());
|
|
|
+ Assertions.assertTrue(response.isSuccess());
|
|
|
// 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下
|
|
|
Integer count = context.getData("count");
|
|
|
- Assert.assertEquals(new Integer(2), count);
|
|
|
+ Assertions.assertEquals(new Integer(2), count);
|
|
|
// 因为配置了不抛错,所以response里的cause应该为null
|
|
|
- Assert.assertNull(response.getCause());
|
|
|
+ Assertions.assertNull(response.getCause());
|
|
|
}
|
|
|
|
|
|
// 相同group的并行组,会合并,并且errorResume根据第一个when来,这里第一个when配置了会抛错
|
|
@@ -88,12 +89,12 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "it's a base request");
|
|
|
DefaultContext context = response.getFirstContextBean();
|
|
|
// 整个并行组是报错的,所以最终结果是false
|
|
|
- Assert.assertFalse(response.isSuccess());
|
|
|
+ Assertions.assertFalse(response.isSuccess());
|
|
|
// 因为是并行组,所以即便抛错了,其他组件也会执行,i在流程里配置了2遍,i抛错,但是也执行了2遍,这里验证下
|
|
|
Integer count = context.getData("count");
|
|
|
- Assert.assertEquals(new Integer(2), count);
|
|
|
+ Assertions.assertEquals(new Integer(2), count);
|
|
|
// 因为第一个when配置了会报错,所以response里的cause里应该会有TestException
|
|
|
- Assert.assertEquals(TestException.class, response.getCause().getClass());
|
|
|
+ Assertions.assertEquals(TestException.class, response.getCause().getClass());
|
|
|
}
|
|
|
|
|
|
// 不同group的并行组,不会合并,第一个when的errorResume是false,会抛错,那第二个when就不会执行
|
|
@@ -102,12 +103,12 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "it's a base request");
|
|
|
DefaultContext context = response.getFirstContextBean();
|
|
|
// 第一个when会抛错,所以最终结果是false
|
|
|
- Assert.assertFalse(response.isSuccess());
|
|
|
+ Assertions.assertFalse(response.isSuccess());
|
|
|
// 因为是不同组并行组,第一组的when里的i就抛错了,所以i就执行了1遍
|
|
|
Integer count = context.getData("count");
|
|
|
- Assert.assertEquals(new Integer(1), count);
|
|
|
+ Assertions.assertEquals(new Integer(1), count);
|
|
|
// 第一个when会报错,所以最终response的cause里应该会有TestException
|
|
|
- Assert.assertEquals(TestException.class, response.getCause().getClass());
|
|
|
+ Assertions.assertEquals(TestException.class, response.getCause().getClass());
|
|
|
}
|
|
|
|
|
|
// 不同group的并行组,不会合并,第一个when的errorResume是true,不会报错,那第二个when还会继续执行,但是第二个when的errorResume是false,所以第二个when会报错
|
|
@@ -116,12 +117,12 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain7", "it's a base request");
|
|
|
DefaultContext context = response.getFirstContextBean();
|
|
|
// 第二个when会抛错,所以最终结果是false
|
|
|
- Assert.assertFalse(response.isSuccess());
|
|
|
+ Assertions.assertFalse(response.isSuccess());
|
|
|
// 传递了slotIndex,则set的size==2
|
|
|
Integer count = context.getData("count");
|
|
|
- Assert.assertEquals(new Integer(2), count);
|
|
|
+ Assertions.assertEquals(new Integer(2), count);
|
|
|
// 第一个when会报错,所以最终response的cause里应该会有TestException
|
|
|
- Assert.assertEquals(TestException.class, response.getCause().getClass());
|
|
|
+ Assertions.assertEquals(TestException.class, response.getCause().getClass());
|
|
|
}
|
|
|
|
|
|
// 测试任意异步一个执行完即继续的场景
|
|
@@ -132,8 +133,8 @@ public class AsyncNodeELDeclSpringbootTest extends BaseTest {
|
|
|
public void testAsyncFlow8() throws Exception {
|
|
|
LiteflowResponse response = flowExecutor.execute2Resp("chain8", "it's a base request");
|
|
|
DefaultContext context = response.getFirstContextBean();
|
|
|
- Assert.assertTrue(response.isSuccess());
|
|
|
- Assert.assertTrue(context.getData("check").toString().startsWith("habc"));
|
|
|
+ Assertions.assertTrue(response.isSuccess());
|
|
|
+ Assertions.assertTrue(context.getData("check").toString().startsWith("habc"));
|
|
|
}
|
|
|
|
|
|
}
|