增加关于声明式组件继承父类的测试用例

This commit is contained in:
everywhere.z
2025-11-05 19:15:12 +08:00
parent b49e5716b5
commit ff89a9aa20
5 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package com.yomahub.liteflow.test.parent;
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.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.Resource;
/**
* springboot环境最普通的例子测试
*
* @author Bryan.Zhang
* @since 2.6.4
*/
@ExtendWith(SpringExtension.class)
@TestPropertySource(value = "classpath:/parent/application.properties")
@SpringBootTest(classes = ParentDeclMultiSpringbootTest.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.parent.cmp" })
public class ParentDeclMultiSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
@Test
public void testBase1() throws Exception {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assertions.assertTrue(response.isSuccess());
}
}

View File

@@ -0,0 +1,31 @@
package com.yomahub.liteflow.test.parent.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.test.base.cmp.TestDomain;
import javax.annotation.Resource;
@LiteflowComponent
public class CmpConfig extends ParentClass{
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a")
public void processA(NodeComponent bindCmp) {
this.setName("jack");
System.out.println(this.sayHi());
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "b")
public void processB(NodeComponent bindCmp) {
this.setName("tom");
System.out.println(this.sayHi());
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "c")
public void processC(NodeComponent bindCmp) {
this.setName("jerry");
System.out.println(this.sayHi());
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.test.parent.cmp;
public class ParentClass {
private String name;
public void setName(String name) {
this.name = name;
}
public String sayHi() {
return "hello " + name;
}
}

View File

@@ -0,0 +1 @@
liteflow.rule-source=parent/flow.el.xml

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
THEN(a, b, c);
</chain>
</flow>