enhancement #I7KR2F 测试用例全面更新为junit5

enhancement #I7J59V java17下进行完整的测试用例测试
This commit is contained in:
everywhere.z 2023-07-12 23:51:36 +08:00
parent 269e1ec145
commit fb87a1b06a
406 changed files with 4073 additions and 4052 deletions

View File

@ -5,7 +5,6 @@ import com.yomahub.liteflow.log.LFLoggerManager;
import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
import com.yomahub.liteflow.thread.ExecutorHelper;
import javax.annotation.PreDestroy;
import java.util.concurrent.ExecutorService;
/**
@ -17,7 +16,6 @@ public class LiteFlowExecutorPoolShutdown {
private static final LFLog LOG = LFLoggerManager.getLogger(LiteFlowExecutorPoolShutdown.class);
@PreDestroy
public void destroy() throws Exception {
ExecutorService executorService = ContextAwareHolder.loadContextAware().getBean("whenExecutors");

View File

@ -19,5 +19,9 @@
<version>${revision}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -6,7 +6,7 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter;
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
import com.yomahub.liteflow.spring.ComponentScanner;
import com.yomahub.liteflow.thread.ExecutorHelper;
import org.junit.AfterClass;
import org.junit.jupiter.api.AfterAll;
/**
* @Description:
@ -15,7 +15,7 @@ import org.junit.AfterClass;
*/
public class BaseTest {
@AfterClass
@AfterAll
public static void cleanScanCache() {
ComponentScanner.cleanCache();
FlowBus.cleanCache();

View File

@ -1,27 +1,25 @@
package com.yomahub.liteflow.test.apollo;
import cn.hutool.core.util.StrUtil;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.flow.LiteflowResponse;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.event.annotation.AfterTestClass;
import org.springframework.test.context.event.annotation.BeforeTestClass;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.Resource;
import java.util.List;
import java.util.Set;
import static org.mockito.Mockito.*;
@ -31,7 +29,7 @@ import static org.mockito.Mockito.*;
* @Author: zhanghua
* @Date: 2022/12/3 15:22
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/apollo/application-xml.properties")
@SpringBootTest(classes = ApolloWithXmlELSpringbootTest.class)
@EnableAutoConfiguration
@ -47,16 +45,10 @@ public class ApolloWithXmlELSpringbootTest {
@Resource
private FlowExecutor flowExecutor;
@Before
@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
}
@After
public void after() {
FlowBus.cleanCache();
}
@Test
public void testApolloWithXml1() {
Set<String> chainNameList = Sets.newHashSet("chain1");
@ -70,7 +62,6 @@ public class ApolloWithXmlELSpringbootTest {
when(scriptConfig.getProperty(anyString(), anyString())).thenReturn(scriptNodeValue);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>b==>c==>s1[脚本s1]", response.getExecuteStepStrWithoutTime());
Assertions.assertEquals("a==>b==>c==>s1[脚本s1]", response.getExecuteStepStrWithoutTime());
}
}

View File

@ -6,11 +6,13 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter;
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
import com.yomahub.liteflow.spring.ComponentScanner;
import com.yomahub.liteflow.thread.ExecutorHelper;
import org.junit.AfterClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.springframework.test.context.event.annotation.AfterTestClass;
public class BaseTest {
@AfterClass
@AfterAll
public static void cleanScanCache() {
ComponentScanner.cleanCache();
FlowBus.cleanCache();

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.absoluteConfigPath;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -22,7 +23,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties")
@SpringBootTest(classes = AbsoluteConfigPathELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -37,7 +38,7 @@ public class AbsoluteConfigPathELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testAbsoluteConfig() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -6,10 +6,12 @@ import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.spring.ComponentScanner;
import com.yomahub.liteflow.test.BaseTest;
import com.yomahub.liteflow.test.aop.aspect.CmpAspect;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.event.annotation.AfterTestClass;
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;
@ -24,7 +26,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/aop/application.properties")
@SpringBootTest(classes = GlobalAOPELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -40,12 +42,12 @@ public class GlobalAOPELDeclMultiSpringbootTest extends BaseTest {
public void testGlobalAopS() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("before_after", context.getData("a"));
Assert.assertEquals("before_after", context.getData("b"));
Assert.assertEquals("before_after", context.getData("c"));
Assert.assertEquals("before_after", context.getData("d"));
Assert.assertEquals("before_after", context.getData("e"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("before_after", context.getData("a"));
Assertions.assertEquals("before_after", context.getData("b"));
Assertions.assertEquals("before_after", context.getData("c"));
Assertions.assertEquals("before_after", context.getData("d"));
Assertions.assertEquals("before_after", context.getData("e"));
}
// 测试全局AOP并行场景
@ -53,26 +55,26 @@ public class GlobalAOPELDeclMultiSpringbootTest extends BaseTest {
public void testGlobalAopP() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a request");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("before_after", context.getData("a"));
Assert.assertEquals("before_after", context.getData("b"));
Assert.assertEquals("before_after", context.getData("c"));
Assert.assertEquals("before_after", context.getData("d"));
Assert.assertEquals("before_after", context.getData("e"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("before_after", context.getData("a"));
Assertions.assertEquals("before_after", context.getData("b"));
Assertions.assertEquals("before_after", context.getData("c"));
Assertions.assertEquals("before_after", context.getData("d"));
Assertions.assertEquals("before_after", context.getData("e"));
}
@Test
public void testGlobalAopException() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("before_after", context.getData("a"));
Assert.assertEquals("before_after", context.getData("b"));
Assert.assertEquals("before_after", context.getData("c"));
Assert.assertEquals("before_after", context.getData("f"));
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("before_after", context.getData("a"));
Assertions.assertEquals("before_after", context.getData("b"));
Assertions.assertEquals("before_after", context.getData("c"));
Assertions.assertEquals("before_after", context.getData("f"));
}
@AfterClass
@AfterAll
public static void cleanScanCache() {
BaseTest.cleanScanCache();
ComponentScanner.cmpAroundAspect = null;

View File

@ -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 = AsyncNodeELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -38,7 +39,7 @@ public class AsyncNodeELDeclMultiSpringbootTest 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 AsyncNodeELDeclMultiSpringbootTest 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 AsyncNodeELDeclMultiSpringbootTest 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 AsyncNodeELDeclMultiSpringbootTest 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(2, count);
// 因为配置了不抛错所以response里的cause应该为null
Assert.assertNull(response.getCause());
Assertions.assertNull(response.getCause());
}
// 相同group的并行组会合并并且errorResume根据第一个when来这里第一个when配置了会抛错
@ -88,12 +89,12 @@ public class AsyncNodeELDeclMultiSpringbootTest 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(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 AsyncNodeELDeclMultiSpringbootTest 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(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 AsyncNodeELDeclMultiSpringbootTest 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(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 AsyncNodeELDeclMultiSpringbootTest 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"));
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.base;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/base/application.properties")
@SpringBootTest(classes = BaseELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -33,7 +34,7 @@ public class BaseELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testBase() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -7,9 +7,10 @@ import com.yomahub.liteflow.enums.NodeTypeEnum;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import com.yomahub.liteflow.test.builder.cmp1.*;
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.test.context.junit4.SpringRunner;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
//基于builder模式的单元测试
//这里只是最基本的builder模式的测试只是为了验证在springboot模式下的正常性
//更详细的builder模式测试用例会单独拉testcase去做
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = BuilderELDeclMultiSpringbootTest1.class)
@EnableAutoConfiguration
public class BuilderELDeclMultiSpringbootTest1 extends BaseTest {
@ -81,8 +82,8 @@ public class BuilderELDeclMultiSpringbootTest1 extends BaseTest {
.build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr());
}
// 基于普通组件的builder模式测试
@ -139,8 +140,8 @@ public class BuilderELDeclMultiSpringbootTest1 extends BaseTest {
.build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a[组件A]==>b[组件B]==>e[组件E]==>c[组件C]==>d[组件D]", response.getExecuteStepStr());
}
@Test
@ -173,8 +174,8 @@ public class BuilderELDeclMultiSpringbootTest1 extends BaseTest {
LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(a1,c2,a2,c1)").build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a1[组件A1]==>c2[组件C2]==>a2[组件A2]==>c1[组件C1]", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -16,7 +17,7 @@ import javax.annotation.Resource;
//基于builder模式的单元测试
//这里测试的是通过spring去扫描但是通过代码去构建chain的用例
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = BuilderELDeclMultiSpringbootTest2.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.builder.cmp2" })
@ -31,8 +32,8 @@ public class BuilderELDeclMultiSpringbootTest2 extends BaseTest {
LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(h, i, j)").build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("h==>i==>j", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("h==>i==>j", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.cmpRetry;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.10
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/cmpRetry/application.properties")
@SpringBootTest(classes = LiteflowRetryELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,31 +35,31 @@ public class LiteflowRetryELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testRetry1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>b==>b", response.getExecuteStepStr());
}
// 单个组件重试配置测试
@Test
public void testRetry2() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr());
}
// 单个组件指定异常但抛出的并不是指定异常的场景测试
@Test
public void testRetry3() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertFalse(response.isSuccess());
Assertions.assertFalse(response.isSuccess());
}
// 单个组件指定异常重试抛出的是指定异常或者
@Test
public void testRetry4() {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.flow.entity.CmpStep;
import com.yomahub.liteflow.test.BaseTest;
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 java.util.*;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/cmpStep/application.properties")
@SpringBootTest(classes = CmpStepELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -35,31 +36,31 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
@Test
public void testStep() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
Assertions.assertFalse(response.isSuccess());
Assertions.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assertions.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assertions.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assertions.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assertions.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
}
@Test
public void testStep2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testStep3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
Map<String, List<CmpStep>> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Assertions.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());
Assertions.assertEquals(5, queue.size());
Set<String> tagSet = new HashSet<>();
response.getExecuteStepQueue()
@ -67,7 +68,7 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
.filter(cmpStep -> cmpStep.getNodeId().equals("a"))
.forEach(cmpStep -> tagSet.add(cmpStep.getTag()));
Assert.assertEquals(3, tagSet.size());
Assertions.assertEquals(3, tagSet.size());
}

View File

@ -4,9 +4,10 @@ import cn.hutool.core.collection.ListUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/comments/application.properties")
@SpringBootTest(classes = LiteflowNodeELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -29,8 +30,8 @@ public class LiteflowNodeELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testAsyncFlow1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request");
Assert.assertTrue(response.isSuccess());
Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr()));
Assertions.assertTrue(response.isSuccess());
Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr()));
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.complex;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/complex/application1.properties")
@SpringBootTest(classes = ComplexELDeclMultiSpringbootTest1.class)
@EnableAutoConfiguration
@ -35,7 +36,7 @@ public class ComplexELDeclMultiSpringbootTest1 extends BaseTest {
@Test
public void testComplex1_1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1_1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// 测试复杂例子优化后
@ -44,7 +45,7 @@ public class ComplexELDeclMultiSpringbootTest1 extends BaseTest {
@Test
public void testComplex1_2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1_2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.complex;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/complex/application2.properties")
@SpringBootTest(classes = ComplexELDeclMultiSpringbootTest2.class)
@EnableAutoConfiguration
@ -35,7 +36,7 @@ public class ComplexELDeclMultiSpringbootTest2 extends BaseTest {
@Test
public void testComplex2_1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2_1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// 测试复杂例子优化后
@ -44,7 +45,7 @@ public class ComplexELDeclMultiSpringbootTest2 extends BaseTest {
@Test
public void testComplex2_2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2_2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,11 @@ package com.yomahub.liteflow.test.component;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.junit.jupiter.api.function.Executable;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -22,7 +24,7 @@ import javax.annotation.Resource;
*
* @author donguo.tao
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/component/application.properties")
@SpringBootTest(classes = FlowExecutorELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -38,56 +40,58 @@ public class FlowExecutorELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testIsAccess() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101);
Assert.assertTrue(response.isSuccess());
Assert.assertNotNull(response.getSlot().getResponseData());
Assertions.assertTrue(response.isSuccess());
Assertions.assertNotNull(response.getSlot().getResponseData());
}
// 组件抛错的功能点测试
@Test(expected = ArithmeticException.class)
@Test
public void testComponentException() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0);
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("/ by zero", response.getMessage());
ReflectionUtils.rethrowException(response.getCause());
Assertions.assertThrows(ArithmeticException.class, () -> {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0);
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("/ by zero", response.getMessage());
ReflectionUtils.rethrowException(response.getCause());
});
}
// isContinueOnError方法的功能点测试
@Test
public void testIsContinueOnError() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0);
Assert.assertTrue(response.isSuccess());
Assert.assertNull(response.getCause());
Assertions.assertTrue(response.isSuccess());
Assertions.assertNull(response.getCause());
}
// isEnd方法的功能点测试
@Test
public void testIsEnd() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("d", response.getExecuteStepStr());
}
// setIsEnd方法的功能点测试
@Test
public void testSetIsEnd1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("e", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("e", response.getExecuteStepStr());
}
// 条件组件的功能点测试
@Test
public void testNodeCondComponent() {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0);
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// 测试setIsEnd如果为truecontinueError也为true那不应该continue了
@Test
public void testSetIsEnd2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("g", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("g", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.customMethodName;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.7.2
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/customMethodName/application.properties")
@SpringBootTest(classes = CustomMethodNameELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -33,7 +34,7 @@ public class CustomMethodNameELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testCustomMethodName() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.customNodes;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -22,7 +23,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/customNodes/application.properties")
@SpringBootTest(classes = CustomNodesELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -37,9 +38,9 @@ public class CustomNodesELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testCustomNodes() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -23,7 +24,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/customWhenThreadPool/application.properties")
@SpringBootTest(classes = CustomWhenThreadPoolELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -42,8 +43,8 @@ public class CustomWhenThreadPoolELDeclMultiSpringbootTest extends BaseTest {
public void testGlobalThreadPool() {
LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead"));
}
/**
@ -53,8 +54,8 @@ public class CustomWhenThreadPoolELDeclMultiSpringbootTest extends BaseTest {
public void testGlobalAndCustomWhenThreadPool() {
LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response1.getFirstContextBean();
Assert.assertTrue(response1.isSuccess());
Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead"));
Assertions.assertTrue(response1.isSuccess());
Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead"));
}
/**
@ -67,8 +68,8 @@ public class CustomWhenThreadPoolELDeclMultiSpringbootTest extends BaseTest {
// chain配置同一个thead1
LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg");
DefaultContext context = response2.getFirstContextBean();
Assert.assertTrue(response2.isSuccess());
Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead"));
Assertions.assertTrue(response2.isSuccess());
Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead"));
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/event/application.properties")
@SpringBootTest(classes = EventELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -36,8 +37,8 @@ public class EventELDeclMultiSpringbootTest extends BaseTest {
public void testEvent1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("abc", context.getData("test"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("abc", context.getData("test"));
}
// 测试组件失败事件
@ -45,10 +46,10 @@ public class EventELDeclMultiSpringbootTest extends BaseTest {
public void testEvent2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
Assert.assertEquals("ab", context.getData("test"));
Assert.assertEquals("error:d", context.getData("error"));
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals(NullPointerException.class, response.getCause().getClass());
Assertions.assertEquals("ab", context.getData("test"));
Assertions.assertEquals("error:d", context.getData("error"));
}
// 测试组件失败事件本身抛出异常
@ -56,10 +57,10 @@ public class EventELDeclMultiSpringbootTest extends BaseTest {
public void testEvent3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
Assert.assertEquals("a", context.getData("test"));
Assert.assertEquals("error:e", context.getData("error"));
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals(NullPointerException.class, response.getCause().getClass());
Assertions.assertEquals("a", context.getData("test"));
Assertions.assertEquals("error:e", context.getData("error"));
}
}

View File

@ -4,14 +4,18 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.exception.ChainDuplicateException;
import com.yomahub.liteflow.exception.ConfigErrorException;
import com.yomahub.liteflow.exception.FlowExecutorNotInitException;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.property.LiteflowConfigGetter;
import com.yomahub.liteflow.test.BaseTest;
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.test.context.junit4.SpringRunner;
import org.springframework.util.ReflectionUtils;
import javax.annotation.Resource;
@ -20,7 +24,7 @@ import javax.annotation.Resource;
*
* @author zendwang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Exception1ELDeclMultiSpringBootTest.class)
@EnableAutoConfiguration
public class Exception1ELDeclMultiSpringBootTest extends BaseTest {
@ -31,31 +35,38 @@ public class Exception1ELDeclMultiSpringBootTest extends BaseTest {
/**
* 验证 chain 节点重复的异常
*/
@Test(expected = ChainDuplicateException.class)
@Test
public void testChainDuplicateException() {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.el.xml");
flowExecutor.reloadRule();
Assertions.assertThrows(ChainDuplicateException.class, () -> {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.el.xml");
flowExecutor.reloadRule();
});
}
@Test(expected = ConfigErrorException.class)
@Test
public void testConfigErrorException() {
flowExecutor.setLiteflowConfig(null);
flowExecutor.reloadRule();
Assertions.assertThrows(ConfigErrorException.class, () -> {
flowExecutor.setLiteflowConfig(null);
flowExecutor.reloadRule();
});
}
@Test(expected = FlowExecutorNotInitException.class)
@Test
public void testFlowExecutorNotInitException() {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("error/flow.txt");
flowExecutor.reloadRule();
Assertions.assertThrows(FlowExecutorNotInitException.class, () -> {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("error/flow.txt");
flowExecutor.reloadRule();
});
}
@Test(expected = FlowExecutorNotInitException.class)
@Test
public void testNoConditionInChainException() throws Exception {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-blank.el.xml");
flowExecutor.reloadRule();
Assertions.assertThrows(FlowExecutorNotInitException.class, () -> {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-blank.el.xml");
flowExecutor.reloadRule();
});
}
}

View File

@ -6,9 +6,10 @@ import com.yomahub.liteflow.exception.LiteFlowException;
import com.yomahub.liteflow.exception.NoSwitchTargetNodeException;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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 zendwang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/exception/application.properties")
@SpringBootTest(classes = Exception2ELDeclMultiSpringBootTest.class)
@EnableAutoConfiguration
@ -32,46 +33,49 @@ public class Exception2ELDeclMultiSpringBootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
@Test(expected = ChainNotFoundException.class)
@Test
public void testChainNotFoundException() throws Exception {
flowExecutor.execute("chain0", "it's a request");
Assertions.assertThrows(ChainNotFoundException.class, () -> flowExecutor.execute("chain0", "it's a request"));
}
@Test(expected = RuntimeException.class)
@Test
public void testComponentCustomException() throws Exception {
flowExecutor.execute("chain1", "exception");
Assertions.assertThrows(RuntimeException.class, () -> flowExecutor.execute("chain1", "exception"));
}
@Test
public void testGetSlotFromResponseWhenException() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test");
Assert.assertFalse(response.isSuccess());
Assert.assertNotNull(response.getCause());
Assert.assertNotNull(response.getSlot());
Assertions.assertFalse(response.isSuccess());
Assertions.assertNotNull(response.getCause());
Assertions.assertNotNull(response.getSlot());
}
@Test(expected = NoSwitchTargetNodeException.class)
@Test
public void testNoTargetFindException() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test");
Assert.assertFalse(response.isSuccess());
throw response.getCause();
Assertions.assertThrows(NoSwitchTargetNodeException.class, () -> {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test");
Assertions.assertFalse(response.isSuccess());
throw response.getCause();
});
}
@Test
public void testInvokeCustomStatefulException() {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "custom-stateful-exception");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("300", response.getCode());
Assert.assertNotNull(response.getCause());
Assert.assertTrue(response.getCause() instanceof LiteFlowException);
Assert.assertNotNull(response.getSlot());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("300", response.getCode());
Assertions.assertNotNull(response.getCause());
Assertions.assertTrue(response.getCause() instanceof LiteFlowException);
Assertions.assertNotNull(response.getSlot());
}
@Test
public void testNotInvokeCustomStatefulException() {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "test");
Assert.assertTrue(response.isSuccess());
Assert.assertNull(response.getCode());
Assertions.assertTrue(response.isSuccess());
Assertions.assertNull(response.getCode());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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 java.util.concurrent.Future;
* @author Bryan.Zhang
* @since 2.6.13
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/execute2Future/application.properties")
@SpringBootTest(classes = Executor2FutureELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -36,7 +37,7 @@ public class Executor2FutureELDeclMultiSpringbootTest extends BaseTest {
public void testFuture() throws Exception {
Future<LiteflowResponse> future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class);
LiteflowResponse response = future.get();
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.extend;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.7.1
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/extend/application.properties")
@SpringBootTest(classes = CmpExtendELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -33,7 +34,7 @@ public class CmpExtendELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testExtend() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/getChainName/application.properties")
@SpringBootTest(classes = GetChainNameELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,28 +35,28 @@ public class GetChainNameELDeclMultiSpringbootTest extends BaseTest {
public void testGetChainName1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("sub1", context.getData("a"));
Assert.assertEquals("sub2", context.getData("b"));
Assert.assertEquals("sub3", context.getData("c"));
Assert.assertEquals("sub4", context.getData("d"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("sub1", context.getData("a"));
Assertions.assertEquals("sub2", context.getData("b"));
Assertions.assertEquals("sub3", context.getData("c"));
Assertions.assertEquals("sub4", context.getData("d"));
}
@Test
public void testGetChainName2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("chain2", context.getData("g"));
Assert.assertEquals("sub1", context.getData("a"));
Assert.assertEquals("sub2", context.getData("b"));
Assert.assertEquals("sub3", context.getData("c"));
Assert.assertEquals("sub4", context.getData("d"));
Assert.assertEquals("sub5", context.getData("f"));
Assert.assertEquals("sub5_chain2", context.getData("e"));
Assert.assertEquals("sub6", context.getData("h"));
Assert.assertEquals("sub6", context.getData("j"));
Assert.assertNull(context.getData("k"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("chain2", context.getData("g"));
Assertions.assertEquals("sub1", context.getData("a"));
Assertions.assertEquals("sub2", context.getData("b"));
Assertions.assertEquals("sub3", context.getData("c"));
Assertions.assertEquals("sub4", context.getData("d"));
Assertions.assertEquals("sub5", context.getData("f"));
Assertions.assertEquals("sub5_chain2", context.getData("e"));
Assertions.assertEquals("sub6", context.getData("h"));
Assertions.assertEquals("sub6", context.getData("j"));
Assertions.assertNull(context.getData("k"));
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.ifelse;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/ifelse/application.properties")
@SpringBootTest(classes = IfElseELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,56 +35,56 @@ public class IfElseELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testIf1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime());
}
// IF只有3个参数
@Test
public void testIf2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime());
}
// IF有3个参数进行嵌套
@Test
public void testIf3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime());
}
// IF有2个参数加上ELSE
@Test
public void testIf4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime());
}
// IF有2个参数ELSE里再嵌套一个IF
@Test
public void testIf5() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime());
}
// 标准的IF ELIF ELSE
@Test
public void testIf6() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime());
}
// IF ELIF... ELSE 的形式
@Test
public void testIf7() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime());
}
}

