From cded9b1ad45dfe9d445d742cf41800c3c91ac468 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 28 Sep 2021 10:14:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96)=20=E6=89=A7=E8=A1=8C=E5=BE=AE=E8=B0=83=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=89=B9=E6=AE=8A=E6=95=B0=E6=8D=AE=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/definition/request/ElementUtil.java | 59 ++++++++----------- .../automation/scenario/EditApiScenario.vue | 2 + .../scenario/maximize/MaximizeScenario.vue | 8 +++ 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 9a0a3cbb00..48067aefb2 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -268,26 +268,33 @@ public class ElementUtil { } }; + private static void formatSampler(JSONObject element) { + if (element == null || StringUtils.isEmpty(element.getString("type"))) { + return; + } + if (element.get("clazzName") == null && element.getString("type").equals("TCPSampler")) { + if (element.getString("tcpPreProcessor") != null) { + JSONObject tcpPreProcessor = JSON.parseObject(element.getString("tcpPreProcessor")); + if (tcpPreProcessor != null && tcpPreProcessor.get("clazzName") == null) { + tcpPreProcessor.fluentPut("clazzName", clazzMap.get(tcpPreProcessor.getString("type"))); + element.fluentPut("tcpPreProcessor", tcpPreProcessor); + } + } + } else if (element.getString("type").equals("HTTPSamplerProxy")) { + if (element.getString("authManager") != null) { + JSONObject authManager = JSON.parseObject(element.getString("authManager")); + if (authManager != null && authManager.get("clazzName") == null) { + authManager.fluentPut("clazzName", clazzMap.get(authManager.getString("type"))); + element.fluentPut("authManager", authManager); + } + } + } + } + public static void dataFormatting(JSONArray hashTree) { for (int i = 0; i < hashTree.size(); i++) { JSONObject element = hashTree.getJSONObject(i); - if (element != null && element.get("clazzName") == null && element.getString("type").equals("TCPSampler")) { - if (element.getString("tcpPreProcessor") != null) { - JSONObject tcpPreProcessor = JSON.parseObject(element.getString("tcpPreProcessor")); - if (tcpPreProcessor != null && tcpPreProcessor.get("clazzName") == null) { - tcpPreProcessor.fluentPut("clazzName", clazzMap.get(tcpPreProcessor.getString("type"))); - element.fluentPut("tcpPreProcessor", tcpPreProcessor); - } - } - } else if (element != null && element.getString("type").equals("HTTPSamplerProxy")) { - if (element.getString("authManager") != null) { - JSONObject authManager = JSON.parseObject(element.getString("authManager")); - if (authManager != null && authManager.get("clazzName") == null) { - authManager.fluentPut("clazzName", clazzMap.get(authManager.getString("type"))); - element.fluentPut("authManager", authManager); - } - } - } + formatSampler(element); if (element != null && element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) { element.fluentPut("clazzName", clazzMap.get(element.getString("type"))); } @@ -302,23 +309,7 @@ public class ElementUtil { if (element != null && element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) { element.fluentPut("clazzName", clazzMap.get(element.getString("type"))); } - if (element != null && element.get("clazzName") == null && element.getString("type").equals("TCPSampler")) { - if (element.getString("tcpPreProcessor") != null) { - JSONObject tcpPreProcessor = JSON.parseObject(element.getString("tcpPreProcessor")); - if (tcpPreProcessor != null && tcpPreProcessor.get("clazzName") == null) { - tcpPreProcessor.fluentPut("clazzName", clazzMap.get(tcpPreProcessor.getString("type"))); - element.fluentPut("tcpPreProcessor", tcpPreProcessor); - } - } - } else if (element != null && element.getString("type").equals("HTTPSamplerProxy")) { - if (element.getString("authManager") != null) { - JSONObject authManager = JSON.parseObject(element.getString("authManager")); - if (authManager != null && authManager.get("clazzName") == null) { - authManager.fluentPut("clazzName", clazzMap.get(authManager.getString("type"))); - element.fluentPut("authManager", authManager); - } - } - } + formatSampler(element); if (element != null && element.containsKey("hashTree")) { JSONArray elementJSONArray = element.getJSONArray("hashTree"); dataFormatting(elementJSONArray); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 0ed80407e4..a62b58134a 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -315,6 +315,8 @@ :stepReEnable="stepEnable" :message="message" @openScenario="openScenario" + @runScenario="runDebug" + @stopScenario="stop" ref="maximizeScenario"/> diff --git a/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue b/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue index 9770a70ec9..33eb551c9d 100644 --- a/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue @@ -48,6 +48,8 @@ :env-map="projectEnvMap" :message="message" @remove="remove" @copyRow="copyRow" + @runScenario="runScenario" + @stopScenario="stopScenario" @suggestClick="suggestClick" @refReload="refReload" @openScenario="openScenario"/> @@ -874,6 +876,12 @@ export default { disableAll() { this.stepEnable = false; this.stepNode(); + }, + runScenario(scenario) { + this.$emit('runScenario', scenario); + }, + stopScenario(){ + this.$emit('stopScenario'); } } }