From b97f224e0da01ceab35d505f774c8c24af8c7afb Mon Sep 17 00:00:00 2001 From: zhangdahai112 Date: Tue, 13 Sep 2022 19:14:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor(UI=E8=87=AA=E5=8A=A8=E5=8C=96):=20?= =?UTF-8?q?=E6=8A=A5=E5=91=8Aerror=E4=BB=A3=E7=A0=81=E5=8F=AF=E8=AF=BB?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiScenarioReportService.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 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 137a0c5be8..89a37d1150 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -992,17 +992,19 @@ 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); - if (stepResult.containsKey("success") && !stepResult.getBoolean("success")) { - if ((stepResult.containsKey("processType") && StringUtils.equalsIgnoreCase("MAIN", stepResult.getString("processType"))) - || (stepResult.containsKey("cmdName") - && ((stepResult.getString("cmdName").startsWith("verify")) || stepResult.getString("cmdName").startsWith("assert")))) { - errorSize++; - } + 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++; } } }