View File

@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -23,7 +24,7 @@ import java.util.List;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/iterator/application.properties")
@SpringBootTest(classes = IteratorELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -38,10 +39,10 @@ public class IteratorELDeclMultiSpringbootTest extends BaseTest {
public void testIt1() throws Exception {
List<String> list = ListUtil.toList("1", "2", "3");
LiteflowResponse response = flowExecutor.execute2Resp("chain1", list);
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
DefaultContext context = response.getFirstContextBean();
String str = context.getData("test");
Assert.assertEquals("123", str);
Assertions.assertEquals("123", str);
}
// 迭代器带break
@ -49,10 +50,10 @@ public class IteratorELDeclMultiSpringbootTest extends BaseTest {
public void testIt2() throws Exception {
List<String> list = ListUtil.toList("1", "2", "3");
LiteflowResponse response = flowExecutor.execute2Resp("chain2", list);
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
DefaultContext context = response.getFirstContextBean();
String str = context.getData("test");
Assert.assertEquals("12", str);
Assertions.assertEquals("12", str);
}
}

View File

@ -3,7 +3,7 @@ package com.yomahub.liteflow.test.lazy;
import com.yomahub.liteflow.test.BaseTest;
//spring的延迟加载在el表达形式模式下不起作用
/*@RunWith(SpringRunner.class)
/*@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/lazy/application.properties")
@SpringBootTest(classes = LazyELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -15,7 +15,7 @@ public class LazyELDeclMultiSpringbootTest extends BaseTest {
*
* @Test public void testLazy() throws Exception{ LiteflowResponse response =
* flowExecutor.execute2Resp("chain1", "arg");
* Assert.assertTrue(response.isSuccess()); }
* Assertions.assertTrue(response.isSuccess()); }
*/
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.lfCmpAnno;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
@ -19,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @author Bryan.Zhang
* @since 2.5.10
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/lfCmpAnno/application.properties")
@SpringBootTest(classes = LiteflowComponentELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -32,8 +33,8 @@ public class LiteflowComponentELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testConfig() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/loop/application.properties")
@SpringBootTest(classes = LoopELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -35,31 +36,31 @@ public class LoopELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testLoop1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr());
}
// FPR循环由For组件定义
@Test
public void testLoop2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr());
}
// FOR循环中加入BREAK组件
@Test
public void testLoop3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// WHILE循环
@Test
public void testLoop4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z",
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z",
response.getExecuteStepStr());
}
@ -67,8 +68,8 @@ public class LoopELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testLoop5() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y",
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y",
response.getExecuteStepStr());
}
@ -77,10 +78,10 @@ public class LoopELDeclMultiSpringbootTest extends BaseTest {
public void testLoop6() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("01234", context.getData("loop_e1"));
Assert.assertEquals("01234", context.getData("loop_e2"));
Assert.assertEquals("01234", context.getData("loop_e3"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("01234", context.getData("loop_e1"));
Assertions.assertEquals("01234", context.getData("loop_e2"));
Assertions.assertEquals("01234", context.getData("loop_e3"));
}
// 测试WHILE循环中的index
@ -88,10 +89,10 @@ public class LoopELDeclMultiSpringbootTest extends BaseTest {
public void testLoop7() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("01234", context.getData("loop_e1"));
Assert.assertEquals("01234", context.getData("loop_e2"));
Assert.assertEquals("01234", context.getData("loop_e3"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("01234", context.getData("loop_e1"));
Assertions.assertEquals("01234", context.getData("loop_e2"));
Assertions.assertEquals("01234", context.getData("loop_e3"));
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.mixDefine;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/mixDefine/application.properties")
@SpringBootTest(classes = MixDefineELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,7 +35,7 @@ public class MixDefineELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testMixDefine1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -5,10 +5,12 @@ import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.monitor.MonitorBus;
import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.event.annotation.AfterTestClass;
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;
@ -23,7 +25,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/monitor/application.properties")
@SpringBootTest(classes = MonitorELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -36,13 +38,14 @@ public class MonitorELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testMonitor() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
Thread.sleep(10000);
}
@AfterClass
@AfterAll
public static void clean() {
BaseTest.cleanScanCache();
MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class);
monitorBus.closeScheduler();
}

View File

@ -6,9 +6,10 @@ import cn.hutool.core.util.CharsetUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -18,7 +19,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.io.File;
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/monitorFile/application.properties")
@SpringBootTest(classes = MonitorFileELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -36,7 +37,7 @@ public class MonitorFileELDeclMultiSpringbootTest extends BaseTest {
FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
Thread.sleep(3000);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>c==>b", response.getExecuteStepStr());
Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr());
}

View File

@ -6,9 +6,10 @@ import com.yomahub.liteflow.exception.NoSuchContextBeanException;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -23,7 +24,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/multiContext/application.properties")
@SpringBootTest(classes = MultiContextELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -38,18 +39,19 @@ public class MultiContextELDeclMultiSpringbootTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class);
OrderContext orderContext = response.getContextBean(OrderContext.class);
CheckContext checkContext = response.getContextBean(CheckContext.class);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("987XYZ", checkContext.getSign());
Assert.assertEquals(95, checkContext.getRandomId());
Assert.assertEquals("SO12345", orderContext.getOrderNo());
Assert.assertEquals(2, orderContext.getOrderType());
Assert.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("987XYZ", checkContext.getSign());
Assertions.assertEquals(95, checkContext.getRandomId());
Assertions.assertEquals("SO12345", orderContext.getOrderNo());
Assertions.assertEquals(2, orderContext.getOrderType());
Assertions.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime());
}
@Test(expected = NoSuchContextBeanException.class)
@Test
public void testMultiContext2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class);
DefaultContext context = response.getContextBean(DefaultContext.class);
Assertions.assertThrows(NoSuchContextBeanException.class, () -> {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class);
DefaultContext context = response.getContextBean(DefaultContext.class);
});
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.multipleType;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
@ -19,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @author Bryan.Zhang
* @since 2.5.10
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/multipleType/application.properties")
@SpringBootTest(classes = LiteflowMultipleTypeELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -32,11 +33,11 @@ public class LiteflowMultipleTypeELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testMultipleType() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr());
response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.10
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/nodeExecutor/application.properties")
@SpringBootTest(classes = LiteflowNodeExecutorELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -36,9 +37,9 @@ public class LiteflowNodeExecutorELDeclMultiSpringbootTest extends BaseTest {
public void testCustomerDefaultNodeExecutor() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor"));
Assert.assertEquals("a", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor"));
Assertions.assertEquals("a", response.getExecuteStepStr());
}
// 默认执行器测试+全局重试配置测试
@ -46,17 +47,17 @@ public class LiteflowNodeExecutorELDeclMultiSpringbootTest extends BaseTest {
public void testDefaultExecutorForRetry() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor"));
Assert.assertEquals("b==>b==>b", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor"));
Assertions.assertEquals("b==>b==>b", response.getExecuteStepStr());
}
// 自定义执行器测试
@Test
public void testCustomerExecutor() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("c", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("c", response.getExecuteStepStr());
}
// 自定义执行器测试+全局重试配置测试
@ -64,9 +65,9 @@ public class LiteflowNodeExecutorELDeclMultiSpringbootTest extends BaseTest {
public void testCustomExecutorForRetry() {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic"));
Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic"));
Assertions.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parsecustom;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author dongguo.tao
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parsecustom/application-custom-json.properties")
@SpringBootTest(classes = CustomParserJsonELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,7 +35,7 @@ public class CustomParserJsonELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testJsonCustomParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parsecustom;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author bryan.zhang
* @since 2.5.7
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parsecustom/application-custom-xml.properties")
@SpringBootTest(classes = CustomParserXmlELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,7 +35,7 @@ public class CustomParserXmlELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testXmlCustomParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parser/application-json.properties")
@SpringBootTest(classes = JsonParserELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,7 +35,7 @@ public class JsonParserELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testJsonParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -14,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parser/application-springEL.properties")
@SpringBootTest(classes = SpringELSupportELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -28,7 +29,7 @@ public class SpringELSupportELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testSpringELParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parser/application-xml.properties")
@SpringBootTest(classes = XmlParserELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,7 +35,7 @@ public class XmlParserELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testXmlParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parser/application-yml.properties")
@SpringBootTest(classes = YmlParserELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -34,7 +35,7 @@ public class YmlParserELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testYmlParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/preAndFinally/application.properties")
@SpringBootTest(classes = PreAndFinallyELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -35,24 +36,24 @@ public class PreAndFinallyELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testPreAndFinally1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.getExecuteStepStr());
}
// 测试pre和finally节点不放在开头和结尾的情况
@Test
public void testPreAndFinally2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.getExecuteStepStr());
}
// 测试有节点报错是否还执行finally节点的情况其中d节点会报错但依旧执行f1,f2节点
@Test
public void testPreAndFinally3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr());
}
// 测试在finally节点里是否能获取exception
@ -60,15 +61,15 @@ public class PreAndFinallyELDeclMultiSpringbootTest extends BaseTest {
public void testPreAndFinally4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(context.getData("hasEx"));
Assertions.assertFalse(response.isSuccess());
Assertions.assertTrue((Boolean) context.getData("hasEx"));
}
@Test
public void testPreAndFinally5() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime());
}
}

View File

@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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 Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/privateDelivery/application.properties")
@SpringBootTest(classes = PrivateDeliveryELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -37,8 +38,8 @@ public class PrivateDeliveryELDeclMultiSpringbootTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
ConcurrentHashSet<Integer> set = context.getData("testSet");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(100, set.size());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals(100, set.size());
}
}

View File

@ -6,9 +6,10 @@ import com.yomahub.liteflow.enums.FlowParserTypeEnum;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -23,7 +24,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/refreshRule/application.properties")
@SpringBootTest(classes = RefreshRuleELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -39,7 +40,7 @@ public class RefreshRuleELDeclMultiSpringbootTest extends BaseTest {
String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.el.xml");
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_EL_XML, content);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// 测试优雅刷新的场景
@ -59,7 +60,7 @@ public class RefreshRuleELDeclMultiSpringbootTest extends BaseTest {
for (int i = 0; i < 500; i++) {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
try {
Thread.sleep(10L);
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.reload;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/reload/application.properties")
@SpringBootTest(classes = ReloadELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -36,7 +37,7 @@ public class ReloadELDeclMultiSpringbootTest extends BaseTest {
public void testReload() throws Exception {
flowExecutor.reloadRule();
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.requestId;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -17,7 +18,7 @@ import javax.annotation.Resource;
/**
* @author tangkc
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/requestId/application.properties")
@SpringBootTest(classes = LiteflowRequestIdELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -30,8 +31,8 @@ public class LiteflowRequestIdELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testRequestId() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("1", response.getSlot().getRequestId());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("1", response.getSlot().getRequestId());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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 java.util.Set;
*
* @author justin.xu
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/subflow/application-implicit.properties")
@SpringBootTest(classes = ImplicitSubFlowELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -39,15 +40,15 @@ public class ImplicitSubFlowELDeclMultiSpringbootTest extends BaseTest {
public void testImplicitSubFlow1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("f==>g==>h==>m", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("f==>g==>h==>m", response.getExecuteStepStr());
// 传递了slotIndex则set的size==1
Assert.assertEquals(1, RUN_TIME_SLOT.size());
Assertions.assertEquals(1, RUN_TIME_SLOT.size());
// set中第一次设置的requestId和response中的requestId一致
Assert.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId()));
Assertions.assertTrue(RUN_TIME_SLOT.contains(response.getSlot().getRequestId()));
// requestData的取值正确
Assert.assertEquals("it's implicit subflow.", context.getData("innerRequest"));
Assertions.assertEquals("it's implicit subflow.", context.getData("innerRequest"));
}
// 在p里多线程调用q 10次每个q取到的参数都是不同的
@ -55,12 +56,12 @@ public class ImplicitSubFlowELDeclMultiSpringbootTest extends BaseTest {
public void testImplicitSubFlow2() {
LiteflowResponse response = flowExecutor.execute2Resp("c1", "it's a request");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
Set<String> set = context.getData("test");
// requestData的取值正确
Assert.assertEquals(10, set.size());
Assertions.assertEquals(10, set.size());
}
}

View File

@ -5,9 +5,10 @@ import com.yomahub.liteflow.exception.MultipleParsersException;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.test.BaseTest;
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.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
@ -23,7 +24,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/subflow/application-subInDifferentConfig1.properties")
@SpringBootTest(classes = SubflowInDifferentConfigELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -37,19 +38,21 @@ public class SubflowInDifferentConfigELDeclMultiSpringbootTest extends BaseTest
@Test
public void testExplicitSubFlow1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>b==>a==>e==>d", response.getExecuteStepStr());
}
@Autowired
private ApplicationContext context;
// 主要测试有不同的配置类型后会不会报出既定的错误
@Test(expected = MultipleParsersException.class)
@Test
public void testExplicitSubFlow2() {
LiteflowConfig config = context.getBean(LiteflowConfig.class);
config.setRuleSource("subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.yml");
flowExecutor.reloadRule();
Assertions.assertThrows(MultipleParsersException.class, () -> {
LiteflowConfig config = context.getBean(LiteflowConfig.class);
config.setRuleSource("subflow/flow-main.xml,subflow/flow-sub1.xml,subflow/flow-sub2.yml");
flowExecutor.reloadRule();
});
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
*
* @author justin.xu
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/subflow/application-json.properties")
@SpringBootTest(classes = SubflowJsonELDeclMultiSpringBootTest.class)
@EnableAutoConfiguration
@ -33,8 +34,8 @@ public class SubflowJsonELDeclMultiSpringBootTest extends BaseTest {
@Test
public void testExplicitSubFlow() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
*
* @author justin.xu
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/subflow/application-xml.properties")
@SpringBootTest(classes = SubflowXMLELDeclMultiSpringBootTest.class)
@EnableAutoConfiguration
@ -33,8 +34,8 @@ public class SubflowXMLELDeclMultiSpringBootTest extends BaseTest {
@Test
public void testExplicitSubFlow() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.subflow;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
*
* @author justin.xu
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/subflow/application-yml.properties")
@SpringBootTest(classes = SubflowYmlELDeclMultiSpringBootTest.class)
@EnableAutoConfiguration
@ -33,8 +34,8 @@ public class SubflowYmlELDeclMultiSpringBootTest extends BaseTest {
@Test
public void testExplicitSubFlowYml() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c==>b==>a==>e==>d", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.switchcase;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/switchcase/application.properties")
@SpringBootTest(classes = SwitchELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -33,36 +34,36 @@ public class SwitchELDeclMultiSpringbootTest extends BaseTest {
@Test
public void testSwitch1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>e==>d==>b", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>e==>d==>b", response.getExecuteStepStr());
}
@Test
public void testSwitch2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>e==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>e==>d", response.getExecuteStepStr());
}
@Test
public void testSwitch3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>f==>b", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>f==>b", response.getExecuteStepStr());
}
@Test
public void testSwitch4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>g==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>g==>d", response.getExecuteStepStr());
}
@Test
public void testSwitch5() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>h==>b", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>h==>b", response.getExecuteStepStr());
}
}

View File

@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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 Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/tag/application-json.properties")
@SpringBootTest(classes = NodeTagELDeclMultiSpringbootJsonTest.class)
@EnableAutoConfiguration
@ -36,15 +37,15 @@ public class NodeTagELDeclMultiSpringbootJsonTest extends BaseTest {
public void testTag1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("123", context.getData("test"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("123", context.getData("test"));
}
@Test
public void testTag2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr());
}
// 测试多线程when情况下的tag取值是否正确
@ -54,9 +55,9 @@ public class NodeTagELDeclMultiSpringbootJsonTest extends BaseTest {
for (int i = 0; i < 50; i++) {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
ConcurrentHashSet<String> testSet = context.getData("test");
Assert.assertEquals(3, testSet.size());
Assertions.assertEquals(3, testSet.size());
}
}
@ -64,8 +65,8 @@ public class NodeTagELDeclMultiSpringbootJsonTest extends BaseTest {
@Test
public void testTag4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("g", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("g", response.getExecuteStepStr());
}
}

View File

@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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 Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/tag/application-xml.properties")
@SpringBootTest(classes = NodeTagELDeclMultiSpringbootXmlTest.class)
@EnableAutoConfiguration
@ -36,15 +37,15 @@ public class NodeTagELDeclMultiSpringbootXmlTest extends BaseTest {
public void testTag1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("123", context.getData("test"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("123", context.getData("test"));
}
@Test
public void testTag2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>a==>a==>c==>e", response.getExecuteStepStr());
}
// 测试多线程when情况下的tag取值是否正确
@ -54,9 +55,9 @@ public class NodeTagELDeclMultiSpringbootXmlTest extends BaseTest {
for (int i = 0; i < 50; i++) {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
ConcurrentHashSet<String> testSet = context.getData("test");
Assert.assertEquals(3, testSet.size());
Assertions.assertEquals(3, testSet.size());
}
}
@ -64,8 +65,8 @@ public class NodeTagELDeclMultiSpringbootXmlTest extends BaseTest {
@Test
public void testTag4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("g", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("g", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.3
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/useTTLInWhen/application.properties")
@SpringBootTest(classes = UseTTLInWhenELDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ -35,11 +36,11 @@ public class UseTTLInWhenELDeclMultiSpringbootTest extends BaseTest {
public void testUseTTLInWhen() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertEquals("hello,b", context.getData("b"));
Assert.assertEquals("hello,c", context.getData("c"));
Assert.assertEquals("hello,d", context.getData("d"));
Assert.assertEquals("hello,e", context.getData("e"));
Assert.assertEquals("hello,f", context.getData("f"));
Assertions.assertEquals("hello,b", context.getData("b"));
Assertions.assertEquals("hello,c", context.getData("c"));
Assertions.assertEquals("hello,d", context.getData("d"));
Assertions.assertEquals("hello,e", context.getData("e"));
Assertions.assertEquals("hello,f", context.getData("f"));
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.exception.WhenTimeoutException;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -23,7 +24,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/whenTimeOut/application1.properties")
@SpringBootTest(classes = WhenTimeOutELDeclMultiSpringbootTest1.class)
@EnableAutoConfiguration
@ -39,8 +40,8 @@ public class WhenTimeOutELDeclMultiSpringbootTest1 extends BaseTest {
@Test
public void testWhenTimeOut() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals(WhenTimeoutException.class, response.getCause().getClass());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals(WhenTimeoutException.class, response.getCause().getClass());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.whenTimeOut;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -22,7 +23,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/whenTimeOut/application2.properties")
@SpringBootTest(classes = WhenTimeOutELDeclMultiSpringbootTest2.class)
@EnableAutoConfiguration
@ -38,7 +39,7 @@ public class WhenTimeOutELDeclMultiSpringbootTest2 extends BaseTest {
@Test
public void testWhenTimeOut() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -6,11 +6,11 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter;
import com.yomahub.liteflow.spi.holder.SpiFactoryCleaner;
import com.yomahub.liteflow.spring.ComponentScanner;
import com.yomahub.liteflow.thread.ExecutorHelper;
import org.junit.AfterClass;
import org.junit.jupiter.api.AfterAll;
public class BaseTest {
@AfterClass
@AfterAll
public static void cleanScanCache() {
ComponentScanner.cleanCache();
FlowBus.cleanCache();

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.absoluteConfigPath;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -22,7 +23,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties")
@SpringBootTest(classes = AbsoluteConfigPathELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -37,7 +38,7 @@ public class AbsoluteConfigPathELDeclSpringbootTest extends BaseTest {
@Test
public void testAbsoluteConfig() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -9,7 +9,7 @@ import com.yomahub.liteflow.test.BaseTest;
* @author Bryan.Zhang
*/
/*
* @RunWith(SpringRunner.class)
* @ExtendWith(SpringExtension.class)
*
* @TestPropertySource(value = "classpath:/aop/application.properties")
*
@ -31,17 +31,17 @@ public class CustomAOPELDeclSpringbootTest extends BaseTest {
*
* @Test public void testCustomAopS() { LiteflowResponse response=
* flowExecutor.execute2Resp("chain1", "it's a request");
* Assert.assertTrue(response.isSuccess()); Assert.assertEquals("before_after",
* response.getContextBean.getData("a")); Assert.assertEquals("before_after",
* context.getData("b")); Assert.assertEquals("before_after", context.getData("c")); }
* Assertions.assertTrue(response.isSuccess()); Assertions.assertEquals("before_after",
* response.getContextBean.getData("a")); Assertions.assertEquals("before_after",
* context.getData("b")); Assertions.assertEquals("before_after", context.getData("c")); }
*
* //测试自定义AOP并行场景
*
* @Test public void testCustomAopP() { LiteflowResponse response=
* flowExecutor.execute2Resp("chain2", "it's a request");
* Assert.assertTrue(response.isSuccess()); Assert.assertEquals("before_after",
* context.getData("a")); Assert.assertEquals("before_after", context.getData("b"));
* Assert.assertEquals("before_after", context.getData("c")); }
* Assertions.assertTrue(response.isSuccess()); Assertions.assertEquals("before_after",
* context.getData("a")); Assertions.assertEquals("before_after", context.getData("b"));
* Assertions.assertEquals("before_after", context.getData("c")); }
*/
}

View File

@ -6,10 +6,11 @@ import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.spring.ComponentScanner;
import com.yomahub.liteflow.test.BaseTest;
import com.yomahub.liteflow.test.aop.aspect.CmpAspect;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterAll;
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;
@ -24,7 +25,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/aop/application.properties")
@SpringBootTest(classes = GlobalAOPELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -40,12 +41,12 @@ public class GlobalAOPELDeclSpringbootTest extends BaseTest {
public void testGlobalAopS() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a request");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("before_after", context.getData("a"));
Assert.assertEquals("before_after", context.getData("b"));
Assert.assertEquals("before_after", context.getData("c"));
Assert.assertEquals("before_after", context.getData("d"));
Assert.assertEquals("before_after", context.getData("e"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("before_after", context.getData("a"));
Assertions.assertEquals("before_after", context.getData("b"));
Assertions.assertEquals("before_after", context.getData("c"));
Assertions.assertEquals("before_after", context.getData("d"));
Assertions.assertEquals("before_after", context.getData("e"));
}
// 测试全局AOP并行场景
@ -53,26 +54,26 @@ public class GlobalAOPELDeclSpringbootTest extends BaseTest {
public void testGlobalAopP() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "it's a request");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("before_after", context.getData("a"));
Assert.assertEquals("before_after", context.getData("b"));
Assert.assertEquals("before_after", context.getData("c"));
Assert.assertEquals("before_after", context.getData("d"));
Assert.assertEquals("before_after", context.getData("e"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("before_after", context.getData("a"));
Assertions.assertEquals("before_after", context.getData("b"));
Assertions.assertEquals("before_after", context.getData("c"));
Assertions.assertEquals("before_after", context.getData("d"));
Assertions.assertEquals("before_after", context.getData("e"));
}
@Test
public void testGlobalAopException() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "it's a request");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("before_after", context.getData("a"));
Assert.assertEquals("before_after", context.getData("b"));
Assert.assertEquals("before_after", context.getData("c"));
Assert.assertEquals("before_after", context.getData("f"));
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("before_after", context.getData("a"));
Assertions.assertEquals("before_after", context.getData("b"));
Assertions.assertEquals("before_after", context.getData("c"));
Assertions.assertEquals("before_after", context.getData("f"));
}
@AfterClass
@AfterAll
public static void cleanScanCache() {
BaseTest.cleanScanCache();
ComponentScanner.cmpAroundAspect = null;

View File

@ -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"));
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.base;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/base/application.properties")
@SpringBootTest(classes = BaseELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -33,7 +34,7 @@ public class BaseELDeclSpringbootTest extends BaseTest {
@Test
public void testBase() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import com.yomahub.liteflow.test.base.BaseELDeclSpringbootTest;
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;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
//基于builder模式的单元测试
//这里只是最基本的builder模式的测试只是为了验证在springboot模式下的正常性
//更详细的builder模式测试用例会单独拉testcase去做
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = BuilderELDeclSpringbootTest1.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.builder.cmp1" })
@ -39,8 +40,8 @@ public class BuilderELDeclSpringbootTest1 extends BaseTest {
.build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>e==>c==>d", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>e==>c==>d", response.getExecuteStepStrWithoutTime());
}
// 基于普通组件的builder模式测试
@ -54,8 +55,8 @@ public class BuilderELDeclSpringbootTest1 extends BaseTest {
.build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>e==>c==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>e==>c==>d", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -16,7 +17,7 @@ import javax.annotation.Resource;
//基于builder模式的单元测试
//这里测试的是通过spring去扫描但是通过代码去构建chain的用例
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = BuilderELDeclSpringbootTest2.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.builder.cmp2" })
@ -31,8 +32,8 @@ public class BuilderELDeclSpringbootTest2 extends BaseTest {
LiteFlowChainELBuilder.createChain().setChainName("chain1").setEL("THEN(h, i, j)").build();
LiteflowResponse response = flowExecutor.execute2Resp("chain1");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("h==>i==>j", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("h==>i==>j", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.cmpRetry;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.10
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/cmpRetry/application.properties")
@SpringBootTest(classes = LiteflowRetryELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -34,31 +35,31 @@ public class LiteflowRetryELDeclSpringbootTest extends BaseTest {
@Test
public void testRetry1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>b==>b", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>b==>b", response.getExecuteStepStr());
}
// 单个组件重试配置测试
@Test
public void testRetry2() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("c==>c==>c==>c==>c==>c", response.getExecuteStepStr());
}
// 单个组件指定异常但抛出的并不是指定异常的场景测试
@Test
public void testRetry3() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertFalse(response.isSuccess());
Assertions.assertFalse(response.isSuccess());
}
// 单个组件指定异常重试抛出的是指定异常或者
@Test
public void testRetry4() {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("e==>e==>e==>e==>e==>e", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.flow.entity.CmpStep;
import com.yomahub.liteflow.test.BaseTest;
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 java.util.*;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/cmpStep/application.properties")
@SpringBootTest(classes = CmpStepELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -35,31 +36,31 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
@Test
public void testStep() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assert.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assert.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assert.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
Assertions.assertFalse(response.isSuccess());
Assertions.assertTrue(response.getExecuteSteps().get("a").get(0).isSuccess());
Assertions.assertTrue(response.getExecuteSteps().get("b").get(0).isSuccess());
Assertions.assertFalse(response.getExecuteSteps().get("c").get(0).isSuccess());
Assertions.assertFalse(response.getExecuteSteps().get("d").get(0).isSuccess());
Assertions.assertTrue(response.getExecuteSteps().get("c").get(0).getTimeSpent() >= 2000);
Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("c").get(0).getException().getClass());
Assertions.assertEquals(RuntimeException.class, response.getExecuteSteps().get("d").get(0).getException().getClass());
}
@Test
public void testStep2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b", response.getExecuteStepStrWithoutTime());
}
@Test
public void testStep3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
Map<String, List<CmpStep>> stepMap = response.getExecuteSteps();
Assert.assertEquals(2, stepMap.size());
Assertions.assertEquals(2, stepMap.size());
Queue<CmpStep> queue = response.getExecuteStepQueue();
Assert.assertEquals(5, queue.size());
Assertions.assertEquals(5, queue.size());
Set<String> tagSet = new HashSet<>();
response.getExecuteStepQueue()
@ -67,7 +68,7 @@ public class CmpStepELDeclSpringbootTest extends BaseTest {
.filter(cmpStep -> cmpStep.getNodeId().equals("a"))
.forEach(cmpStep -> tagSet.add(cmpStep.getTag()));
Assert.assertEquals(3, tagSet.size());
Assertions.assertEquals(3, tagSet.size());
}

View File

@ -4,9 +4,10 @@ import cn.hutool.core.collection.ListUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/comments/application.properties")
@SpringBootTest(classes = LiteflowNodeELSpringbootTest.class)
@EnableAutoConfiguration
@ -29,8 +30,8 @@ public class LiteflowNodeELSpringbootTest extends BaseTest {
@Test
public void testAsyncFlow1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "it's a base request");
Assert.assertTrue(response.isSuccess());
Assert.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr()));
Assertions.assertTrue(response.isSuccess());
Assertions.assertTrue(ListUtil.toList("a==>b==>c==>b", "a==>b==>b==>c").contains(response.getExecuteStepStr()));
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.complex;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/complex/application1.properties")
@SpringBootTest(classes = ComplexELDeclSpringbootTest1.class)
@EnableAutoConfiguration
@ -35,7 +36,7 @@ public class ComplexELDeclSpringbootTest1 extends BaseTest {
@Test
public void testComplex1_1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1_1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// 测试复杂例子优化后
@ -44,7 +45,7 @@ public class ComplexELDeclSpringbootTest1 extends BaseTest {
@Test
public void testComplex1_2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1_2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.complex;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/complex/application2.properties")
@SpringBootTest(classes = ComplexELDeclSpringbootTest2.class)
@EnableAutoConfiguration
@ -35,7 +36,7 @@ public class ComplexELDeclSpringbootTest2 extends BaseTest {
@Test
public void testComplex2_1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2_1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// 测试复杂例子优化后
@ -44,7 +45,7 @@ public class ComplexELDeclSpringbootTest2 extends BaseTest {
@Test
public void testComplex2_2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2_2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.component;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -22,7 +23,7 @@ import javax.annotation.Resource;
*
* @author donguo.tao
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/component/application.properties")
@SpringBootTest(classes = FlowExecutorELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -38,56 +39,57 @@ public class FlowExecutorELDeclSpringbootTest extends BaseTest {
@Test
public void testIsAccess() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", 101);
Assert.assertTrue(response.isSuccess());
Assert.assertNotNull(response.getSlot().getResponseData());
Assertions.assertTrue(response.isSuccess());
Assertions.assertNotNull(response.getSlot().getResponseData());
}
// 组件抛错的功能点测试
@Test(expected = ArithmeticException.class)
public void testComponentException() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0);
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("/ by zero", response.getMessage());
ReflectionUtils.rethrowException(response.getCause());
Assertions.assertThrows(ArithmeticException.class, () -> {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", 0);
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("/ by zero", response.getMessage());
ReflectionUtils.rethrowException(response.getCause());
});
}
// isContinueOnError方法的功能点测试
@Test
public void testIsContinueOnError() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", 0);
Assert.assertTrue(response.isSuccess());
Assert.assertNull(response.getCause());
Assertions.assertTrue(response.isSuccess());
Assertions.assertNull(response.getCause());
}
// isEnd方法的功能点测试
@Test
public void testIsEnd() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", 10);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("d", response.getExecuteStepStr());
}
// setIsEnd方法的功能点测试
@Test
public void testSetIsEnd1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", 10);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("e", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("e", response.getExecuteStepStr());
}
// 条件组件的功能点测试
@Test
public void testNodeCondComponent() {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", 0);
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// 测试setIsEnd如果为truecontinueError也为true那不应该continue了
@Test
public void testSetIsEnd2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain7", 10);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("g", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("g", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.customMethodName;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.7.2
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/customMethodName/application.properties")
@SpringBootTest(classes = CustomMethodNameELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -33,7 +34,7 @@ public class CustomMethodNameELDeclSpringbootTest extends BaseTest {
@Test
public void testCustomMethodName() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.customNodes;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -22,7 +23,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/customNodes/application.properties")
@SpringBootTest(classes = CustomNodesELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -37,9 +38,9 @@ public class CustomNodesELDeclSpringbootTest extends BaseTest {
@Test
public void testCustomNodes() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -23,7 +24,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/customWhenThreadPool/application.properties")
@SpringBootTest(classes = CustomWhenThreadPoolELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -42,8 +43,8 @@ public class CustomWhenThreadPoolELDeclSpringbootTest extends BaseTest {
public void testGlobalThreadPool() {
LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertTrue(context.getData("threadName").toString().startsWith("lf-when-thead"));
}
/**
@ -53,8 +54,8 @@ public class CustomWhenThreadPoolELDeclSpringbootTest extends BaseTest {
public void testGlobalAndCustomWhenThreadPool() {
LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response1.getFirstContextBean();
Assert.assertTrue(response1.isSuccess());
Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead"));
Assertions.assertTrue(response1.isSuccess());
Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead"));
}
/**
@ -67,8 +68,8 @@ public class CustomWhenThreadPoolELDeclSpringbootTest extends BaseTest {
// chain配置同一个thead1
LiteflowResponse response2 = flowExecutor.execute2Resp("chain2", "arg");
DefaultContext context = response2.getFirstContextBean();
Assert.assertTrue(response2.isSuccess());
Assert.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead"));
Assertions.assertTrue(response2.isSuccess());
Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-1-thead"));
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/event/application.properties")
@SpringBootTest(classes = EventELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -36,8 +37,8 @@ public class EventELDeclSpringbootTest extends BaseTest {
public void testEvent1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("abc", context.getData("test"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("abc", context.getData("test"));
}
// 测试组件失败事件
@ -45,10 +46,10 @@ public class EventELDeclSpringbootTest extends BaseTest {
public void testEvent2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
Assert.assertEquals("ab", context.getData("test"));
Assert.assertEquals("error:d", context.getData("error"));
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals(NullPointerException.class, response.getCause().getClass());
Assertions.assertEquals("ab", context.getData("test"));
Assertions.assertEquals("error:d", context.getData("error"));
}
// 测试组件失败事件本身抛出异常
@ -56,10 +57,10 @@ public class EventELDeclSpringbootTest extends BaseTest {
public void testEvent3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertEquals(NullPointerException.class, response.getCause().getClass());
Assert.assertEquals("a", context.getData("test"));
Assert.assertEquals("error:e", context.getData("error"));
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals(NullPointerException.class, response.getCause().getClass());
Assertions.assertEquals("a", context.getData("test"));
Assertions.assertEquals("error:e", context.getData("error"));
}
}

View File

@ -7,8 +7,10 @@ import com.yomahub.liteflow.exception.FlowExecutorNotInitException;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.property.LiteflowConfigGetter;
import com.yomahub.liteflow.test.BaseTest;
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.test.context.junit4.SpringRunner;
@ -20,7 +22,7 @@ import javax.annotation.Resource;
*
* @author zendwang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Exception1ELDeclSpringBootTest.class)
@EnableAutoConfiguration
public class Exception1ELDeclSpringBootTest extends BaseTest {
@ -31,31 +33,38 @@ public class Exception1ELDeclSpringBootTest extends BaseTest {
/**
* 验证 chain 节点重复的异常
*/
@Test(expected = ChainDuplicateException.class)
@Test
public void testChainDuplicateException() {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.el.xml");
flowExecutor.reloadRule();
Assertions.assertThrows(ChainDuplicateException.class, () -> {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.el.xml");
flowExecutor.reloadRule();
});
}
@Test(expected = ConfigErrorException.class)
@Test
public void testConfigErrorException() {
flowExecutor.setLiteflowConfig(null);
flowExecutor.reloadRule();
Assertions.assertThrows(ConfigErrorException.class, () -> {
flowExecutor.setLiteflowConfig(null);
flowExecutor.reloadRule();
});
}
@Test(expected = FlowExecutorNotInitException.class)
@Test
public void testFlowExecutorNotInitException() {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("error/flow.txt");
flowExecutor.reloadRule();
Assertions.assertThrows(FlowExecutorNotInitException.class, () -> {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("error/flow.txt");
flowExecutor.reloadRule();
});
}
@Test(expected = FlowExecutorNotInitException.class)
@Test
public void testNoConditionInChainException() throws Exception {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-blank.el.xml");
flowExecutor.reloadRule();
Assertions.assertThrows(FlowExecutorNotInitException.class, () -> {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-blank.el.xml");
flowExecutor.reloadRule();
});
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.exception.*;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
*
* @author zendwang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/exception/application.properties")
@SpringBootTest(classes = Exception2ELDeclSpringBootTest.class)
@EnableAutoConfiguration
@ -31,46 +32,53 @@ public class Exception2ELDeclSpringBootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
@Test(expected = ChainNotFoundException.class)
@Test
public void testChainNotFoundException() throws Exception {
flowExecutor.execute("chain0", "it's a request");
Assertions.assertThrows(ChainNotFoundException.class, () -> {
flowExecutor.execute("chain0", "it's a request");
});
}
@Test(expected = RuntimeException.class)
@Test
public void testComponentCustomException() throws Exception {
flowExecutor.execute("chain1", "exception");
Assertions.assertThrows(RuntimeException.class, () -> {
flowExecutor.execute("chain1", "exception");
});
}
@Test
public void testGetSlotFromResponseWhenException() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "test");
Assert.assertFalse(response.isSuccess());
Assert.assertNotNull(response.getCause());
Assert.assertNotNull(response.getSlot());
Assertions.assertFalse(response.isSuccess());
Assertions.assertNotNull(response.getCause());
Assertions.assertNotNull(response.getSlot());
}
@Test(expected = NoSwitchTargetNodeException.class)
@Test
public void testNoTargetFindException() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test");
Assert.assertFalse(response.isSuccess());
throw response.getCause();
Assertions.assertThrows(NoSwitchTargetNodeException.class, () -> {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "test");
Assertions.assertFalse(response.isSuccess());
throw response.getCause();
});
}
@Test
public void testInvokeCustomStatefulException() {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "custom-stateful-exception");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("300", response.getCode());
Assert.assertNotNull(response.getCause());
Assert.assertTrue(response.getCause() instanceof LiteFlowException);
Assert.assertNotNull(response.getSlot());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("300", response.getCode());
Assertions.assertNotNull(response.getCause());
Assertions.assertTrue(response.getCause() instanceof LiteFlowException);
Assertions.assertNotNull(response.getSlot());
}
@Test
public void testNotInvokeCustomStatefulException() {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "test");
Assert.assertTrue(response.isSuccess());
Assert.assertNull(response.getCode());
Assertions.assertTrue(response.isSuccess());
Assertions.assertNull(response.getCode());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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 java.util.concurrent.Future;
* @author Bryan.Zhang
* @since 2.6.13
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/execute2Future/application.properties")
@SpringBootTest(classes = Executor2FutureELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -36,7 +37,7 @@ public class Executor2FutureELDeclSpringbootTest extends BaseTest {
public void testFuture() throws Exception {
Future<LiteflowResponse> future = flowExecutor.execute2Future("chain1", "arg", DefaultContext.class);
LiteflowResponse response = future.get();
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.extend;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.7.1
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/extend/application.properties")
@SpringBootTest(classes = CmpExtendELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -33,7 +34,7 @@ public class CmpExtendELDeclSpringbootTest extends BaseTest {
@Test
public void testExtend() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/getChainName/application.properties")
@SpringBootTest(classes = GetChainNameELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -34,28 +35,28 @@ public class GetChainNameELDeclSpringbootTest extends BaseTest {
public void testGetChainName1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("sub1", context.getData("a"));
Assert.assertEquals("sub2", context.getData("b"));
Assert.assertEquals("sub3", context.getData("c"));
Assert.assertEquals("sub4", context.getData("d"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("sub1", context.getData("a"));
Assertions.assertEquals("sub2", context.getData("b"));
Assertions.assertEquals("sub3", context.getData("c"));
Assertions.assertEquals("sub4", context.getData("d"));
}
@Test
public void testGetChainName2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("chain2", context.getData("g"));
Assert.assertEquals("sub1", context.getData("a"));
Assert.assertEquals("sub2", context.getData("b"));
Assert.assertEquals("sub3", context.getData("c"));
Assert.assertEquals("sub4", context.getData("d"));
Assert.assertEquals("sub5", context.getData("f"));
Assert.assertEquals("sub5_chain2", context.getData("e"));
Assert.assertEquals("sub6", context.getData("h"));
Assert.assertEquals("sub6", context.getData("j"));
Assert.assertNull(context.getData("k"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("chain2", context.getData("g"));
Assertions.assertEquals("sub1", context.getData("a"));
Assertions.assertEquals("sub2", context.getData("b"));
Assertions.assertEquals("sub3", context.getData("c"));
Assertions.assertEquals("sub4", context.getData("d"));
Assertions.assertEquals("sub5", context.getData("f"));
Assertions.assertEquals("sub5_chain2", context.getData("e"));
Assertions.assertEquals("sub6", context.getData("h"));
Assertions.assertEquals("sub6", context.getData("j"));
Assertions.assertNull(context.getData("k"));
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.ifelse;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/ifelse/application.properties")
@SpringBootTest(classes = IfElseELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -34,56 +35,56 @@ public class IfElseELDeclSpringbootTest extends BaseTest {
@Test
public void testIf1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>a==>b", response.getExecuteStepStrWithoutTime());
}
// IF只有3个参数
@Test
public void testIf2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime());
}
// IF有3个参数进行嵌套
@Test
public void testIf3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime());
}
// IF有2个参数加上ELSE
@Test
public void testIf4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>c==>d", response.getExecuteStepStrWithoutTime());
}
// IF有2个参数ELSE里再嵌套一个IF
@Test
public void testIf5() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>x1==>c==>c==>b", response.getExecuteStepStrWithoutTime());
}
// 标准的IF ELIF ELSE
@Test
public void testIf6() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>x1==>c==>c", response.getExecuteStepStrWithoutTime());
}
// IF ELIF... ELSE 的形式
@Test
public void testIf7() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x1==>x1==>x1==>x1==>d==>b==>a", response.getExecuteStepStrWithoutTime());
}
}

View File

@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -23,7 +24,7 @@ import java.util.List;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/iterator/application.properties")
@SpringBootTest(classes = IteratorELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -38,10 +39,10 @@ public class IteratorELDeclSpringbootTest extends BaseTest {
public void testIt1() throws Exception {
List<String> list = ListUtil.toList("1", "2", "3");
LiteflowResponse response = flowExecutor.execute2Resp("chain1", list);
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
DefaultContext context = response.getFirstContextBean();
String str = context.getData("test");
Assert.assertEquals("123", str);
Assertions.assertEquals("123", str);
}
// 迭代器带break
@ -49,10 +50,10 @@ public class IteratorELDeclSpringbootTest extends BaseTest {
public void testIt2() throws Exception {
List<String> list = ListUtil.toList("1", "2", "3");
LiteflowResponse response = flowExecutor.execute2Resp("chain2", list);
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
DefaultContext context = response.getFirstContextBean();
String str = context.getData("test");
Assert.assertEquals("12", str);
Assertions.assertEquals("12", str);
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.lazy;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
//spring的延迟加载在el表达形式模式下不起作用
/*@RunWith(SpringRunner.class)
/*@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/lazy/application.properties")
@SpringBootTest(classes = LazyELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -27,7 +28,7 @@ public class LazyELDeclSpringbootTest extends BaseTest {
*
* @Test public void testLazy() throws Exception{ LiteflowResponse response =
* flowExecutor.execute2Resp("chain1", "arg");
* Assert.assertTrue(response.isSuccess()); }
* Assertions.assertTrue(response.isSuccess()); }
*/
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.lfCmpAnno;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
@ -19,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @author Bryan.Zhang
* @since 2.5.10
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/lfCmpAnno/application.properties")
@SpringBootTest(classes = LiteflowComponentELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -32,8 +33,8 @@ public class LiteflowComponentELDeclSpringbootTest extends BaseTest {
@Test
public void testConfig() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a[A组件]==>b[B组件]==>c[C组件]==>b[B组件]==>a[A组件]==>d", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
*
* @author Bryan.Zhang
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/loop/application.properties")
@SpringBootTest(classes = LoopELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -34,31 +35,31 @@ public class LoopELDeclSpringbootTest extends BaseTest {
@Test
public void testLoop1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("LOOP_2==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr());
}
// FPR循环由For组件定义
@Test
public void testLoop2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("x==>a==>b==>c==>a==>b==>c==>a==>b==>c", response.getExecuteStepStr());
}
// FOR循环中加入BREAK组件
@Test
public void testLoop3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
// WHILE循环
@Test
public void testLoop4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z",
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z==>a==>d==>z",
response.getExecuteStepStr());
}
@ -66,8 +67,8 @@ public class LoopELDeclSpringbootTest extends BaseTest {
@Test
public void testLoop5() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y",
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y==>z==>a==>d==>y",
response.getExecuteStepStr());
}
@ -76,10 +77,10 @@ public class LoopELDeclSpringbootTest extends BaseTest {
public void testLoop6() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain6", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("01234", context.getData("loop_e1"));
Assert.assertEquals("01234", context.getData("loop_e2"));
Assert.assertEquals("01234", context.getData("loop_e3"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("01234", context.getData("loop_e1"));
Assertions.assertEquals("01234", context.getData("loop_e2"));
Assertions.assertEquals("01234", context.getData("loop_e3"));
}
// 测试WHILE循环中的index
@ -87,10 +88,10 @@ public class LoopELDeclSpringbootTest extends BaseTest {
public void testLoop7() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain7", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("01234", context.getData("loop_e1"));
Assert.assertEquals("01234", context.getData("loop_e2"));
Assert.assertEquals("01234", context.getData("loop_e3"));
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("01234", context.getData("loop_e1"));
Assertions.assertEquals("01234", context.getData("loop_e2"));
Assertions.assertEquals("01234", context.getData("loop_e3"));
}
}

View File

@ -5,10 +5,11 @@ import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.monitor.MonitorBus;
import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterAll;
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;
@ -23,7 +24,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/monitor/application.properties")
@SpringBootTest(classes = MonitorELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -36,13 +37,14 @@ public class MonitorELDeclSpringbootTest extends BaseTest {
@Test
public void testMonitor() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
Thread.sleep(10000);
}
@AfterClass
@AfterAll
public static void clean() {
BaseTest.cleanScanCache();
MonitorBus monitorBus = ContextAwareHolder.loadContextAware().getBean(MonitorBus.class);
monitorBus.closeScheduler();
}

View File

@ -6,9 +6,10 @@ import cn.hutool.core.util.CharsetUtil;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -18,7 +19,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.io.File;
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/monitorFile/application.properties")
@SpringBootTest(classes = MonitorFileELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -36,7 +37,7 @@ public class MonitorFileELDeclSpringbootTest extends BaseTest {
FileUtil.writeString(newContent, new File(absolutePath), CharsetUtil.CHARSET_UTF_8);
Thread.sleep(3000);
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>c==>b", response.getExecuteStepStr());
Assertions.assertEquals("a==>c==>b", response.getExecuteStepStr());
}
}

View File

@ -6,9 +6,10 @@ import com.yomahub.liteflow.exception.NoSuchContextBeanException;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -23,7 +24,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/multiContext/application.properties")
@SpringBootTest(classes = MultiContextELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -38,18 +39,20 @@ public class MultiContextELDeclSpringbootTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class);
OrderContext orderContext = response.getContextBean(OrderContext.class);
CheckContext checkContext = response.getContextBean(CheckContext.class);
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("987XYZ", checkContext.getSign());
Assert.assertEquals(95, checkContext.getRandomId());
Assert.assertEquals("SO12345", orderContext.getOrderNo());
Assert.assertEquals(2, orderContext.getOrderType());
Assert.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("987XYZ", checkContext.getSign());
Assertions.assertEquals(95, checkContext.getRandomId());
Assertions.assertEquals("SO12345", orderContext.getOrderNo());
Assertions.assertEquals(2, orderContext.getOrderType());
Assertions.assertEquals(DateUtil.parseDate("2022-06-15"), orderContext.getCreateTime());
}
@Test(expected = NoSuchContextBeanException.class)
@Test
public void testMultiContext2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class);
DefaultContext context = response.getContextBean(DefaultContext.class);
Assertions.assertThrows(NoSuchContextBeanException.class, () -> {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", OrderContext.class, CheckContext.class);
DefaultContext context = response.getContextBean(DefaultContext.class);
});
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.multipleType;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
@ -19,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* @author Bryan.Zhang
* @since 2.5.10
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/multipleType/application.properties")
@SpringBootTest(classes = LiteflowMultipleTypeELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -32,11 +33,11 @@ public class LiteflowMultipleTypeELDeclSpringbootTest extends BaseTest {
@Test
public void testMultipleType() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c==>b==>a", response.getExecuteStepStr());
response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("a==>b==>c", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c", response.getExecuteStepStr());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.10
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/nodeExecutor/application.properties")
@SpringBootTest(classes = LiteflowNodeExecutorELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -36,9 +37,9 @@ public class LiteflowNodeExecutorELDeclSpringbootTest extends BaseTest {
public void testCustomerDefaultNodeExecutor() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor"));
Assert.assertEquals("a", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor"));
Assertions.assertEquals("a", response.getExecuteStepStr());
}
// 默认执行器测试+全局重试配置测试
@ -46,17 +47,17 @@ public class LiteflowNodeExecutorELDeclSpringbootTest extends BaseTest {
public void testDefaultExecutorForRetry() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor"));
Assert.assertEquals("b==>b==>b", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals(CustomerDefaultNodeExecutor.class, context.getData("customerDefaultNodeExecutor"));
Assertions.assertEquals("b==>b==>b", response.getExecuteStepStr());
}
// 自定义执行器测试
@Test
public void testCustomerExecutor() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("c", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("c", response.getExecuteStepStr());
}
// 自定义执行器测试+全局重试配置测试
@ -64,9 +65,9 @@ public class LiteflowNodeExecutorELDeclSpringbootTest extends BaseTest {
public void testCustomExecutorForRetry() {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic"));
Assert.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals(CustomerNodeExecutorAndCustomRetry.class, context.getData("retryLogic"));
Assertions.assertEquals("d==>d==>d==>d==>d==>d", response.getExecuteStepStr());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parsecustom;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author dongguo.tao
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parsecustom/application-custom-json.properties")
@SpringBootTest(classes = CustomParserJsonELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -34,7 +35,7 @@ public class CustomParserJsonELDeclSpringbootTest extends BaseTest {
@Test
public void testJsonCustomParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parsecustom;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -20,7 +21,7 @@ import javax.annotation.Resource;
* @author bryan.zhang
* @since 2.5.7
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parsecustom/application-custom-xml.properties")
@SpringBootTest(classes = CustomParserXmlELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -34,7 +35,7 @@ public class CustomParserXmlELDeclSpringbootTest extends BaseTest {
@Test
public void testXmlCustomParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "args");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.test.context.TestPropertySource;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parser/application-json.properties")
@SpringBootTest(classes = JsonParserELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -32,7 +33,7 @@ public class JsonParserELDeclSpringbootTest extends BaseTest {
@Test
public void testJsonParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.test.context.TestPropertySource;
@ -13,7 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parser/application-springEL.properties")
@SpringBootTest(classes = SpringELSupportELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -26,7 +27,7 @@ public class SpringELSupportELDeclSpringbootTest extends BaseTest {
@Test
public void testSpringELParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain11", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.test.context.TestPropertySource;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parser/application-xml.properties")
@SpringBootTest(classes = XmlParserELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -32,7 +33,7 @@ public class XmlParserELDeclSpringbootTest extends BaseTest {
@Test
public void testXmlParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -3,9 +3,10 @@ package com.yomahub.liteflow.test.parser;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
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.test.context.TestPropertySource;
@ -19,7 +20,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parser/application-yml.properties")
@SpringBootTest(classes = YmlParserELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -32,7 +33,7 @@ public class YmlParserELDeclSpringbootTest extends BaseTest {
@Test
public void testYmlParser() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assertions.assertTrue(response.isSuccess());
}
}

View File

@ -4,9 +4,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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;
@ -21,7 +22,7 @@ import javax.annotation.Resource;
* @author Bryan.Zhang
* @since 2.6.4
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/preAndFinally/application.properties")
@SpringBootTest(classes = PreAndFinallyELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -35,24 +36,24 @@ public class PreAndFinallyELDeclSpringbootTest extends BaseTest {
@Test
public void testPreAndFinally1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.getExecuteStepStr());
}
// 测试pre和finally节点不放在开头和结尾的情况
@Test
public void testPreAndFinally2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.getExecuteStepStr());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("p1==>p2==>a==>b==>c==>f1==>f2", response.getExecuteStepStr());
}
// 测试有节点报错是否还执行finally节点的情况其中d节点会报错但依旧执行f1,f2节点
@Test
public void testPreAndFinally3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertFalse(response.isSuccess());
Assert.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr());
Assertions.assertFalse(response.isSuccess());
Assertions.assertEquals("p1==>p2==>a==>d==>f1==>f2", response.getExecuteStepStr());
}
// 测试在finally节点里是否能获取exception
@ -60,15 +61,15 @@ public class PreAndFinallyELDeclSpringbootTest extends BaseTest {
public void testPreAndFinally4() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
DefaultContext context = response.getFirstContextBean();
Assert.assertFalse(response.isSuccess());
Assert.assertTrue(context.getData("hasEx"));
Assertions.assertFalse(response.isSuccess());
Assertions.assertTrue((Boolean) context.getData("hasEx"));
}
@Test
public void testPreAndFinally5() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("p1==>p2==>p1==>p2==>a==>b==>c==>f1==>f2==>f1", response.getExecuteStepStrWithoutTime());
}
}

View File

@ -5,9 +5,10 @@ import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.slot.DefaultContext;
import com.yomahub.liteflow.test.BaseTest;
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 Bryan.Zhang
* @since 2.5.0
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/privateDelivery/application.properties")
@SpringBootTest(classes = PrivateDeliveryELDeclSpringbootTest.class)
@EnableAutoConfiguration
@ -37,8 +38,8 @@ public class PrivateDeliveryELDeclSpringbootTest extends BaseTest {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
DefaultContext context = response.getFirstContextBean();
ConcurrentHashSet<Integer> set = context.getData("testSet");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals(100, set.size());
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals(100, set.size());
}
}

Some files were not shown because too many files have changed in this diff Show More