aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-01-11 22:24:32 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-01-11 22:24:46 -0500
commit45986141965394d115f41e1b404834f386cb5fa2 (patch)
tree4475dd368c7d0c43d41057e60624b3451ec83c17 /bpmn
parentc286ac0022ccef0ea4f7d74f8626fba6e3060b86 (diff)
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) <mb388a@us.att.com>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java5
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java2
10 files changed, 28 insertions, 20 deletions
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<String> 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<S extends FlowValidator, E extends Flo
}
protected boolean validate(List<? extends FlowValidator> validators, String bbName, BuildingBlockExecution execution) {
- List<Pair<String, Boolean>> results = runValidations(validators, bbName, execution);
+ List<Pair<String, Optional<String>>> 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<Pair<String, Boolean>> runValidations(List<? extends FlowValidator> validators, String bbName, BuildingBlockExecution execution) {
+ protected List<Pair<String, Optional<String>>> runValidations(List<? extends FlowValidator> validators, String bbName, BuildingBlockExecution execution) {
List<FlowValidator> filtered = filterValidators(validators, bbName);
- List<Pair<String,Boolean>> results = new ArrayList<>();
+ List<Pair<String,Optional<String>>> 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<FlowValidator> filterValidators(List<? extends FlowValidator> validators, String bbName) {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java
index 7246af0cb5..617f63f6f8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java
@@ -76,7 +76,7 @@ public class BuildingBlockValidatorRunnerTest {
fail("exception not thrown");
} catch (BpmnError e) {
WorkflowException workflowException = (WorkflowException)execution.getVariable("WorkflowException");
- assertEquals("Failed Validations:\norg.onap.so.bpmn.common.validation.MyPreValidatorTwo\norg.onap.so.bpmn.common.validation.MyPreValidatorOne", workflowException.getErrorMessage());
+ assertEquals("Failed Validations:\norg.onap.so.bpmn.common.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.MyPreValidatorOne: my-error-one", workflowException.getErrorMessage());
}
runner.preValidate("test2", mock(BuildingBlockExecution.class));
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
index 7aa42248ac..fbd709b058 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.common.validation;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -35,8 +36,8 @@ public class MyPreValidatorFour implements PreBuildingBlockValidator {
}
@Override
- public boolean validate(BuildingBlockExecution exeuction) {
- return true;
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-four");
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
index 302bb2b023..f642f915b7 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.common.validation;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -36,8 +37,8 @@ public class MyPreValidatorOne implements PreBuildingBlockValidator {
}
@Override
- public boolean validate(BuildingBlockExecution exeuction) {
- return false;
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-one");
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
index ca1a959104..780fb43c2a 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.common.validation;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -35,8 +36,8 @@ public class MyPreValidatorThree implements PreBuildingBlockValidator {
}
@Override
- public boolean validate(BuildingBlockExecution exeuction) {
- return true;
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-three");
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
index b74c91433f..c8ff6ef848 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.common.validation;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import javax.annotation.Priority;
@@ -38,8 +39,8 @@ public class MyPreValidatorTwo implements PreBuildingBlockValidator {
}
@Override
- public boolean validate(BuildingBlockExecution exeuction) {
- return false;
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-two");
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
index 6538fe5378..bfe3ec06a3 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.common.validation;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -36,8 +37,8 @@ public class WorkflowPreValidatorOne implements PreWorkflowValidator {
}
@Override
- public boolean validate(BuildingBlockExecution exeuction) {
- return false;
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-one");
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
index e20f0f2b0e..ddf5f22f00 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.common.validation;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import javax.annotation.Priority;
@@ -38,8 +39,8 @@ public class WorkflowPreValidatorTwo implements PreWorkflowValidator {
}
@Override
- public boolean validate(BuildingBlockExecution execution) {
- return false;
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-two");
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java
index 0dd2f410f3..5629f99feb 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java
@@ -75,7 +75,7 @@ public class WorkflowValidatorRunnerTest {
fail("exception not thrown");
} catch (BpmnError e) {
WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
- assertEquals("Failed Validations:\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorTwo\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorOne", workflowException.getErrorMessage());
+ assertEquals("Failed Validations:\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorOne: my-error-one", workflowException.getErrorMessage());
}
runner.preValidate("test2", mock(DelegateExecution.class));
}