From 45986141965394d115f41e1b404834f386cb5fa2 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 11 Jan 2019 22:24:32 -0500 Subject: descriptive messages now returned by validator descriptive messages now returned by validator Change-Id: I49db843fbdfe20979fba6991744c62aa1f745d5f Issue-ID: SO-1388 Signed-off-by: Benjamin, Max (mb388a) --- .../java/org/onap/so/bpmn/common/validation/FlowValidator.java | 4 +++- .../onap/so/bpmn/common/validation/FlowValidatorRunner.java | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'bpmn/MSOCommonBPMN/src/main/java') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java index 9995b95c50..96322c3c88 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java @@ -1,5 +1,6 @@ package org.onap.so.bpmn.common.validation; +import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -14,10 +15,11 @@ public interface FlowValidator { /** * Determines whether or not the workflow should be executed + * * @param execution * @return */ - public boolean validate(BuildingBlockExecution execution); + public Optional validate(BuildingBlockExecution execution); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java index c2e7d1f4d9..9e6ea53a47 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java @@ -99,24 +99,24 @@ public abstract class FlowValidatorRunner validators, String bbName, BuildingBlockExecution execution) { - List> results = runValidations(validators, bbName, execution); + List>> results = runValidations(validators, bbName, execution); if (!results.isEmpty()) { exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, - "Failed Validations:\n" + results.stream().map(item -> item.getValue0()).collect(Collectors.joining("\n"))); + "Failed Validations:\n" + results.stream().map(item -> String.format("%s: %s", item.getValue0(), item.getValue1().get())).collect(Collectors.joining("\n"))); } return true; } - protected List> runValidations(List validators, String bbName, BuildingBlockExecution execution) { + protected List>> runValidations(List validators, String bbName, BuildingBlockExecution execution) { List filtered = filterValidators(validators, bbName); - List> results = new ArrayList<>(); + List>> results = new ArrayList<>(); filtered.forEach(item -> results.add(new Pair<>(item.getClass().getName(), item.validate(execution)))); - return results.stream().filter(item -> item.getValue1().equals(false)).collect(Collectors.toList()); + return results.stream().filter(item -> item.getValue1().isPresent()).collect(Collectors.toList()); } protected List filterValidators(List validators, String bbName) { -- cgit 1.2.3-korg