fix(接口测试): 修复导入其他项目的用例,用例列表显示环境的问题

--bug=1028708 --user=王孝刚 【接口测试】项目A导出接口带用例且配置了运行环境-导入项目B-用例详情未显示运行环境
https://www.tapd.cn/55049933/s/1403611
This commit is contained in:
wxg0103 2023-08-15 10:57:11 +08:00 committed by 刘瑞斌
parent 6bc01bea6d
commit 138005a10a
1 changed files with 4 additions and 1 deletions

View File

@ -1102,7 +1102,7 @@ public class ApiTestCaseService {
List<String> envIds = environments.stream().filter(t -> StringUtils.isNotBlank(t.getValue()) && !StringUtils.equalsIgnoreCase(t.getValue(), "null")).map(ParamsDTO::getValue).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(envIds)) {
ApiTestEnvironmentExample example = new ApiTestEnvironmentExample();
example.createCriteria().andIdIn(envIds);
example.createCriteria().andIdIn(envIds).andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
List<ApiTestEnvironment> environmentList = apiTestEnvironmentMapper.selectByExample(example);
if (CollectionUtils.isEmpty(environmentList)) {
@ -1111,6 +1111,9 @@ public class ApiTestCaseService {
Map<String, String> envMap = environmentList.stream().collect(Collectors.toMap(ApiTestEnvironment::getId, ApiTestEnvironment::getName));
Map<String, String> caseEnvMap = environments.stream().filter(t -> StringUtils.isNotBlank(t.getValue()) && !StringUtils.equalsIgnoreCase(t.getValue(), "null")).collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getValue()), HashMap::putAll);
//caseEnvMap和envMap的key不存在的要删除
caseEnvMap.keySet().removeIf(k -> !envMap.containsKey(caseEnvMap.get(k)));
caseEnvMap.forEach((k, v) -> {
if (envMap.containsKey(v)) {
caseEnvMap.put(k, envMap.get(v));