refactor(接口自动化): 优化部分代码
This commit is contained in:
parent
6567dd2ec7
commit
331b241dc1
|
@ -16,6 +16,7 @@ import io.metersphere.api.service.ApiTestEnvironmentService;
|
|||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.constants.RunModeConstants;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.FileUtils;
|
||||
import lombok.Data;
|
||||
|
@ -122,7 +123,7 @@ public class MsScenario extends MsTestElement {
|
|||
this.environmentMap = new HashMap<>(16);
|
||||
if (StringUtils.isNotBlank(environmentId)) {
|
||||
// 兼容1.8之前 没有environmentMap但有environmentId的数据
|
||||
this.environmentMap.put("historyProjectID", environmentId);
|
||||
this.environmentMap.put(RunModeConstants.HIS_PRO_ID.toString(), environmentId);
|
||||
}
|
||||
}
|
||||
if (this.environmentMap != null && !this.environmentMap.isEmpty()) {
|
||||
|
|
|
@ -147,12 +147,6 @@ public abstract class MsTestElement {
|
|||
return jmeterTestPlanHashTree;
|
||||
}
|
||||
|
||||
public HashTree generateHashTree() {
|
||||
HashTree jmeterTestPlanHashTree = new ListedHashTree();
|
||||
this.toHashTree(jmeterTestPlanHashTree, this.hashTree, new ParameterConfig());
|
||||
return jmeterTestPlanHashTree;
|
||||
}
|
||||
|
||||
public Arguments addArguments(ParameterConfig config) {
|
||||
if (config.isEffective(this.getProjectId()) && config.getConfig().get(this.getProjectId()).getCommonConfig() != null
|
||||
&& CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables())) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import io.metersphere.base.domain.TestPlanApiCase;
|
|||
import io.metersphere.commons.constants.ConditionType;
|
||||
import io.metersphere.commons.constants.DelimiterConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.constants.RunModeConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
@ -185,22 +186,22 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
|
||||
// 数据兼容处理
|
||||
if (config.getConfig() != null && StringUtils.isNotEmpty(this.getProjectId()) && config.getConfig().containsKey(this.getProjectId())) {
|
||||
// 1.8 之后 当前正常数据
|
||||
} else if (config.getConfig() != null && config.getConfig().containsKey(getParentProjectId())) {
|
||||
if (config.getConfig() != null && config.getConfig().containsKey(getParentProjectId())) {
|
||||
// 1.8 前后 混合数据
|
||||
this.setProjectId(getParentProjectId());
|
||||
} else if (config.getConfig() != null && StringUtils.isNotEmpty(this.getProjectId()) && config.getConfig().containsKey(this.getProjectId())) {
|
||||
// 1.8 之后 当前正常数据
|
||||
} else {
|
||||
// 1.8 之前 数据
|
||||
if (config.getConfig() != null) {
|
||||
if (config.getConfig().containsKey("historyProjectID")) {
|
||||
this.setProjectId("historyProjectID");
|
||||
} else {
|
||||
if (!config.getConfig().containsKey(RunModeConstants.HIS_PRO_ID.toString())) {
|
||||
// 测试计划执行
|
||||
Iterator<String> it = config.getConfig().keySet().iterator();
|
||||
if (it.hasNext()) {
|
||||
this.setProjectId(it.next());
|
||||
}
|
||||
} else {
|
||||
this.setProjectId(RunModeConstants.HIS_PRO_ID.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
|||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.constants.DelimiterConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.constants.RunModeConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
@ -91,8 +92,8 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
} else {
|
||||
// 1.8 之前 数据
|
||||
if (config.getConfig() != null) {
|
||||
if (config.getConfig().containsKey("historyProjectID")) {
|
||||
this.setProjectId("historyProjectID");
|
||||
if (config.getConfig().containsKey(RunModeConstants.HIS_PRO_ID.toString())) {
|
||||
this.setProjectId(RunModeConstants.HIS_PRO_ID.toString());
|
||||
} else {
|
||||
// 测试计划执行
|
||||
Iterator<String> it = config.getConfig().keySet().iterator();
|
||||
|
|
|
@ -2,7 +2,7 @@ package io.metersphere.commons.constants;
|
|||
|
||||
public enum RunModeConstants {
|
||||
|
||||
SERIAL("serial"), SET_REPORT("setReport"), PARALLEL("parallel");
|
||||
SERIAL("serial"), SET_REPORT("setReport"), PARALLEL("parallel"), HIS_PRO_ID("historyProjectID");
|
||||
|
||||
private String value;
|
||||
|
||||
|
|
Loading…
Reference in New Issue