!60 chain重名的检测

Merge pull request !60 from 与或非/issues/I5BR5M
This commit is contained in:
铂赛东
2022-06-13 12:57:34 +00:00
committed by Gitee
20 changed files with 176 additions and 55 deletions

View File

@@ -1,26 +1,17 @@
package com.yomahub.liteflow.test.exception;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.exception.ChainNotFoundException;
import com.yomahub.liteflow.exception.ChainDuplicateException;
import com.yomahub.liteflow.exception.ConfigErrorException;
import com.yomahub.liteflow.exception.FlowExecutorNotInitException;
import com.yomahub.liteflow.exception.FlowSystemException;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.property.LiteflowConfigGetter;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ReflectionUtils;
import javax.annotation.Resource;
@@ -34,10 +25,20 @@ import javax.annotation.Resource;
@SpringBootTest(classes = Exception1SpringBootTest.class)
@EnableAutoConfiguration
public class Exception1SpringBootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
/**
* 验证 chain 节点重复的异常
*/
@Test(expected = ChainDuplicateException.class)
public void testChainDuplicateException() {
LiteflowConfig config = LiteflowConfigGetter.get();
config.setRuleSource("exception/flow-exception.xml");
flowExecutor.init();
}
@Test(expected = ConfigErrorException.class)
public void testConfigErrorException() {
flowExecutor.setLiteflowConfig(null);

View File

@@ -26,7 +26,7 @@ public class SpringELSupportSpringbootTest extends BaseTest {
//测试springEL的解析情况
@Test
public void testSpringELParser() {
LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain1", "arg");
LiteflowResponse<DefaultContext> response = flowExecutor.execute2Resp("chain11", "arg");
Assert.assertTrue(response.isSuccess());
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
<then value="a,b,c"/>
</chain>
<chain name="chain1">
<then value="a,b,c"/>
</chain>
</flow>

View File

@@ -10,13 +10,13 @@
<node id="g" class="com.yomahub.liteflow.test.parser.cmp.GCmp"/>
</nodes>
<chain name="chain1">
<chain name="chain11">
<then value="a,c"/>
<when value="b,d,e(f|g)"/>
<then value="chain2"/>
</chain>
<chain name="chain2">
<chain name="chain12">
<then value="c,g,f"/>
</chain>
</flow>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
<chain name="chain21">
<then value="a,c"/>
<when value="b,d,e(f|g)"/>
<then value="chain2"/>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain2">
<chain name="chain32">
<then value="c,g,f"/>
</chain>
</flow>