test #I7SVZF 补全springnative下抽象chain解析相关测试用例

This commit is contained in:
zy
2023-09-19 19:51:05 +08:00
parent 3242f03b18
commit 5eb40d68f3
17 changed files with 399 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package com.yomahub.liteflow.test.abstractChain;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.Resource;
@ExtendWith(SpringExtension.class)
@ContextConfiguration("classpath:/abstractChain/application-json.xml")
public class AbstractChainJsonELSpringTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
// 是否按照流程定义配置执行
@Test
public void test1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implA", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c==>d==>f==>j", response.getExecuteStepStrWithoutTime());
}
//测试嵌套继承的baseChain是否重复解析
@Test
public void test2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implB", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>j", response.getExecuteStepStrWithoutTime());
}
//测试嵌套继承的baseChain是否重复解析
@Test
public void test3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implC", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>a==>b", response.getExecuteStepStrWithoutTime());
}
}

View File

@@ -0,0 +1,46 @@
package com.yomahub.liteflow.test.abstractChain;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.Resource;
@ExtendWith(SpringExtension.class)
@ContextConfiguration("classpath:/abstractChain/application-xml.xml")
public class AbstractChainXMLELSpringTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
// 是否按照流程定义配置执行
@Test
public void test1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implA", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c==>d==>f==>j", response.getExecuteStepStrWithoutTime());
}
//测试嵌套继承的baseChain是否重复解析
@Test
public void test2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implB", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>j", response.getExecuteStepStrWithoutTime());
}
//测试嵌套继承的baseChain是否重复解析
@Test
public void test3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implC", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>a==>b", response.getExecuteStepStrWithoutTime());
}
}

View File

@@ -0,0 +1,46 @@
package com.yomahub.liteflow.test.abstractChain;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.test.BaseTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.Resource;
@ExtendWith(SpringExtension.class)
@ContextConfiguration("classpath:/abstractChain/application-yml.xml")
public class AbstractChainYMLELSpringTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
// 是否按照流程定义配置执行
@Test
public void test1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implA", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>c==>d==>f==>j", response.getExecuteStepStrWithoutTime());
}
//测试嵌套继承的baseChain是否重复解析
@Test
public void test2() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implB", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>j", response.getExecuteStepStrWithoutTime());
}
//测试嵌套继承的baseChain是否重复解析
@Test
public void test3() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("implC", "arg");
Assertions.assertTrue(response.isSuccess());
Assertions.assertEquals("a==>b==>a==>b==>a==>b==>f==>a==>b", response.getExecuteStepStrWithoutTime());
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("a")
public class ACmp extends NodeComponent {
@Override
public void process() {
System.out.println("ACmp executed!");
}
}

View File

@@ -0,0 +1,16 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("b")
public class BCmp extends NodeComponent {
@Override
public void process() {
System.out.println("BCmp executed!");
}
}

View File

@@ -0,0 +1,15 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.core.NodeIfComponent;
import org.springframework.stereotype.Component;
@Component("c")
public class CCmp extends NodeIfComponent {
@Override
public boolean processIf() throws Exception {
//do your biz
return true;
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("d")
public class DCmp extends NodeComponent {
@Override
public void process() {
System.out.println("DCmp executed!");
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("e")
public class ECmp extends NodeComponent {
@Override
public void process() {
System.out.println("ECmp executed!");
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.core.NodeSwitchComponent;
import org.springframework.stereotype.Component;
@Component("f")
public class FSwitchCmp extends NodeSwitchComponent {
@Override
public String processSwitch() throws Exception {
return "j";
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("j")
public class JCmp extends NodeComponent {
@Override
public void process() {
System.out.println("JCmp executed!");
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.test.abstractChain.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("k")
public class KCmp extends NodeComponent {
@Override
public void process() {
System.out.println("KCmp executed!");
}
}

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="com.yomahub.liteflow.test.abstractChain.cmp" />
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
<property name="ruleSource" value="abstractChain/flow.el.json"/>
</bean>
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
<constructor-arg name="liteflowConfig" ref="liteflowConfig"/>
</bean>
</beans>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="com.yomahub.liteflow.test.abstractChain.cmp" />
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
<property name="ruleSource" value="abstractChain/flow.el.xml"/>
</bean>
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
<constructor-arg name="liteflowConfig" ref="liteflowConfig"/>
</bean>
</beans>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="com.yomahub.liteflow.test.abstractChain.cmp" />
<bean id="springAware" class="com.yomahub.liteflow.spi.spring.SpringAware"/>
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
<property name="ruleSource" value="abstractChain/flow.el.yml"/>
</bean>
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
<constructor-arg name="liteflowConfig" ref="liteflowConfig"/>
</bean>
</beans>

View File

@@ -0,0 +1,32 @@
{
"flow": {
"chain": [
{
"id": "implB",
"extends": "base2",
"value": "{3}=THEN(a,b);\n {4}=j;"
},
{
"id": "implC",
"extends": "base2",
"value": "{3}=THEN(a,b);\n {4}=THEN(a,b).id(\"j\");"
},
{
"id": "base",
"abstract": true,
"value": "THEN(a, b, {0}, {1});"
},
{
"id": "implA",
"extends": "base",
"value": "{0}=IF(c, d, e);\n {1}=SWITCH(f).to(j,k);"
},
{
"id": "base2",
"extends": "base",
"abstract": true,
"value": "{0}=THEN(a,b,{3});\n {1}=SWITCH(f).to({4},k);"
}
]
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain id="implB" extends="base2">
{3}=THEN(a,b);
{4}=j;
</chain>
<chain id="implC" extends="base2">
{3}=THEN(a,b);
{4}=THEN(a,b).id("j");
</chain>
<chain abstract="true" name="base">
THEN(a, b, {0}, {1})
</chain>
<chain id="implA" extends="base">
{0}=IF(c, d, e);
{1}=SWITCH(f).to(j,k);
</chain>
<chain abstract="true" id="base2" extends="base">
{0}=THEN(a,b,{3});
{1}=SWITCH(f).to({4},k);
</chain>
</flow>

View File

@@ -0,0 +1,18 @@
flow:
chain:
- id: implB
extends: base2
value: "{3}=THEN(a,b);\n {4}=j;"
- id: implC
extends: base2
value: "{3}=THEN(a,b);\n {4}=THEN(a,b).id(\"j\");"
- id: base
abstract: true
value: "THEN(a, b, {0}, {1});"
- id: implA
extends: base
value: "{0}=IF(c, d, e);\n {1}=SWITCH(f).to(j,k);"
- id: base2
extends: base
abstract: true
value: "{0}=THEN(a,b,{3});\n {1}=SWITCH(f).to({4},k);"