From 90ed04e5b9a55b5435e89c7774cc1defbc98f452 Mon Sep 17 00:00:00 2001
From: Dale Lee <1658850308@qq.com>
Date: Sat, 4 May 2024 14:36:50 +0800
Subject: [PATCH] =?UTF-8?q?feature=20#I9H6GN=20=E8=AE=BE=E7=BD=AE=20koltin?=
=?UTF-8?q?=20=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../liteflow-script-kotlin/pom.xml | 1 -
.../pom.xml | 2 +-
.../ValidateKotlinScriptComponentTest.java | 22 ++++++++++++++++++-
.../src/test/resources/cmpdata/flow.xml | 2 --
.../src/test/resources/meta/flow.xml | 2 +-
pom.xml | 6 +++++
6 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/liteflow-script-plugin/liteflow-script-kotlin/pom.xml b/liteflow-script-plugin/liteflow-script-kotlin/pom.xml
index c89e6d796..df3bed9da 100644
--- a/liteflow-script-plugin/liteflow-script-kotlin/pom.xml
+++ b/liteflow-script-plugin/liteflow-script-kotlin/pom.xml
@@ -23,7 +23,6 @@
org.jetbrains.kotlin
kotlin-scripting-jsr223
- 1.9.23
\ No newline at end of file
diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/pom.xml
index e76dca32f..0563cb2d5 100644
--- a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/pom.xml
+++ b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/pom.xml
@@ -21,7 +21,7 @@
com.yomahub
liteflow-script-kotlin
- 2.12.0
+ ${revision}
test
diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/java/com/yomahub/liteflow/test/script/kotlin/validate/ValidateKotlinScriptComponentTest.java b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/java/com/yomahub/liteflow/test/script/kotlin/validate/ValidateKotlinScriptComponentTest.java
index 727b2641d..9c9e1885d 100644
--- a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/java/com/yomahub/liteflow/test/script/kotlin/validate/ValidateKotlinScriptComponentTest.java
+++ b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/java/com/yomahub/liteflow/test/script/kotlin/validate/ValidateKotlinScriptComponentTest.java
@@ -1,21 +1,41 @@
package com.yomahub.liteflow.test.script.kotlin.validate;
import com.yomahub.liteflow.enums.ScriptTypeEnum;
+import com.yomahub.liteflow.script.ScriptExecutor;
+import com.yomahub.liteflow.script.ScriptExecutorFactory;
import com.yomahub.liteflow.script.validator.ScriptValidator;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
+import javax.script.Compilable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
@SpringBootTest(classes = ValidateKotlinScriptComponentTest.class)
@EnableAutoConfiguration
public class ValidateKotlinScriptComponentTest {
@Test
- public void testGroovyScriptComponentValidateFunction(){
+ public void testScriptComponentValidateFunction() throws Exception {
// 编译错误,字符串不能直接赋值给Int
String wrongScript = "val number: Int = \"123\"";
// 使用转换函数
String correctScript = "val number: Int = \"123\".toInt()";
+// ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
+// ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("kotlin");
+// Compilable compilable = (Compilable) scriptEngine;
+// compilable.compile(correctScript);
+
+// try {
+// ScriptExecutor scriptExecutor = ScriptExecutorFactory.loadInstance()
+// .getScriptExecutor(ScriptTypeEnum.KOTLIN.getDisplayName());
+// scriptExecutor.compile(wrongScript);
+// } catch (Exception e) {
+//
+// }
+
Assertions.assertTrue(ScriptValidator.validate(correctScript));
Assertions.assertFalse(ScriptValidator.validate(wrongScript));
diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/cmpdata/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/cmpdata/flow.xml
index 4d333a05b..889ae01eb 100644
--- a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/cmpdata/flow.xml
+++ b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/cmpdata/flow.xml
@@ -4,11 +4,9 @@
- println(_meta)
var cmpData = _meta["cmpData"] as Map
var context = bindings["defaultContext"] as DefaultContext
context.setData("s1", cmpData["birth"])
diff --git a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/meta/flow.xml b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/meta/flow.xml
index 01afbc11f..ff49ec51d 100644
--- a/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/meta/flow.xml
+++ b/liteflow-testcase-el/liteflow-testcase-el-script-kotlin-springboot/src/test/resources/meta/flow.xml
@@ -5,7 +5,7 @@
+ var _meta = bindings["_meta"] as Map
var nodeId = _meta["nodeId"]
var currChainId = _meta["currChainId"]
var requestData = _meta["requestData"]
diff --git a/pom.xml b/pom.xml
index fe2b4d1de..793082b57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,7 @@
1.3.5
3.21.0
3.1.11
+ 1.9.23
@@ -314,6 +315,11 @@
redisson
${redisson.version}
+
+ org.jetbrains.kotlin
+ kotlin-scripting-jsr223
+ ${kotlin.version}
+