mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
增加springEL的测试用例
This commit is contained in:
@@ -22,10 +22,9 @@ import javax.annotation.Resource;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/parser/application-json.properties")
|
||||
@SpringBootTest(classes = LFParserJsonSpringbootTest.class)
|
||||
@SpringBootTest(classes = JsonParserSpringbootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.parser.cmp"})
|
||||
public class LFParserJsonSpringbootTest extends BaseTest {
|
||||
public class JsonParserSpringbootTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.yomahub.liteflow.test.parser;
|
||||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DefaultSlot;
|
||||
import com.yomahub.liteflow.entity.data.LiteflowResponse;
|
||||
import com.yomahub.liteflow.test.BaseTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/parser/application-springEL.properties")
|
||||
@SpringBootTest(classes = SpringELSupportSpringbootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
public class SpringELSupportSpringbootTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
//测试springEL的解析情况
|
||||
@Test
|
||||
public void testSpringELParser() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,9 @@ import javax.annotation.Resource;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/parser/application-xml.properties")
|
||||
@SpringBootTest(classes = LFParserXmlSpringbootTest.class)
|
||||
@SpringBootTest(classes = XmlParserSpringbootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.parser.cmp"})
|
||||
public class LFParserXmlSpringbootTest extends BaseTest {
|
||||
public class XmlParserSpringbootTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
@@ -22,10 +22,9 @@ import javax.annotation.Resource;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@TestPropertySource(value = "classpath:/parser/application-yml.properties")
|
||||
@SpringBootTest(classes = LFParserYmlSpringbootTest.class)
|
||||
@SpringBootTest(classes = YmlParserSpringbootTest.class)
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan({"com.yomahub.liteflow.test.parser.cmp"})
|
||||
public class LFParserYmlSpringbootTest extends BaseTest {
|
||||
public class YmlParserSpringbootTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private FlowExecutor flowExecutor;
|
||||
@@ -17,10 +17,6 @@ public class ACmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
String str = this.getSlot().getRequestData();
|
||||
if(StrUtil.isNotBlank(str) && str.equals("exception")) {
|
||||
throw new FlowSystemException("chain execute execption");
|
||||
}
|
||||
System.out.println("ACmp executed!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
liteflow.rule-source=parser/**/*.xml
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<nodes>
|
||||
<node id="a" class="com.yomahub.liteflow.test.parser.cmp.ACmp"/>
|
||||
<node id="b" class="com.yomahub.liteflow.test.parser.cmp.BCmp"/>
|
||||
<node id="c" class="com.yomahub.liteflow.test.parser.cmp.CCmp"/>
|
||||
<node id="d" class="com.yomahub.liteflow.test.parser.cmp.DCmp"/>
|
||||
<node id="e" class="com.yomahub.liteflow.test.parser.cmp.ECmp"/>
|
||||
<node id="f" class="com.yomahub.liteflow.test.parser.cmp.FCmp"/>
|
||||
<node id="g" class="com.yomahub.liteflow.test.parser.cmp.GCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
<then value="a,c"/>
|
||||
<when value="b,d,e(f|g)"/>
|
||||
<then value="chain2"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
<then value="c,g,f"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
|
||||
<chain name="chain1">
|
||||
<then value="a,c"/>
|
||||
<when value="b,d,e(f|g)"/>
|
||||
<then value="chain2"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain2">
|
||||
<then value="c,g,f"/>
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user