diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 1ea5523f52..3bfecbfc1b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -118,8 +118,7 @@ public abstract class MsTestElement { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId()); - element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() { - }); + element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() {}); hashTree.add(element); } catch (Exception ex) { ex.printStackTrace(); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 50862bf5a0..21b416fb4e 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -243,11 +243,9 @@ public class ApiAutomationService { MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class); // 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取 LinkedList elements = mapper.readValue(element.getString("hashTree"), - new TypeReference>() { - }); + new TypeReference>() {}); LinkedList variables = mapper.readValue(element.getString("variables"), - new TypeReference>() { - }); + new TypeReference>() {}); scenario.setHashTree(elements); scenario.setVariables(variables); LinkedList scenarios = new LinkedList<>(); @@ -285,8 +283,6 @@ public class ApiAutomationService { ParameterConfig config = new ParameterConfig(); config.setConfig(envConfig); HashTree hashTree = request.getTestElement().generateHashTree(config); - request.getTestElement().getJmx(hashTree); - // 调用执行方法 jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), ApiRunMode.SCENARIO.name()); createAPIReportResult(request.getId(), ReportTriggerMode.MANUAL.name()); diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index d2fc8f5ead..8b489609e5 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -1,14 +1,13 @@ @@ -245,7 +245,7 @@ - + @@ -263,7 +263,7 @@ @runRefresh="runRefresh" ref="runTest"/> - + @@ -286,7 +286,7 @@ import MsApiComponent from "./ApiComponent"; import {ELEMENTS, ELEMENT_TYPE} from "./Setting"; import MsApiCustomize from "./ApiCustomize"; - import {getUUID} from "@/common/js/utils"; + import {getUUID, getCurrentProjectID} from "@/common/js/utils"; import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig"; import MsAddTag from "./AddTag"; import MsRun from "./DebugRun"; @@ -295,12 +295,10 @@ import MsApiReportDetail from "../report/ApiReportDetail"; import MsScenarioParameters from "./ScenarioParameters"; - export default { name: "EditApiScenario", props: { moduleOptions: Array, - currentProject: {}, currentScenario: {}, }, components: { @@ -350,9 +348,11 @@ path: "/api/automation/create", debugData: {}, reportId: "", + projectId: "", } }, created() { + this.projectId = getCurrentProjectID(); this.operatingElements = ELEMENTS.get("ALL"); this.getMaintainerOptions(); this.refreshTags(); @@ -514,14 +514,14 @@ }, openTagConfig() { - if (!this.currentProject) { + if (!this.projectId) { this.$error(this.$t('api_test.select_project')); return; } - this.$refs.tag.open(this.currentProject.id); + this.$refs.tag.open(); }, refreshTags() { - let obj = {projectId: this.currentProject.id}; + let obj = {projectId: this.projectId}; let tagIds = []; this.$post('/api/tag/list', obj, response => { this.tags = response.data; @@ -562,8 +562,8 @@ this.reportId = getUUID().substring(0, 8); }, getEnvironments() { - if (this.currentProject) { - this.$get('/api/environment/list/' + this.currentProject.id, response => { + if (this.projectId) { + this.$get('/api/environment/list/' + this.projectId, response => { this.environments = response.data; this.environments.forEach(environment => { parseEnvironment(environment); @@ -572,11 +572,11 @@ } }, openEnvironmentConfig() { - if (!this.currentProject) { + if (!this.projectId) { this.$error(this.$t('api_test.select_project')); return; } - this.$refs.environmentConfig.open(this.currentProject.id); + this.$refs.environmentConfig.open(this.projectId); }, environmentConfigClose() { this.getEnvironments(); @@ -696,7 +696,7 @@ } }, setParameter() { - this.currentScenario.projectId = this.currentProject.id; + this.currentScenario.projectId = this.projectId; if (!this.currentScenario.id) { this.currentScenario.id = getUUID(); } diff --git a/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue b/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue index 6ea4043675..01c1ab5daa 100644 --- a/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue @@ -1,12 +1,11 @@