From f45db38d9612405a34ae7648ae4bb8a19cd1ef66 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 17 Feb 2023 19:31:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8A=A5=E5=91=8A=E4=B8=AD=E5=8F=AA=E5=B1=95=E7=A4=BA?= =?UTF-8?q?UI=E7=8E=AF=E5=A2=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1023068 --user=宋天阳 【测试跟踪】执行测试计划-查看报告统计/测试计划列表-操作-查看测试报告-运行环境未展示接口用例执行环境 https://www.tapd.cn/55049933/s/1337429 --- .../metersphere/plan/service/TestPlanService.java | 8 ++++---- .../remote/api/PlanTestPlanApiCaseService.java | 14 +++++++++++--- .../api/PlanTestPlanScenarioCaseService.java | 11 ++++++++--- .../ui/PlanTestPlanUiScenarioCaseService.java | 9 +++++++-- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index ab64c2e6f8..9d58630422 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -49,8 +49,10 @@ import io.metersphere.request.ScheduleRequest; import io.metersphere.service.*; import io.metersphere.utils.DiscoveryUtil; import io.metersphere.utils.LoggerUtil; -import io.metersphere.service.ApiPoolDebugService; 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.MapUtils; 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.Transactional; -import jakarta.annotation.Resource; -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.HttpServletResponse; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; @@ -1584,6 +1583,7 @@ public class TestPlanService { /** * 合并ui场景的环境信息 + * * @param planId * @param scenarioEnv * @return diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java index b6186e7aca..520b6441a3 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java @@ -6,18 +6,22 @@ import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; 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.service.TestPlanService; import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.utils.DiscoveryUtil; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -47,7 +51,11 @@ public class PlanTestPlanApiCaseService extends ApiTestService { //记录接口用例的运行环境信息 List idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); try { - report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + if (MapUtils.isEmpty(report.getProjectEnvMap())) { + report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + } else { + report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList)); + } } catch (Exception e) { LogUtil.error(e); } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java index bc9b09949f..6cc47e4039 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java @@ -12,12 +12,13 @@ import io.metersphere.plan.request.api.ApiScenarioRequest; import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.utils.DiscoveryUtil; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import jakarta.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -40,7 +41,11 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService { //记录接口用例的运行环境信息 List idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); try { - report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + if (MapUtils.isEmpty(report.getProjectEnvMap())) { + report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + } else { + report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList)); + } } catch (Exception e) { LogUtil.error(e); } @@ -115,7 +120,7 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService { } 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 scenarioIds, String planId) { diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java index 2fe8160493..9834d53751 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java @@ -17,12 +17,13 @@ import io.metersphere.plan.service.remote.api.PlanUiScenarioReportService; import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.request.ResetOrderRequest; import io.metersphere.utils.DiscoveryUtil; +import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import jakarta.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -70,7 +71,11 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService { //记录UI用例的运行环境信息 List idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); try { - report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + if (MapUtils.isEmpty(report.getProjectEnvMap())) { + report.setProjectEnvMap(getPlanProjectEnvMap(idList)); + } else { + report.getProjectEnvMap().putAll(getPlanProjectEnvMap(idList)); + } } catch (Exception e) { LogUtil.error(e); }