fix(接口自动化) 执行微调增加特殊数据保护

This commit is contained in:
fit2-zhao 2021-09-28 10:14:44 +08:00 committed by fit2-zhao
parent a3c7dbde7f
commit cded9b1ad4
3 changed files with 35 additions and 34 deletions

View File

@ -268,10 +268,11 @@ public class ElementUtil {
} }
}; };
public static void dataFormatting(JSONArray hashTree) { private static void formatSampler(JSONObject element) {
for (int i = 0; i < hashTree.size(); i++) { if (element == null || StringUtils.isEmpty(element.getString("type"))) {
JSONObject element = hashTree.getJSONObject(i); return;
if (element != null && element.get("clazzName") == null && element.getString("type").equals("TCPSampler")) { }
if (element.get("clazzName") == null && element.getString("type").equals("TCPSampler")) {
if (element.getString("tcpPreProcessor") != null) { if (element.getString("tcpPreProcessor") != null) {
JSONObject tcpPreProcessor = JSON.parseObject(element.getString("tcpPreProcessor")); JSONObject tcpPreProcessor = JSON.parseObject(element.getString("tcpPreProcessor"));
if (tcpPreProcessor != null && tcpPreProcessor.get("clazzName") == null) { if (tcpPreProcessor != null && tcpPreProcessor.get("clazzName") == null) {
@ -279,7 +280,7 @@ public class ElementUtil {
element.fluentPut("tcpPreProcessor", tcpPreProcessor); element.fluentPut("tcpPreProcessor", tcpPreProcessor);
} }
} }
} else if (element != null && element.getString("type").equals("HTTPSamplerProxy")) { } else if (element.getString("type").equals("HTTPSamplerProxy")) {
if (element.getString("authManager") != null) { if (element.getString("authManager") != null) {
JSONObject authManager = JSON.parseObject(element.getString("authManager")); JSONObject authManager = JSON.parseObject(element.getString("authManager"));
if (authManager != null && authManager.get("clazzName") == null) { if (authManager != null && authManager.get("clazzName") == null) {
@ -288,6 +289,12 @@ public class ElementUtil {
} }
} }
} }
}
public static void dataFormatting(JSONArray hashTree) {
for (int i = 0; i < hashTree.size(); i++) {
JSONObject element = hashTree.getJSONObject(i);
formatSampler(element);
if (element != null && element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) { if (element != null && element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) {
element.fluentPut("clazzName", clazzMap.get(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"))) { if (element != null && element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) {
element.fluentPut("clazzName", clazzMap.get(element.getString("type"))); element.fluentPut("clazzName", clazzMap.get(element.getString("type")));
} }
if (element != null && element.get("clazzName") == null && element.getString("type").equals("TCPSampler")) { formatSampler(element);
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);
}
}
}
if (element != null && element.containsKey("hashTree")) { if (element != null && element.containsKey("hashTree")) {
JSONArray elementJSONArray = element.getJSONArray("hashTree"); JSONArray elementJSONArray = element.getJSONArray("hashTree");
dataFormatting(elementJSONArray); dataFormatting(elementJSONArray);

View File

@ -315,6 +315,8 @@
:stepReEnable="stepEnable" :stepReEnable="stepEnable"
:message="message" :message="message"
@openScenario="openScenario" @openScenario="openScenario"
@runScenario="runDebug"
@stopScenario="stop"
ref="maximizeScenario"/> ref="maximizeScenario"/>
</ms-drawer> </ms-drawer>
<ms-change-history ref="changeHistory"/> <ms-change-history ref="changeHistory"/>

View File

@ -48,6 +48,8 @@
:env-map="projectEnvMap" :env-map="projectEnvMap"
:message="message" :message="message"
@remove="remove" @copyRow="copyRow" @remove="remove" @copyRow="copyRow"
@runScenario="runScenario"
@stopScenario="stopScenario"
@suggestClick="suggestClick" @suggestClick="suggestClick"
@refReload="refReload" @openScenario="openScenario"/> @refReload="refReload" @openScenario="openScenario"/>
</span> </span>
@ -874,6 +876,12 @@ export default {
disableAll() { disableAll() {
this.stepEnable = false; this.stepEnable = false;
this.stepNode(); this.stepNode();
},
runScenario(scenario) {
this.$emit('runScenario', scenario);
},
stopScenario(){
this.$emit('stopScenario');
} }
} }
} }