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) --- .../so/openstack/utils/StackCreationException.java | 20 +++ .../so/openstack/utils/StackResultWrapper.java | 20 +++ .../so/openstack/utils/StackRollbackException.java | 20 +++ .../so/openstack/utils/StackStatusHandler.java | 20 +++ .../so/openstack/utils/StackStatusHandlerTest.java | 20 +++ .../catalogdb/CatalogDbAdapterBaseTest.java | 20 +++ .../catalogdb/catalogrest/ServiceMapperTest.java | 20 +++ .../inventory/create/InventoryException.java | 20 +++ .../java/org/onap/so/heatbridge/HeatBridgeApi.java | 20 +++ .../onap/so/heatbridge/HeatBridgeException.java | 20 +++ .../org/onap/so/heatbridge/HeatBridgeImpl.java | 20 +++ .../heatbridge/constants/HeatBridgeConstants.java | 20 +++ .../heatbridge/factory/MsoCloudClientFactory.java | 20 +++ .../factory/MsoCloudClientFactoryImpl.java | 20 +++ .../org/onap/so/heatbridge/helpers/AaiHelper.java | 20 +++ .../heatbridge/openstack/api/OpenstackAccess.java | 20 +++ .../heatbridge/openstack/api/OpenstackClient.java | 20 +++ .../openstack/api/OpenstackClientException.java | 20 +++ .../openstack/api/OpenstackClientImpl.java | 20 +++ .../openstack/api/OpenstackV2ClientImpl.java | 20 +++ .../openstack/api/OpenstackV3ClientImpl.java | 20 +++ .../openstack/factory/OpenstackClientFactory.java | 20 +++ .../factory/OpenstackClientFactoryImpl.java | 20 +++ .../onap/so/heatbridge/utils/HeatBridgeUtils.java | 20 +++ .../so/adapters/audit/AuditStackServiceTest.java | 20 +++ .../inventory/create/CreateInventoryTaskTest.java | 20 +++ .../org/onap/so/heatbridge/HeatBridgeImplTest.java | 20 +++ .../adapters/requestsdb/RequestsAdapterBase.java | 20 +++ .../java/org/onap/so/bpmn/common/BBConstants.java | 35 +++++ .../so/bpmn/common/BuildingBlockExecution.java | 2 + .../onap/so/bpmn/common/DelegateExecutionImpl.java | 5 + .../so/bpmn/common/listener/ListenerRunner.java | 60 ++++++++ .../org/onap/so/bpmn/common/listener/Skip.java | 29 ++++ .../listener/flowmanipulator/FlowManipulator.java | 33 +++++ .../FlowManipulatorListenerRunner.java | 65 +++++++++ .../validation/BuildingBlockValidatorRunner.java | 61 ++++++++ .../common/listener/validation/FlowValidator.java | 45 ++++++ .../listener/validation/FlowValidatorRunner.java | 118 +++++++++++++++ .../validation/PostBuildingBlockValidator.java | 26 ++++ .../listener/validation/PostWorkflowValidator.java | 25 ++++ .../validation/PreBuildingBlockValidator.java | 25 ++++ .../listener/validation/PreWorkflowValidator.java | 25 ++++ .../validation/WorkflowValidatorRunner.java | 60 ++++++++ .../validation/BuildingBlockValidatorRunner.java | 61 -------- .../so/bpmn/common/validation/FlowValidator.java | 45 ------ .../common/validation/FlowValidatorRunner.java | 161 --------------------- .../validation/PostBuildingBlockValidator.java | 26 ---- .../common/validation/PostWorkflowValidator.java | 25 ---- .../validation/PreBuildingBlockValidator.java | 25 ---- .../common/validation/PreWorkflowValidator.java | 25 ---- .../org/onap/so/bpmn/common/validation/Skip.java | 29 ---- .../common/validation/WorkflowValidatorRunner.java | 60 -------- .../bpmn/servicedecomposition/bbobjects/Vnfc.java | 20 +++ .../bbobjects/wrappers/ServiceInstanceWrapper.java | 20 +++ .../exceptions/ServiceProxyNotFoundException.java | 20 +++ .../entities/ExecuteBuildingBlock.java | 2 +- .../so/client/exception/ExpectedDataException.java | 20 +++ .../client/exception/UnexpectedDataException.java | 20 +++ .../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 +++ .../test/java/org/onap/so/bpmn/BaseBPMNTest.java | 2 +- .../vnfm/tasks/MonitorVnfmCreateJobTask.java | 6 +- .../vnfm/tasks/MonitorVnfmDeleteJobTask.java | 6 +- .../flowspecific/tasks/ConfigDeployVnf.java | 29 ++-- .../manualhandling/tasks/ManualHandlingTasks.java | 20 +++ .../exceptions/SDNCErrorResponseException.java | 20 +++ .../CloudRegionOrchestrationValidator.java | 4 +- .../workflow/tasks/VrfBondingServiceException.java | 20 +++ .../workflow/tasks/VrfValidation.java | 20 +++ .../workflow/tasks/WorkflowAction.java | 35 ++--- .../workflow/tasks/WorkflowActionBBTasks.java | 34 +---- .../workflow/tasks/listeners/HomingListener.java | 51 +++++++ .../tasks/listeners/MultiStageSkipListener.java | 70 +++++++++ .../tasks/listeners/SkipConfigVnfListener.java | 44 ++++++ .../client/namingservice/NamingRequestObject.java | 20 +++ .../namingservice/NamingServiceConstants.java | 20 +++ .../client/namingservice/NamingServiceUtils.java | 20 +++ .../org/onap/so/client/ticket/ExternalTicket.java | 20 +++ .../tasks/InputParameterRetrieverTaskTest.java | 5 + .../vnfm/tasks/StubbedBuildingBlockExecution.java | 5 + .../flowspecific/tasks/ConfigDeployVnfTest.java | 30 ++-- .../tasks/ManualHandlingTasksTest.java | 20 +++ .../workflow/tasks/VrfValidationTest.java | 20 +++ .../workflow/tasks/WorkflowActionBBTasksTest.java | 4 + .../workflow/tasks/WorkflowActionTest.java | 11 +- .../tasks/listeners/MultiStageSkipTest.java | 112 ++++++++++++++ .../main/java/org/onap/so/logger/ErrorCode.java | 20 +++ .../org/onap/so/logger/HttpHeadersConstants.java | 20 +++ .../main/java/org/onap/so/logger/MdcConstants.java | 20 +++ .../org/onap/so/objects/audit/AAIObjectAudit.java | 20 +++ .../onap/so/objects/audit/AAIObjectAuditList.java | 20 +++ .../so/serviceinstancebeans/ModelTypeTest.java | 20 +++ .../TestServiceInstanceBean.java | 20 +++ .../so/apihandler/filters/RequestIdFilterTest.java | 20 +++ 113 files changed, 2547 insertions(+), 1060 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/BuildingBlockValidatorRunner.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidator.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostBuildingBlockValidator.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostWorkflowValidator.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreBuildingBlockValidator.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreWorkflowValidator.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowValidatorRunner.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/Skip.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java 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 create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackCreationException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackCreationException.java index 3a377efce6..e3936e31f7 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackCreationException.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackCreationException.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.openstack.utils; import org.onap.so.openstack.exceptions.MsoException; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackResultWrapper.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackResultWrapper.java index c3b3c1de2a..5e52a0a2ae 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackResultWrapper.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackResultWrapper.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.openstack.utils; import org.apache.commons.lang3.builder.ToStringBuilder; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackRollbackException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackRollbackException.java index 1bad7ef51c..ee284b11fe 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackRollbackException.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackRollbackException.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.openstack.utils; import org.onap.so.openstack.exceptions.MsoException; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java index 625b584257..bf29c39f99 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.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.openstack.utils; diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java index 0d5cd6a118..985a39a76b 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.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.openstack.utils; import static org.junit.Assert.assertEquals; diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java index 3fb156d68a..499310748e 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.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.adapters.catalogdb; import org.junit.Test; diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java index b8161de6b2..8decd77656 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.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.adapters.catalogdb.catalogrest; import static com.shazam.shazamcrest.MatcherAssert.assertThat; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/InventoryException.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/InventoryException.java index 24fa9af7f9..ed31c1c67e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/InventoryException.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/InventoryException.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.adapters.inventory.create; public class InventoryException extends Exception { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java index c6fd73d9cb..aebd04f32c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeException.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeException.java index 9bf2ec73f4..60dfded1f8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeException.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeException.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index 3b80da1ba9..ae15b70b00 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java index 933b42e0b2..f2d61d2587 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java index edf5e2d339..018a4eac8d 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java index bd74bf6aa0..f0c5a0b434 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 515f2dc0e5..137aaa9f41 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java index fd5dabc784..69c76fad84 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.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========================================================= + */ + /*- * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java index 1fa41ee2a0..7184ec1e93 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.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========================================================= + */ + /*- * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientException.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientException.java index a062ca826d..26d92ebb80 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientException.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientException.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========================================================= + */ + /*- * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java index 2843eb226e..5a2b0732dc 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.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========================================================= + */ + /*- * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV2ClientImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV2ClientImpl.java index 760be72b3f..95b4cd7cfd 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV2ClientImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV2ClientImpl.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========================================================= + */ + /*- * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.java index dddd82ce6a..a0c05b4dba 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackV3ClientImpl.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========================================================= + */ + /*- * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactory.java index 5019eec09b..b00f926e52 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactory.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========================================================= + */ + /*- * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java index 25b3f1dbeb..bbcd54e6f8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.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========================================================= + */ + /*- * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java index 788e038855..be086677db 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java index 2eb8d8ef39..c9aef950f7 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.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.adapters.audit; import static com.shazam.shazamcrest.MatcherAssert.assertThat; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java index 8513f30d4b..8dc9d7fe5c 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/inventory/create/CreateInventoryTaskTest.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.adapters.inventory.create; import static org.mockito.Mockito.doReturn; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index 0787cef75d..d611322c02 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.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========================================================= + */ + /* * Copyright (C) 2018 Bell Canada. All rights reserved. * diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.java index cb6feacfb2..6ef228ef79 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/RequestsAdapterBase.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.adapters.requestsdb; import org.junit.runner.RunWith; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java new file mode 100644 index 0000000000..49ccc7b4a8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java @@ -0,0 +1,35 @@ +/*- + * ============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.common; + +public class BBConstants { + public static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; + public static final String G_ACTION = "requestAction"; + public static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; + public static final String G_REQUEST_ID = "mso-request-id"; + public static final String G_BPMN_REQUEST = "bpmnRequest"; + public static final String G_ALACARTE = "aLaCarte"; + public static final String G_APIVERSION = "apiVersion"; + public static final String G_URI = "requestUri"; + public static final String G_ISTOPLEVELFLOW = "isTopLevelFlow"; + public static final String G_SERVICE_TYPE = "serviceType"; + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java index 83a44cfe8b..248f3b5f1a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java @@ -39,4 +39,6 @@ public interface BuildingBlockExecution { public Map getLookupMap(); public String getFlowToBeCalled(); + + public int getCurrentSequence(); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java index 734262aa55..9aed5e9408 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java @@ -112,6 +112,11 @@ public class DelegateExecutionImpl implements BuildingBlockExecution, Serializab return this.get("flowToBeCalled"); } + @JsonIgnore + @Override + public int getCurrentSequence() { + return this.get("gCurrentSequence"); + } public void setDelegateExecution(final DelegateExecution execution) { this.execution = execution; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java new file mode 100644 index 0000000000..3c36052dca --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java @@ -0,0 +1,60 @@ +/*- + * ============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.common.listener; + +import java.lang.annotation.Annotation; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import javax.annotation.Priority; +import org.onap.so.client.exception.ExceptionBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; + +public abstract class ListenerRunner { + + @Autowired + protected ApplicationContext context; + + @Autowired + protected ExceptionBuilder exceptionBuilder; + + protected List filterListeners(List validators, Predicate predicate) { + return validators.stream().filter(item -> { + return !item.getClass().isAnnotationPresent(Skip.class) && predicate.test(item); + }).sorted(Comparator.comparing(item -> { + Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() { + public int value() { + return 1000; + } + + @Override + public Class annotationType() { + return Priority.class; + } + }); + return p.value(); + })).collect(Collectors.toList()); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java new file mode 100644 index 0000000000..a0543fd3cc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java @@ -0,0 +1,29 @@ +/*- + * ============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.common.listener; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface Skip { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java new file mode 100644 index 0000000000..5e2882cb5b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java @@ -0,0 +1,33 @@ +/*- + * ============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.common.listener.flowmanipulator; + +import java.util.List; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; + +public interface FlowManipulator { + + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution); + + public void run(List flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java new file mode 100644 index 0000000000..5f4dc871fb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java @@ -0,0 +1,65 @@ +/*- + * ============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.common.listener.flowmanipulator; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.ListenerRunner; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class FlowManipulatorListenerRunner extends ListenerRunner { + + private static Logger logger = LoggerFactory.getLogger(FlowManipulatorListenerRunner.class); + + protected List flowManipulators; + + @PostConstruct + protected void init() { + + flowManipulators = new ArrayList<>( + Optional.ofNullable(context.getBeansOfType(FlowManipulator.class)).orElse(new HashMap<>()).values()); + + } + + public void modifyFlows(List flowsToExecute, BuildingBlockExecution execution) { + + ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); + List filtered = filterListeners(flowManipulators, + (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), + execution.getCurrentSequence() == 0, execution))); + + logger.info("Running flow manipulators:\n{}", + filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); + filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); + + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/BuildingBlockValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/BuildingBlockValidatorRunner.java new file mode 100644 index 0000000000..78d897fd87 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/BuildingBlockValidatorRunner.java @@ -0,0 +1,61 @@ +/*- + * ============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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import javax.annotation.PostConstruct; +import org.springframework.stereotype.Component; + + +/** + * Controls running all pre and post validation for building blocks. + * + * To define a validation you must make it a spring bean and implement either + * {@link org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator} or + * {@link org.onap.so.bpmn.common.listener.validation.PostBuildingBlockValidator} your validation will automatically be + * run by this class. + * + */ +@Component +public class BuildingBlockValidatorRunner + extends FlowValidatorRunner { + + @PostConstruct + protected void init() { + + preFlowValidators = new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PreBuildingBlockValidator.class)) + .orElse(new HashMap<>()).values()); + postFlowValidators = new ArrayList<>(Optional + .ofNullable(context.getBeansOfType(PostBuildingBlockValidator.class)).orElse(new HashMap<>()).values()); + } + + protected List getPreFlowValidators() { + return this.preFlowValidators; + } + + protected List getPostFlowValidators() { + return this.postFlowValidators; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidator.java new file mode 100644 index 0000000000..657e1d9539 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidator.java @@ -0,0 +1,45 @@ +/*- + * ============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.common.listener.validation; + +import java.util.Optional; +import org.onap.so.bpmn.common.BuildingBlockExecution; + +public interface FlowValidator { + + /** + * Should this validator run for given bb + * + * @return + * + */ + public boolean shouldRunFor(String bbName); + + /** + * Determines whether or not the workflow should be executed + * + * + * @param execution + * @return + */ + public Optional validate(BuildingBlockExecution execution); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java new file mode 100644 index 0000000000..040522b576 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java @@ -0,0 +1,118 @@ +/*- + * ============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.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.javatuples.Pair; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.common.listener.ListenerRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + + +/** + * Controls running all pre and post validation for flows. + * + * To define a validation you must make it a spring bean and implement either + * {@link org.onap.so.bpmn.common.validation.PreFlowValidator} or + * {@link org.onap.so.bpmn.common.validation.PostFlowValidator} your validation will automatically be run by this class. + * + */ +@Component +public abstract class FlowValidatorRunner extends ListenerRunner { + + private static Logger logger = LoggerFactory.getLogger(FlowValidatorRunner.class); + + protected List preFlowValidators; + protected List postFlowValidators; + + + + /** + * Changed to object because JUEL does not support overloaded methods + * + * @param bbName + * @param execution + * @return + */ + public boolean preValidate(String bbName, Object execution) { + return validateHelper(bbName, preFlowValidators, execution); + } + + /** + * Changed to object because JUEL does not support overloaded methods + * + * @param bbName + * @param execution + * @return + */ + public boolean postValidate(String bbName, Object execution) { + return validateHelper(bbName, postFlowValidators, execution); + } + + protected boolean validateHelper(String bbName, List validators, Object obj) { + + if (obj instanceof DelegateExecution) { + return validate(validators, bbName, new DelegateExecutionImpl((DelegateExecution) obj)); + } else if (obj instanceof BuildingBlockExecution) { + return validate(validators, bbName, (BuildingBlockExecution) obj); + } else { + return false; + } + } + + protected boolean validate(List validators, String bbName, + BuildingBlockExecution execution) { + List>> results = runValidations(validators, bbName, execution); + + if (!results.isEmpty()) { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, + "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) { + + List filtered = filterListeners(validators, (item -> item.shouldRunFor(bbName))); + + List>> results = new ArrayList<>(); + filtered.forEach(item -> results.add(new Pair<>(item.getClass().getName(), item.validate(execution)))); + + return results.stream().filter(item -> item.getValue1().isPresent()).collect(Collectors.toList()); + } + + protected abstract List getPreFlowValidators(); + + protected abstract List getPostFlowValidators(); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostBuildingBlockValidator.java new file mode 100644 index 0000000000..75dc75de43 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostBuildingBlockValidator.java @@ -0,0 +1,26 @@ +/*- + * ============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; + + +public interface PostBuildingBlockValidator extends FlowValidator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostWorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostWorkflowValidator.java new file mode 100644 index 0000000000..7d5f68a482 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostWorkflowValidator.java @@ -0,0 +1,25 @@ +/*- + * ============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; + +public interface PostWorkflowValidator extends FlowValidator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreBuildingBlockValidator.java new file mode 100644 index 0000000000..fda2d264d8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreBuildingBlockValidator.java @@ -0,0 +1,25 @@ +/*- + * ============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; + +public interface PreBuildingBlockValidator extends FlowValidator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreWorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreWorkflowValidator.java new file mode 100644 index 0000000000..a8e8642058 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreWorkflowValidator.java @@ -0,0 +1,25 @@ +/*- + * ============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; + +public interface PreWorkflowValidator extends FlowValidator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowValidatorRunner.java new file mode 100644 index 0000000000..c6afa16ec2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowValidatorRunner.java @@ -0,0 +1,60 @@ +/*- + * ============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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import javax.annotation.PostConstruct; +import org.springframework.stereotype.Component; + + +/** + * Controls running all pre and post validation for workflows. + * + * To define a validation you must make it a spring bean and implement either + * {@link org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator} or + * {@link org.onap.so.bpmn.common.listener.validation.PostWorkflowValidator} your validation will automatically be run + * by this class. + * + */ +@Component +public class WorkflowValidatorRunner extends FlowValidatorRunner { + + @PostConstruct + protected void init() { + + preFlowValidators = new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PreWorkflowValidator.class)) + .orElse(new HashMap<>()).values()); + postFlowValidators = new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PostWorkflowValidator.class)) + .orElse(new HashMap<>()).values()); + } + + protected List getPreFlowValidators() { + return this.preFlowValidators; + } + + protected List getPostFlowValidators() { + return this.postFlowValidators; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java deleted file mode 100644 index 7777584b80..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java +++ /dev/null @@ -1,61 +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.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import javax.annotation.PostConstruct; -import org.springframework.stereotype.Component; - - -/** - * Controls running all pre and post validation for building blocks. - * - * To define a validation you must make it a spring bean and implement either - * {@link org.onap.so.bpmn.common.validation.PreBuildingBlockValidator} or - * {@link org.onap.so.bpmn.common.validation.PostBuildingBlockValidator} your validation will automatically be run by - * this class. - * - */ -@Component -public class BuildingBlockValidatorRunner - extends FlowValidatorRunner { - - @PostConstruct - protected void init() { - - preFlowValidators = new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PreBuildingBlockValidator.class)) - .orElse(new HashMap<>()).values()); - postFlowValidators = new ArrayList<>(Optional - .ofNullable(context.getBeansOfType(PostBuildingBlockValidator.class)).orElse(new HashMap<>()).values()); - } - - protected List getPreFlowValidators() { - return this.preFlowValidators; - } - - protected List getPostFlowValidators() { - return this.postFlowValidators; - } - -} 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 deleted file mode 100644 index 05d7a1f417..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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.common.validation; - -import java.util.Optional; -import org.onap.so.bpmn.common.BuildingBlockExecution; - -public interface FlowValidator { - - /** - * Should this validator run for given bb - * - * @return - * - */ - public boolean shouldRunFor(String bbName); - - /** - * Determines whether or not the workflow should be executed - * - * - * @param execution - * @return - */ - 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 deleted file mode 100644 index 0bdf4e35a2..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java +++ /dev/null @@ -1,161 +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.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import javax.annotation.Priority; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.javatuples.Pair; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.client.exception.ExceptionBuilder; -import org.reflections.Reflections; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - - -/** - * Controls running all pre and post validation for flows. - * - * To define a validation you must make it a spring bean and implement either - * {@link org.onap.so.bpmn.common.validation.PreFlowValidator} or - * {@link org.onap.so.bpmn.common.validation.PostFlowValidator} your validation will automatically be run by this class. - * - */ -@Component -public abstract class FlowValidatorRunner { - - private static Logger logger = LoggerFactory.getLogger(FlowValidatorRunner.class); - @Autowired - protected ApplicationContext context; - - @Autowired - protected ExceptionBuilder exceptionBuilder; - - protected List preFlowValidators; - protected List postFlowValidators; - - - - /** - * Changed to object because JUEL does not support overloaded methods - * - * @param bbName - * @param execution - * @return - */ - public boolean preValidate(String bbName, Object execution) { - return validateHelper(bbName, preFlowValidators, execution); - } - - /** - * Changed to object because JUEL does not support overloaded methods - * - * @param bbName - * @param execution - * @return - */ - public boolean postValidate(String bbName, Object execution) { - return validateHelper(bbName, postFlowValidators, execution); - } - - protected boolean validateHelper(String bbName, List validators, Object obj) { - - if (obj instanceof DelegateExecution) { - return validate(validators, bbName, new DelegateExecutionImpl((DelegateExecution) obj)); - } else if (obj instanceof BuildingBlockExecution) { - return validate(validators, bbName, (BuildingBlockExecution) obj); - } else { - return false; - } - } - - protected boolean validate(List validators, String bbName, - BuildingBlockExecution execution) { - List>> results = runValidations(validators, bbName, execution); - - if (!results.isEmpty()) { - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, - "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) { - - List filtered = filterValidators(validators, bbName); - - List>> results = new ArrayList<>(); - filtered.forEach(item -> results.add(new Pair<>(item.getClass().getName(), item.validate(execution)))); - - return results.stream().filter(item -> item.getValue1().isPresent()).collect(Collectors.toList()); - } - - protected List filterValidators(List validators, String bbName) { - return validators.stream().filter(item -> { - return !item.getClass().isAnnotationPresent(Skip.class) && item.shouldRunFor(bbName); - }).sorted(Comparator.comparing(item -> { - Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() { - public int value() { - return 1000; - } - - @Override - public Class annotationType() { - return Priority.class; - } - }); - return p.value(); - })).collect(Collectors.toList()); - } - - protected List buildalidatorList(Reflections reflections, Class clazz) { - List result = new ArrayList<>(); - try { - for (Class klass : reflections.getSubTypesOf(clazz)) { - result.add(klass.newInstance()); - } - } catch (InstantiationException | IllegalAccessException e) { - logger.error("failed to build validator list for {}", clazz.getName(), e); - throw new RuntimeException(e); - } - - return result; - } - - protected abstract List getPreFlowValidators(); - - protected abstract List getPostFlowValidators(); - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java deleted file mode 100644 index f26a2ee479..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java +++ /dev/null @@ -1,26 +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; - - -public interface PostBuildingBlockValidator extends FlowValidator { - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.java deleted file mode 100644 index 9070615a7a..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.java +++ /dev/null @@ -1,25 +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; - -public interface PostWorkflowValidator extends FlowValidator { - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java deleted file mode 100644 index fda687e072..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java +++ /dev/null @@ -1,25 +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; - -public interface PreBuildingBlockValidator extends FlowValidator { - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.java deleted file mode 100644 index 0bfbf5602f..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.java +++ /dev/null @@ -1,25 +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; - -public interface PreWorkflowValidator extends FlowValidator { - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/Skip.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/Skip.java deleted file mode 100644 index fe03a10795..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/Skip.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============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.common.validation; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface Skip { - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java deleted file mode 100644 index 493bb0e89b..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java +++ /dev/null @@ -1,60 +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.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import javax.annotation.PostConstruct; -import org.springframework.stereotype.Component; - - -/** - * Controls running all pre and post validation for workflows. - * - * To define a validation you must make it a spring bean and implement either - * {@link org.onap.so.bpmn.common.validation.PreWorkflowValidator} or - * {@link org.onap.so.bpmn.common.validation.PostWorkflowValidator} your validation will automatically be run by this - * class. - * - */ -@Component -public class WorkflowValidatorRunner extends FlowValidatorRunner { - - @PostConstruct - protected void init() { - - preFlowValidators = new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PreWorkflowValidator.class)) - .orElse(new HashMap<>()).values()); - postFlowValidators = new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PostWorkflowValidator.class)) - .orElse(new HashMap<>()).values()); - } - - protected List getPreFlowValidators() { - return this.preFlowValidators; - } - - protected List getPostFlowValidators() { - return this.postFlowValidators; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java index 087edff7c0..08b1124726 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.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; import java.io.Serializable; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java index 40ffe7356c..1f7f970058 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.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 org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java index 924d9eda87..046299bb13 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.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.exceptions; public class ServiceProxyNotFoundException extends Exception { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java index af9eb525aa..f1de0cc6f6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java @@ -35,7 +35,7 @@ public class ExecuteBuildingBlock implements Serializable { private String requestAction; private String vnfType; private Boolean aLaCarte; - private Boolean homing; + private Boolean homing = false; private WorkflowResourceIds workflowResourceIds; private RequestDetails requestDetails; private ConfigurationResourceKeys configurationResourceKeys; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java index 12ab165c3a..9ead1576cb 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.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.client.exception; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java index 84cf491355..9ae14a0162 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.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.client.exception; 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; diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java index 5ef4d7ea98..ff987b75d4 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java @@ -36,7 +36,7 @@ import org.junit.runner.RunWith; import org.onap.so.TestApplication; import org.onap.so.bpmn.buildingblock.HomingV2; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.bpmn.common.validation.BuildingBlockValidatorRunner; +import org.onap.so.bpmn.common.listener.validation.BuildingBlockValidatorRunner; import org.onap.so.bpmn.infrastructure.aai.tasks.AAICommonTasks; import org.onap.so.bpmn.infrastructure.aai.tasks.AAICreateTasks; import org.onap.so.bpmn.infrastructure.aai.tasks.AAIDeleteTasks; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java index 4c84bcaa1f..30f0d38754 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Ericsson. All rights reserved. + * Copyright (C) 2019 Ericsson. All rights reserved. * ================================================================================ - * Modifications Copyright (c) 2019 Samsung + * Copyright (C) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ * 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. - * - * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java index 34e3efa8f5..8fecb81d75 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Ericsson. All rights reserved. + * Copyright (C) 2019 Ericsson. All rights reserved. * ================================================================================ - * Modifications Copyright (c) 2019 Samsung + * Copyright (C) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ * 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. - * - * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java index dd36900139..cdbe0db57c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java @@ -1,15 +1,20 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright 2019 TechMahindra - * ================================================================================= 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_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 TechMahindra + * ================================================================================ + * 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========================================================= */ diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java index 3bf5139ac1..17089be571 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.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.infrastructure.manualhandling.tasks; import java.util.Map; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java index d76d860b3b..b8f025aaa6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.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.infrastructure.sdnc.exceptions; public class SDNCErrorResponseException extends Exception { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java index 47855eaa6e..fc3f2aec7a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java @@ -23,8 +23,8 @@ package org.onap.so.bpmn.infrastructure.validations; import java.util.Optional; import java.util.regex.Pattern; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.validation.PreBuildingBlockValidator; -import org.onap.so.bpmn.common.validation.Skip; +import org.onap.so.bpmn.common.listener.Skip; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.client.exception.ExceptionBuilder; import org.slf4j.Logger; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfBondingServiceException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfBondingServiceException.java index 2f99b46d10..0584472e14 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfBondingServiceException.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfBondingServiceException.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.infrastructure.workflow.tasks; public class VrfBondingServiceException extends Exception { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java index 9092b68491..1e0208b6ec 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.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.infrastructure.workflow.tasks; import java.util.List; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index ad84b38d7b..2e9e215ee0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -42,6 +42,7 @@ import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VpnBinding; +import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; @@ -95,15 +96,6 @@ public class WorkflowAction { private static final String VF_MODULES = "vfModules"; private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI."; - private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; - private static final String G_ACTION = "requestAction"; - private static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; - private static final String G_REQUEST_ID = "mso-request-id"; - private static final String G_BPMN_REQUEST = "bpmnRequest"; - private static final String G_ALACARTE = "aLaCarte"; - private static final String G_APIVERSION = "apiVersion"; - private static final String G_URI = "requestUri"; - private static final String G_ISTOPLEVELFLOW = "isTopLevelFlow"; private static final String VNF_TYPE = "vnfType"; private static final String SERVICE = "Service"; private static final String VNF = "Vnf"; @@ -119,7 +111,6 @@ public class WorkflowAction { "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups"; private static final String HOMINGSOLUTION = "Homing_Solution"; private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; - private static final String G_SERVICE_TYPE = "serviceType"; private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT"; private static final String SERVICE_TYPE_BONDING = "BONDING"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @@ -152,17 +143,19 @@ public class WorkflowAction { } public void selectExecutionList(DelegateExecution execution) throws Exception { - final String requestAction = (String) execution.getVariable(G_ACTION); - final String requestId = (String) execution.getVariable(G_REQUEST_ID); - final String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST); - final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); - final String apiVersion = (String) execution.getVariable(G_APIVERSION); - final String uri = (String) execution.getVariable(G_URI); + final String requestAction = (String) execution.getVariable(BBConstants.G_ACTION); + final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID); + final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST); + final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE); + final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION); + final String uri = (String) execution.getVariable(BBConstants.G_URI); final String vnfType = (String) execution.getVariable(VNF_TYPE); String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); - final String serviceType = Optional.ofNullable((String) execution.getVariable(G_SERVICE_TYPE)).orElse(""); + final String serviceType = + Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse(""); - List orchFlows = (List) execution.getVariable(G_ORCHESTRATION_FLOW); + List orchFlows = + (List) execution.getVariable(BBConstants.G_ORCHESTRATION_FLOW); List flowsToExecute = new ArrayList<>(); WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); List> aaiResourceIds = new ArrayList<>(); @@ -173,7 +166,7 @@ public class WorkflowAction { try { ObjectMapper mapper = new ObjectMapper(); - execution.setVariable(G_ISTOPLEVELFLOW, true); + execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); RequestDetails requestDetails = sIRequest.getRequestDetails(); String cloudOwner = ""; @@ -361,7 +354,7 @@ public class WorkflowAction { flowNames.add(ebb.getBuildingBlock().getBpmnFlowName()); } execution.setVariable("flowNames", flowNames); - execution.setVariable(G_CURRENT_SEQUENCE, 0); + execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0); execution.setVariable("retryCount", 0); execution.setVariable("isRollback", false); execution.setVariable("flowsToExecute", flowsToExecute); @@ -1428,7 +1421,7 @@ public class WorkflowAction { } } else { if (northBoundRequest.getIsToplevelflow() != null) { - execution.setVariable(G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow()); + execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow()); } List flows = northBoundRequest.getOrchestrationFlowList(); if (flows == null) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index e1c0d57b10..44152fcaf4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -27,6 +27,8 @@ import java.util.UUID; import javax.persistence.EntityNotFoundException; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.aai.domain.yang.Vnfc; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse; import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; @@ -77,41 +79,19 @@ public class WorkflowActionBBTasks { private BBInputSetupUtils bbInputSetupUtils; @Autowired private CatalogDbClient catalogDbClient; + @Autowired + private FlowManipulatorListenerRunner flowManipulatorListenerRunner; public void selectBB(DelegateExecution execution) { List flowsToExecute = (List) execution.getVariable("flowsToExecute"); execution.setVariable("MacroRollback", false); - int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); - ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); - if (ebb.getBuildingBlock().getBpmnFlowName().equals("ConfigAssignVnfBB") - || ebb.getBuildingBlock().getBpmnFlowName().equals("ConfigDeployVnfBB")) { - String vnfCustomizationUUID = ebb.getBuildingBlock().getKey(); + flowManipulatorListenerRunner.modifyFlows(flowsToExecute, new DelegateExecutionImpl(execution)); + int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); - List vnfResourceCustomizations = catalogDbClient - .getVnfResourceCustomizationByModelUuid(ebb.getRequestDetails().getModelInfo().getModelUuid()); - if (vnfResourceCustomizations != null && vnfResourceCustomizations.size() >= 1) { - VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, - vnfResourceCustomizations); - boolean skipConfigVNF = vrc.isSkipPostInstConf(); - if (skipConfigVNF) { - currentSequence++; - ebb = flowsToExecute.get(currentSequence); - } - } - } + ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); - boolean homing = (boolean) execution.getVariable("homing"); - boolean calledHoming = (boolean) execution.getVariable("calledHoming"); - if (homing && !calledHoming) { - if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignVnfBB")) { - ebb.setHoming(true); - execution.setVariable("calledHoming", true); - } - } else { - ebb.setHoming(false); - } execution.setVariable("buildingBlock", ebb); currentSequence++; if (currentSequence >= flowsToExecute.size()) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java new file mode 100644 index 0000000000..6254aae029 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java @@ -0,0 +1,51 @@ +/*- + * ============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.infrastructure.workflow.tasks.listeners; + +import java.util.List; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.springframework.stereotype.Component; + +@Component +public class HomingListener implements FlowManipulator { + + + @Override + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { + return "AssignVnfBB".equals(currentBBName); + } + + @Override + public void run(List flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution) { + + boolean homing = (boolean) execution.getVariable("homing"); + boolean calledHoming = (boolean) execution.getVariable("calledHoming"); + if (homing && !calledHoming) { + currentBB.setHoming(true); + execution.setVariable("calledHoming", true); + } + } + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java new file mode 100644 index 0000000000..fd0de086ad --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java @@ -0,0 +1,70 @@ +/*- + * ============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.infrastructure.workflow.tasks.listeners; + +import java.util.Collections; +import java.util.List; +import org.onap.so.bpmn.common.BBConstants; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class MultiStageSkipListener implements FlowManipulator { + + @Autowired + protected BBInputSetupUtils bbInputSetupUtils; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Override + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { + return ((boolean) execution.getVariable(BBConstants.G_ALACARTE)) && "AssignVfModuleBB".equals(currentBBName) + && isFirst; + } + + @Override + public void run(List flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution) { + String vfModuleId = currentBB.getResourceId(); + String vnfId = currentBB.getWorkflowResourceIds().getVnfId(); + org.onap.aai.domain.yang.VfModule vfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId); + if (vfModule == null) { + org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); + if (vnf != null) { + VnfResourceCustomization vnfCust = catalogDbClient + .getVnfResourceCustomizationByModelCustomizationUUID(vnf.getModelCustomizationId()); + if (vnfCust != null && vnfCust.getMultiStageDesign() != null + && vnfCust.getMultiStageDesign().equalsIgnoreCase("true")) { + flowsToExecute.retainAll(Collections.singletonList(currentBB)); + } + } + } + + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java new file mode 100644 index 0000000000..772fca0841 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java @@ -0,0 +1,44 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; + +import java.util.List; +import org.onap.so.bpmn.common.BBConstants; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SkipConfigVnfListener implements FlowManipulator { + + @Autowired + private CatalogDbClient catalogDbClient; + + @Override + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { + return "ConfigAssignVnfBB".equals(currentBBName) || "ConfigDeployVnfBB".equals(currentBBName); + } + + @Override + public void run(List flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution) { + String vnfCustomizationUUID = currentBB.getBuildingBlock().getKey(); + + List vnfResourceCustomizations = catalogDbClient + .getVnfResourceCustomizationByModelUuid(currentBB.getRequestDetails().getModelInfo().getModelUuid()); + if (vnfResourceCustomizations != null && !vnfResourceCustomizations.isEmpty()) { + VnfResourceCustomization vrc = + catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations); + boolean skipConfigVNF = vrc.isSkipPostInstConf(); + if (skipConfigVNF) { + execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, + ((int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE)) + 1); + } + } + } + + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java index 14af6890f3..3d3058da0b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.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.client.namingservice; import java.util.HashMap; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceConstants.java index da9e449ee7..5637410af0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceConstants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceConstants.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.client.namingservice; public class NamingServiceConstants { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceUtils.java index 771309abc4..16c8e5549c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceUtils.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceUtils.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.client.namingservice; import org.onap.so.bpmn.common.BuildingBlockExecution; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java index a78dffb4e0..12adec9e24 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.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.client.ticket; public class ExternalTicket { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java index 5805ea5ec1..caae90bfff 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java @@ -119,5 +119,10 @@ public class InputParameterRetrieverTaskTest extends BaseTaskTest { return null; } + @Override + public int getCurrentSequence() { + return 0; + } + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java index 84012e8b8d..a4d8aa85a2 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java @@ -79,6 +79,11 @@ public class StubbedBuildingBlockExecution implements BuildingBlockExecution { return null; } + @Override + public int getCurrentSequence() { + return 0; + } + public static String getTenantId() { return TENANT_ID; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java index 6f76c83c6f..982b75ae8e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java @@ -1,16 +1,20 @@ - -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright 2019 TechMahindra - * ================================================================================= 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_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 TechMahindra + * ================================================================================ + * 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========================================================= */ diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java index f9ad473e5a..9677f8e8f3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.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.infrastructure.manualhandling.tasks; import static org.junit.Assert.assertEquals; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java index 3a8c318cc2..c05fd879ac 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.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.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 1013cc8330..aac09b4475 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -42,6 +42,7 @@ import org.mockito.Mockito; import org.mockito.Spy; import org.onap.aai.domain.yang.GenericVnf; import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; @@ -72,6 +73,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { @Mock protected Environment environment; + @Mock + private FlowManipulatorListenerRunner flowManipulatorListenerRunner; + @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index ece3682d65..09ba55aac0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -25,10 +25,14 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; @@ -62,7 +66,6 @@ import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; -import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; @@ -80,6 +83,7 @@ import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ConfigurationResource; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.HeatEnvironment; import org.onap.so.db.catalog.beans.HeatTemplate; @@ -88,7 +92,6 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; -import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.serviceinstancebeans.RequestDetails; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java new file mode 100644 index 0000000000..b6f8aafa55 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java @@ -0,0 +1,112 @@ +/*- + * ============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.infrastructure.workflow.tasks.listeners; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.BBConstants; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.infrastructure.workflow.tasks.listeners.MultiStageSkipListener; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; + +@RunWith(MockitoJUnitRunner.class) +public class MultiStageSkipTest { + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private BBInputSetupUtils bbInputSetupUtils; + + @InjectMocks + private MultiStageSkipListener multiStageSkipListener; + + @Test + public void testTrigger() { + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); + execution.setVariable(BBConstants.G_ALACARTE, true); + + assertTrue("should be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB", true, execution)); + + execution.setVariable(BBConstants.G_ALACARTE, false); + assertFalse("should not be triggered", + multiStageSkipListener.shouldRunFor("AssignVfModuleBB", true, execution)); + + execution.setVariable(BBConstants.G_ALACARTE, true); + assertFalse("should not be triggered", + multiStageSkipListener.shouldRunFor("AssignVfModuleBB2", true, execution)); + + + } + + @Test + public void testProcessMultiStageSkip() { + String vfModuleId = "vfModuleId"; + String vnfId = "vnfId"; + List flowsToExecute = new ArrayList<>(); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("serviceInstanceId"); + workflowResourceIds.setVnfId(vnfId); + flowsToExecute.add(new ExecuteBuildingBlock()); + flowsToExecute.add(new ExecuteBuildingBlock()); + flowsToExecute.add(new ExecuteBuildingBlock()); + flowsToExecute.get(0).setResourceId(vfModuleId); + flowsToExecute.get(0).setBuildingBlock(new BuildingBlock()); + flowsToExecute.get(0).getBuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + flowsToExecute.get(0).setWorkflowResourceIds(workflowResourceIds); + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); + + org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); + vfModule.setVfModuleId(vfModuleId); + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setModelCustomizationId("modelCustomizationUUID"); + VnfResourceCustomization vnfCust = new VnfResourceCustomization(); + vnfCust.setModelCustomizationUUID("modelCustomizationUUID"); + vnfCust.setMultiStageDesign("true"); + when(catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(vnf.getModelCustomizationId())) + .thenReturn(vnfCust); + when(bbInputSetupUtils.getAAIVfModule(eq(vnfId), eq(vfModuleId))).thenReturn(null); + when(bbInputSetupUtils.getAAIGenericVnf(eq(vnfId))).thenReturn(vnf); + + multiStageSkipListener.run(flowsToExecute, flowsToExecute.get(0), execution); + assertEquals("Flows should only have Assign", flowsToExecute.size(), 1); + assertEquals("Flows should only have Assign", flowsToExecute.get(0).getBuildingBlock().getBpmnFlowName(), + "AssignVfModuleBB"); + + } +} diff --git a/common/src/main/java/org/onap/so/logger/ErrorCode.java b/common/src/main/java/org/onap/so/logger/ErrorCode.java index f0a78e9699..7fb9522b7c 100644 --- a/common/src/main/java/org/onap/so/logger/ErrorCode.java +++ b/common/src/main/java/org/onap/so/logger/ErrorCode.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.logger; public enum ErrorCode { diff --git a/common/src/main/java/org/onap/so/logger/HttpHeadersConstants.java b/common/src/main/java/org/onap/so/logger/HttpHeadersConstants.java index f34b4b5a9a..83b860ff01 100644 --- a/common/src/main/java/org/onap/so/logger/HttpHeadersConstants.java +++ b/common/src/main/java/org/onap/so/logger/HttpHeadersConstants.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.logger; public class HttpHeadersConstants { diff --git a/common/src/main/java/org/onap/so/logger/MdcConstants.java b/common/src/main/java/org/onap/so/logger/MdcConstants.java index e3212733c8..33fceb2f0f 100644 --- a/common/src/main/java/org/onap/so/logger/MdcConstants.java +++ b/common/src/main/java/org/onap/so/logger/MdcConstants.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.logger; public class MdcConstants { diff --git a/common/src/main/java/org/onap/so/objects/audit/AAIObjectAudit.java b/common/src/main/java/org/onap/so/objects/audit/AAIObjectAudit.java index a27e8fbbd1..d45cc00b85 100644 --- a/common/src/main/java/org/onap/so/objects/audit/AAIObjectAudit.java +++ b/common/src/main/java/org/onap/so/objects/audit/AAIObjectAudit.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.objects.audit; import java.io.Serializable; diff --git a/common/src/main/java/org/onap/so/objects/audit/AAIObjectAuditList.java b/common/src/main/java/org/onap/so/objects/audit/AAIObjectAuditList.java index 675701d598..2a4b90eef7 100644 --- a/common/src/main/java/org/onap/so/objects/audit/AAIObjectAuditList.java +++ b/common/src/main/java/org/onap/so/objects/audit/AAIObjectAuditList.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.objects.audit; import java.io.Serializable; diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/ModelTypeTest.java b/common/src/test/java/org/onap/so/serviceinstancebeans/ModelTypeTest.java index e4b694cd15..fd1977225f 100644 --- a/common/src/test/java/org/onap/so/serviceinstancebeans/ModelTypeTest.java +++ b/common/src/test/java/org/onap/so/serviceinstancebeans/ModelTypeTest.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.serviceinstancebeans; import static org.junit.Assert.assertEquals; diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/TestServiceInstanceBean.java b/common/src/test/java/org/onap/so/serviceinstancebeans/TestServiceInstanceBean.java index b8cf6141e3..a14f3bace4 100644 --- a/common/src/test/java/org/onap/so/serviceinstancebeans/TestServiceInstanceBean.java +++ b/common/src/test/java/org/onap/so/serviceinstancebeans/TestServiceInstanceBean.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.serviceinstancebeans; public class TestServiceInstanceBean { diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java index 6c674db9f4..9bf83153b3 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.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.apihandler.filters; import static org.junit.Assert.assertEquals; -- cgit 1.2.3-korg