fix(接口测试): 修复场景执行报错执行失败的缺陷

--bug=1032423 --user=王孝刚 【接口自动化】全新环境-首次导入接口场景用例,批量编辑选运行环境不生效
https://www.tapd.cn/55049933/s/1436365
This commit is contained in:
wxg0103 2023-11-14 16:19:45 +08:00 committed by Craftsman
parent f49576ccd0
commit 34b8689e22
1 changed files with 4 additions and 4 deletions

View File

@ -1119,7 +1119,7 @@ public class ElementUtil {
} }
dataSource = ElementUtil.initDataSource(environmentId, dataSourceId); dataSource = ElementUtil.initDataSource(environmentId, dataSourceId);
if (dataSource == null && CollectionUtils.isNotEmpty(environmentConfig.getDatabaseConfigs())) { if (dataSource == null && CollectionUtils.isNotEmpty(environmentConfig.getDatabaseConfigs())) {
dataSource = environmentConfig.getDatabaseConfigs().get(0); return environmentConfig.getDatabaseConfigs().get(0);
} }
} else { } else {
// 取当前环境下默认的一个数据源 // 取当前环境下默认的一个数据源
@ -1127,10 +1127,10 @@ public class ElementUtil {
LoggerUtil.info(processorName + ":开始获取当前环境下默认数据源"); LoggerUtil.info(processorName + ":开始获取当前环境下默认数据源");
DatabaseConfig dataSourceOrg = ElementUtil.dataSource(projectId, dataSourceId, config.get(projectId)); DatabaseConfig dataSourceOrg = ElementUtil.dataSource(projectId, dataSourceId, config.get(projectId));
if (dataSourceOrg != null) { if (dataSourceOrg != null) {
dataSource = dataSourceOrg; return dataSourceOrg;
} else { } else {
LoggerUtil.info(processorName + ":获取当前环境下默认数据源结束!未查找到默认数据源"); LoggerUtil.info(processorName + ":获取当前环境下默认数据源结束!未查找到默认数据源");
dataSource = config.get(projectId).getDatabaseConfigs().get(0); return config.get(projectId).getDatabaseConfigs().get(0);
} }
} }
} }
@ -1222,7 +1222,7 @@ public class ElementUtil {
public static Map<String, String> getProjectEnvMap(List<String> projectIdLists, Map<String, String> projectEnvMap) { public static Map<String, String> getProjectEnvMap(List<String> projectIdLists, Map<String, String> projectEnvMap) {
if (CollectionUtils.isNotEmpty(projectIdLists)) { if (CollectionUtils.isNotEmpty(projectIdLists)) {
projectEnvMap = projectEnvMap.entrySet().stream() projectEnvMap = projectEnvMap.entrySet().stream()
.filter(entry -> projectIdLists.contains(entry.getKey())) .filter(entry -> projectIdLists.contains(entry.getKey()) && StringUtils.isNotEmpty(entry.getValue()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
} }
return projectEnvMap; return projectEnvMap;