From f9a3c0a4d5c184ad6e6c4abfe4b12ad478803755 Mon Sep 17 00:00:00 2001 From: gj0dcsa <135594855+gj0dcsa@users.noreply.github.com> Date: Fri, 13 Dec 2024 23:12:19 +0100 Subject: [PATCH] SD-1887 No more NPE after error handling response from adopter system --- .../conformance/core/check/ActionCheck.java | 4 ++-- .../core/check/ConformanceResult.java | 18 ++++-------------- .../core/scenario/ConformanceAction.java | 2 -- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/org/dcsa/conformance/core/check/ActionCheck.java b/core/src/main/java/org/dcsa/conformance/core/check/ActionCheck.java index 8aacaf93..eb54edbc 100644 --- a/core/src/main/java/org/dcsa/conformance/core/check/ActionCheck.java +++ b/core/src/main/java/org/dcsa/conformance/core/check/ActionCheck.java @@ -55,11 +55,11 @@ protected final void doCheck(Function getExchangeByUu switch (httpMessageType) { case REQUEST -> { if (isRelevantForRole(exchange.getRequest().message().sourcePartyRole())) - this.addResult(ConformanceResult.forSourceParty(exchange, conformanceErrors)); + this.addResult(ConformanceResult.forSourceParty(conformanceErrors)); } case RESPONSE -> { if (isRelevantForRole(exchange.getRequest().message().targetPartyRole())) - this.addResult(ConformanceResult.forTargetParty(exchange, conformanceErrors)); + this.addResult(ConformanceResult.forTargetParty(conformanceErrors)); } } } diff --git a/core/src/main/java/org/dcsa/conformance/core/check/ConformanceResult.java b/core/src/main/java/org/dcsa/conformance/core/check/ConformanceResult.java index c37bfc2e..c083182d 100644 --- a/core/src/main/java/org/dcsa/conformance/core/check/ConformanceResult.java +++ b/core/src/main/java/org/dcsa/conformance/core/check/ConformanceResult.java @@ -2,34 +2,24 @@ import java.util.*; import lombok.Getter; -import org.dcsa.conformance.core.traffic.ConformanceExchange; @Getter public class ConformanceResult { - private final String checkedPartyName; - private final LinkedList checkedExchanges; private final boolean conformant; private final Set errors; private ConformanceResult( - String checkedPartyName, - ConformanceExchange checkedExchange, boolean conformant, Set errors) { - this.checkedPartyName = checkedPartyName; - this.checkedExchanges = new LinkedList<>(List.of(checkedExchange)); this.conformant = conformant; this.errors = Collections.unmodifiableSet(errors); } - public static ConformanceResult forSourceParty(ConformanceExchange exchange, Set errors) { - return new ConformanceResult( - exchange.getRequest().message().sourcePartyName(), exchange, errors.isEmpty(), errors); + public static ConformanceResult forSourceParty(Set errors) { + return new ConformanceResult(errors.isEmpty(), errors); } - public static ConformanceResult forTargetParty(ConformanceExchange exchange, Set errors) { - return new ConformanceResult( - exchange.getRequest().message().targetPartyName(), exchange, errors.isEmpty(), errors); + public static ConformanceResult forTargetParty(Set errors) { + return new ConformanceResult(errors.isEmpty(), errors); } - } diff --git a/core/src/main/java/org/dcsa/conformance/core/scenario/ConformanceAction.java b/core/src/main/java/org/dcsa/conformance/core/scenario/ConformanceAction.java index 1f3e9368..1b15a39d 100644 --- a/core/src/main/java/org/dcsa/conformance/core/scenario/ConformanceAction.java +++ b/core/src/main/java/org/dcsa/conformance/core/scenario/ConformanceAction.java @@ -197,7 +197,6 @@ protected void doCheck( Function getExchangeByUuid) { addResult( ConformanceResult.forSourceParty( - getExchangeByUuid.apply(matchedExchangeUuid), Set.of(exchangeHandlingExceptionMessage))); } }, @@ -209,7 +208,6 @@ protected void doCheck( Function getExchangeByUuid) { addResult( ConformanceResult.forTargetParty( - getExchangeByUuid.apply(matchedNotificationExchangeUuid), Set.of(notificationHandlingExceptionMessage))); } },