refactor(接口测试): 重构jmx解析脚本组件所属语言方法
This commit is contained in:
parent
58014ab961
commit
ad97ee0ef9
|
@ -12,10 +12,11 @@ public class JSR223PostProcessConverter extends AbstractMsElementConverter<JSR22
|
|||
@Override
|
||||
public void toMsElement(AbstractMsTestElement parent, JSR223PostProcessor 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"));
|
||||
|
|
|
@ -11,12 +11,12 @@ import org.apache.jorphan.collections.HashTree;
|
|||
public class JSR223PreProcessConverter extends AbstractMsElementConverter<JSR223PreProcessor> {
|
||||
@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"));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue