From 98e40f8cb33db387328605e8180b033ba94fccf0 Mon Sep 17 00:00:00 2001 From: zhangdahai112 Date: Tue, 13 Sep 2022 19:23:33 +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 ae8b29c883..50507f8cbb 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -914,17 +914,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++; } } }