fix(测试跟踪): 修复测试计划列表报告中只展示UI环境的问题

--bug=1023068 --user=宋天阳
【测试跟踪】执行测试计划-查看报告统计/测试计划列表-操作-查看测试报告-运行环境未展示接口用例执行环境
https://www.tapd.cn/55049933/s/1337429
This commit is contained in:
song-tianyang 2023-02-17 19:31:50 +08:00 committed by 建国
parent 9b3fb2d9e6
commit 3edd7e30b3
4 changed files with 30 additions and 12 deletions

View File

@ -49,8 +49,10 @@ import io.metersphere.request.ScheduleRequest;
import io.metersphere.service.*; import io.metersphere.service.*;
import io.metersphere.utils.DiscoveryUtil; import io.metersphere.utils.DiscoveryUtil;
import io.metersphere.utils.LoggerUtil; import io.metersphere.utils.LoggerUtil;
import io.metersphere.service.ApiPoolDebugService;
import io.metersphere.xpack.track.dto.IssuesDao; import io.metersphere.xpack.track.dto.IssuesDao;
import jakarta.annotation.Resource;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
@ -67,9 +69,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -1584,6 +1583,7 @@ public class TestPlanService {
/** /**
* 合并ui场景的环境信息 * 合并ui场景的环境信息
*
* @param planId * @param planId
* @param scenarioEnv * @param scenarioEnv
* @return * @return

View File

@ -6,18 +6,22 @@ import io.metersphere.commons.constants.MicroServiceName;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.*; import io.metersphere.dto.*;
import io.metersphere.plan.dto.*; import io.metersphere.plan.dto.ApiModuleDTO;
import io.metersphere.plan.dto.BatchRunDefinitionRequest;
import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import io.metersphere.plan.dto.TestPlanSimpleReportDTO;
import io.metersphere.plan.request.api.ApiTestCaseRequest; import io.metersphere.plan.request.api.ApiTestCaseRequest;
import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.plan.utils.TestPlanStatusCalculator;
import io.metersphere.utils.DiscoveryUtil; import io.metersphere.utils.DiscoveryUtil;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -47,7 +51,11 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
//记录接口用例的运行环境信息 //记录接口用例的运行环境信息
List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList());
try { try {
report.setProjectEnvMap(getPlanProjectEnvMap(idList)); if (MapUtils.isEmpty(report.getProjectEnvMap())) {
report.setProjectEnvMap(getPlanProjectEnvMap(idList));
} else {
report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList));
}
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
} }

View File

@ -12,12 +12,13 @@ import io.metersphere.plan.request.api.ApiScenarioRequest;
import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.plan.utils.TestPlanStatusCalculator;
import io.metersphere.utils.DiscoveryUtil; import io.metersphere.utils.DiscoveryUtil;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -40,7 +41,11 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService {
//记录接口用例的运行环境信息 //记录接口用例的运行环境信息
List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList());
try { try {
report.setProjectEnvMap(getPlanProjectEnvMap(idList)); if (MapUtils.isEmpty(report.getProjectEnvMap())) {
report.setProjectEnvMap(getPlanProjectEnvMap(idList));
} else {
report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList));
}
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
} }
@ -115,7 +120,7 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService {
} }
public RunModeConfigDTO setScenarioEnv(String planId, RunModeConfigDTO runModeConfig) { public RunModeConfigDTO setScenarioEnv(String planId, RunModeConfigDTO runModeConfig) {
return microService.postForData(serviceName, BASE_UEL + "/set/env/" + planId, runModeConfig, RunModeConfigDTO.class); return microService.postForData(serviceName, BASE_UEL + "/set/env/" + planId, runModeConfig, RunModeConfigDTO.class);
} }
public void relevanceByTestIds(List<String> scenarioIds, String planId) { public void relevanceByTestIds(List<String> scenarioIds, String planId) {

View File

@ -17,12 +17,13 @@ import io.metersphere.plan.service.remote.api.PlanUiScenarioReportService;
import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.plan.utils.TestPlanStatusCalculator;
import io.metersphere.request.ResetOrderRequest; import io.metersphere.request.ResetOrderRequest;
import io.metersphere.utils.DiscoveryUtil; import io.metersphere.utils.DiscoveryUtil;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -70,7 +71,11 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService {
//记录UI用例的运行环境信息 //记录UI用例的运行环境信息
List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList());
try { try {
report.setProjectEnvMap(getPlanProjectEnvMap(idList)); if (MapUtils.isEmpty(report.getProjectEnvMap())) {
report.setProjectEnvMap(getPlanProjectEnvMap(idList));
} else {
report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList));
}
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e); LogUtil.error(e);
} }