Skip to content

Commit

Permalink
SD-1887 No more NPE after error handling response from adopter system
Browse files Browse the repository at this point in the history
  • Loading branch information
gj0dcsa committed Dec 13, 2024
1 parent 8ea8632 commit f9a3c0a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ protected final void doCheck(Function<UUID, ConformanceExchange> 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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConformanceExchange> checkedExchanges;
private final boolean conformant;
private final Set<String> errors;

private ConformanceResult(
String checkedPartyName,
ConformanceExchange checkedExchange,
boolean conformant,
Set<String> 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<String> errors) {
return new ConformanceResult(
exchange.getRequest().message().sourcePartyName(), exchange, errors.isEmpty(), errors);
public static ConformanceResult forSourceParty(Set<String> errors) {
return new ConformanceResult(errors.isEmpty(), errors);
}

public static ConformanceResult forTargetParty(ConformanceExchange exchange, Set<String> errors) {
return new ConformanceResult(
exchange.getRequest().message().targetPartyName(), exchange, errors.isEmpty(), errors);
public static ConformanceResult forTargetParty(Set<String> errors) {
return new ConformanceResult(errors.isEmpty(), errors);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ protected void doCheck(
Function<UUID, ConformanceExchange> getExchangeByUuid) {
addResult(
ConformanceResult.forSourceParty(
getExchangeByUuid.apply(matchedExchangeUuid),
Set.of(exchangeHandlingExceptionMessage)));
}
},
Expand All @@ -209,7 +208,6 @@ protected void doCheck(
Function<UUID, ConformanceExchange> getExchangeByUuid) {
addResult(
ConformanceResult.forTargetParty(
getExchangeByUuid.apply(matchedNotificationExchangeUuid),
Set.of(notificationHandlingExceptionMessage)));
}
},
Expand Down

0 comments on commit f9a3c0a

Please sign in to comment.