fix(测试计划): 修复测试计划执行功能用例时环境选择有误的问题

--bug=1033900 --user=宋天阳 【测试跟踪】计划详情-接口用例-批量执行选择新环境-跨项目接口用例也显示当前项目选择的环境
https://www.tapd.cn/55049933/s/1447472
This commit is contained in:
song-tianyang 2023-12-22 15:14:55 +08:00 committed by Craftsman
parent 347d81b533
commit 8a1db58c36

View File

@ -124,7 +124,12 @@ public class ApiCaseExecuteService {
if (testCase == null) {
continue;
}
if (MapUtils.isEmpty(runModeConfigDTO.getEnvMap())) {
String envId = null;
if (MapUtils.isNotEmpty(runModeConfigDTO.getEnvMap())) {
envId = runModeConfigDTO.getEnvMap().get(testCase.getProjectId());
}
if (StringUtils.isBlank(envId)) {
//请求中没有指定用例所在项目的环境ID则从用例中获取
if (StringUtils.isEmpty(testPlanApiCase.getEnvironmentId())) {
JSONObject jsonObject = new JSONObject(testCase.getRequest());
runModeConfigDTO.setEnvMap(this.getEnvMap(jsonObject, testCase.getProjectId()));
@ -133,7 +138,13 @@ public class ApiCaseExecuteService {
this.put(testCase.getProjectId(), testPlanApiCase.getEnvironmentId());
}});
}
} else {
String finalEnvId = envId;
runModeConfigDTO.setEnvMap(new HashMap<>() {{
this.put(testCase.getProjectId(), finalEnvId);
}});
}
ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.addResult(request, runModeConfigDTO, testPlanApiCase, status, testCase, resourcePoolId);
executeQueue.put(testPlanApiCase.getId(), report);
responseDTOS.add(new MsExecResponseDTO(testPlanApiCase.getId(), report.getId(), request.getTriggerMode()));