diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java index 4941a65a89..ded2e53374 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java @@ -192,18 +192,15 @@ public class MsAssertions extends MsTestElement { } private TestElement jsr223Assertion(MsAssertionJSR223 assertionJSR223) { - TestElement assertion = new BeanShellAssertion(); - if (assertionJSR223.getJsrEnable() == null || BooleanUtils.isTrue(assertionJSR223.getJsrEnable())) { - assertion = new JSR223Assertion(); - } + TestElement assertion = new JSR223Assertion(); assertion.setEnabled(this.isEnable()); if (StringUtils.isNotEmpty(assertionJSR223.getDesc())) { assertion.setName("JSR223" + delimiter + this.getName() + delimiter + assertionJSR223.getDesc() + delimiterScript + assertionJSR223.getScript()); } else { assertion.setName("JSR223" + delimiter + this.getName() + delimiter + "JSR223Assertion" + delimiterScript + assertionJSR223.getScript()); } - assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); + assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName()); assertion.setProperty("cacheKey", "false"); String scriptLanguage = assertionJSR223.getScriptLanguage(); if (StringUtils.equals(scriptLanguage, "nashornScript")) { @@ -215,6 +212,12 @@ public class MsAssertions extends MsTestElement { if (StringUtils.equals(scriptLanguage, "javascript")) { scriptLanguage = "rhino"; } + if (StringUtils.equals(scriptLanguage, "beanshell") && BooleanUtils.isFalse(assertionJSR223.getJsrEnable())) { + assertion = new BeanShellAssertion(); + scriptLanguage = "beanshell"; + assertion.setProperty(TestElement.TEST_CLASS, BeanShellAssertion.class.getName()); + assertion.setProperty(BeanShellAssertion.SCRIPT, assertionJSR223.getScript()); + } assertion.setProperty("scriptLanguage", scriptLanguage); assertion.setProperty(ElementConstants.SCRIPT, assertionJSR223.getScript()); return assertion; diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java index 8c9832f910..56ab4253d0 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java @@ -482,6 +482,10 @@ public class ApiScenarioExecuteService { if (testElement != null) { apiScenario.setName(testElement.getName()); apiScenario.setScenarioDefinition(JSON.toJSONString(testElement)); + List projectIdLists = getProjectIds(apiScenario.getScenarioDefinition()); + Map envMap = getProjectEnvMap(projectIdLists, request.getEnvironmentMap()); + request.getConfig().setEnvMap(envMap); + report.setEnvConfig(JSON.toJSONString(request.getConfig())); apiScenarioReportStructureService.save(apiScenario, report.getId(), request.getConfig().getReportType()); } }