diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenarioRequest.java b/api-test/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenarioRequest.java index 589d956c85..bb38f11a42 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenarioRequest.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/automation/ApiScenarioRequest.java @@ -40,4 +40,6 @@ public class ApiScenarioRequest extends BaseQueryRequest { //测试计划关联场景过滤掉步骤为0的场景 private String stepTotal; + //场景引用类型 + private String refType; } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index c6e3d23319..8feda609b7 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -876,11 +876,11 @@ public class ElementUtil { } } - public static String getScriptEnv(String environmentId, ParameterConfig config) { + public static String getScriptEnv(String environmentId, ParameterConfig config, String projectId) { if (StringUtils.isEmpty(environmentId)) { if (config.getConfig() != null) { - if (config.getProjectId() != null && config.getConfig().containsKey(config.getProjectId())) { - return config.getConfig().get(config.getProjectId()).getEnvironmentId(); + if (StringUtils.isNotBlank(projectId) && config.getConfig().containsKey(projectId)) { + return config.getConfig().get(projectId).getEnvironmentId(); } else { if (CollectionUtils.isNotEmpty(config.getConfig().values())) { Optional values = config.getConfig().entrySet().stream().findFirst().map(Map.Entry::getValue); diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java index 369f7e92d3..c2884b311a 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java @@ -44,7 +44,7 @@ public class MsJSR223Processor extends MsTestElement { if (!config.isOperating() && !this.isEnable()) { return; } - this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config)); + this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config, this.getProjectId())); TestElement processor = new BeanShellSampler(); if (jsrEnable == null || BooleanUtils.isTrue(jsrEnable)) { diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java index 2747ff7def..65768e73a8 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java @@ -43,7 +43,7 @@ public class MsJSR223PostProcessor extends MsTestElement { if (!config.isOperating() && !this.isEnable()) { return; } - this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config)); + this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config, this.getProjectId())); TestElement processor = new BeanShellPostProcessor(); if (jsrEnable == null || BooleanUtils.isTrue(jsrEnable)) { diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java index 5e230cabbd..2208341196 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java @@ -43,7 +43,7 @@ public class MsJSR223PreProcessor extends MsTestElement { } } ScriptFilter.verify(this.getScriptLanguage(), this.getName(), script); - this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config)); + this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config, this.getProjectId())); final HashTree jsr223PreTree = tree.add(getShellProcessor()); if (CollectionUtils.isNotEmpty(hashTree)) { diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml index e75c1144c3..4e0bf72d08 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml @@ -462,9 +462,11 @@