From 9184f074624b668e29b0536d6ba5c2b62e6dd53d Mon Sep 17 00:00:00 2001 From: I M Date: Wed, 11 Jan 2023 08:06:25 +0300 Subject: [PATCH] crash fixed on node field access (via #43) --- .../xcresults/export/Allure2ExportFormatter.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/eroshenkoam/xcresults/export/Allure2ExportFormatter.java b/src/main/java/io/eroshenkoam/xcresults/export/Allure2ExportFormatter.java index 3ec3dcf..d93fe7c 100644 --- a/src/main/java/io/eroshenkoam/xcresults/export/Allure2ExportFormatter.java +++ b/src/main/java/io/eroshenkoam/xcresults/export/Allure2ExportFormatter.java @@ -92,7 +92,7 @@ public TestResult format(final ExportMeta meta, final JsonNode node) { } } final Optional topLevelFailure = context.getFailures().values().stream() - .filter(f -> f.get(FAILURE_IS_TOP_LEVEL).get(VALUE).asBoolean()) + .filter(this::isTopLevelFailure) .map(this::getFailureStep) .findFirst(); if (topLevelFailure.isPresent()) { @@ -291,6 +291,13 @@ private Optional getActivityTitle(final JsonNode node) { return Optional.empty(); } + private Boolean isTopLevelFailure(final JsonNode activityFailure) { + if (activityFailure.has(FAILURE_IS_TOP_LEVEL)) { + return activityFailure.get(FAILURE_IS_TOP_LEVEL).get(VALUE).asBoolean(); + } + return false; + } + private StepResult getFailureStep(final JsonNode activityFailure) { final Long timestamp = parseDate(activityFailure.get(FAILURE_TIMESTAMP).get(VALUE).asText()); final String message = activityFailure.get(FAILURE_MESSAGE).get(VALUE).asText();