feat #I6O2YE sql 外置存储支持多脚本混合调用

This commit is contained in:
gaibu
2023-03-20 21:57:29 +08:00
parent 9bcad1a883
commit 30a12da03b
4 changed files with 336 additions and 322 deletions

View File

@@ -31,73 +31,80 @@ import java.sql.Statement;
@TestPropertySource(value = "classpath:/application-xml.properties")
@SpringBootTest(classes = SQLWithXmlELSpringbootTest.class)
@EnableAutoConfiguration
@ComponentScan({"com.yomahub.liteflow.test.sql.cmp"})
@ComponentScan({ "com.yomahub.liteflow.test.sql.cmp" })
public class SQLWithXmlELSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
@Test
public void testSQLWithXml() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>b==>c", response.getExecuteStepStr());
@Resource
private FlowExecutor flowExecutor;
// 修改数据库
changeData();
@Test
public void testSQLWithXml() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertEquals("a==>b==>c", response.getExecuteStepStr());
// 重新加载规则
flowExecutor.reloadRule();
Assert.assertEquals("a==>c==>b", flowExecutor.execute2Resp("chain1", "arg").getExecuteStepStr());
}
// 修改数据库
changeData();
@Test
public void testSQLWithScriptXml() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime());
// 重新加载规则
flowExecutor.reloadRule();
Assert.assertEquals("a==>c==>b", flowExecutor.execute2Resp("chain1", "arg").getExecuteStepStr());
}
// 修改数据库
changeScriptData();
// 重新加载规则
flowExecutor.reloadRule();
Assert.assertEquals("x0[if 脚本]", flowExecutor.execute2Resp("chain3", "arg").getExecuteStepStr());
}
@Test
public void testSQLWithScriptXml() {
LiteflowResponse response = flowExecutor.execute2Resp("chain3", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime());
@Test
public void testMultiLanguage1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x2[python脚本]==>x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime());
}
// 修改数据库
changeScriptData();
// 重新加载规则
flowExecutor.reloadRule();
Assert.assertEquals("x0[if 脚本]", flowExecutor.execute2Resp("chain3", "arg").getExecuteStepStr());
}
/**
* 修改数据库数据
*/
private void changeData() {
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class);
Connection connection;
try {
connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), sqlParserVO.getPassword());
Statement statement = connection.createStatement();
statement.executeUpdate("UPDATE EL_TABLE SET EL_DATA='THEN(a, c, b);' WHERE chain_name='chain1'");
} catch (SQLException e) {
throw new ELSQLException(e.getMessage());
}
}
@Test
public void testMultiLanguage1() {
LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg");
Assert.assertTrue(response.isSuccess());
Assert.assertEquals("x2[python脚本]==>x0[if 脚本]==>a==>b", response.getExecuteStepStrWithoutTime());
}
/**
* 修改数据库数据
*/
private void changeData() {
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class);
Connection connection;
try {
connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(),
sqlParserVO.getPassword());
Statement statement = connection.createStatement();
statement.executeUpdate("UPDATE EL_TABLE SET EL_DATA='THEN(a, c, b);' WHERE chain_name='chain1'");
}
catch (SQLException e) {
throw new ELSQLException(e.getMessage());
}
}
/**
* 修改数据库数据
*/
private void changeScriptData() {
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class);
Connection connection;
try {
connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(),
sqlParserVO.getPassword());
Statement statement = connection.createStatement();
statement.executeUpdate(
"UPDATE SCRIPT_NODE_TABLE SET SCRIPT_NODE_DATA='return false;' WHERE SCRIPT_NODE_ID='x0'");
}
catch (SQLException e) {
throw new ELSQLException(e.getMessage());
}
}
/**
* 修改数据库数据
*/
private void changeScriptData() {
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
SQLParserVO sqlParserVO = JsonUtil.parseObject(liteflowConfig.getRuleSourceExtData(), SQLParserVO.class);
Connection connection;
try {
connection = DriverManager.getConnection(sqlParserVO.getUrl(), sqlParserVO.getUsername(), sqlParserVO.getPassword());
Statement statement = connection.createStatement();
statement.executeUpdate("UPDATE SCRIPT_NODE_TABLE SET SCRIPT_NODE_DATA='return false;' WHERE SCRIPT_NODE_ID='x0'");
} catch (SQLException e) {
throw new ELSQLException(e.getMessage());
}
}
}