fix(接口测试): 修复场景中SQL步骤自定义数据源显示问题

--bug=1009124 --user=赵勇 【github#8654】场景用例里切换数据库名-保存,再进来看数据库名不是上次保存的数据库名 https://www.tapd.cn/55049933/s/1085725
This commit is contained in:
fit2-zhao 2021-12-22 20:50:28 +08:00 committed by fit2-zhao
parent 7ae67838b7
commit 13b1e35880
3 changed files with 11 additions and 8 deletions

View File

@ -84,9 +84,9 @@ public class JMeterScriptUtil {
} }
private static void addItemHashTree(MsTestElement element, HashTree samplerHashTree, ParameterConfig config, String enviromentId) { private static void addItemHashTree(MsTestElement element, HashTree samplerHashTree, ParameterConfig config, String enviromentId) {
if (element != null && element.getEnvironmentId() == null) { if (element != null) {
element.setEnvironmentId(enviromentId); element.setEnvironmentId(element.getEnvironmentId() == null ? enviromentId : element.getEnvironmentId());
}
element.toHashTree(samplerHashTree, element.getHashTree(), config); element.toHashTree(samplerHashTree, element.getHashTree(), config);
} }
} }
}

View File

@ -31,10 +31,13 @@ import java.util.Map;
public class GenerateHashTreeUtil { public class GenerateHashTreeUtil {
public static MsScenario parseScenarioDefinition(String scenarioDefinition) { public static MsScenario parseScenarioDefinition(String scenarioDefinition) {
if(StringUtils.isNotEmpty(scenarioDefinition)) {
MsScenario scenario = JSONObject.parseObject(scenarioDefinition, MsScenario.class); MsScenario scenario = JSONObject.parseObject(scenarioDefinition, MsScenario.class);
parse(scenarioDefinition, scenario, scenario.getId(), null); parse(scenarioDefinition, scenario, scenario.getId(), null);
return scenario; return scenario;
} }
return null;
}
public static void parse(String scenarioDefinition, MsScenario scenario, String id, String reportType) { public static void parse(String scenarioDefinition, MsScenario scenario, String id, String reportType) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();

View File

@ -364,7 +364,7 @@ export default {
} }
} }
} }
if (databaseConfigsOptions.length > 0) { if (databaseConfigsOptions.length > 0 && this.request.environmentId !== this.environment.id) {
this.request.dataSourceId = databaseConfigsOptions[0].id; this.request.dataSourceId = databaseConfigsOptions[0].id;
this.request.environmentId = this.environment.id; this.request.environmentId = this.environment.id;
} }