enhancement 补充测试用例,调整 ElRegexUtil.normalize 方法逻辑

This commit is contained in:
luoyi
2025-07-09 18:56:48 +08:00
parent 3d52ce73f6
commit 1450cda7ae
2 changed files with 9 additions and 2 deletions

View File

@@ -57,12 +57,13 @@ public class ElRegexUtil {
/**
* 规范化 EL
*
* @param elStr
* @return String
*/
public static String normalize(String elStr) {
// 替换 EL 中多余空格,并在末尾保留分号
return elStr.replaceAll("\\s", "").replaceFirst(";*$", ";");
// 剔除 EL 中多余空格,且将单引号变为双引号,并在末尾保留一个分号
return elStr.replace("'", "\"").replaceAll("\\s", "").replaceFirst(";*$", ";");
}
}

View File

@@ -96,6 +96,12 @@ public class BaseELSpringbootTest extends BaseTest {
Assertions.assertTrue(response.isSuccess());
// 应返回 chain2
Assertions.assertEquals("chain2", response.getChainId());
LiteflowResponse response1 = flowExecutor.execute2RespWithEL("t1=THEN(c, WHEN(j,k));w1 = WHEN(q, THEN(p, r)).id('w01');t2 = THEN(h, i);\n" +
"THEN(a,b,WHEN(t1, d, t2 ),SWITCH(x).to(m, n, w1),z);");
Assertions.assertTrue(response1.isSuccess());
// 应返回 chain5
Assertions.assertEquals("chain5", response1.getChainId());
}
}