From 6915cc71478cd49cd7c1c70c05ecd7cd998d3bfd Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 6 Apr 2023 17:59:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B91.20=E7=B3=BB=E5=88=97=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 测试计划报告增加对1.20系列数据的支持 --- .../plan/service/TestPlanService.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) 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 426c01771a..6e898ea0ac 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 @@ -1476,12 +1476,38 @@ public class TestPlanService { testPlanReport, testPlan, testPlanExecuteReportDTO); } + //处理旧数据 + this.dealOldVersionData(testPlanReportStruct); //查找运行环境 testPlanReportService.initRunInformation(testPlanReportStruct, testPlanReport); } return testPlanReportStruct == null ? new TestPlanReportDataStruct() : testPlanReportStruct; } + /** + * 处理旧版本数据(例如版本升级过程中由于统一了状态字段的数据) + */ + private void dealOldVersionData(TestPlanReportDataStruct testPlanReportStruct) { + if (CollectionUtils.isNotEmpty(testPlanReportStruct.getScenarioAllCases())) { + //使用LinkedHashMap是为了确保reportId的一致性,同时保证顺序 + Map errorScenarioDTOMap = new LinkedHashMap<>(); + if (CollectionUtils.isNotEmpty(testPlanReportStruct.getScenarioFailureCases())) { + testPlanReportStruct.getScenarioFailureCases().forEach(item -> { + if (StringUtils.isNotBlank(item.getReportId())) { + errorScenarioDTOMap.put(item.getReportId(), item); + } + }); + + } + testPlanReportStruct.getScenarioAllCases().forEach(item -> { + if (StringUtils.equalsIgnoreCase(item.getLastResult(), "Fail")) { + errorScenarioDTOMap.put(item.getReportId(), item); + } + }); + testPlanReportStruct.setScenarioFailureCases(new ArrayList<>(errorScenarioDTOMap.values())); + } + } + //获取已生成过的测试计划报告内容 private TestPlanReportDataStruct getTestPlanReportStructByCreated(TestPlanReportContentWithBLOBs testPlanReportContentWithBLOBs) {