增加springEL的测试用例

This commit is contained in:
bryan31
2022-01-19 13:47:59 +08:00
parent 92cc1934ea
commit 664d42c05b
9 changed files with 76 additions and 13 deletions

View File

@@ -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;

View File

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

View File

@@ -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;

View File

@@ -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;

View File

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

View File

@@ -0,0 +1 @@
liteflow.rule-source=parser/**/*.xml

View File

@@ -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>

View File

@@ -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>

View File

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