From d482d74260ca80cceb8b9d965b54970dfea9526d Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Fri, 14 Jun 2019 10:12:35 -0400 Subject: update multi stage code to accurately skip bbs moved around classes to packages that make more sense updated license headers in java files converted MultiStage logic to FlowManipulator moved tests to new package location and fixed issues allow for custom listeners before flowsToExecute moved validation classes to listener.validation Change-Id: Ic5416812ef9c5611fe19bf9b6aa316373b110ec6 Issue-ID: SO-2021 Signed-off-by: Benjamin, Max (mb388a) --- .../listener/BuildingBlockValidatorRunnerTest.java | 96 ++++++++++++++++++++++ .../listener/WorkflowValidatorRunnerTest.java | 93 +++++++++++++++++++++ .../listener/validation/MyDisabledValidator.java | 45 ++++++++++ .../listener/validation/MyPreValidatorFour.java | 43 ++++++++++ .../listener/validation/MyPreValidatorOne.java | 44 ++++++++++ .../listener/validation/MyPreValidatorThree.java | 43 ++++++++++ .../listener/validation/MyPreValidatorTwo.java | 45 ++++++++++ .../listener/validation/ValidationConfig.java | 34 ++++++++ .../validation/WorkflowPreValidatorOne.java | 44 ++++++++++ .../validation/WorkflowPreValidatorTwo.java | 45 ++++++++++ .../BuildingBlockValidatorRunnerTest.java | 90 -------------------- .../common/validation/MyDisabledValidator.java | 43 ---------- .../bpmn/common/validation/MyPreValidatorFour.java | 42 ---------- .../bpmn/common/validation/MyPreValidatorOne.java | 43 ---------- .../common/validation/MyPreValidatorThree.java | 42 ---------- .../bpmn/common/validation/MyPreValidatorTwo.java | 44 ---------- .../bpmn/common/validation/ValidationConfig.java | 34 -------- .../common/validation/WorkflowPreValidatorOne.java | 43 ---------- .../common/validation/WorkflowPreValidatorTwo.java | 44 ---------- .../validation/WorkflowValidatorRunnerTest.java | 89 -------------------- .../wrappers/ServiceInstanceWrapperTest.java | 20 +++++ 21 files changed, 552 insertions(+), 514 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorFour.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorOne.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorThree.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorTwo.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorOne.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorTwo.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java (limited to 'bpmn/MSOCommonBPMN/src/test/java') diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java new file mode 100644 index 0000000000..2c0377d11c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java @@ -0,0 +1,96 @@ +/*- + * ============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.listener; + +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.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.common.listener.validation.BuildingBlockValidatorRunner; +import org.onap.so.bpmn.common.listener.validation.FlowValidator; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorOne; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorThree; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorTwo; +import org.onap.so.bpmn.common.listener.validation.ValidationConfig; +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 BuildingBlockValidatorRunnerTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Autowired + private BuildingBlockValidatorRunner runner; + + @Test + public void filterValidatorTest() { + + MyPreValidatorOne one = new MyPreValidatorOne(); + MyPreValidatorTwo two = new MyPreValidatorTwo(); + MyPreValidatorThree three = new MyPreValidatorThree(); + List validators = Arrays.asList(one, two, three); + + List result = runner.filterListeners(validators, (item -> item.shouldRunFor("test"))); + + List expected = Arrays.asList(two, one); + + assertEquals(expected, result); + } + + @Test + public void testValidate() { + + BuildingBlockExecution execution = new DelegateExecutionImpl(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.listener.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.listener.validation.MyPreValidatorOne: my-error-one", + workflowException.getErrorMessage()); + } + runner.preValidate("test2", mock(BuildingBlockExecution.class)); + } + + @Test + public void testEmptyList() { + boolean result = runner.preValidate("test3", mock(BuildingBlockExecution.class)); + + assertTrue(result); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java new file mode 100644 index 0000000000..0143e567af --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java @@ -0,0 +1,93 @@ +/*- + * ============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.listener; + +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.listener.validation.FlowValidator; +import org.onap.so.bpmn.common.listener.validation.ValidationConfig; +import org.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorOne; +import org.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorTwo; +import org.onap.so.bpmn.common.listener.validation.WorkflowValidatorRunner; +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 validators = Arrays.asList(one, two); + + List result = runner.filterListeners(validators, (item -> item.shouldRunFor("test"))); + + List 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.listener.validation.WorkflowPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorOne: my-error-one", + workflowException.getErrorMessage()); + } + runner.preValidate("test2", mock(DelegateExecution.class)); + } + + @Test + public void testEmptyList() { + boolean result = runner.preValidate("test3", mock(DelegateExecution.class)); + + assertTrue(result); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java new file mode 100644 index 0000000000..af64ed2de6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.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.listener.validation; + +import java.util.Collections; +import java.util.Optional; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.Skip; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; +import org.springframework.stereotype.Component; + +@Component +@Skip +public class MyDisabledValidator implements PreBuildingBlockValidator { + + @Override + public boolean shouldRunFor(String bbName) { + + return Collections.singleton("test").contains(bbName); + } + + @Override + public Optional validate(BuildingBlockExecution exeuction) { + return Optional.of("my-disabled-validator"); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorFour.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorFour.java new file mode 100644 index 0000000000..f0f27172a5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorFour.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.listener.validation; + +import java.util.Collections; +import java.util.Optional; +import java.util.Set; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; +import org.springframework.stereotype.Component; + +@Component +public class MyPreValidatorFour implements PreBuildingBlockValidator { + + @Override + public boolean shouldRunFor(String bbName) { + return Collections.singleton("test2").contains(bbName); + } + + @Override + public Optional validate(BuildingBlockExecution exeuction) { + return Optional.of("my-error-four"); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorOne.java new file mode 100644 index 0000000000..e705bafafe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorOne.java @@ -0,0 +1,44 @@ +/*- + * ============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.listener.validation; + +import java.util.Collections; +import java.util.Optional; +import java.util.Set; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; +import org.springframework.stereotype.Component; + +@Component +public class MyPreValidatorOne implements PreBuildingBlockValidator { + + @Override + public boolean shouldRunFor(String bbName) { + + return Collections.singleton("test").contains(bbName); + } + + @Override + public Optional validate(BuildingBlockExecution exeuction) { + return Optional.of("my-error-one"); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorThree.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorThree.java new file mode 100644 index 0000000000..3c747dd20f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorThree.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.listener.validation; + +import java.util.Collections; +import java.util.Optional; +import java.util.Set; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; +import org.springframework.stereotype.Component; + +@Component +public class MyPreValidatorThree implements PreBuildingBlockValidator { + + @Override + public boolean shouldRunFor(String bbName) { + return Collections.singleton("test2").contains(bbName); + } + + @Override + public Optional validate(BuildingBlockExecution exeuction) { + return Optional.of("my-error-three"); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorTwo.java new file mode 100644 index 0000000000..3fb3485c39 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorTwo.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.listener.validation; + +import java.util.Collections; +import java.util.Optional; +import java.util.Set; +import javax.annotation.Priority; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; +import org.springframework.stereotype.Component; + +@Priority(1) +@Component +public class MyPreValidatorTwo implements PreBuildingBlockValidator { + + @Override + public boolean shouldRunFor(String bbName) { + return Collections.singleton("test").contains(bbName); + } + + @Override + public Optional validate(BuildingBlockExecution exeuction) { + return Optional.of("my-error-two"); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java new file mode 100644 index 0000000000..068f433dd5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java @@ -0,0 +1,34 @@ +/*- + * ============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.listener.validation; + +import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; +import org.onap.so.bpmn.common.listener.ListenerRunner; +import org.onap.so.client.exception.ExceptionBuilder; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan(basePackageClasses = {ExceptionBuilder.class, ListenerRunner.class}, + nameGenerator = DefaultToShortClassNameBeanNameGenerator.class) +public class ValidationConfig { + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorOne.java new file mode 100644 index 0000000000..f7aedcfd6f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorOne.java @@ -0,0 +1,44 @@ +/*- + * ============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.listener.validation; + +import java.util.Collections; +import java.util.Optional; +import java.util.Set; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator; +import org.springframework.stereotype.Component; + +@Component +public class WorkflowPreValidatorOne implements PreWorkflowValidator { + + @Override + public boolean shouldRunFor(String bbName) { + + return Collections.singleton("test").contains(bbName); + } + + @Override + public Optional validate(BuildingBlockExecution exeuction) { + return Optional.of("my-error-one"); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorTwo.java new file mode 100644 index 0000000000..99a7e161a9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/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.listener.validation; + +import java.util.Collections; +import java.util.Optional; +import java.util.Set; +import javax.annotation.Priority; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator; +import org.springframework.stereotype.Component; + +@Priority(1) +@Component +public class WorkflowPreValidatorTwo implements PreWorkflowValidator { + + @Override + public boolean shouldRunFor(String bbName) { + return Collections.singleton("test").contains(bbName); + } + + @Override + public Optional validate(BuildingBlockExecution exeuction) { + return Optional.of("my-error-two"); + } + +} 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 deleted file mode 100644 index f13bcb8a93..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============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.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 BuildingBlockValidatorRunnerTest { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Autowired - private BuildingBlockValidatorRunner runner; - - @Test - public void filterValidatorTest() { - - MyPreValidatorOne one = new MyPreValidatorOne(); - MyPreValidatorTwo two = new MyPreValidatorTwo(); - MyPreValidatorThree three = new MyPreValidatorThree(); - List validators = Arrays.asList(one, two, three); - - List result = runner.filterValidators(validators, "test"); - - List expected = Arrays.asList(two, one); - - assertEquals(expected, result); - } - - @Test - public void testValidate() { - - BuildingBlockExecution execution = new DelegateExecutionImpl(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.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.MyPreValidatorOne: my-error-one", - workflowException.getErrorMessage()); - } - runner.preValidate("test2", mock(BuildingBlockExecution.class)); - } - - @Test - public void testEmptyList() { - boolean result = runner.preValidate("test3", mock(BuildingBlockExecution.class)); - - assertTrue(result); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java deleted file mode 100644 index 7572e930cd..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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.Optional; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.springframework.stereotype.Component; - -@Component -@Skip -public class MyDisabledValidator implements PreBuildingBlockValidator { - - @Override - public boolean shouldRunFor(String bbName) { - - return Collections.singleton("test").contains(bbName); - } - - @Override - public Optional validate(BuildingBlockExecution exeuction) { - return Optional.of("my-disabled-validator"); - } - -} 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 deleted file mode 100644 index 85531719d5..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============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.Optional; -import java.util.Set; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.springframework.stereotype.Component; - -@Component -public class MyPreValidatorFour implements PreBuildingBlockValidator { - - @Override - public boolean shouldRunFor(String bbName) { - return Collections.singleton("test2").contains(bbName); - } - - @Override - public Optional 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 deleted file mode 100644 index 989a65fe47..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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.Optional; -import java.util.Set; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.springframework.stereotype.Component; - -@Component -public class MyPreValidatorOne implements PreBuildingBlockValidator { - - @Override - public boolean shouldRunFor(String bbName) { - - return Collections.singleton("test").contains(bbName); - } - - @Override - public Optional 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 deleted file mode 100644 index a51d3836da..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============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.Optional; -import java.util.Set; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.springframework.stereotype.Component; - -@Component -public class MyPreValidatorThree implements PreBuildingBlockValidator { - - @Override - public boolean shouldRunFor(String bbName) { - return Collections.singleton("test2").contains(bbName); - } - - @Override - public Optional 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 deleted file mode 100644 index 1276d8f1d2..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============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.Optional; -import java.util.Set; -import javax.annotation.Priority; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.springframework.stereotype.Component; - -@Priority(1) -@Component -public class MyPreValidatorTwo implements PreBuildingBlockValidator { - - @Override - public boolean shouldRunFor(String bbName) { - return Collections.singleton("test").contains(bbName); - } - - @Override - public Optional validate(BuildingBlockExecution exeuction) { - return Optional.of("my-error-two"); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java deleted file mode 100644 index 90d094ce41..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============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 org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; -import org.onap.so.client.exception.ExceptionBuilder; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - -@Configuration -@ComponentScan(basePackages = {"org.onap.so.bpmn.common.validation"}, basePackageClasses = {ExceptionBuilder.class}, - nameGenerator = DefaultToShortClassNameBeanNameGenerator.class) -public class ValidationConfig { - -} 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 deleted file mode 100644 index 485aae2fcc..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============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.Optional; -import java.util.Set; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.springframework.stereotype.Component; - -@Component -public class WorkflowPreValidatorOne implements PreWorkflowValidator { - - @Override - public boolean shouldRunFor(String bbName) { - - return Collections.singleton("test").contains(bbName); - } - - @Override - public Optional 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 deleted file mode 100644 index 9596524a56..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============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.Optional; -import java.util.Set; -import javax.annotation.Priority; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.springframework.stereotype.Component; - -@Priority(1) -@Component -public class WorkflowPreValidatorTwo implements PreWorkflowValidator { - - @Override - public boolean shouldRunFor(String bbName) { - return Collections.singleton("test").contains(bbName); - } - - @Override - public Optional 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 deleted file mode 100644 index 07cd790ed1..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============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.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 validators = Arrays.asList(one, two); - - List result = runner.filterValidators(validators, "test"); - - List 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: my-error-two\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorOne: my-error-one", - workflowException.getErrorMessage()); - } - runner.preValidate("test2", mock(DelegateExecution.class)); - } - - @Test - public void testEmptyList() { - boolean result = runner.preValidate("test3", mock(DelegateExecution.class)); - - assertTrue(result); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java index bcee62013f..fa8de7ff23 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 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.servicedecomposition.bbobjects.wrappers; import static org.junit.Assert.assertEquals; -- cgit 1.2.3-korg