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'); } } }