fix(接口自动化): 环境配置问题
This commit is contained in:
parent
8fe8ff48ad
commit
c90c061738
|
@ -85,6 +85,7 @@ public class MsScenario extends MsTestElement {
|
|||
JSONObject element = JSON.parseObject(scenario.getScenarioDefinition());
|
||||
hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
|
||||
});
|
||||
OldVersionUtil.transferHashTree(hashTree);
|
||||
// 场景变量
|
||||
if (StringUtils.isNotEmpty(element.getString("variables"))) {
|
||||
LinkedList<ScenarioVariable> variables = mapper.readValue(element.getString("variables"),
|
||||
|
|
|
@ -161,6 +161,7 @@ public abstract class MsTestElement {
|
|||
element = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsTestElement>() {
|
||||
});
|
||||
hashTree.add(element);
|
||||
OldVersionUtil.transferHashTree(hashTree);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package io.metersphere.api.dto.definition.request;
|
||||
|
||||
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OldVersionUtil {
|
||||
|
||||
public static void transferHashTree(List<MsTestElement> hashTree) {
|
||||
for (int i = 0; i < hashTree.size(); i++) {
|
||||
MsTestElement element = hashTree.get(i);
|
||||
if (StringUtils.isBlank(element.getProjectId())) {
|
||||
element.setProjectId(SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
if (element.getHashTree() != null && element.getHashTree().size() > 0) {
|
||||
transferHashTree(element.getHashTree());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -532,6 +532,9 @@
|
|||
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
||||
arr[i].countController.proceed = true;
|
||||
}
|
||||
if (!arr[i].projectId) {
|
||||
arr[i].projectId = getCurrentProjectID();
|
||||
}
|
||||
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
||||
this.recursiveSorting(arr[i].hashTree);
|
||||
}
|
||||
|
@ -544,6 +547,9 @@
|
|||
&& this.scenarioDefinition[i].hashTree.length > 1) {
|
||||
this.scenarioDefinition[i].countController.proceed = true;
|
||||
}
|
||||
if (!this.scenarioDefinition[i].projectId) {
|
||||
this.scenarioDefinition.projectId = getCurrentProjectID();
|
||||
}
|
||||
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
|
||||
this.recursiveSorting(this.scenarioDefinition[i].hashTree);
|
||||
}
|
||||
|
@ -919,14 +925,15 @@
|
|||
}
|
||||
this.enableCookieShare = obj.enableCookieShare;
|
||||
this.scenarioDefinition = obj.hashTree;
|
||||
this.initProjectIds();
|
||||
}
|
||||
}
|
||||
if (this.currentScenario.copy) {
|
||||
this.path = "/api/automation/create";
|
||||
}
|
||||
}
|
||||
this.getEnvironments();
|
||||
this.sort();
|
||||
this.initProjectIds();
|
||||
// this.getEnvironments();
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
|
@ -108,6 +108,9 @@
|
|||
recursive(arr) {
|
||||
for (let i in arr) {
|
||||
arr[i].disabled = true;
|
||||
if (!arr[i].projectId) {
|
||||
arr[i].projectId = getCurrentProjectID();
|
||||
}
|
||||
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
||||
this.recursive(arr[i].hashTree);
|
||||
}
|
||||
|
@ -116,6 +119,9 @@
|
|||
setDisabled(scenarioDefinition) {
|
||||
for (let i in scenarioDefinition) {
|
||||
scenarioDefinition[i].disabled = true;
|
||||
if (!scenarioDefinition[i].projectId) {
|
||||
scenarioDefinition[i].projectId = getCurrentProjectID();
|
||||
}
|
||||
if (scenarioDefinition[i].hashTree != undefined && scenarioDefinition[i].hashTree.length > 0) {
|
||||
this.recursive(scenarioDefinition[i].hashTree);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue