summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-01-11 21:09:59 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-01-11 21:10:13 -0500
commit801cddd65cad0bd01ea8fec5d33f9e53e17aa62b (patch)
tree6f5139c1f289f6fc6eacc157668ed7b1188298b7 /bpmn/MSOCommonBPMN/src/test
parentde5958dddd97b086ec8b603974f434fd814386ac (diff)
validation for vnfs before WorkflowAction starts
Removed accidental merge markup from WorkflowActionBB Addition of prevalidation to WorkflowActionBB. Implement more JUnits for validation methods. Implement verification of deleteInstance workflow for VNR configuration dependencies. Added a validation mechanism on a workflow level to check for valid actions. Change-Id: Icb2859c3b8ece534d4e9831ca5f48a15dfaef58d Issue-ID: SO-1379 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java43
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java45
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java90
3 files changed, 178 insertions, 0 deletions
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
new file mode 100644
index 0000000000..9ad87b5aeb
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.validation;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.springframework.stereotype.Component;
+
+@Component
+public class WorkflowPreValidatorOne implements PreWorkflowValidator {
+
+ @Override
+ public Set<String> forWorkflowAction() {
+
+ return Collections.singleton("test");
+ }
+
+ @Override
+ public boolean validate(DelegateExecution 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
new file mode 100644
index 0000000000..2157c673dc
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.validation;
+
+import java.util.Collections;
+import java.util.Set;
+
+import javax.annotation.Priority;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.springframework.stereotype.Component;
+
+@Priority(1)
+@Component
+public class WorkflowPreValidatorTwo implements PreWorkflowValidator {
+
+ @Override
+ public Set<String> forWorkflowAction() {
+ return Collections.singleton("test");
+ }
+
+ @Override
+ public boolean validate(DelegateExecution 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
new file mode 100644
index 0000000000..313fe6b0c3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.validation;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Rule;
+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;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {ValidationConfig.class})
+public class WorkflowValidatorRunnerTest {
+
+ @Rule
+ public ExpectedException thrown= ExpectedException.none();
+
+ @Autowired
+ private WorkflowValidatorRunner runner;
+
+ @Test
+ public void filterValidatorTest() {
+
+ WorkflowPreValidatorOne one = new WorkflowPreValidatorOne();
+ WorkflowPreValidatorTwo two = new WorkflowPreValidatorTwo();
+ List<WorkflowValidator> validators = Arrays.asList(one, two);
+
+ List<WorkflowValidator> result = runner.filterValidators(validators, "test");
+
+ List<WorkflowValidator> expected = Arrays.asList(two, one);
+
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testValidate() {
+
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable("testProcessKey", "1234");
+ try {
+ runner.preValidate("test", execution);
+ 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());
+ }
+ runner.preValidate("test2", mock(DelegateExecution.class));
+ }
+
+ @Test
+ public void testEmptyList() {
+ boolean result = runner.preValidate("test3", mock(DelegateExecution.class));
+
+ assertTrue(result);
+ }
+}