diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/ms/http/post/JSR223PostProcessConverter.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/ms/http/post/JSR223PostProcessConverter.java index 2a5e3af9d6..0ea0f8bbc2 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/ms/http/post/JSR223PostProcessConverter.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/ms/http/post/JSR223PostProcessConverter.java @@ -12,10 +12,11 @@ public class JSR223PostProcessConverter extends AbstractMsElementConverter { @Override public void toMsElement(AbstractMsTestElement parent, JSR223PreProcessor element, HashTree hashTree) { - ScriptProcessor msScriptElement = new ScriptProcessor(); - msScriptElement.setScriptLanguage(element.getScriptLanguage()); - if (StringUtil.isBlank(msScriptElement.getScriptLanguage())) { - msScriptElement.setScriptLanguage(element.getPropertyAsString("scriptLanguage")); + String scriptLanguage = element.getScriptLanguage(); + if (StringUtil.isBlank(scriptLanguage)) { + scriptLanguage = element.getPropertyAsString("scriptLanguage"); } + msScriptElement.setScriptLanguage(ConverterUtils.parseScriptLanguage(scriptLanguage)); msScriptElement.setEnable(element.isEnabled()); msScriptElement.setName(element.getPropertyAsString("TestElement.name")); msScriptElement.setScript(element.getPropertyAsString("script")); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/utils/ConverterUtils.java b/backend/services/api-test/src/main/java/io/metersphere/api/utils/ConverterUtils.java index f5bb92cf47..955d2d6abf 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/utils/ConverterUtils.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/utils/ConverterUtils.java @@ -9,7 +9,9 @@ import io.metersphere.project.api.processor.ExtractPostProcessor; import io.metersphere.project.api.processor.MsProcessor; import io.metersphere.project.api.processor.SQLProcessor; import io.metersphere.project.api.processor.extract.MsExtract; +import io.metersphere.project.constants.ScriptLanguageType; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.testelement.AbstractTestElement; import java.util.LinkedList; @@ -148,4 +150,18 @@ public class ConverterUtils { } } + + public static String parseScriptLanguage(String scriptLanguage) { + if (StringUtils.equalsIgnoreCase(scriptLanguage, "beanshell")) { + return ScriptLanguageType.BEANSHELL_JSR233.name(); + } else if (StringUtils.equalsIgnoreCase(scriptLanguage, "groovy")) { + return ScriptLanguageType.GROOVY.name(); + } else if (StringUtils.equalsIgnoreCase(scriptLanguage, "javascript")) { + return ScriptLanguageType.JAVASCRIPT.name(); + } else if (StringUtils.equalsIgnoreCase(scriptLanguage, "python")) { + return ScriptLanguageType.PYTHON.name(); + } else { + return scriptLanguage; + } + } }