From 297a9746aae5843921ae6b43c82a6f9573bb7b59 Mon Sep 17 00:00:00 2001 From: Mike Reiche Date: Wed, 3 Nov 2021 10:01:20 +0100 Subject: [PATCH] Refactored API access --- build.gradle | 3 +- settings.gradle | 2 +- .../AzureDevOpsResultSynchronizer.java | 35 ++++++++++--------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index d179dca..d29ed96 100644 --- a/build.gradle +++ b/build.gradle @@ -2,8 +2,7 @@ plugins { id "io.codearte.nexus-staging" version "0.30.0" } -apply plugin: 'java' -apply plugin: 'maven' +apply plugin: 'java-library' apply plugin: 'maven-publish' apply plugin: 'signing' apply plugin: 'io.codearte.nexus-staging' diff --git a/settings.gradle b/settings.gradle index cd2c055..d601949 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ rootProject.name = 'azure-devops-connector' - +//includeBuild("../testerra") diff --git a/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/synchronize/AzureDevOpsResultSynchronizer.java b/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/synchronize/AzureDevOpsResultSynchronizer.java index f8955b5..b79bf92 100644 --- a/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/synchronize/AzureDevOpsResultSynchronizer.java +++ b/src/main/java/eu/tsystems/mms/tic/testerra/plugins/azuredevops/synchronize/AzureDevOpsResultSynchronizer.java @@ -145,12 +145,18 @@ private synchronized void syncTestresult(MethodEndEvent event, Outcome outcome) // result.setPriority(this.getPriorityByFailureCorridor(event.getMethodContext().failureCorridorValue)); if (outcome.equals(Outcome.FAILED)) { - ErrorContext errorContext = event.getMethodContext().getErrorContext(); - final String errorMessage = StringUtils.isNotEmpty(errorContext.getDescription()) ? errorContext.getDescription() : errorContext.getThrowable().getMessage(); - result.setErrorMessage(errorMessage); - result.setFailureType(this.getFailureType(event).toString()); - final String stackTrace = ExceptionUtils.getStackTrace(event.getMethodContext().getErrorContext().getThrowable()); - result.setStackTrace(stackTrace); + event.getMethodContext() + .readErrors() + .filter(ErrorContext::isNotOptional) + .findFirst() + .ifPresent(errorContext -> { + Throwable throwable = errorContext.getThrowable(); + final String errorMessage = throwable.getMessage(); + result.setErrorMessage(errorMessage); + result.setFailureType(this.getFailureType(event).toString()); + final String stackTrace = ExceptionUtils.getStackTrace(throwable); + result.setStackTrace(stackTrace); + }); } List resultList = new ArrayList<>(); @@ -209,16 +215,13 @@ private AzureTest getAnnotation(MethodEndEvent event) { } } - private int getPriorityByFailureCorridor(FailureCorridor.Value value) { - switch (value) { - case HIGH: - return 1; - case MID: - return 2; - case LOW: - return 3; - default: - return 1; + private int getPriorityByFailureCorridor(Class failureCorridorClass) { + if (failureCorridorClass == FailureCorridor.Mid.class) { + return 2; + } else if (failureCorridorClass == FailureCorridor.Low.class) { + return 3; + } else { + return 1; } }