From 7ff56b4d018022e835771a075a31b3d6cd02e8bc Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 25 Mar 2022 19:27:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=9C=BA=E6=99=AF=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4=E6=8E=92=E5=BA=8F=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E8=A7=A3=E5=86=B3=E5=AD=98=E5=9C=A8=E6=9C=AA=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=AD=A5=E9=AA=A4=E6=97=B6=E6=8A=A5=E5=91=8A=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E6=8E=92=E5=BA=8F=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1011633 --user=宋天阳 【测试跟踪】-测试报告中功能用例ID顺序和测试计划功能用例顺序不一致 https://www.tapd.cn/55049933/s/1126292 --- .../ApiScenarioReportStructureService.java | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java index 21b50c15fe..131c3e18d7 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportStructureService.java @@ -298,7 +298,7 @@ public class ApiScenarioReportStructureService { requestResultExpandDTO.setName(dto.getLabel()); dto.setTotalStatus("unexecute"); dto.setValue(requestResultExpandDTO); - } else if(StringUtils.isNotEmpty(dto.getType()) && controls.contains(dto.getType()) && dto.getValue() == null){ + } else if (StringUtils.isNotEmpty(dto.getType()) && controls.contains(dto.getType()) && dto.getValue() == null) { RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO(); requestResultExpandDTO.setStatus("success"); requestResultExpandDTO.setName(dto.getLabel()); @@ -383,25 +383,12 @@ public class ApiScenarioReportStructureService { if (dtoList.stream().filter(e -> e.getValue() != null).collect(Collectors.toList()).size() == dtoList.size()) { List unList = dtoList.stream().filter(e -> e.getValue() != null && StringUtils.equalsIgnoreCase(e.getTotalStatus(), "unexecute")).collect(Collectors.toList()); - Map map = unList.stream().collect(Collectors.toMap(StepTreeDTO::getResourceId, StepTreeDTO::getIndex)); - - List list = dtoList.stream() - .sorted( - (x, y) -> { - // 如果开始时间是0,即未开始,则排后面 - if (x.getValue().getStartTime() == 0) { - return -1; - } else { - return x.getValue().getStartTime() - y.getValue().getStartTime() > 0 ? 1 : -1; - } - } - ) - .collect(Collectors.toList()); - - for (int index = 0; index < list.size(); index++) { - if (map.containsKey(list.get(index).getResourceId())) { - Collections.swap(list, index, (map.get(list.get(index).getResourceId()) - 1)); - } + List list = dtoList.stream().filter(e -> e.getValue().getStartTime() != 0).collect(Collectors.toList()); + list = list.stream().sorted(Comparator.comparing(x -> x.getValue().getStartTime())).collect(Collectors.toList()); + unList = unList.stream().sorted(Comparator.comparing(x -> x.getIndex())).collect(Collectors.toList()); + for (StepTreeDTO unListDTO : unList) { + int index = unListDTO.getIndex(); + list.add(index - 1, unListDTO); } for (int index = 0; index < list.size(); index++) { list.get(index).setIndex((index + 1)); @@ -480,7 +467,7 @@ public class ApiScenarioReportStructureService { if (CollectionUtils.isNotEmpty(reportResults)) { reportDTO.setTotal(reportResults.size()); reportDTO.setError(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "Error")).collect(Collectors.toList()).size()); - reportDTO.setUnExecute(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "STOP","unexecute")).collect(Collectors.toList()).size()); + reportDTO.setUnExecute(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "STOP", "unexecute")).collect(Collectors.toList()).size()); reportDTO.setErrorCode(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "errorReportResult")).collect(Collectors.toList()).size()); reportDTO.setPassAssertions(reportResults.stream().mapToLong(ApiDefinitionExecResultVo::getPassAssertions).sum()); reportDTO.setTotalAssertions(reportResults.stream().mapToLong(ApiDefinitionExecResultVo::getTotalAssertions).sum()); @@ -543,7 +530,7 @@ public class ApiScenarioReportStructureService { AtomicLong stepError = new AtomicLong(); AtomicLong stepTotal = new AtomicLong(); - reportDTO.setScenarioSuccess((reportDTO.getScenarioTotal() - reportDTO.getScenarioError() - reportDTO.getScenarioUnExecute() -reportDTO.getScenarioErrorReport())); + reportDTO.setScenarioSuccess((reportDTO.getScenarioTotal() - reportDTO.getScenarioError() - reportDTO.getScenarioUnExecute() - reportDTO.getScenarioErrorReport())); //统计步骤数据 AtomicLong stepErrorCode = new AtomicLong();