fix (接口自动化): 修复导入场景数据缺失问题 #1005681
--bug=1005681 --user=赵勇 【接口自动化】测试报... https://www.tapd.cn/55049933/s/1037540
This commit is contained in:
parent
2a6d2117ff
commit
5cc1b69764
|
@ -65,6 +65,20 @@ public class MsScenarioParser extends MsAbstractParser<ScenarioImport> {
|
||||||
return scenarioWithBLOBs;
|
return scenarioWithBLOBs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void formatHashTree(JSONArray hashTree) {
|
||||||
|
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||||
|
for (int i = 0; i < hashTree.size(); i++) {
|
||||||
|
JSONObject object = (JSONObject) hashTree.get(i);
|
||||||
|
object.put("index", i + 1);
|
||||||
|
object.put("resourceId", UUID.randomUUID().toString());
|
||||||
|
hashTree.set(i, object);
|
||||||
|
if (CollectionUtils.isNotEmpty(object.getJSONArray("hashTree"))) {
|
||||||
|
formatHashTree(object.getJSONArray("hashTree"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ScenarioImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) {
|
private ScenarioImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) {
|
||||||
ScenarioImport scenarioImport = JSON.parseObject(testStr, ScenarioImport.class);
|
ScenarioImport scenarioImport = JSON.parseObject(testStr, ScenarioImport.class);
|
||||||
List<ApiScenarioWithBLOBs> data = scenarioImport.getData();
|
List<ApiScenarioWithBLOBs> data = scenarioImport.getData();
|
||||||
|
@ -88,6 +102,7 @@ public class MsScenarioParser extends MsAbstractParser<ScenarioImport> {
|
||||||
JSONObject scenarioDefinition = JSONObject.parseObject(scenarioDefinitionStr);
|
JSONObject scenarioDefinition = JSONObject.parseObject(scenarioDefinitionStr);
|
||||||
if (scenarioDefinition != null) {
|
if (scenarioDefinition != null) {
|
||||||
JSONArray hashTree = scenarioDefinition.getJSONArray("hashTree");
|
JSONArray hashTree = scenarioDefinition.getJSONArray("hashTree");
|
||||||
|
formatHashTree(hashTree);
|
||||||
setCopy(hashTree);
|
setCopy(hashTree);
|
||||||
JSONObject environmentMap = scenarioDefinition.getJSONObject("environmentMap");
|
JSONObject environmentMap = scenarioDefinition.getJSONObject("environmentMap");
|
||||||
if (environmentMap != null) {
|
if (environmentMap != null) {
|
||||||
|
|
|
@ -107,7 +107,13 @@ export default {
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.scenarioId) {
|
if (this.scenarioId) {
|
||||||
this.getApiScenario();
|
this.getApiScenario().then(() => {
|
||||||
|
this.initTree();
|
||||||
|
this.initWebSocket();
|
||||||
|
this.initMessageSocket();
|
||||||
|
this.clearDebug();
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (this.scenario && this.scenario.scenarioDefinition) {
|
if (this.scenario && this.scenario.scenarioDefinition) {
|
||||||
this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length;
|
this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length;
|
||||||
|
@ -129,24 +135,21 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
getApiScenario() {
|
getApiScenario() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.result = this.$get("/api/automation/getApiScenario/" + this.scenarioId, response => {
|
return new Promise((resolve) => {
|
||||||
if (response.data) {
|
this.result = this.$get("/api/automation/getApiScenario/" + this.scenarioId, response => {
|
||||||
this.path = "/api/automation/update";
|
if (response.data) {
|
||||||
if (response.data.scenarioDefinition != null) {
|
if (response.data.scenarioDefinition != null) {
|
||||||
let obj = JSON.parse(response.data.scenarioDefinition);
|
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||||
this.scenario.scenarioDefinition = obj;
|
this.scenario.scenarioDefinition = obj;
|
||||||
this.scenario.name = response.data.name;
|
this.scenario.name = response.data.name;
|
||||||
this.content.scenarioStepTotal = obj.hashTree.length;
|
this.content.scenarioStepTotal = obj.hashTree.length;
|
||||||
this.initTree();
|
if (this.scenario.scenarioDefinition && this.scenario.scenarioDefinition.hashTree) {
|
||||||
this.initWebSocket();
|
this.sort(this.scenario.scenarioDefinition.hashTree);
|
||||||
this.initMessageSocket();
|
}
|
||||||
this.clearDebug();
|
resolve();
|
||||||
if (this.scenario.scenarioDefinition && this.scenario.scenarioDefinition.hashTree) {
|
|
||||||
this.sort(this.scenario.scenarioDefinition.hashTree);
|
|
||||||
}
|
}
|
||||||
this.loading = false;
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
sort(stepArray) {
|
sort(stepArray) {
|
||||||
|
@ -156,7 +159,6 @@ export default {
|
||||||
stepArray[i].resourceId = getUUID();
|
stepArray[i].resourceId = getUUID();
|
||||||
}
|
}
|
||||||
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
|
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
|
||||||
this.stepSize += stepArray[i].hashTree.length;
|
|
||||||
this.sort(stepArray[i].hashTree);
|
this.sort(stepArray[i].hashTree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue