From bf4aa4e8c879a5b6c23c31e37edea5596217280b Mon Sep 17 00:00:00 2001 From: zhangdahai112 Date: Fri, 16 Sep 2022 01:31:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(UI=E8=87=AA=E5=8A=A8=E5=8C=96):=20=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=87=8D=E8=AF=95=E5=A2=9E=E5=8A=A0grid=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=90=AF=E5=8A=A8=E5=88=A4=E6=96=AD=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E6=AD=BB=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiScenarioReportService.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 89a37d1150..e69e883e30 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -992,20 +992,22 @@ public class ApiScenarioReportService { */ private long getUiErrorSize(ResultDTO dto) { int errorSize = 0; - boolean success = false; - String processType = null; - String cmdName = null; - for (RequestResult r : dto.getRequestResults()) { - if (StringUtils.isNotEmpty(r.getResponseResult().getHeaders())) { - JSONArray responseArr = JSONArray.parseArray(r.getResponseResult().getHeaders()); - for (int i = 0; i < responseArr.size(); i++) { - JSONObject stepResult = responseArr.getJSONObject(i); - success = Optional.ofNullable(stepResult.getBoolean("success")).orElse(Boolean.FALSE); - processType = Optional.ofNullable(stepResult.getString("processType")).orElse(""); - cmdName = Optional.ofNullable(stepResult.getString("cmdName")).orElse(""); - if (!success && (StringUtils.equalsIgnoreCase("MAIN", processType) || cmdName.startsWith("verify") || cmdName.startsWith("assert"))) { - errorSize++; - } + boolean success; + String processType; + String cmdName; + RequestResult r = null; + if (CollectionUtils.isNotEmpty(dto.getRequestResults())) { + r = dto.getRequestResults().get(dto.getRequestResults().size() - 1); + } + if (StringUtils.isNotEmpty(r.getResponseResult().getHeaders())) { + JSONArray responseArr = JSONArray.parseArray(r.getResponseResult().getHeaders()); + for (int i = 0; i < responseArr.size(); i++) { + JSONObject stepResult = responseArr.getJSONObject(i); + success = Optional.ofNullable(stepResult.getBoolean("success")).orElse(Boolean.FALSE); + processType = Optional.ofNullable(stepResult.getString("processType")).orElse(""); + cmdName = Optional.ofNullable(stepResult.getString("cmdName")).orElse(""); + if (!success && (StringUtils.equalsIgnoreCase("MAIN", processType) || cmdName.startsWith("verify") || cmdName.startsWith("assert"))) { + errorSize++; } } }