From c286ac0022ccef0ea4f7d74f8626fba6e3060b86 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 11 Jan 2019 21:35:13 -0500 Subject: refactored validator to be more generic removed overloaded method from class for JUEL changed test back to DelegateExecution added methods to allow validations with DelegateExecution refactored validator to be more generic Change-Id: I6c6d7a50e8b5470ffa5619cc83966f5ad68e66fe Issue-ID: SO-1383 Signed-off-by: Benjamin, Max (mb388a) --- .../bpmn/common/validation/BuildingBlockValidatorRunnerTest.java | 8 ++++---- .../org/onap/so/bpmn/common/validation/MyPreValidatorFour.java | 2 +- .../org/onap/so/bpmn/common/validation/MyPreValidatorOne.java | 2 +- .../org/onap/so/bpmn/common/validation/MyPreValidatorThree.java | 2 +- .../org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java | 2 +- .../onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java | 6 +++--- .../onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java | 6 +++--- .../so/bpmn/common/validation/WorkflowValidatorRunnerTest.java | 7 +++---- 8 files changed, 17 insertions(+), 18 deletions(-) (limited to 'bpmn/MSOCommonBPMN/src/test/java/org') 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 9478b8f1f6..7246af0cb5 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 @@ -57,11 +57,11 @@ public class BuildingBlockValidatorRunnerTest { MyPreValidatorOne one = new MyPreValidatorOne(); MyPreValidatorTwo two = new MyPreValidatorTwo(); MyPreValidatorThree three = new MyPreValidatorThree(); - List validators = Arrays.asList(one, two, three); + List validators = Arrays.asList(one, two, three); - List result = runner.filterValidators(validators, "test"); + List result = runner.filterValidators(validators, "test"); - List expected = Arrays.asList(two, one); + List expected = Arrays.asList(two, one); assertEquals(expected, result); } @@ -75,7 +75,7 @@ public class BuildingBlockValidatorRunnerTest { runner.preValidate("test", execution); fail("exception not thrown"); } catch (BpmnError e) { - WorkflowException workflowException = execution.getVariable("WorkflowException"); + 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()); } 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 1b52f049b3..7aa42248ac 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 @@ -30,7 +30,7 @@ import org.springframework.stereotype.Component; public class MyPreValidatorFour implements PreBuildingBlockValidator { @Override - public Set forBuildingBlock() { + public Set forItems() { return Collections.singleton("test2"); } 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 d6afea9b19..302bb2b023 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 @@ -30,7 +30,7 @@ import org.springframework.stereotype.Component; public class MyPreValidatorOne implements PreBuildingBlockValidator { @Override - public Set forBuildingBlock() { + public Set forItems() { return Collections.singleton("test"); } 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 f7e93d5bd2..ca1a959104 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 @@ -30,7 +30,7 @@ import org.springframework.stereotype.Component; public class MyPreValidatorThree implements PreBuildingBlockValidator { @Override - public Set forBuildingBlock() { + public Set forItems() { return Collections.singleton("test2"); } 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 0c15fd8589..b74c91433f 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 @@ -33,7 +33,7 @@ import org.springframework.stereotype.Component; public class MyPreValidatorTwo implements PreBuildingBlockValidator { @Override - public Set forBuildingBlock() { + public Set forItems() { return Collections.singleton("test"); } 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 9ad87b5aeb..6538fe5378 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 @@ -23,20 +23,20 @@ package org.onap.so.bpmn.common.validation; import java.util.Collections; import java.util.Set; -import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.BuildingBlockExecution; import org.springframework.stereotype.Component; @Component public class WorkflowPreValidatorOne implements PreWorkflowValidator { @Override - public Set forWorkflowAction() { + public Set forItems() { return Collections.singleton("test"); } @Override - public boolean validate(DelegateExecution exeuction) { + public boolean validate(BuildingBlockExecution exeuction) { return false; } 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 2157c673dc..e20f0f2b0e 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 @@ -25,7 +25,7 @@ import java.util.Set; import javax.annotation.Priority; -import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.BuildingBlockExecution; import org.springframework.stereotype.Component; @Priority(1) @@ -33,12 +33,12 @@ import org.springframework.stereotype.Component; public class WorkflowPreValidatorTwo implements PreWorkflowValidator { @Override - public Set forWorkflowAction() { + public Set forItems() { return Collections.singleton("test"); } @Override - public boolean validate(DelegateExecution execution) { + public boolean validate(BuildingBlockExecution execution) { return false; } 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 313fe6b0c3..0dd2f410f3 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 @@ -36,7 +36,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.core.WorkflowException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; @@ -57,11 +56,11 @@ public class WorkflowValidatorRunnerTest { WorkflowPreValidatorOne one = new WorkflowPreValidatorOne(); WorkflowPreValidatorTwo two = new WorkflowPreValidatorTwo(); - List validators = Arrays.asList(one, two); + List validators = Arrays.asList(one, two); - List result = runner.filterValidators(validators, "test"); + List result = runner.filterValidators(validators, "test"); - List expected = Arrays.asList(two, one); + List expected = Arrays.asList(two, one); assertEquals(expected, result); } -- cgit 1.2.3-korg