From da366370647e6b72df4d8433bb52ec22a443d0ca Mon Sep 17 00:00:00 2001 From: "Boslet, Cory" Date: Tue, 7 Jul 2020 11:46:43 -0400 Subject: move sdn clients to own package Began moving the sdn clients into one central isolated location Added test files, removed unused methods, fixed poms Fixed the client so that is doesnt have to import bpmn and can be built at top level Fixed bad merge that hapeened due to conflicts Added missing test files for sdno unit test Added maria db driver java client for spring test and jersey depend Issue-ID: SO-3034 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I4c0a6288623194c517dbc8fa6120d577b400ee01 --- .../onap/so/client/exception/MapperException.java | 31 - bpmn/so-bpmn-tasks/pom.xml | 24 +- .../mapper/GCTopologyOperationRequestMapper.java | 107 ++ .../sdnc/mapper/GeneralTopologyObjectMapper.java | 267 +++++ .../NetworkTopologyOperationRequestMapper.java | 114 ++ .../mapper/ServiceTopologyOperationMapper.java | 89 ++ .../VfModuleTopologyOperationRequestMapper.java | 202 ++++ .../mapper/VnfTopologyOperationRequestMapper.java | 164 +++ .../orchestration/SDNCConfigurationResources.java | 2 +- .../client/orchestration/SDNCNetworkResources.java | 2 +- .../SDNCServiceInstanceResources.java | 2 +- .../orchestration/SDNCVfModuleResources.java | 2 +- .../so/client/orchestration/SDNCVnfResources.java | 2 +- .../java/org/onap/so/client/sdnc/SDNCClient.java | 97 -- .../org/onap/so/client/sdnc/SdnCommonTasks.java | 168 --- .../onap/so/client/sdnc/beans/SDNCProperties.java | 57 - .../org/onap/so/client/sdnc/beans/SDNCRequest.java | 97 -- .../onap/so/client/sdnc/beans/SDNCSvcAction.java | 55 - .../so/client/sdnc/beans/SDNCSvcOperation.java | 44 - .../onap/so/client/sdnc/endpoint/SDNCTopology.java | 44 - .../mapper/GCTopologyOperationRequestMapper.java | 107 -- .../sdnc/mapper/GeneralTopologyObjectMapper.java | 267 ----- .../NetworkTopologyOperationRequestMapper.java | 114 -- .../mapper/ServiceTopologyOperationMapper.java | 89 -- .../VfModuleTopologyOperationRequestMapper.java | 202 ---- .../mapper/VnfTopologyOperationRequestMapper.java | 164 --- .../onap/so/client/sdno/SDNOHealthCheckClient.java | 167 --- .../org/onap/so/client/sdno/SDNOValidator.java | 55 - .../org/onap/so/client/sdno/SDNOValidatorImpl.java | 128 --- .../onap/so/client/sdno/beans/AAIParamList.java | 83 -- .../java/org/onap/so/client/sdno/beans/Body.java | 77 -- .../java/org/onap/so/client/sdno/beans/Input.java | 90 -- .../onap/so/client/sdno/beans/RequestHdCustom.java | 183 --- .../client/sdno/beans/RequestHealthDiagnostic.java | 197 ---- .../org/onap/so/client/sdno/beans/ResultInfo.java | 112 -- .../java/org/onap/so/client/sdno/beans/SDNO.java | 128 --- .../GCTopologyOperationRequestMapperTest.java | 83 ++ .../mapper/GeneralTopologyObjectMapperTest.java | 447 ++++++++ .../NetworkTopologyOperationRequestMapperTest.java | 234 ++++ .../mapper/ServiceTopologyOperationMapperTest.java | 105 ++ ...VfModuleTopologyOperationRequestMapperTest.java | 404 +++++++ .../VnfTopologyOperationRequestMapperTest.java | 154 +++ .../SDNCConfigurationResourcesTest.java | 2 +- .../orchestration/SDNCNetworkResourcesTest.java | 2 +- .../SDNCServiceInstanceResourcesTest.java | 2 +- .../orchestration/SDNCVfModuleResourcesTest.java | 4 +- .../client/orchestration/SDNCVnfResourcesTest.java | 2 +- .../so/client/sdn/common/SdnCommonTasksTest.java | 104 -- .../java/org/onap/so/client/sdnc/SDNCClientIT.java | 79 -- .../GCTopologyOperationRequestMapperTest.java | 158 --- .../mapper/GeneralTopologyObjectMapperTest.java | 446 -------- .../NetworkTopologyOperationRequestMapperTest.java | 232 ---- .../mapper/ServiceTopologyOperationMapperTest.java | 103 -- ...VfModuleTopologyOperationRequestMapperTest.java | 402 ------- .../VnfTopologyOperationRequestMapperTest.java | 152 --- .../so/client/sdno/SDNOHealthCheckClientTest.java | 94 -- .../org/onap/so/client/sdno/SDNOValidatorIT.java | 124 -- .../onap/so/client/sdno/SDNOValidatorImplTest.java | 56 - .../custom-lport-mirror-post-check-request.json | 27 - .../custom-lport-mirror-pre-check-request.json | 27 - .../custom-port-mirror-post-check-request.json | 23 - .../custom-port-mirror-pre-check-request.json | 23 - .../org/onap/so/client/sdno/output-failure.json | 25 - .../org/onap/so/client/sdno/output-success.json | 22 - .../org/onap/so/client/sdno/response.json | 17 - .../onap/so/client/exception/MapperException.java | 31 + pom.xml | 1 + so-sdn-clients/pom.xml | 173 +++ .../java/org/onap/so/client/sdnc/SDNCClient.java | 97 ++ .../org/onap/so/client/sdnc/SdnCommonTasks.java | 168 +++ .../onap/so/client/sdnc/beans/SDNCProperties.java | 57 + .../org/onap/so/client/sdnc/beans/SDNCRequest.java | 97 ++ .../onap/so/client/sdnc/beans/SDNCSvcAction.java | 55 + .../so/client/sdnc/beans/SDNCSvcOperation.java | 44 + .../onap/so/client/sdnc/endpoint/SDNCTopology.java | 44 + .../onap/so/client/sdno/SDNOHealthCheckClient.java | 167 +++ .../org/onap/so/client/sdno/SDNOValidator.java | 40 + .../org/onap/so/client/sdno/SDNOValidatorImpl.java | 116 ++ .../onap/so/client/sdno/beans/AAIParamList.java | 83 ++ .../java/org/onap/so/client/sdno/beans/Body.java | 77 ++ .../java/org/onap/so/client/sdno/beans/Input.java | 90 ++ .../onap/so/client/sdno/beans/RequestHdCustom.java | 183 +++ .../client/sdno/beans/RequestHealthDiagnostic.java | 197 ++++ .../org/onap/so/client/sdno/beans/ResultInfo.java | 112 ++ .../java/org/onap/so/client/sdno/beans/SDNO.java | 128 +++ .../test/java/org/onap/so/BaseIntegrationTest.java | 60 + .../java/org/onap/so/EmbeddedMariaDbConfig.java | 60 + .../java/org/onap/so/IntegrationTestSuite.java | 31 + .../src/test/java/org/onap/so/TestApplication.java | 43 + .../src/test/java/org/onap/so/UnitTestSuite.java | 32 + .../so/client/sdn/common/SdnCommonTasksTest.java | 104 ++ .../java/org/onap/so/client/sdnc/SDNCClientIT.java | 79 ++ .../so/client/sdno/SDNOHealthCheckClientTest.java | 94 ++ .../org/onap/so/client/sdno/SDNOValidatorIT.java | 124 ++ .../onap/so/client/sdno/SDNOValidatorImplTest.java | 56 + .../genericResourceApiEcompModelInformation.json | 7 + ...ericResourceApiNetworkOperationInformation.json | 54 + ...piNetworkOperationInformationNoNetworkName.json | 53 + ...urceApiNetworkOperationInformationUnAssign.json | 54 + ...ourceApiVfModuleOperationInformationAssign.json | 74 ++ ...rceApiVfModuleOperationInformationUnassign.json | 31 + .../resources/__files/SDNCClientGetResponse.json | 27 + .../__files/SDNCClientPrelaodDataResponse.json | 127 +++ ...aResponseWithInvalidAdditionalAndExtVmData.json | 47 + ...NCClientPrelaodDataResponseWithInvalidData.json | 39 + ...PrelaodDataResponseWithInvalidVnfParamsTag.json | 34 + .../__files/SDNCClientPut200Response.json | 15 + .../__files/SDNCClientPut200ResponseNotFinal.json | 15 + .../__files/SDNCClientPut404Response.json | 8 + .../__files/SDNCClientResponseIncorrectPath.json | 29 + .../__files/sdno/client/output-failure.json | 25 + .../__files/sdno/client/output-success.json | 22 + .../resources/__files/sdno/client/response.json | 17 + .../custom-lport-mirror-post-check-request.json | 27 + .../custom-lport-mirror-pre-check-request.json | 27 + .../custom-port-mirror-post-check-request.json | 23 + .../custom-port-mirror-pre-check-request.json | 23 + .../src/test/resources/application-test.yaml | 231 ++++ so-sdn-clients/src/test/resources/dmaap.properties | 10 + so-sdn-clients/src/test/resources/schema.sql | 1195 ++++++++++++++++++++ 120 files changed, 7243 insertions(+), 4900 deletions(-) delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java delete mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json delete mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json delete mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json delete mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json delete mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json delete mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json delete mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json create mode 100644 common/src/main/java/org/onap/so/client/exception/MapperException.java create mode 100644 so-sdn-clients/pom.xml create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SDNCClient.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidator.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Body.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Input.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java create mode 100644 so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/SDNO.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/TestApplication.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java create mode 100644 so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java create mode 100644 so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json create mode 100644 so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json create mode 100644 so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json create mode 100644 so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json create mode 100644 so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json create mode 100644 so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json create mode 100644 so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json create mode 100644 so-sdn-clients/src/test/resources/__files/sdno/client/output-failure.json create mode 100644 so-sdn-clients/src/test/resources/__files/sdno/client/output-success.json create mode 100644 so-sdn-clients/src/test/resources/__files/sdno/client/response.json create mode 100644 so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-post-check-request.json create mode 100644 so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-pre-check-request.json create mode 100644 so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-post-check-request.json create mode 100644 so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-pre-check-request.json create mode 100644 so-sdn-clients/src/test/resources/application-test.yaml create mode 100644 so-sdn-clients/src/test/resources/dmaap.properties create mode 100644 so-sdn-clients/src/test/resources/schema.sql diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java deleted file mode 100644 index 354c669d62..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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; - -public class MapperException extends Exception { - - public MapperException() {} - - public MapperException(String message) { - super(message); - } - -} diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index e89bbec9e1..d1245ce92a 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -201,25 +201,6 @@ mso-adapter-utils ${project.version} - - org.onap.sdnc.northbound - generic-resource-api-client - ${sdnc.northbound.version} - - - javax.ws.rs - jsr311-api - - - io.swagger - swagger-annotations - - - io.swagger - swagger-models - - - ch.vorburger.mariaDB4j mariaDB4j @@ -257,5 +238,10 @@ so-optimization-clients ${project.version} + + org.onap.so + so-sdn-clients + ${project.version} + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..5b6043f303 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapper.java @@ -0,0 +1,107 @@ +/*- + * ============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.infrastructure.sdnc.mapper; + +import java.net.URI; +import java.util.UUID; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component(value = "sdncGCTopologyOperationRequestMapper") +public class GCTopologyOperationRequestMapper { + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction, + GenericResourceApiRequestActionEnumeration reqAction, ServiceInstance serviceInstance, + RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf, + String sdncReqId, URI callbackUri) { + + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString()); + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); + GenericResourceApiServiceinformationServiceInformation serviceInformation = + generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false); + GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = + generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration, true); + GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = + generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf, null); + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setConfigurationInformation(configurationInformation); + req.setGcRequestInput(gcRequestInput); + + return req; + + } + + + public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction, + ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration, + String sdncReqId, URI callbackUri) { + + String msoRequestId = null; + if (requestContext != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString()); + GenericResourceApiRequestinformationRequestInformation requestInformation = + generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, + GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE); + GenericResourceApiServiceinformationServiceInformation serviceInformation = + new GenericResourceApiServiceinformationServiceInformation(); + serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = + new GenericResourceApiConfigurationinformationConfigurationInformation(); + configurationInformation.setConfigurationId(vnrConfiguration.getConfigurationId()); + configurationInformation.setConfigurationType(vnrConfiguration.getConfigurationType()); + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setConfigurationInformation(configurationInformation); + return req; + + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java new file mode 100644 index 0000000000..48a384c48a --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -0,0 +1,267 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class GeneralTopologyObjectMapper { + + private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class); + private ObjectMapper mapper = new ObjectMapper(); + + /* + * Build GenericResourceApiRequestinformationRequestInformation + */ + public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation( + String msoReqId, GenericResourceApiRequestActionEnumeration requestAction) { + + GenericResourceApiRequestinformationRequestInformation requestInformation = + new GenericResourceApiRequestinformationRequestInformation(); + requestInformation.setRequestId(msoReqId); + requestInformation.setRequestAction(requestAction); + requestInformation.setSource("MSO"); + return requestInformation; + } + + /* + * Build GenericResourceApiServiceinformationServiceInformation + */ + public GenericResourceApiServiceinformationServiceInformation buildServiceInformation( + ServiceInstance serviceInstance, RequestContext requestContext, Customer customer, + boolean includeModelInformation) { + GenericResourceApiServiceinformationServiceInformation serviceInformation = + new GenericResourceApiServiceinformationServiceInformation(); + serviceInformation.serviceId(serviceInstance.getServiceInstanceId()); + if (requestContext != null) { + serviceInformation.setSubscriptionServiceType(requestContext.getProductFamilyId()); + } + if (includeModelInformation) { + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + onapModelInformation + .setModelInvariantUuid(serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid()); + onapModelInformation.setModelVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion()); + onapModelInformation.setModelName(serviceInstance.getModelInfoServiceInstance().getModelName()); + onapModelInformation.setModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid()); + serviceInformation.setOnapModelInformation(onapModelInformation); + } + serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + + if (customer != null) { + serviceInformation.setGlobalCustomerId(customer.getGlobalCustomerId()); + if (customer.getServiceSubscription() != null) { + serviceInformation.setSubscriptionServiceType(customer.getServiceSubscription().getServiceType()); + } + + } + return serviceInformation; + } + + /* + * Build GenericResourceApiNetworkinformationNetworkInformation + */ + public GenericResourceApiNetworkinformationNetworkInformation buildNetworkInformation(L3Network network) { + GenericResourceApiNetworkinformationNetworkInformation networkInformation = + new GenericResourceApiNetworkinformationNetworkInformation(); + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + if (network.getModelInfoNetwork() != null) { + onapModelInformation.setModelInvariantUuid(network.getModelInfoNetwork().getModelInvariantUUID()); + onapModelInformation.setModelName(network.getModelInfoNetwork().getModelName()); + onapModelInformation.setModelVersion(network.getModelInfoNetwork().getModelVersion()); + onapModelInformation.setModelUuid(network.getModelInfoNetwork().getModelUUID()); + onapModelInformation.setModelCustomizationUuid(network.getModelInfoNetwork().getModelCustomizationUUID()); + networkInformation.setOnapModelInformation(onapModelInformation); + } + + networkInformation.setFromPreload(null); + networkInformation.setNetworkId(network.getNetworkId()); + networkInformation.setNetworkType(network.getNetworkType()); + networkInformation.setNetworkTechnology(network.getNetworkTechnology()); + return networkInformation; + } + + /* + * Build GenericResourceApiVnfinformationVnfInformation + */ + public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf, + ServiceInstance serviceInstance, boolean includeModelInformation) { + GenericResourceApiVnfinformationVnfInformation vnfInformation = + new GenericResourceApiVnfinformationVnfInformation(); + if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) { + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid()); + onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName()); + onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion()); + onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid()); + onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + vnfInformation.setOnapModelInformation(onapModelInformation); + } + vnfInformation.setVnfId(vnf.getVnfId()); + vnfInformation.setVnfType(vnf.getVnfType()); + vnfInformation.setVnfName(vnf.getVnfName()); + return vnfInformation; + } + + /* + * Build GenericResourceApiVfModuleinformationVfModuleInformation + */ + public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, + GenericVnf vnf, ServiceInstance serviceInstance, RequestContext requestContext, + boolean includeModelInformation) throws MapperException { + GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = + new GenericResourceApiVfmoduleinformationVfModuleInformation(); + if (includeModelInformation) { + if (vfModule.getModelInfoVfModule() == null) { + throw new MapperException("VF Module model info is null for " + vfModule.getVfModuleId()); + } else { + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID()); + onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName()); + onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion()); + onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID()); + onapModelInformation + .setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID()); + vfModuleInformation.setOnapModelInformation(onapModelInformation); + } + } + if (vfModule.getModelInfoVfModule() != null) { + vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName()); + } + vfModuleInformation.setVfModuleId(vfModule.getVfModuleId()); + if (requestContext != null && requestContext.getRequestParameters() != null) { + vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload()); + } else { + vfModuleInformation.setFromPreload(true); + } + + return vfModuleInformation; + } + + + public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, + String sdncReqId) { + return buildSdncRequestHeader(svcAction, sdncReqId, null); + } + + public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, + String sdncReqId, String callbackUrl) { + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + new GenericResourceApiSdncrequestheaderSdncRequestHeader(); + sdncRequestHeader.setSvcAction(svcAction.getSdncApiAction()); + sdncRequestHeader.setSvcRequestId(sdncReqId); + sdncRequestHeader.setSvcNotificationUrl(callbackUrl); + return sdncRequestHeader; + } + + /** + * Build ConfigurationInformation + * + * @param configuration + * @param includeModelInformation + * @return + */ + public GenericResourceApiConfigurationinformationConfigurationInformation buildConfigurationInformation( + Configuration configuration, boolean includeModelInformation) { + GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = + new GenericResourceApiConfigurationinformationConfigurationInformation(); + configurationInformation.setConfigurationId(configuration.getConfigurationId()); + configurationInformation.setConfigurationName(configuration.getConfigurationName()); + configurationInformation.setConfigurationType(configuration.getConfigurationType()); + if (includeModelInformation) { + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + onapModelInformation.setModelInvariantUuid(configuration.getModelInfoConfiguration().getModelInvariantId()); + onapModelInformation.setModelUuid(configuration.getModelInfoConfiguration().getModelVersionId()); + onapModelInformation + .setModelCustomizationUuid(configuration.getModelInfoConfiguration().getModelCustomizationId()); + configurationInformation.setOnapModelInformation(onapModelInformation); + } + return configurationInformation; + } + + + /** + * Build GcRequestInformation + * + * @param vnf + * @param genericResourceApiParam + * @return + */ + public GenericResourceApiGcrequestinputGcRequestInput buildGcRequestInformation(GenericVnf vnf, + GenericResourceApiParam genericResourceApiParam) { + GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = + new GenericResourceApiGcrequestinputGcRequestInput(); + gcRequestInput.setVnfId(vnf.getVnfId()); + if (genericResourceApiParam != null) { + gcRequestInput.setInputParameters(genericResourceApiParam); + } + return gcRequestInput; + } + + + public String mapUserParamValue(Object value) { + if (value == null) { + return null; + } else { + if (value instanceof Map || value instanceof Set || value instanceof List) { + try { + return mapper.writeValueAsString(value); + } catch (JsonProcessingException e) { + logger.error("could not map value to string", e); + throw new IllegalArgumentException(e); + } + } else { + return value.toString(); + } + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..593c15d6cc --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapper.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import java.util.Map; +import java.util.UUID; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkrequestinputNetworkRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Mapper creating SDNC request + * + */ +@Component +public class NetworkTopologyOperationRequestMapper { + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + public GenericResourceApiNetworkOperationInformation reqMapper(SDNCSvcOperation svcOperation, + SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, L3Network network, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, + CloudRegion cloudRegion) { + GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation(); + String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); + GenericResourceApiServiceinformationServiceInformation serviceInformation = + generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); + GenericResourceApiNetworkinformationNetworkInformation networkInformation = + generalTopologyObjectMapper.buildNetworkInformation(network); + GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = + buildNetworkRequestInput(network, serviceInstance, cloudRegion); + + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setNetworkInformation(networkInformation); + + if (requestContext != null && requestContext.getUserParams() != null) { + for (Map.Entry entry : requestContext.getUserParams().entrySet()) { + GenericResourceApiParam networkInputParameters = new GenericResourceApiParam(); + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); + networkInputParameters.addParamItem(paramItem); + networkRequestInput.setNetworkInputParameters(networkInputParameters); + } + } + + req.setNetworkRequestInput(networkRequestInput); + return req; + } + + /* + * Private helper to build GenericResourceApiNetworkrequestinputNetworkRequestInput + */ + private GenericResourceApiNetworkrequestinputNetworkRequestInput buildNetworkRequestInput(L3Network network, + ServiceInstance serviceInstance, CloudRegion cloudRegion) { + GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = + new GenericResourceApiNetworkrequestinputNetworkRequestInput(); + networkRequestInput.setTenant(cloudRegion.getTenantId()); + networkRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); + networkRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); + if (network.getNetworkName() != null && !network.getNetworkName().equals("")) { + networkRequestInput.setNetworkName(network.getNetworkName()); + } + if (serviceInstance.getCollection() != null && serviceInstance.getCollection().getInstanceGroup() != null) { + // set only for network created as part of the collection/instance since 1806 + networkRequestInput.setNetworkInstanceGroupId(serviceInstance.getCollection().getInstanceGroup().getId()); + } + return networkRequestInput; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java new file mode 100644 index 0000000000..69606393c3 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapper.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import java.util.Map; +import java.util.UUID; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServicerequestinputServiceRequestInput; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ServiceTopologyOperationMapper { + + @Autowired + public GeneralTopologyObjectMapper generalTopologyObjectMapper; + + public GenericResourceApiServiceOperationInformation reqMapper(SDNCSvcOperation svcOperation, + SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction, + ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) { + + String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation(); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); + GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction); + GenericResourceApiServiceinformationServiceInformation servInfo = + generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); + GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = + new GenericResourceApiServicerequestinputServiceRequestInput(); + + servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName()); + + servOpInput.setSdncRequestHeader(sdncRequestHeader); + servOpInput.setRequestInformation(reqInfo); + servOpInput.setServiceInformation(servInfo); + servOpInput.setServiceRequestInput(servReqInfo); + + if (requestContext != null && requestContext.getUserParams() != null) { + for (Map.Entry entry : requestContext.getUserParams().entrySet()) { + GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = + new GenericResourceApiServicerequestinputServiceRequestInput(); + serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName()); + GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam(); + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); + serviceInputParameters.addParamItem(paramItem); + serviceRequestInput.serviceInputParameters(serviceInputParameters); + servOpInput.setServiceRequestInput(serviceRequestInput); + } + } + return servOpInput; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..901187e231 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -0,0 +1,202 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications 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. + * 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.mapper; + +import java.net.URI; +import java.util.Map; +import java.util.UUID; +import org.onap.so.logger.LoggingAnchor; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleResponseInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.logger.MessageEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class VfModuleTopologyOperationRequestMapper { + private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class); + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation, + SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, + ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, + String sdncAssignResponse, URI callbackURL) throws MapperException { + GenericResourceApiVfModuleOperationInformation req = new GenericResourceApiVfModuleOperationInformation(); + + boolean includeModelInformation = false; + + GenericResourceApiRequestActionEnumeration requestAction = + GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + GenericResourceApiSvcActionEnumeration genericResourceApiSvcAction = + GenericResourceApiSvcActionEnumeration.ASSIGN; + + if (svcAction.equals(SDNCSvcAction.ACTIVATE)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ACTIVATE; + requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + includeModelInformation = true; + } else if (svcAction.equals(SDNCSvcAction.ASSIGN)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN; + requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + includeModelInformation = true; + } else if (svcAction.equals(SDNCSvcAction.DEACTIVATE)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DEACTIVATE; + requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; + includeModelInformation = false; + } else if (svcAction.equals(SDNCSvcAction.DELETE)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DELETE; + requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; + includeModelInformation = false; + } else if (svcAction.equals(SDNCSvcAction.UNASSIGN)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.UNASSIGN; + requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; + includeModelInformation = false; + } else if (svcAction.equals(SDNCSvcAction.CHANGE_ASSIGN)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.CHANGEASSIGN; + requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + includeModelInformation = true; + } + + String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); + GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper + .buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation); + GenericResourceApiVnfinformationVnfInformation vnfInformation = + generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation); + GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper + .buildVfModuleInformation(vfModule, vnf, serviceInstance, requestContext, includeModelInformation); + GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = + buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction, callbackURL); + + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setVnfInformation(vnfInformation); + req.setVfModuleInformation(vfModuleInformation); + req.setVfModuleRequestInput(vfModuleRequestInput); + + return req; + } + + private GenericResourceApiVfmodulerequestinputVfModuleRequestInput buildVfModuleRequestInput(VfModule vfModule, + VolumeGroup volumeGroup, CloudRegion cloudRegion, RequestContext requestContext) { + GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = + new GenericResourceApiVfmodulerequestinputVfModuleRequestInput(); + if (cloudRegion != null) { + vfModuleRequestInput.setTenant(cloudRegion.getTenantId()); + vfModuleRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); + vfModuleRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); + } + if (vfModule.getVfModuleName() != null && !vfModule.getVfModuleName().equals("")) { + vfModuleRequestInput.setVfModuleName(vfModule.getVfModuleName()); + } + GenericResourceApiParam vfModuleInputParameters = new GenericResourceApiParam(); + + if (requestContext != null && requestContext.getUserParams() != null) { + for (Map.Entry entry : requestContext.getUserParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); + vfModuleInputParameters.addParamItem(paramItem); + } + } + + if (vfModule.getCloudParams() != null) { + for (Map.Entry entry : vfModule.getCloudParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(entry.getValue()); + vfModuleInputParameters.addParamItem(paramItem); + } + } + + if (volumeGroup != null) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName("volume-group-id"); + paramItem.setValue(volumeGroup.getVolumeGroupId()); + vfModuleInputParameters.addParamItem(paramItem); + } + vfModuleRequestInput.setVfModuleInputParameters(vfModuleInputParameters); + + return vfModuleRequestInput; + } + + private GenericResourceApiSdncrequestheaderSdncRequestHeader buildVfModuleSdncRequestHeader(String sdncReqId, + GenericResourceApiSvcActionEnumeration svcAction, URI callbackUrl) { + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + new GenericResourceApiSdncrequestheaderSdncRequestHeader(); + sdncRequestHeader.setSvcRequestId(sdncReqId); + sdncRequestHeader.setSvcAction(svcAction); + sdncRequestHeader.setSvcNotificationUrl(callbackUrl.toString()); + return sdncRequestHeader; + } + + public String buildObjectPath(String sdncAssignResponse) { + String objectPath = null; + if (sdncAssignResponse != null) { + ObjectMapper mapper = new ObjectMapper(); + try { + GenericResourceApiVfModuleResponseInformation assignResponseInfo = + mapper.readValue(sdncAssignResponse, GenericResourceApiVfModuleResponseInformation.class); + objectPath = assignResponseInfo.getVfModuleResponseInformation().getObjectPath(); + } catch (Exception e) { + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN", + ErrorCode.UnknownError.getValue(), e.getMessage()); + } + } + return objectPath; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..c2dcb8f290 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -0,0 +1,164 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.apache.commons.lang.StringUtils; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.License; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class VnfTopologyOperationRequestMapper { + + @Autowired + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + /** + * This method is used for creating the vnf request. + * + * By these parameter it will get he detailas and prepare the request. + * + * @param svcOperation + * @param svcAction + * @param requestAction + * @param vnf + * @param serviceInstance + * @param customer + * @param cloudRegion + * @param requestContext + * @param homing + * @return request + */ + public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, + GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing, + URI callbackUrl) { + String sdncReqId = UUID.randomUUID().toString(); + String msoRequestId = UUID.randomUUID().toString(); + if (requestContext != null && requestContext.getMsoRequestId() != null) { + msoRequestId = requestContext.getMsoRequestId(); + } + GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation(); + GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUrl.toString()); + GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper + .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); + GenericResourceApiServiceinformationServiceInformation serviceInformation = + generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); + GenericResourceApiVnfinformationVnfInformation vnfInformation = + generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, true); + GenericResourceApiVnfrequestinputVnfRequestInput vnfRequestInput = + new GenericResourceApiVnfrequestinputVnfRequestInput(); + + vnfRequestInput.setTenant(cloudRegion.getTenantId()); + vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); + vnfRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); + + if (StringUtils.isNotBlank(vnf.getVnfName())) { + vnfRequestInput.setVnfName(vnf.getVnfName()); + } + + req.setRequestInformation(requestInformation); + req.setSdncRequestHeader(sdncRequestHeader); + req.setServiceInformation(serviceInformation); + req.setVnfInformation(vnfInformation); + + GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam(); + if (requestContext != null && requestContext.getUserParams() != null) { + for (Map.Entry entry : requestContext.getUserParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); + vnfInputParameters.addParamItem(paramItem); + vnfRequestInput.setVnfInputParameters(vnfInputParameters); + } + } + if (vnf.getCloudParams() != null) { + for (Map.Entry entry : vnf.getCloudParams().entrySet()) { + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName(entry.getKey()); + paramItem.setValue(entry.getValue()); + vnfInputParameters.addParamItem(paramItem); + } + } + if (homing) { + License license = vnf.getLicense(); + if (license != null) { + if (license.getEntitlementPoolUuids() != null && !license.getEntitlementPoolUuids().isEmpty()) { + String entitlementPoolUuid = license.getEntitlementPoolUuids().get(0); + GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); + paramItem.setName("entitlement_assignment_group_uuid"); + paramItem.setValue(entitlementPoolUuid); + vnfInputParameters.addParamItem(paramItem); + } + if (license.getLicenseKeyGroupUuids() != null && !license.getLicenseKeyGroupUuids().isEmpty()) { + String licenseKeyGroupUuid = license.getLicenseKeyGroupUuids().get(0); + GenericResourceApiParamParam paramItem2 = new GenericResourceApiParamParam(); + paramItem2.setName("license_assignment_group_uuid"); + paramItem2.setValue(licenseKeyGroupUuid); + vnfInputParameters.addParamItem(paramItem2); + } + } + } + List instanceGroups = vnf.getInstanceGroups(); + List networkInstanceGroupIdList = + new ArrayList<>(); + + for (InstanceGroup instanceGroup : instanceGroups) { + if (ModelInfoInstanceGroup.TYPE_L3_NETWORK + .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { + GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds instanceGroupId = + new GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds(); + instanceGroupId.setVnfNetworkInstanceGroupId(instanceGroup.getId()); + networkInstanceGroupIdList.add(instanceGroupId); + } + } + + vnfRequestInput.setVnfNetworkInstanceGroupIds(networkInstanceGroupIdList); + vnfRequestInput.setVnfInputParameters(vnfInputParameters); + req.setVnfRequestInput(vnfRequestInput); + return req; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java index 4aa6a1026a..da675bb498 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java @@ -21,6 +21,7 @@ package org.onap.so.client.orchestration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -29,7 +30,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.net.URI; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java index 0123eb67be..dc59969492 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java @@ -24,6 +24,7 @@ package org.onap.so.client.orchestration; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -31,7 +32,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java index 960efea2f0..54efd23bf9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCServiceInstanceResources.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -29,7 +30,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java index 01511eaccc..c500374dc1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java @@ -24,6 +24,7 @@ package org.onap.so.client.orchestration; import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -36,7 +37,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java index 27edeed02a..d198756b1e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java @@ -25,6 +25,7 @@ package org.onap.so.client.orchestration; import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -35,7 +36,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java deleted file mode 100644 index 7d2fc10d0b..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications 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. - * 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.sdnc; - -import java.util.LinkedHashMap; -import javax.ws.rs.core.UriBuilder; -import org.onap.so.client.BaseClient; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.beans.SDNCProperties; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpHeaders; -import org.springframework.stereotype.Component; - -@Component -public class SDNCClient { - - @Autowired - private SDNCProperties properties; - @Autowired - private SdnCommonTasks sdnCommonTasks; - - /** - * - * @param request - takes in a generated object from sdnc client - creates a json request string and sends it to - * sdnc - receives and validates the linkedhashmap sent back from sdnc - * @throws MapperException - * @throws BadResponseException - */ - public String post(Object request, SDNCTopology topology) throws MapperException, BadResponseException { - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/"; - BaseClient> STOClient = new BaseClient<>(); - - STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap output = - STOClient.post(jsonRequest, new ParameterizedTypeReference>() {}); - return sdnCommonTasks.validateSDNResponse(output); - } - - - public String post(Object request, String url) throws MapperException, BadResponseException { - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - BaseClient> STOClient = new BaseClient<>(); - STOClient.setTargetUrl(url); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap output = - STOClient.post(jsonRequest, new ParameterizedTypeReference>() {}); - return sdnCommonTasks.validateSDNResponse(output); - } - - /** - * - * @param queryLink - takes in a link to topology that needs to be queried - creates a json request string and sends - * it to sdnc - receives and validates the linkedhashmap sent back from sdnc * - * @throws MapperException - * @throws BadResponseException - */ - public String get(String queryLink) throws MapperException, BadResponseException { - String request = ""; - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); - BaseClient> STOClient = new BaseClient<>(); - STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), false); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap output = - STOClient.get(jsonRequest, new ParameterizedTypeReference>() {}); - return sdnCommonTasks.validateSDNGetResponse(output); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java deleted file mode 100644 index 01ac675d83..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications 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. - * 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.sdnc; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import org.onap.so.logger.LoggingAnchor; -import org.apache.commons.lang.StringUtils; -import org.apache.http.HttpStatus; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.exception.MapperException; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Component -public class SdnCommonTasks { - - private static final Logger logger = LoggerFactory.getLogger(SDNCClient.class); - private static final String RESPONSE_CODE = "response-code"; - private static final String RESPONSE_MESSAGE = "response-message"; - private static final String NO_RESPONSE_FROM_SDNC = "Error did not receive a response from SDNC."; - private static final String BAD_RESPONSE_FROM_SDNC = "Error received a bad response from SDNC."; - private static final String SDNC_CODE_NOT_0_OR_IN_200_299 = "Error from SDNC: %s"; - private static final String COULD_NOT_CONVERT_SDNC_POJO_TO_JSON = - "ERROR: Could not convert SDNC pojo to json string."; - private static final String BRACKETS = LoggingAnchor.FIVE; - - /*** - * - * @param request - * @return - * @throws MapperException - */ - public String buildJsonRequest(Object request) throws MapperException { - String jsonRequest; - ObjectMapper objMapper = new ObjectMapper(); - objMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - try { - jsonRequest = objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(request); - } catch (JsonProcessingException e) { - logger.error(BRACKETS, MessageEnum.JAXB_EXCEPTION.toString(), COULD_NOT_CONVERT_SDNC_POJO_TO_JSON, "BPMN", - ErrorCode.DataError.getValue(), e.getMessage()); - throw new MapperException(COULD_NOT_CONVERT_SDNC_POJO_TO_JSON); - } - jsonRequest = "{\"input\":" + jsonRequest + "}"; - logger.info(jsonRequest); - return jsonRequest; - } - - /*** - * - * @param auth - * @return - */ - public HttpHeaders getHttpHeaders(String auth, boolean includeContentType) { - HttpHeaders httpHeader = new HttpHeaders(); - httpHeader.set("Authorization", auth); - if (includeContentType) { - httpHeader.setContentType(MediaType.APPLICATION_JSON); - } - List acceptMediaTypes = new ArrayList<>(); - acceptMediaTypes.add(MediaType.APPLICATION_JSON); - httpHeader.setAccept(acceptMediaTypes); - return httpHeader; - } - - /*** - * - * @param output - * @return - * @throws BadResponseException - */ - public String validateSDNResponse(LinkedHashMap output) throws BadResponseException { - if (CollectionUtils.isEmpty(output)) { - logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", - ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); - throw new BadResponseException(NO_RESPONSE_FROM_SDNC); - } - LinkedHashMap embeddedResponse = (LinkedHashMap) output.get("output"); - String responseCode = ""; - String responseMessage = ""; - if (embeddedResponse != null) { - responseCode = (String) embeddedResponse.get(RESPONSE_CODE); - responseMessage = (String) embeddedResponse.get(RESPONSE_MESSAGE); - } - ObjectMapper objMapper = new ObjectMapper(); - String jsonResponse; - try { - jsonResponse = objMapper.writeValueAsString(output); - logger.debug(jsonResponse); - } catch (JsonProcessingException e) { - logger.warn("Could not convert SDNC Response to String", e); - jsonResponse = ""; - } - logger.info("ResponseCode: {} ResponseMessage: {}", responseCode, responseMessage); - int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0; - if (isHttpCodeSuccess(code)) { - logger.info("Successful Response from SDNC"); - return jsonResponse; - } else { - String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage); - logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), errorMessage, "BPMN", - ErrorCode.DataError.getValue(), errorMessage); - throw new BadResponseException(errorMessage); - } - } - - /*** - * - * @param output - * @return - * @throws BadResponseException - */ - public String validateSDNGetResponse(LinkedHashMap output) throws BadResponseException { - if (CollectionUtils.isEmpty(output)) { - logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", - ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); - throw new BadResponseException(NO_RESPONSE_FROM_SDNC); - } - ObjectMapper objMapper = new ObjectMapper(); - logger.debug("Using object mapper"); - String stringOutput = ""; - try { - stringOutput = objMapper.writeValueAsString(output); - } catch (Exception e) { - logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), BAD_RESPONSE_FROM_SDNC, "BPMN", - ErrorCode.UnknownError.getValue(), BAD_RESPONSE_FROM_SDNC); - throw new BadResponseException(BAD_RESPONSE_FROM_SDNC); - } - logger.debug("Received from GET request: {}", stringOutput); - return stringOutput; - } - - - private boolean isHttpCodeSuccess(int code) { - return code >= HttpStatus.SC_OK && code < HttpStatus.SC_MULTIPLE_CHOICES || code == 0; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java deleted file mode 100644 index 15076fa45a..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.beans; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ConfigurationProperties(prefix = "sdnc") -public class SDNCProperties { - - private String host; - private String path; - private String auth; - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public String getAuth() { - return auth; - } - - public void setAuth(String auth) { - this.auth = auth; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java deleted file mode 100644 index 2c8bdd931c..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java +++ /dev/null @@ -1,97 +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.client.sdnc.beans; - -import java.io.Serializable; -import java.util.UUID; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; - -public class SDNCRequest implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 4679678988657593282L; - private String timeOut = "PT1H"; - private SDNCTopology topology; - private String correlationValue = UUID.randomUUID().toString(); - private String correlationName = "SDNCCallback"; - private transient Object sdncPayload; - - - public String getTimeOut() { - return timeOut; - } - - public void setTimeOut(String timeOut) { - this.timeOut = timeOut; - } - - public SDNCTopology getTopology() { - return topology; - } - - public void setTopology(SDNCTopology topology) { - this.topology = topology; - } - - public String getCorrelationValue() { - return correlationValue; - } - - public void setCorrelationValue(String correlationValue) { - this.correlationValue = correlationValue; - } - - public String getCorrelationName() { - return correlationName; - } - - public void setCorrelationName(String correlationName) { - this.correlationName = correlationName; - } - - public Object getSDNCPayload() { - return sdncPayload; - } - - public void setSDNCPayload(Object sDNCPayload) { - this.sdncPayload = sDNCPayload; - } - - @Override - public boolean equals(final Object other) { - if (!(other instanceof SDNCRequest)) { - return false; - } - SDNCRequest castOther = (SDNCRequest) other; - return new EqualsBuilder().append(correlationValue, castOther.correlationValue) - .append(correlationName, castOther.correlationName).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(correlationValue).append(correlationName).toHashCode(); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java deleted file mode 100644 index d6216c509d..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.beans; - -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; - -public enum SDNCSvcAction { - ACTIVATE("activate", GenericResourceApiSvcActionEnumeration.ACTIVATE), - DELETE("delete", GenericResourceApiSvcActionEnumeration.DELETE), - ASSIGN("assign", GenericResourceApiSvcActionEnumeration.ASSIGN), - ROLLBACK("rollback", GenericResourceApiSvcActionEnumeration.ROLLBACK), - UNASSIGN("unassign", GenericResourceApiSvcActionEnumeration.UNASSIGN), - DEACTIVATE("deactivate", GenericResourceApiSvcActionEnumeration.DEACTIVATE), - CHANGE_DELETE("changedelete", GenericResourceApiSvcActionEnumeration.CHANGEDELETE), - CHANGE_ASSIGN("changeassign", GenericResourceApiSvcActionEnumeration.CHANGEASSIGN), - CREATE("create", GenericResourceApiSvcActionEnumeration.CREATE), - ENABLE("enable", GenericResourceApiSvcActionEnumeration.ENABLE), - DISABLE("disable", GenericResourceApiSvcActionEnumeration.DISABLE); - - private final String name; - - private GenericResourceApiSvcActionEnumeration sdncApiAction; - - private SDNCSvcAction(String name, GenericResourceApiSvcActionEnumeration sdncApiAction) { - this.name = name; - this.sdncApiAction = sdncApiAction; - } - - public GenericResourceApiSvcActionEnumeration getSdncApiAction() { - return this.sdncApiAction; - } - - @Override - public String toString() { - return name; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java deleted file mode 100644 index 4edbf37bad..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.beans; - -public enum SDNCSvcOperation { - - VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"), - NETWORK_TOPOLOGY_OPERATION("network-topology-operation"), - VNF_TOPOLOGY_OPERATION("vnf-topology-operation"), - CONTRAIL_ROUTE_TOPOLOGY_OPERATION("contrail-route-topology-operation"), - SECURITY_ZONE_TOPOLOGY_OPERATION("security-zone-topology-operation"), - PORT_MIRROR_TOPOLOGY_OPERATION("port-mirror-topology-operation"), - SERVICE_TOPOLOGY_OPERATION("service-topology-operation"), - GENERIC_CONFIGURATION_TOPOLOGY_OPERATION("generic-configuration-topology-operation"); - - private final String name; - - private SDNCSvcOperation(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java deleted file mode 100644 index ae9fe6ad70..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.endpoint; - -public enum SDNCTopology { - - SERVICE("service-topology-operation"), - VNF("vnf-topology-operation"), - VFMODULE("vf-module-topology-operation"), - CONTRAILROUTE("contrail-route-topology-operation"), - PORTMIRROR("port-mirror-topology-operation"), - NETWORK("network-topology-operation"), - SECURITYZONE("security-zone-topology-operation"), - CONFIGURATION("generic-configuration-topology-operation"); - - private final String topology; - - private SDNCTopology(String topology) { - this.topology = topology; - } - - @Override - public String toString() { - return this.topology; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java deleted file mode 100644 index 6af8c2f9c5..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapper.java +++ /dev/null @@ -1,107 +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.client.sdnc.mapper; - -import java.net.URI; -import java.util.UUID; -import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component(value = "sdncGCTopologyOperationRequestMapper") -public class GCTopologyOperationRequestMapper { - - @Autowired - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - public GenericResourceApiGcTopologyOperationInformation assignOrActivateVnrReqMapper(SDNCSvcAction svcAction, - GenericResourceApiRequestActionEnumeration reqAction, ServiceInstance serviceInstance, - RequestContext requestContext, Customer customer, Configuration vnrConfiguration, GenericVnf voiceVnf, - String sdncReqId, URI callbackUri) { - - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString()); - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); - GenericResourceApiServiceinformationServiceInformation serviceInformation = - generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, false); - GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = - generalTopologyObjectMapper.buildConfigurationInformation(vnrConfiguration, true); - GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = - generalTopologyObjectMapper.buildGcRequestInformation(voiceVnf, null); - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setConfigurationInformation(configurationInformation); - req.setGcRequestInput(gcRequestInput); - - return req; - - } - - - public GenericResourceApiGcTopologyOperationInformation deactivateOrUnassignVnrReqMapper(SDNCSvcAction svcAction, - ServiceInstance serviceInstance, RequestContext requestContext, Configuration vnrConfiguration, - String sdncReqId, URI callbackUri) { - - String msoRequestId = null; - if (requestContext != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiGcTopologyOperationInformation req = new GenericResourceApiGcTopologyOperationInformation(); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUri.toString()); - GenericResourceApiRequestinformationRequestInformation requestInformation = - generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, - GenericResourceApiRequestActionEnumeration.DELETEGENERICCONFIGURATIONINSTANCE); - GenericResourceApiServiceinformationServiceInformation serviceInformation = - new GenericResourceApiServiceinformationServiceInformation(); - serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); - GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = - new GenericResourceApiConfigurationinformationConfigurationInformation(); - configurationInformation.setConfigurationId(vnrConfiguration.getConfigurationId()); - configurationInformation.setConfigurationType(vnrConfiguration.getConfigurationType()); - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setConfigurationInformation(configurationInformation); - return req; - - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java deleted file mode 100644 index a9611cbde5..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ /dev/null @@ -1,267 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Component -public class GeneralTopologyObjectMapper { - - private static final Logger logger = LoggerFactory.getLogger(GeneralTopologyObjectMapper.class); - private ObjectMapper mapper = new ObjectMapper(); - - /* - * Build GenericResourceApiRequestinformationRequestInformation - */ - public GenericResourceApiRequestinformationRequestInformation buildGenericResourceApiRequestinformationRequestInformation( - String msoReqId, GenericResourceApiRequestActionEnumeration requestAction) { - - GenericResourceApiRequestinformationRequestInformation requestInformation = - new GenericResourceApiRequestinformationRequestInformation(); - requestInformation.setRequestId(msoReqId); - requestInformation.setRequestAction(requestAction); - requestInformation.setSource("MSO"); - return requestInformation; - } - - /* - * Build GenericResourceApiServiceinformationServiceInformation - */ - public GenericResourceApiServiceinformationServiceInformation buildServiceInformation( - ServiceInstance serviceInstance, RequestContext requestContext, Customer customer, - boolean includeModelInformation) { - GenericResourceApiServiceinformationServiceInformation serviceInformation = - new GenericResourceApiServiceinformationServiceInformation(); - serviceInformation.serviceId(serviceInstance.getServiceInstanceId()); - if (requestContext != null) { - serviceInformation.setSubscriptionServiceType(requestContext.getProductFamilyId()); - } - if (includeModelInformation) { - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - onapModelInformation - .setModelInvariantUuid(serviceInstance.getModelInfoServiceInstance().getModelInvariantUuid()); - onapModelInformation.setModelVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion()); - onapModelInformation.setModelName(serviceInstance.getModelInfoServiceInstance().getModelName()); - onapModelInformation.setModelUuid(serviceInstance.getModelInfoServiceInstance().getModelUuid()); - serviceInformation.setOnapModelInformation(onapModelInformation); - } - serviceInformation.setServiceInstanceId(serviceInstance.getServiceInstanceId()); - - if (customer != null) { - serviceInformation.setGlobalCustomerId(customer.getGlobalCustomerId()); - if (customer.getServiceSubscription() != null) { - serviceInformation.setSubscriptionServiceType(customer.getServiceSubscription().getServiceType()); - } - - } - return serviceInformation; - } - - /* - * Build GenericResourceApiNetworkinformationNetworkInformation - */ - public GenericResourceApiNetworkinformationNetworkInformation buildNetworkInformation(L3Network network) { - GenericResourceApiNetworkinformationNetworkInformation networkInformation = - new GenericResourceApiNetworkinformationNetworkInformation(); - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - if (network.getModelInfoNetwork() != null) { - onapModelInformation.setModelInvariantUuid(network.getModelInfoNetwork().getModelInvariantUUID()); - onapModelInformation.setModelName(network.getModelInfoNetwork().getModelName()); - onapModelInformation.setModelVersion(network.getModelInfoNetwork().getModelVersion()); - onapModelInformation.setModelUuid(network.getModelInfoNetwork().getModelUUID()); - onapModelInformation.setModelCustomizationUuid(network.getModelInfoNetwork().getModelCustomizationUUID()); - networkInformation.setOnapModelInformation(onapModelInformation); - } - - networkInformation.setFromPreload(null); - networkInformation.setNetworkId(network.getNetworkId()); - networkInformation.setNetworkType(network.getNetworkType()); - networkInformation.setNetworkTechnology(network.getNetworkTechnology()); - return networkInformation; - } - - /* - * Build GenericResourceApiVnfinformationVnfInformation - */ - public GenericResourceApiVnfinformationVnfInformation buildVnfInformation(GenericVnf vnf, - ServiceInstance serviceInstance, boolean includeModelInformation) { - GenericResourceApiVnfinformationVnfInformation vnfInformation = - new GenericResourceApiVnfinformationVnfInformation(); - if (includeModelInformation && vnf.getModelInfoGenericVnf() != null) { - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - onapModelInformation.setModelInvariantUuid(vnf.getModelInfoGenericVnf().getModelInvariantUuid()); - onapModelInformation.setModelName(vnf.getModelInfoGenericVnf().getModelName()); - onapModelInformation.setModelVersion(vnf.getModelInfoGenericVnf().getModelVersion()); - onapModelInformation.setModelUuid(vnf.getModelInfoGenericVnf().getModelUuid()); - onapModelInformation.setModelCustomizationUuid(vnf.getModelInfoGenericVnf().getModelCustomizationUuid()); - vnfInformation.setOnapModelInformation(onapModelInformation); - } - vnfInformation.setVnfId(vnf.getVnfId()); - vnfInformation.setVnfType(vnf.getVnfType()); - vnfInformation.setVnfName(vnf.getVnfName()); - return vnfInformation; - } - - /* - * Build GenericResourceApiVfModuleinformationVfModuleInformation - */ - public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, - GenericVnf vnf, ServiceInstance serviceInstance, RequestContext requestContext, - boolean includeModelInformation) throws MapperException { - GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = - new GenericResourceApiVfmoduleinformationVfModuleInformation(); - if (includeModelInformation) { - if (vfModule.getModelInfoVfModule() == null) { - throw new MapperException("VF Module model info is null for " + vfModule.getVfModuleId()); - } else { - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID()); - onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName()); - onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion()); - onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID()); - onapModelInformation - .setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID()); - vfModuleInformation.setOnapModelInformation(onapModelInformation); - } - } - if (vfModule.getModelInfoVfModule() != null) { - vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName()); - } - vfModuleInformation.setVfModuleId(vfModule.getVfModuleId()); - if (requestContext != null && requestContext.getRequestParameters() != null) { - vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload()); - } else { - vfModuleInformation.setFromPreload(true); - } - - return vfModuleInformation; - } - - - public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, - String sdncReqId) { - return buildSdncRequestHeader(svcAction, sdncReqId, null); - } - - public GenericResourceApiSdncrequestheaderSdncRequestHeader buildSdncRequestHeader(SDNCSvcAction svcAction, - String sdncReqId, String callbackUrl) { - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - new GenericResourceApiSdncrequestheaderSdncRequestHeader(); - sdncRequestHeader.setSvcAction(svcAction.getSdncApiAction()); - sdncRequestHeader.setSvcRequestId(sdncReqId); - sdncRequestHeader.setSvcNotificationUrl(callbackUrl); - return sdncRequestHeader; - } - - /** - * Build ConfigurationInformation - * - * @param configuration - * @param includeModelInformation - * @return - */ - public GenericResourceApiConfigurationinformationConfigurationInformation buildConfigurationInformation( - Configuration configuration, boolean includeModelInformation) { - GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = - new GenericResourceApiConfigurationinformationConfigurationInformation(); - configurationInformation.setConfigurationId(configuration.getConfigurationId()); - configurationInformation.setConfigurationName(configuration.getConfigurationName()); - configurationInformation.setConfigurationType(configuration.getConfigurationType()); - if (includeModelInformation) { - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - onapModelInformation.setModelInvariantUuid(configuration.getModelInfoConfiguration().getModelInvariantId()); - onapModelInformation.setModelUuid(configuration.getModelInfoConfiguration().getModelVersionId()); - onapModelInformation - .setModelCustomizationUuid(configuration.getModelInfoConfiguration().getModelCustomizationId()); - configurationInformation.setOnapModelInformation(onapModelInformation); - } - return configurationInformation; - } - - - /** - * Build GcRequestInformation - * - * @param vnf - * @param genericResourceApiParam - * @return - */ - public GenericResourceApiGcrequestinputGcRequestInput buildGcRequestInformation(GenericVnf vnf, - GenericResourceApiParam genericResourceApiParam) { - GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = - new GenericResourceApiGcrequestinputGcRequestInput(); - gcRequestInput.setVnfId(vnf.getVnfId()); - if (genericResourceApiParam != null) { - gcRequestInput.setInputParameters(genericResourceApiParam); - } - return gcRequestInput; - } - - - public String mapUserParamValue(Object value) { - if (value == null) { - return null; - } else { - if (value instanceof Map || value instanceof Set || value instanceof List) { - try { - return mapper.writeValueAsString(value); - } catch (JsonProcessingException e) { - logger.error("could not map value to string", e); - throw new IllegalArgumentException(e); - } - } else { - return value.toString(); - } - } - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java deleted file mode 100644 index b1c95154c6..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import java.util.Map; -import java.util.UUID; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkrequestinputNetworkRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * Mapper creating SDNC request - * - */ -@Component -public class NetworkTopologyOperationRequestMapper { - - @Autowired - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - public GenericResourceApiNetworkOperationInformation reqMapper(SDNCSvcOperation svcOperation, - SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration reqAction, L3Network network, - ServiceInstance serviceInstance, Customer customer, RequestContext requestContext, - CloudRegion cloudRegion) { - GenericResourceApiNetworkOperationInformation req = new GenericResourceApiNetworkOperationInformation(); - String sdncReqId = UUID.randomUUID().toString(); - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, reqAction); - GenericResourceApiServiceinformationServiceInformation serviceInformation = - generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); - GenericResourceApiNetworkinformationNetworkInformation networkInformation = - generalTopologyObjectMapper.buildNetworkInformation(network); - GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = - buildNetworkRequestInput(network, serviceInstance, cloudRegion); - - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setNetworkInformation(networkInformation); - - if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry entry : requestContext.getUserParams().entrySet()) { - GenericResourceApiParam networkInputParameters = new GenericResourceApiParam(); - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); - networkInputParameters.addParamItem(paramItem); - networkRequestInput.setNetworkInputParameters(networkInputParameters); - } - } - - req.setNetworkRequestInput(networkRequestInput); - return req; - } - - /* - * Private helper to build GenericResourceApiNetworkrequestinputNetworkRequestInput - */ - private GenericResourceApiNetworkrequestinputNetworkRequestInput buildNetworkRequestInput(L3Network network, - ServiceInstance serviceInstance, CloudRegion cloudRegion) { - GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = - new GenericResourceApiNetworkrequestinputNetworkRequestInput(); - networkRequestInput.setTenant(cloudRegion.getTenantId()); - networkRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); - networkRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - if (network.getNetworkName() != null && !network.getNetworkName().equals("")) { - networkRequestInput.setNetworkName(network.getNetworkName()); - } - if (serviceInstance.getCollection() != null && serviceInstance.getCollection().getInstanceGroup() != null) { - // set only for network created as part of the collection/instance since 1806 - networkRequestInput.setNetworkInstanceGroupId(serviceInstance.getCollection().getInstanceGroup().getId()); - } - return networkRequestInput; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java deleted file mode 100644 index b5957b3009..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import java.util.Map; -import java.util.UUID; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServicerequestinputServiceRequestInput; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class ServiceTopologyOperationMapper { - - @Autowired - public GeneralTopologyObjectMapper generalTopologyObjectMapper; - - public GenericResourceApiServiceOperationInformation reqMapper(SDNCSvcOperation svcOperation, - SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction, - ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) { - - String sdncReqId = UUID.randomUUID().toString(); - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation(); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); - GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction); - GenericResourceApiServiceinformationServiceInformation servInfo = - generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); - GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = - new GenericResourceApiServicerequestinputServiceRequestInput(); - - servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName()); - - servOpInput.setSdncRequestHeader(sdncRequestHeader); - servOpInput.setRequestInformation(reqInfo); - servOpInput.setServiceInformation(servInfo); - servOpInput.setServiceRequestInput(servReqInfo); - - if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry entry : requestContext.getUserParams().entrySet()) { - GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = - new GenericResourceApiServicerequestinputServiceRequestInput(); - serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName()); - GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam(); - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); - serviceInputParameters.addParamItem(paramItem); - serviceRequestInput.serviceInputParameters(serviceInputParameters); - servOpInput.setServiceRequestInput(serviceRequestInput); - } - } - return servOpInput; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java deleted file mode 100644 index f6642ab76a..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications 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. - * 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.sdnc.mapper; - -import java.net.URI; -import java.util.Map; -import java.util.UUID; -import org.onap.so.logger.LoggingAnchor; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleResponseInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmodulerequestinputVfModuleRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Component -public class VfModuleTopologyOperationRequestMapper { - private static final Logger logger = LoggerFactory.getLogger(VfModuleTopologyOperationRequestMapper.class); - - @Autowired - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation, - SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, - ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, - String sdncAssignResponse, URI callbackURL) throws MapperException { - GenericResourceApiVfModuleOperationInformation req = new GenericResourceApiVfModuleOperationInformation(); - - boolean includeModelInformation = false; - - GenericResourceApiRequestActionEnumeration requestAction = - GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; - GenericResourceApiSvcActionEnumeration genericResourceApiSvcAction = - GenericResourceApiSvcActionEnumeration.ASSIGN; - - if (svcAction.equals(SDNCSvcAction.ACTIVATE)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ACTIVATE; - requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; - includeModelInformation = true; - } else if (svcAction.equals(SDNCSvcAction.ASSIGN)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.ASSIGN; - requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; - includeModelInformation = true; - } else if (svcAction.equals(SDNCSvcAction.DEACTIVATE)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DEACTIVATE; - requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; - includeModelInformation = false; - } else if (svcAction.equals(SDNCSvcAction.DELETE)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.DELETE; - requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; - includeModelInformation = false; - } else if (svcAction.equals(SDNCSvcAction.UNASSIGN)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.UNASSIGN; - requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; - includeModelInformation = false; - } else if (svcAction.equals(SDNCSvcAction.CHANGE_ASSIGN)) { - genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.CHANGEASSIGN; - requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; - includeModelInformation = true; - } - - String sdncReqId = UUID.randomUUID().toString(); - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); - GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper - .buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation); - GenericResourceApiVnfinformationVnfInformation vnfInformation = - generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation); - GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper - .buildVfModuleInformation(vfModule, vnf, serviceInstance, requestContext, includeModelInformation); - GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = - buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction, callbackURL); - - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setVnfInformation(vnfInformation); - req.setVfModuleInformation(vfModuleInformation); - req.setVfModuleRequestInput(vfModuleRequestInput); - - return req; - } - - private GenericResourceApiVfmodulerequestinputVfModuleRequestInput buildVfModuleRequestInput(VfModule vfModule, - VolumeGroup volumeGroup, CloudRegion cloudRegion, RequestContext requestContext) { - GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = - new GenericResourceApiVfmodulerequestinputVfModuleRequestInput(); - if (cloudRegion != null) { - vfModuleRequestInput.setTenant(cloudRegion.getTenantId()); - vfModuleRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - vfModuleRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); - } - if (vfModule.getVfModuleName() != null && !vfModule.getVfModuleName().equals("")) { - vfModuleRequestInput.setVfModuleName(vfModule.getVfModuleName()); - } - GenericResourceApiParam vfModuleInputParameters = new GenericResourceApiParam(); - - if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry entry : requestContext.getUserParams().entrySet()) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); - vfModuleInputParameters.addParamItem(paramItem); - } - } - - if (vfModule.getCloudParams() != null) { - for (Map.Entry entry : vfModule.getCloudParams().entrySet()) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); - vfModuleInputParameters.addParamItem(paramItem); - } - } - - if (volumeGroup != null) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName("volume-group-id"); - paramItem.setValue(volumeGroup.getVolumeGroupId()); - vfModuleInputParameters.addParamItem(paramItem); - } - vfModuleRequestInput.setVfModuleInputParameters(vfModuleInputParameters); - - return vfModuleRequestInput; - } - - private GenericResourceApiSdncrequestheaderSdncRequestHeader buildVfModuleSdncRequestHeader(String sdncReqId, - GenericResourceApiSvcActionEnumeration svcAction, URI callbackUrl) { - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - new GenericResourceApiSdncrequestheaderSdncRequestHeader(); - sdncRequestHeader.setSvcRequestId(sdncReqId); - sdncRequestHeader.setSvcAction(svcAction); - sdncRequestHeader.setSvcNotificationUrl(callbackUrl.toString()); - return sdncRequestHeader; - } - - public String buildObjectPath(String sdncAssignResponse) { - String objectPath = null; - if (sdncAssignResponse != null) { - ObjectMapper mapper = new ObjectMapper(); - try { - GenericResourceApiVfModuleResponseInformation assignResponseInfo = - mapper.readValue(sdncAssignResponse, GenericResourceApiVfModuleResponseInformation.class); - objectPath = assignResponseInfo.getVfModuleResponseInformation().getObjectPath(); - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN", - ErrorCode.UnknownError.getValue(), e.getMessage()); - } - } - return objectPath; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java deleted file mode 100644 index fd0af3a4dd..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ /dev/null @@ -1,164 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.lang.StringUtils; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.generalobjects.License; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class VnfTopologyOperationRequestMapper { - - @Autowired - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - /** - * This method is used for creating the vnf request. - * - * By these parameter it will get he detailas and prepare the request. - * - * @param svcOperation - * @param svcAction - * @param requestAction - * @param vnf - * @param serviceInstance - * @param customer - * @param cloudRegion - * @param requestContext - * @param homing - * @return request - */ - public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, - GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing, - URI callbackUrl) { - String sdncReqId = UUID.randomUUID().toString(); - String msoRequestId = UUID.randomUUID().toString(); - if (requestContext != null && requestContext.getMsoRequestId() != null) { - msoRequestId = requestContext.getMsoRequestId(); - } - GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation(); - GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUrl.toString()); - GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper - .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); - GenericResourceApiServiceinformationServiceInformation serviceInformation = - generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); - GenericResourceApiVnfinformationVnfInformation vnfInformation = - generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, true); - GenericResourceApiVnfrequestinputVnfRequestInput vnfRequestInput = - new GenericResourceApiVnfrequestinputVnfRequestInput(); - - vnfRequestInput.setTenant(cloudRegion.getTenantId()); - vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - vnfRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); - - if (StringUtils.isNotBlank(vnf.getVnfName())) { - vnfRequestInput.setVnfName(vnf.getVnfName()); - } - - req.setRequestInformation(requestInformation); - req.setSdncRequestHeader(sdncRequestHeader); - req.setServiceInformation(serviceInformation); - req.setVnfInformation(vnfInformation); - - GenericResourceApiParam vnfInputParameters = new GenericResourceApiParam(); - if (requestContext != null && requestContext.getUserParams() != null) { - for (Map.Entry entry : requestContext.getUserParams().entrySet()) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue())); - vnfInputParameters.addParamItem(paramItem); - vnfRequestInput.setVnfInputParameters(vnfInputParameters); - } - } - if (vnf.getCloudParams() != null) { - for (Map.Entry entry : vnf.getCloudParams().entrySet()) { - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName(entry.getKey()); - paramItem.setValue(entry.getValue()); - vnfInputParameters.addParamItem(paramItem); - } - } - if (homing) { - License license = vnf.getLicense(); - if (license != null) { - if (license.getEntitlementPoolUuids() != null && !license.getEntitlementPoolUuids().isEmpty()) { - String entitlementPoolUuid = license.getEntitlementPoolUuids().get(0); - GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); - paramItem.setName("entitlement_assignment_group_uuid"); - paramItem.setValue(entitlementPoolUuid); - vnfInputParameters.addParamItem(paramItem); - } - if (license.getLicenseKeyGroupUuids() != null && !license.getLicenseKeyGroupUuids().isEmpty()) { - String licenseKeyGroupUuid = license.getLicenseKeyGroupUuids().get(0); - GenericResourceApiParamParam paramItem2 = new GenericResourceApiParamParam(); - paramItem2.setName("license_assignment_group_uuid"); - paramItem2.setValue(licenseKeyGroupUuid); - vnfInputParameters.addParamItem(paramItem2); - } - } - } - List instanceGroups = vnf.getInstanceGroups(); - List networkInstanceGroupIdList = - new ArrayList<>(); - - for (InstanceGroup instanceGroup : instanceGroups) { - if (ModelInfoInstanceGroup.TYPE_L3_NETWORK - .equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { - GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds instanceGroupId = - new GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds(); - instanceGroupId.setVnfNetworkInstanceGroupId(instanceGroup.getId()); - networkInstanceGroupIdList.add(instanceGroupId); - } - } - - vnfRequestInput.setVnfNetworkInstanceGroupIds(networkInstanceGroupIdList); - vnfRequestInput.setVnfInputParameters(vnfInputParameters); - req.setVnfRequestInput(vnfRequestInput); - return req; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java deleted file mode 100644 index 9b857dc08c..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import org.onap.so.client.dmaap.DmaapConsumer; -import org.onap.so.client.dmaap.DmaapPublisher; -import org.onap.so.client.sdno.beans.AAIParamList; -import org.onap.so.client.sdno.beans.Body; -import org.onap.so.client.sdno.beans.Input; -import org.onap.so.client.sdno.beans.RequestHdCustom; -import org.onap.so.client.sdno.beans.SDNO; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class SDNOHealthCheckClient { - - private static final String NODE_TYPE = "VROUTER"; - private static final String API_OPERATION_TYPE = "health-diagnostic-custom"; - private static final String MIRRORING_CHECK = "mirroring_check"; - private static final String CLIENT_NAME = "MSO"; - private static final String PRE_CHECK_CODE = "VROUTER000003"; - private static final String POST_CHECK_CODE = "VROUTER000004"; - private static final String LPORT_MIRRORING_CHECK = "lport_mirroring_check"; - private static final String CONFIGURATION_ID = "configuration-id"; - - - public boolean lPortMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId) throws Exception { - String request = buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); - return this.execute(requestId, request); - } - - public boolean lPortMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId) throws Exception { - String request = buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); - return this.execute(requestId, request); - } - - public boolean portMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, - String configurationId) throws Exception { - final String request = this.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); - return this.execute(requestId, request); - } - - public boolean portMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, - String configurationId) throws Exception { - final String request = this.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); - return this.execute(requestId, request); - } - - protected String buildLPortMirrorCheckPreRequest(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId) throws JsonProcessingException { - return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, - PRE_CHECK_CODE); - } - - protected String buildLPortMirrorCheckPostRequest(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId) throws JsonProcessingException { - return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, - POST_CHECK_CODE); - } - - protected String buildPortMirrorPreCheckRequest(String userId, String requestId, Optional clliCode, - String configurationId) throws JsonProcessingException { - return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, PRE_CHECK_CODE); - } - - protected String buildPortMirrorPostCheckRequest(String userId, String requestId, Optional clliCode, - String configurationId) throws JsonProcessingException { - return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, POST_CHECK_CODE); - } - - protected String buildPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, - String configurationId, String diagnosticCode) throws JsonProcessingException { - final AAIParamList list = new AAIParamList(); - list.setKey(CONFIGURATION_ID); - list.setValue(configurationId); - - return this.buildRequest(userId, requestId, clliCode, diagnosticCode, MIRRORING_CHECK, - Collections.singletonList(list)); - } - - protected String buildLPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, - String configurationId, String interfaceId, String diagnosticCode) throws JsonProcessingException { - - final AAIParamList configurationIdParam = new AAIParamList(); - configurationIdParam.setKey(CONFIGURATION_ID); - configurationIdParam.setValue(configurationId); - final AAIParamList interfaceIdParam = new AAIParamList(); - interfaceIdParam.setKey("interface-id"); - interfaceIdParam.setValue(interfaceId); - final List list = new ArrayList<>(); - list.add(configurationIdParam); - list.add(interfaceIdParam); - return this.buildRequest(userId, requestId, clliCode, diagnosticCode, LPORT_MIRRORING_CHECK, list); - } - - - protected String buildRequest(String userId, String requestId, Optional clliCode, String diagnosticCode, - String operationType, List paramList) throws JsonProcessingException { - - final RequestHdCustom hdCustom = new RequestHdCustom(); - hdCustom.withRequestUserId(userId).withRequestId(requestId).withRequestClientName(CLIENT_NAME) - .withHealthDiagnosticCode(diagnosticCode).withOperationType(operationType).withAaiParamList(paramList); - - final Input input = new Input(); - input.setRequestHdCustom(hdCustom); - final Body body = new Body(); - body.setInput(input); - final SDNO request = new SDNO(); - request.withBody(body).withOperation(API_OPERATION_TYPE).withNodeType(NODE_TYPE); - if (clliCode.isPresent()) { - request.setNodeLoc(clliCode.get()); - } - return this.getJson(request); - - } - - protected String getJson(SDNO obj) throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(obj); - } - - protected DmaapPublisher getPublisher() throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapPublisher(); - } - - protected DmaapConsumer getConsumer(String requestId) throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapConsumer(requestId); - } - - protected boolean execute(String requestId, String request) throws Exception { - final DmaapPublisher publisher = this.getPublisher(); - publisher.send(request); - - final DmaapConsumer consumer = this.getConsumer(requestId); - - return consumer.consume(); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java deleted file mode 100644 index 83624dec63..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno; - -import java.io.IOException; -import java.util.UUID; -import org.onap.aai.domain.yang.GenericVnf; - -public interface SDNOValidator { - - /** - * Issues a health diagnostic request for a given vnf to SDN-O - * - * @param vnfId - * @param uuid - * @param requestingUserId - * @return diagnostic result - * @throws IOException - * @throws Exception - */ - public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception; - - - /** - * Issues a health diagnostic request for a given GenericVnf to SDN-O - * - * @param genericVnf - * @param uuid - * @param requestingUserId - * @return diagnostic result - * @throws IOException - * @throws Exception - */ - public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) - throws IOException, Exception; - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java deleted file mode 100644 index 9fc95a6f3f..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; -import java.util.UUID; -import javax.ws.rs.NotFoundException; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aaiclient.client.aai.AAIObjectType; -import org.onap.aaiclient.client.aai.AAIResourcesClient; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; -import org.onap.so.client.dmaap.DmaapConsumer; -import org.onap.so.client.dmaap.DmaapPublisher; -import org.onap.so.client.sdno.beans.Body; -import org.onap.so.client.sdno.beans.Input; -import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; -import org.onap.so.client.sdno.beans.SDNO; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class SDNOValidatorImpl implements SDNOValidator { - - private final static String clientName = "MSO"; - private final static String HEALTH_DIAGNOSTIC_CODE_DEFAULT = "default"; - - @Override - public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception { - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); - AAIResourcesClient client = new AAIResourcesClient(); - GenericVnf vnf = client.get(GenericVnf.class, uri) - .orElseThrow(() -> new NotFoundException(vnfId + " not found in A&AI")); - - SDNO requestDiagnostic = buildRequestDiagnostic(vnf, uuid, requestingUserId); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(requestDiagnostic); - this.submitRequest(json); - boolean status = this.pollForResponse(uuid.toString()); - return status; - } - - @Override - public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) - throws IOException, Exception { - - SDNO requestDiagnostic = buildRequestDiagnostic(genericVnf, uuid, requestingUserId); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(requestDiagnostic); - this.submitRequest(json); - boolean status = this.pollForResponse(uuid.toString()); - return status; - } - - protected SDNO buildRequestDiagnostic(GenericVnf vnf, UUID uuid, String requestingUserId) { - - Optional nfRole; - if (vnf.getNfRole() == null) { - nfRole = Optional.empty(); - } else { - nfRole = Optional.of(vnf.getNfRole()); - } - Input input = new Input(); - SDNO parentRequest = new SDNO(); - Body body = new Body(); - parentRequest.setBody(body); - parentRequest.setNodeType(nfRole.orElse("NONE").toUpperCase()); - parentRequest.setOperation("health-diagnostic"); - - body.setInput(input); - - RequestHealthDiagnostic request = new RequestHealthDiagnostic(); - - request.setRequestClientName(clientName); - request.setRequestNodeName(vnf.getVnfName()); - request.setRequestNodeUuid(vnf.getVnfId()); - request.setRequestNodeType(nfRole.orElse("NONE").toUpperCase()); - request.setRequestNodeIp(vnf.getIpv4OamAddress()); // generic-vnf oam ip - request.setRequestUserId(requestingUserId); // mech id? - request.setRequestId(uuid.toString()); // something to identify this request by for polling - request.setHealthDiagnosticCode(HEALTH_DIAGNOSTIC_CODE_DEFAULT); - - input.setRequestHealthDiagnostic(request); - - return parentRequest; - } - - protected void submitRequest(String json) throws FileNotFoundException, IOException, InterruptedException { - - DmaapPublisher publisher = new SDNOHealthCheckDmaapPublisher(); - publisher.send(json); - } - - protected boolean pollForResponse(String uuid) throws Exception { - DmaapConsumer consumer = this.getConsumer(uuid); - return consumer.consume(); - } - - - - protected DmaapConsumer getConsumer(String uuid) throws FileNotFoundException, IOException { - return new SDNOHealthCheckDmaapConsumer(uuid); - } - - - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java deleted file mode 100644 index 7e98355b4d..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"key", "value"}) -public class AAIParamList { - - @JsonProperty("key") - private String key; - @JsonProperty("value") - private String value; - - /** - * No args constructor for use in serialization - * - */ - public AAIParamList() {} - - /** - * - * @param value - * @param key - */ - public AAIParamList(String key, String value) { - super(); - this.key = key; - this.value = value; - } - - @JsonProperty("key") - public String getKey() { - return key; - } - - @JsonProperty("key") - public void setKey(String key) { - this.key = key; - } - - public AAIParamList withKey(String key) { - this.key = key; - return this; - } - - @JsonProperty("value") - public String getValue() { - return value; - } - - @JsonProperty("value") - public void setValue(String value) { - this.value = value; - } - - public AAIParamList withValue(String value) { - this.value = value; - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java deleted file mode 100644 index 8c40b749a6..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"input"}) -public class Body implements Serializable { - - @JsonProperty("input") - private Input input; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private static final long serialVersionUID = 9101706044452851559L; - - @JsonProperty("input") - public Input getInput() { - return input; - } - - @JsonProperty("input") - public void setInput(Input input) { - this.input = input; - } - - public Body withInput(Input input) { - this.input = input; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public Body withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java deleted file mode 100644 index c8122c06f6..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"request-healthdiagnostic", "request-hd-custom"}) -public class Input implements Serializable { - - @JsonProperty("request-healthdiagnostic") - private RequestHealthDiagnostic RequestHealthDiagnostic; - @JsonProperty("request-hd-custom") - private RequestHdCustom requestHdCustom; - - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = 7155546785389227528L; - - @JsonProperty("request-healthdiagnostic") - public RequestHealthDiagnostic getRequestHealthDiagnostic() { - return RequestHealthDiagnostic; - } - - @JsonProperty("request-healthdiagnostic") - public void setRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { - this.RequestHealthDiagnostic = RequestHealthDiagnostic; - } - - @JsonProperty("request-hd-custom") - public RequestHdCustom getRequestHdCustom() { - return requestHdCustom; - } - - @JsonProperty("request-hd-custom") - public void setRequestHdCustom(RequestHdCustom requestHdCustom) { - this.requestHdCustom = requestHdCustom; - } - - public Input withRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { - this.RequestHealthDiagnostic = RequestHealthDiagnostic; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public Input withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java deleted file mode 100644 index 485f64673f..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno.beans; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"request-client-name", "request-user-id", "request-id", "health-diagnostic-code", "operation-type", - "send-detailed-cmd-response", "aai-param-list"}) -public class RequestHdCustom implements Serializable { - - /** - * - */ - private static final long serialVersionUID = -206110458275127710L; - @JsonProperty("request-client-name") - private String requestClientName; - @JsonProperty("request-user-id") - private String requestUserId; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("health-diagnostic-code") - private String healthDiagnosticCode; - @JsonProperty("operation-type") - private String operationType; - @JsonProperty("send-detailed-cmd-response") - private String sendDetailedCmdResponse = "false"; - @JsonProperty("aai-param-list") - private List aaiParamList = new ArrayList<>(); - - /** - * No args constructor for use in serialization - * - */ - public RequestHdCustom() {} - - /** - * - * @param requestClientName - * @param operationType - * @param requestId - * @param healthDiagnosticCode - * @param aaiParamList - * @param requestUserId - */ - public RequestHdCustom(String requestClientName, String requestUserId, String requestId, - String healthDiagnosticCode, String operationType, List aaiParamList) { - super(); - this.requestClientName = requestClientName; - this.requestUserId = requestUserId; - this.requestId = requestId; - this.healthDiagnosticCode = healthDiagnosticCode; - this.operationType = operationType; - this.aaiParamList = aaiParamList; - } - - @JsonProperty("request-client-name") - public String getRequestClientName() { - return requestClientName; - } - - @JsonProperty("request-client-name") - public void setRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - } - - public RequestHdCustom withRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - return this; - } - - @JsonProperty("request-user-id") - public String getRequestUserId() { - return requestUserId; - } - - @JsonProperty("request-user-id") - public void setRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - } - - public RequestHdCustom withRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - return this; - } - - @JsonProperty("request-id") - public String getRequestId() { - return requestId; - } - - @JsonProperty("request-id") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public RequestHdCustom withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - @JsonProperty("health-diagnostic-code") - public String getHealthDiagnosticCode() { - return healthDiagnosticCode; - } - - @JsonProperty("health-diagnostic-code") - public void setHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - } - - public RequestHdCustom withHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - return this; - } - - @JsonProperty("operation-type") - public String getOperationType() { - return operationType; - } - - @JsonProperty("operation-type") - public void setOperationType(String operationType) { - this.operationType = operationType; - } - - public RequestHdCustom withOperationType(String operationType) { - this.operationType = operationType; - return this; - } - - public void setSendDetailedCmdResponse(String sendDetailedCmdResponse) { - this.sendDetailedCmdResponse = sendDetailedCmdResponse; - } - - public String getSendDetailedCmdResponse() { - return sendDetailedCmdResponse; - } - - public RequestHdCustom withSendDetailedCmdResponse(String sendDetailedCmdResponse) { - this.sendDetailedCmdResponse = sendDetailedCmdResponse; - return this; - } - - @JsonProperty("aai-param-list") - public List getAaiParamList() { - return aaiParamList; - } - - @JsonProperty("aai-param-list") - public void setAaiParamList(List aaiParamList) { - this.aaiParamList = aaiParamList; - } - - public RequestHdCustom withAaiParamList(List aaiParamList) { - this.aaiParamList = aaiParamList; - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java deleted file mode 100644 index b1b75ab412..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"request-client-name", "request-node-name", "request-node-uuid", "request-node-ip", "request-id", - "request-user-id", "request-node-type", "health-diagnostic-code"}) -public class RequestHealthDiagnostic implements Serializable { - - @JsonProperty("request-client-name") - private String requestClientName; - @JsonProperty("request-node-name") - private String requestNodeName; - @JsonProperty("request-node-uuid") - private String requestNodeUuid; - @JsonProperty("request-node-ip") - private String requestNodeIp; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("request-user-id") - private String requestUserId; - @JsonProperty("request-node-type") - private String requestNodeType; - @JsonProperty("health-diagnostic-code") - private String healthDiagnosticCode; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private static final long serialVersionUID = 1166788526178388021L; - - @JsonProperty("request-client-name") - public String getRequestClientName() { - return requestClientName; - } - - @JsonProperty("request-client-name") - public void setRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - } - - public RequestHealthDiagnostic withRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - return this; - } - - @JsonProperty("request-node-name") - public String getRequestNodeName() { - return requestNodeName; - } - - @JsonProperty("request-node-name") - public void setRequestNodeName(String requestNodeName) { - this.requestNodeName = requestNodeName; - } - - public RequestHealthDiagnostic withRequestNodeName(String requestNodeName) { - this.requestNodeName = requestNodeName; - return this; - } - - @JsonProperty("request-node-uuid") - public String getRequestNodeUuid() { - return requestNodeUuid; - } - - @JsonProperty("request-node-uuid") - public void setRequestNodeUuid(String requestNodeUuid) { - this.requestNodeUuid = requestNodeUuid; - } - - public RequestHealthDiagnostic withRequestNodeUuid(String requestNodeUuid) { - this.requestNodeUuid = requestNodeUuid; - return this; - } - - @JsonProperty("request-node-ip") - public String getRequestNodeIp() { - return requestNodeIp; - } - - @JsonProperty("request-node-ip") - public void setRequestNodeIp(String requestNodeIp) { - this.requestNodeIp = requestNodeIp; - } - - public RequestHealthDiagnostic withRequestNodeIp(String requestNodeIp) { - this.requestNodeIp = requestNodeIp; - return this; - } - - @JsonProperty("request-id") - public String getRequestId() { - return requestId; - } - - @JsonProperty("request-id") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public RequestHealthDiagnostic withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - @JsonProperty("request-user-id") - public String getRequestUserId() { - return requestUserId; - } - - @JsonProperty("request-user-id") - public void setRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - } - - public RequestHealthDiagnostic withRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - return this; - } - - @JsonProperty("request-node-type") - public String getRequestNodeType() { - return requestNodeType; - } - - @JsonProperty("request-node-type") - public void setRequestNodeType(String requestNodeType) { - this.requestNodeType = requestNodeType; - } - - public RequestHealthDiagnostic withRequestNodeType(String requestNodeType) { - this.requestNodeType = requestNodeType; - return this; - } - - @JsonProperty("health-diagnostic-code") - public String getHealthDiagnosticCode() { - return healthDiagnosticCode; - } - - @JsonProperty("health-diagnostic-code") - public void setHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - } - - public RequestHealthDiagnostic withHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public RequestHealthDiagnostic withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java deleted file mode 100644 index 8b84cf6659..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno.beans; - -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"client-name", "code", "processing-host", "request-id", "status"}) -public class ResultInfo { - - @JsonProperty("client-name") - private String clientName; - @JsonProperty("code") - private String code; - @JsonProperty("processing-host") - private String processingHost; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("status") - private String status; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - - @JsonProperty("client-name") - public String getClientName() { - return clientName; - } - - @JsonProperty("client-name") - public void setClientName(String clientName) { - this.clientName = clientName; - } - - @JsonProperty("code") - public String getCode() { - return code; - } - - @JsonProperty("code") - public void setCode(String code) { - this.code = code; - } - - @JsonProperty("processing-host") - public String getProcessingHost() { - return processingHost; - } - - @JsonProperty("processing-host") - public void setProcessingHost(String processingHost) { - this.processingHost = processingHost; - } - - @JsonProperty("request-id") - public String getRequestId() { - return requestId; - } - - @JsonProperty("request-id") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - @JsonProperty("status") - public String getStatus() { - return status; - } - - @JsonProperty("status") - public void setStatus(String status) { - this.status = status; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java deleted file mode 100644 index 46e2c1d1fc..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"operation", "nodeLoc", "nodeType", "body"}) -public class SDNO implements Serializable { - - @JsonProperty("operation") - private String operation; - @JsonProperty("nodeLoc") - private String nodeLoc; - @JsonProperty("nodeType") - private String nodeType; - @JsonProperty("body") - private Body body; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private static final long serialVersionUID = -5303297382564282650L; - - @JsonProperty("operation") - public String getOperation() { - return operation; - } - - @JsonProperty("operation") - public void setOperation(String operation) { - this.operation = operation; - } - - @JsonProperty("nodeLoc") - public String getNodeLoc() { - return nodeLoc; - } - - @JsonProperty("nodeLoc") - public void setNodeLoc(String nodeLoc) { - this.nodeLoc = nodeLoc; - } - - public SDNO withNodeLoc(String nodeLoc) { - this.nodeLoc = nodeLoc; - return this; - } - - public SDNO withOperation(String operation) { - this.operation = operation; - return this; - } - - @JsonProperty("nodeType") - public String getNodeType() { - return nodeType; - } - - @JsonProperty("nodeType") - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - public SDNO withNodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - @JsonProperty("body") - public Body getBody() { - return body; - } - - @JsonProperty("body") - public void setBody(Body body) { - this.body = body; - } - - public SDNO withBody(Body body) { - this.body = body; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public void setAdditionalProperties(Map map) { - this.additionalProperties = map; - } - - public SDNO SDNO(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java new file mode 100644 index 0000000000..d4f1660986 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GCTopologyOperationRequestMapperTest.java @@ -0,0 +1,83 @@ +/*- + * ============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.infrastructure.sdnc.mapper; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; +import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; + +@RunWith(MockitoJUnitRunner.Silent.class) +public class GCTopologyOperationRequestMapperTest extends TestDataSetup { + + + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private GCTopologyOperationRequestMapper genObjMapper = new GCTopologyOperationRequestMapper(); + + @Test + public void deactivateOrUnassignVnrReqMapperTest() throws URISyntaxException { + RequestContext requestContext = new RequestContext(); + requestContext.setMsoRequestId("MsoRequestId"); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("ServiceInstanceId"); + Configuration Configuration = new Configuration(); + Configuration.setConfigurationId("ConfigurationId"); + Configuration.setConfigurationType("VLAN-NETWORK-RECEPTOR"); + GenericResourceApiGcTopologyOperationInformation genericInfo = + genObjMapper.deactivateOrUnassignVnrReqMapper(SDNCSvcAction.UNASSIGN, serviceInstance, requestContext, + Configuration, "uuid", new URI("http://localhost")); + + Assert.assertNotNull(genericInfo); + Assert.assertNotNull(genericInfo.getRequestInformation()); + Assert.assertNotNull(genericInfo.getSdncRequestHeader()); + Assert.assertNotNull(genericInfo.getClass()); + Assert.assertNotNull(genericInfo.getServiceInformation()); + Assert.assertEquals("ConfigurationId", genericInfo.getConfigurationInformation().getConfigurationId()); + Assert.assertEquals("VLAN-NETWORK-RECEPTOR", genericInfo.getConfigurationInformation().getConfigurationType()); + Assert.assertEquals("uuid", genericInfo.getSdncRequestHeader().getSvcRequestId()); + Assert.assertEquals("http://localhost", genericInfo.getSdncRequestHeader().getSvcNotificationUrl()); + Assert.assertEquals("MsoRequestId", genericInfo.getRequestInformation().getRequestId()); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java new file mode 100644 index 0000000000..92fc13b633 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/GeneralTopologyObjectMapperTest.java @@ -0,0 +1,447 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import java.util.HashMap; +import java.util.Map; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; +import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; + + +public class GeneralTopologyObjectMapperTest extends TestDataSetup { + @InjectMocks + private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void before() { + + } + + @After + public void after() { + + } + + @Test + public void testBuildServiceInformation() { + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + // prepare Customer object + Customer customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + ServiceSubscription serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType("productFamilyId"); + customer.setServiceSubscription(serviceSubscription); + // set Customer on service instance + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + // + RequestContext requestContext = new RequestContext(); + Map userParams = new HashMap<>(); + userParams.put("key1", "value1"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + + GenericResourceApiServiceinformationServiceInformation serviceInfo = + genObjMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); + + assertEquals("serviceModelInvariantUuid", serviceInfo.getOnapModelInformation().getModelInvariantUuid()); + assertEquals("serviceModelName", serviceInfo.getOnapModelInformation().getModelName()); + assertEquals("serviceModelUuid", serviceInfo.getOnapModelInformation().getModelUuid()); + assertEquals("serviceModelVersion", serviceInfo.getOnapModelInformation().getModelVersion()); + assertNull(serviceInfo.getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("serviceInstanceId", serviceInfo.getServiceInstanceId()); + assertEquals("serviceInstanceId", serviceInfo.getServiceId()); + assertEquals("globalCustomerId", serviceInfo.getGlobalCustomerId()); + assertEquals("productFamilyId", serviceInfo.getSubscriptionServiceType()); + } + + @Test + public void buildSdncRequestHeaderActivateTest() { + GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = + genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ACTIVATE, "sdncReqId"); + + assertEquals(GenericResourceApiSvcActionEnumeration.ACTIVATE, requestHeader.getSvcAction()); + assertEquals("sdncReqId", requestHeader.getSvcRequestId()); + } + + @Test + public void buildSdncRequestHeaderAssignTest() { + GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = + genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ASSIGN, "sdncReqId"); + + assertEquals(GenericResourceApiSvcActionEnumeration.ASSIGN, requestHeader.getSvcAction()); + assertEquals("sdncReqId", requestHeader.getSvcRequestId()); + } + + @Test + public void buildSdncRequestHeaderDeactivateTest() { + GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = + genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DEACTIVATE, "sdncReqId"); + + assertEquals(GenericResourceApiSvcActionEnumeration.DEACTIVATE, requestHeader.getSvcAction()); + assertEquals("sdncReqId", requestHeader.getSvcRequestId()); + } + + @Test + public void buildSdncRequestHeaderDeleteTest() { + GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = + genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DELETE, "sdncReqId"); + + assertEquals(GenericResourceApiSvcActionEnumeration.DELETE, requestHeader.getSvcAction()); + assertEquals("sdncReqId", requestHeader.getSvcRequestId()); + } + + @Test + public void buildSdncRequestHeaderChangeAssignTest() { + GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = + genObjMapper.buildSdncRequestHeader(SDNCSvcAction.CHANGE_ASSIGN, "sdncReqId"); + + assertEquals(GenericResourceApiSvcActionEnumeration.CHANGEASSIGN, requestHeader.getSvcAction()); + assertEquals("sdncReqId", requestHeader.getSvcRequestId()); + } + + @Test + public void buildConfigurationInformationTest_excludesOnapModelInfo() { + Configuration configuration = new Configuration(); + configuration.setConfigurationId("testConfigurationId"); + configuration.setConfigurationType("VNR"); + configuration.setConfigurationName("VNRCONF"); + GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = + genObjMapper.buildConfigurationInformation(configuration, false); + assertEquals(configuration.getConfigurationId(), configurationInformation.getConfigurationId()); + assertEquals(configuration.getConfigurationType(), configurationInformation.getConfigurationType()); + assertEquals(configuration.getConfigurationName(), configurationInformation.getConfigurationName()); + assertNull(configurationInformation.getOnapModelInformation()); + } + + @Test + public void buildConfigurationInformationTest_includesOnapModelInfo() { + Configuration configuration = new Configuration(); + configuration.setConfigurationId("testConfigurationId"); + configuration.setConfigurationType("VNR"); + configuration.setConfigurationName("VNRCONF"); + ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); + modelInfoConfiguration.setModelVersionId("modelVersionId"); + modelInfoConfiguration.setModelInvariantId("modelInvariantId"); + modelInfoConfiguration.setModelCustomizationId("modelCustomizationId"); + configuration.setModelInfoConfiguration(modelInfoConfiguration); + + GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = + genObjMapper.buildConfigurationInformation(configuration, true); + + assertEquals(configuration.getConfigurationId(), configurationInformation.getConfigurationId()); + assertEquals(configuration.getConfigurationType(), configurationInformation.getConfigurationType()); + assertEquals(configuration.getConfigurationName(), configurationInformation.getConfigurationName()); + assertNotNull(configurationInformation.getOnapModelInformation()); + assertEquals(configuration.getModelInfoConfiguration().getModelVersionId(), + configurationInformation.getOnapModelInformation().getModelUuid()); + assertEquals(configuration.getModelInfoConfiguration().getModelInvariantId(), + configurationInformation.getOnapModelInformation().getModelInvariantUuid()); + assertEquals(configuration.getModelInfoConfiguration().getModelCustomizationId(), + configurationInformation.getOnapModelInformation().getModelCustomizationUuid()); + + } + + @Test + public void buildGcRequestInformationTest() { + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("TestVnfId"); + GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = + genObjMapper.buildGcRequestInformation(vnf, null); + assertNotNull(gcRequestInput); + assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId()); + assertNull(gcRequestInput.getInputParameters()); + } + + @Test + public void buildGcRequestInformationTest_withInputParams() { + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("TestVnfId"); + GenericResourceApiParam genericResourceApiParam = new GenericResourceApiParam(); + genericResourceApiParam.addParamItem(new GenericResourceApiParamParam()); + GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = + genObjMapper.buildGcRequestInformation(vnf, genericResourceApiParam); + assertNotNull(gcRequestInput); + assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId()); + assertNotNull(gcRequestInput.getInputParameters()); + } + + @Test + public void buildVnfInformationTest_withNullData() { + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("TestVnfId"); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + GenericResourceApiVnfinformationVnfInformation gcRequestInput = + genObjMapper.buildVnfInformation(vnf, serviceInstance, true); + assertNotNull(gcRequestInput); + assertNull(vnf.getModelInfoGenericVnf()); + assertNull(gcRequestInput.getOnapModelInformation()); + assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId()); + assertNotNull(gcRequestInput.getVnfId()); + } + + @Test + public void buildNetworkInformationTest() { + + L3Network network = new L3Network(); + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); + modelInfoNetwork.setModelInvariantUUID("my-uuid"); + modelInfoNetwork.setModelName("my-model-name"); + modelInfoNetwork.setModelVersion("my-model-version"); + modelInfoNetwork.setModelUUID("my-model-uuid"); + modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid"); + network.setModelInfoNetwork(modelInfoNetwork); + network.setNetworkId("my-network-id"); + network.setNetworkType("my-network-type"); + network.setNetworkTechnology("my-network-technology"); + + GenericResourceApiNetworkinformationNetworkInformation networkInformation = + new GenericResourceApiNetworkinformationNetworkInformation(); + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = + new GenericResourceApiOnapmodelinformationOnapModelInformation(); + networkInformation.setNetworkId("my-network-id"); + networkInformation.setNetworkType("my-network-type"); + networkInformation.networkTechnology("my-network-technology"); + networkInformation.setFromPreload(null); + onapModelInformation.setModelInvariantUuid("my-uuid"); + onapModelInformation.setModelName("my-model-name"); + onapModelInformation.setModelVersion("my-model-version"); + onapModelInformation.setModelUuid("my-model-uuid"); + onapModelInformation.setModelCustomizationUuid("my-customization-uuid"); + networkInformation.setOnapModelInformation(onapModelInformation); + + assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); + + } + + @Test + public void buildNetworkInformationNoModelTest() { + + L3Network network = new L3Network(); + network.setNetworkId("my-network-id"); + network.setNetworkType("my-network-type"); + network.setNetworkTechnology("my-network-technology"); + + GenericResourceApiNetworkinformationNetworkInformation networkInformation = + new GenericResourceApiNetworkinformationNetworkInformation(); + networkInformation.setNetworkId("my-network-id"); + networkInformation.setNetworkType("my-network-type"); + networkInformation.networkTechnology("my-network-technology"); + networkInformation.setFromPreload(null); + + + assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); + + } + + + @Test + public void buildVfModuleInformationTest_withNoModelIsFromPreload() { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("TestVfModuleId"); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId("TestVnfId"); + RequestContext requestContext = new RequestContext(); + RequestParameters requestParameters = new RequestParameters(); + requestParameters.setUsePreload(true); + requestContext.setRequestParameters(requestParameters); + GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; + try { + gcRequestInput = + genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false); + } catch (MapperException ex) { + + } + assertNotNull(gcRequestInput); + assertNull(vfModule.getModelInfoVfModule()); + assertNull(gcRequestInput.getOnapModelInformation()); + assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); + assertNotNull(gcRequestInput.getVfModuleId()); + assertTrue(gcRequestInput.getFromPreload()); + } + + @Test + public void buildVfModuleInformationTest_withNoModelIsNotFromPreload() { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("TestVfModuleId"); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId("TestVnfId"); + RequestContext requestContext = new RequestContext(); + RequestParameters requestParameters = new RequestParameters(); + requestParameters.setUsePreload(false); + requestContext.setRequestParameters(requestParameters); + GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; + try { + gcRequestInput = + genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false); + } catch (MapperException ex) { + + } + assertNotNull(gcRequestInput); + assertNull(vfModule.getModelInfoVfModule()); + assertNull(gcRequestInput.getOnapModelInformation()); + assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); + assertNotNull(gcRequestInput.getVfModuleId()); + assertFalse(gcRequestInput.getFromPreload()); + } + + @Test + public void buildVfModuleInformationTest_withNoModelNoRequestContext() { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("TestVfModuleId"); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId("TestVnfId"); + GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; + try { + gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, null, false); + } catch (MapperException ex) { + + } + assertNotNull(gcRequestInput); + assertNull(vfModule.getModelInfoVfModule()); + assertNull(gcRequestInput.getOnapModelInformation()); + assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); + assertNotNull(gcRequestInput.getVfModuleId()); + assertTrue(gcRequestInput.getFromPreload()); + } + + @Test + public void buildVfModuleInformationTest_withNoModelNoRequestParameters() { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("TestVfModuleId"); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId("TestVnfId"); + RequestContext requestContext = new RequestContext(); + GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; + try { + gcRequestInput = + genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false); + } catch (MapperException ex) { + + } + assertNotNull(gcRequestInput); + assertNull(vfModule.getModelInfoVfModule()); + assertNull(gcRequestInput.getOnapModelInformation()); + assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); + assertNotNull(gcRequestInput.getVfModuleId()); + assertTrue(gcRequestInput.getFromPreload()); + } + + @Test + public void buildVfModuleInformationTest_withModel() { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("TestVfModuleId"); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID"); + modelInfoVfModule.setModelName("testModelName"); + modelInfoVfModule.setModelVersion("testModelVersion"); + modelInfoVfModule.setModelUUID("testModelUUID"); + modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID"); + vfModule.setModelInfoVfModule(modelInfoVfModule); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId("TestVnfId"); + RequestContext requestContext = new RequestContext(); + RequestParameters requestParameters = new RequestParameters(); + requestParameters.setUsePreload(true); + requestContext.setRequestParameters(requestParameters); + GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; + try { + gcRequestInput = + genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, true); + } catch (MapperException ex) { + + } + assertNotNull(gcRequestInput); + assertNotNull(vfModule.getModelInfoVfModule()); + assertNotNull(gcRequestInput.getOnapModelInformation()); + assertEquals(modelInfoVfModule.getModelInvariantUUID(), + gcRequestInput.getOnapModelInformation().getModelInvariantUuid()); + assertEquals(modelInfoVfModule.getModelName(), gcRequestInput.getOnapModelInformation().getModelName()); + assertEquals(modelInfoVfModule.getModelVersion(), gcRequestInput.getOnapModelInformation().getModelVersion()); + assertEquals(modelInfoVfModule.getModelUUID(), gcRequestInput.getOnapModelInformation().getModelUuid()); + assertEquals(modelInfoVfModule.getModelCustomizationUUID(), + gcRequestInput.getOnapModelInformation().getModelCustomizationUuid()); + assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); + assertNotNull(gcRequestInput.getVfModuleId()); + assertTrue(gcRequestInput.getFromPreload()); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java new file mode 100644 index 0000000000..0952a35ab0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java @@ -0,0 +1,234 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class NetworkTopologyOperationRequestMapperTest { + + private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; + + private ServiceInstance serviceInstance; + private ServiceInstance serviceInstanceNoCollection; + private Customer customer; + private RequestContext requestContext; + private L3Network network; + private CloudRegion cloudRegion; + + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper(); + + @Before + public void before() { + // prepare and set service instance + serviceInstance = new ServiceInstance(); + serviceInstanceNoCollection = new ServiceInstance(); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid"); + modelInfoServiceInstance.setModelName("modelName"); + modelInfoServiceInstance.setModelUuid("modelUuid"); + modelInfoServiceInstance.setModelVersion("modelVersion"); + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + serviceInstanceNoCollection.setModelInfoServiceInstance(modelInfoServiceInstance); + // prepare Customer object + customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + // serviceInstance.setCustomer(customer); + // set Customer on service instance + ServiceSubscription serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType("productFamilyId"); + customer.setServiceSubscription(serviceSubscription); + + // set Customer on service instance + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + customer.getServiceSubscription().getServiceInstances().add(serviceInstanceNoCollection); + // + InstanceGroup networkInstanceGroup = new InstanceGroup(); + networkInstanceGroup.setId("networkInstanceGroupId"); + networkInstanceGroup.setInstanceGroupFunction("instanceGroupFunction"); + Collection networkCollection = new Collection(); + networkCollection.setInstanceGroup(networkInstanceGroup); + serviceInstance.setCollection(networkCollection); + // + requestContext = new RequestContext(); + Map userParams = new HashMap<>(); + userParams.put("key1", "value1"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + requestContext.setMsoRequestId("MsoRequestId"); + + network = new L3Network(); + network.setNetworkId("TEST_NETWORK_ID"); + network.setNetworkName("TEST_NETWORK_NAME"); + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); + modelInfoNetwork.setModelInvariantUUID("modelInvariantUuid"); + modelInfoNetwork.setModelName("modelName"); + modelInfoNetwork.setModelVersion("modelVersion"); + modelInfoNetwork.setModelUUID("modelUuid"); + modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID"); + network.setModelInfoNetwork(modelInfoNetwork); + + cloudRegion = new CloudRegion(); + } + + @Test + public void createGenericResourceApiNetworkOperationInformationTest() throws Exception { + + GenericResourceApiNetworkOperationInformation networkSDNCrequest = + mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); + + ObjectMapper omapper = new ObjectMapper(); + GenericResourceApiNetworkOperationInformation reqMapper1 = + omapper.readValue(getJson("genericResourceApiNetworkOperationInformation.json"), + GenericResourceApiNetworkOperationInformation.class); + + assertThat(networkSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId") + .ignoring("requestInformation.requestId")); + assertEquals("MsoRequestId", networkSDNCrequest.getRequestInformation().getRequestId()); + } + + @Test + public void createGenericResourceApiNetworkOperationInformationReqContextNullTest() throws Exception { + + RequestContext rc = new RequestContext(); + rc.setMsoRequestId(null); + GenericResourceApiNetworkOperationInformation networkSDNCrequest = + mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, + customer, rc, cloudRegion); + assertNotNull(networkSDNCrequest.getRequestInformation().getRequestId()); + GenericResourceApiNetworkOperationInformation networkSDNCrequest2 = + mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, + customer, null, cloudRegion); + assertNotNull(networkSDNCrequest2.getRequestInformation().getRequestId()); + } + + @Test + public void reqMapperTest() throws Exception { + + GenericResourceApiNetworkOperationInformation networkSDNCrequest = + mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); + + assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("modelCustomizationUUID", + networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid()); + } + + @Test + public void reqMapperNoCollectionTest() throws Exception { + GenericResourceApiNetworkOperationInformation networkSDNCrequest = + mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, + serviceInstanceNoCollection, customer, requestContext, cloudRegion); + + assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("modelCustomizationUUID", + networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid()); + } + + @Test + public void createGenericResourceApiNetworkOperationInformation_UnassignTest() throws Exception { + + NetworkTopologyOperationRequestMapper mapperUnassign = mapper; + GenericResourceApiNetworkOperationInformation networkSDNCrequestUnassign = + mapperUnassign.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, + GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); + + ObjectMapper omapperUnassign = new ObjectMapper(); + GenericResourceApiNetworkOperationInformation reqMapperUnassign = + omapperUnassign.readValue(getJson("genericResourceApiNetworkOperationInformationUnAssign.json"), + GenericResourceApiNetworkOperationInformation.class); + + assertThat(reqMapperUnassign, sameBeanAs(networkSDNCrequestUnassign).ignoring("sdncRequestHeader.svcRequestId") + .ignoring("requestInformation.requestId")); + assertEquals("MsoRequestId", networkSDNCrequestUnassign.getRequestInformation().getRequestId()); + + } + + @Test + public void createGenericResourceApiNetworkOperationInformationNoNetworkNameTest() throws Exception { + + // set network name NULL + network.setNetworkName(null); + GenericResourceApiNetworkOperationInformation networkSDNCrequest = + mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, + customer, requestContext, cloudRegion); + + ObjectMapper omapper = new ObjectMapper(); + GenericResourceApiNetworkOperationInformation reqMapper1 = + omapper.readValue(getJson("genericResourceApiNetworkOperationInformationNoNetworkName.json"), + GenericResourceApiNetworkOperationInformation.class); + + assertThat(reqMapper1, sameBeanAs(networkSDNCrequest).ignoring("sdncRequestHeader.svcRequestId") + .ignoring("requestInformation.requestId")); + } + + /* + * Helper method to load JSON data + */ + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename))); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java new file mode 100644 index 0000000000..bd5c234e50 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/ServiceTopologyOperationMapperTest.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class ServiceTopologyOperationMapperTest { + + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper(); + + @Test + public void reqMapperTest() throws Exception { + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid"); + modelInfoServiceInstance.setModelName("modelName"); + modelInfoServiceInstance.setModelUuid("modelUuid"); + modelInfoServiceInstance.setModelVersion("modelVersion"); + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + + // prepare Customer object + Customer customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + + customer.setServiceSubscription(new ServiceSubscription()); + // set Customer on service instance + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + + // prepare RequestContext + RequestContext requestContext = new RequestContext(); + Map userParams = new HashMap<>(); + userParams.put("key1", "value1"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + requestContext.setMsoRequestId("MsoRequestId"); + + GenericResourceApiServiceOperationInformation serviceOpInformation = + mapper.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, + requestContext); + GenericResourceApiServiceOperationInformation serviceOpInformationNullReqContext = mapper.reqMapper( + SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, null); + + String jsonToCompare = new String(Files.readAllBytes( + Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json"))); + + ObjectMapper omapper = new ObjectMapper(); + GenericResourceApiOnapmodelinformationOnapModelInformation reqMapper1 = + omapper.readValue(jsonToCompare, GenericResourceApiOnapmodelinformationOnapModelInformation.class); + + assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation())); + assertEquals("MsoRequestId", serviceOpInformation.getRequestInformation().getRequestId()); + assertNotNull(serviceOpInformationNullReqContext.getRequestInformation().getRequestId()); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java new file mode 100644 index 0000000000..e064300ab7 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -0,0 +1,404 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RunWith(MockitoJUnitRunner.class) +public class VfModuleTopologyOperationRequestMapperTest { + + private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; + private final static String ERRORMESSAGE = "VF Module model info is null for testVfModuleId"; + + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Test + public void assignGenericResourceApiVfModuleInformationTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + // prepare Customer object + Customer customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + ServiceSubscription serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType("productFamilyId"); + customer.setServiceSubscription(serviceSubscription); + + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + // + RequestContext requestContext = new RequestContext(); + Map userParams = new HashMap<>(); + userParams.put("key1", "value1"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + RequestParameters requestParameters = new RequestParameters(); + requestParameters.setUsePreload(true); + requestContext.setRequestParameters(requestParameters); + requestContext.setMsoRequestId("MsoRequestId"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("testVnfId"); + vnf.setVnfType("testVnfType"); + vnf.setVnfName("testVnfName"); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); + modelInfoGenericVnf.setModelName("vnfModelName"); + modelInfoGenericVnf.setModelVersion("vnfModelVersion"); + modelInfoGenericVnf.setModelUuid("vnfModelUuid"); + modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); + vnf.setModelInfoGenericVnf(modelInfoGenericVnf); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("testVfModuleId"); + vfModule.setVfModuleName("testVfModuleName"); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); + modelInfoVfModule.setModelName("vfModuleModelName"); + modelInfoVfModule.setModelVersion("vfModuleModelVersion"); + modelInfoVfModule.setModelUUID("vfModuleModelUuid"); + modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); + vfModule.setModelInfoVfModule(modelInfoVfModule); + HashMap cloudParams = new HashMap(); + cloudParams.put("key2", "value2"); + vfModule.setCloudParams(cloudParams); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + volumeGroup.setVolumeGroupName("volumeGroupName"); + + CloudRegion cloudRegion = new CloudRegion(); + + GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( + SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, + serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); + + String jsonToCompare = new String(Files.readAllBytes( + Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json"))); + + ObjectMapper omapper = new ObjectMapper(); + GenericResourceApiVfModuleOperationInformation reqMapper1 = + omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class); + + assertThat(vfModuleSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId") + .ignoring("requestInformation.requestId")); + assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId()); + } + + @Test + public void unassignGenericResourceApiVfModuleInformationTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + + // prepare and set vnf instance + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("testVnfId"); + vnf.setVnfType("testVnfType"); + + // prepare and set vf module instance + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("testVfModuleId"); + vfModule.setVfModuleName("testVfModuleName"); + + RequestContext requestContext = new RequestContext(); + requestContext.setMsoRequestId("MsoRequestId"); + + GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = + mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, + vnf, serviceInstance, null, null, requestContext, null, new URI("http://localhost:8080")); + + String jsonToCompare = new String(Files.readAllBytes( + Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json"))); + + ObjectMapper omapper = new ObjectMapper(); + GenericResourceApiVfModuleOperationInformation reqMapper1 = + omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class); + + assertThat(vfModuleSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId") + .ignoring("requestInformation.requestId")); + assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId()); + } + + @Test + public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + + // prepare and set vnf instance + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("testVnfId"); + vnf.setVnfType("testVnfType"); + + // prepare and set vf module instance + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("testVfModuleId"); + vfModule.setVfModuleName("testVfModuleName"); + + RequestContext requestContext = new RequestContext(); + + GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = + mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, + vnf, serviceInstance, null, null, requestContext, null, new URI("http://localhost:8080")); + + assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId()); + } + + @Test + public void reqMapperTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + // prepare Customer object + Customer customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + customer.setServiceSubscription(new ServiceSubscription()); + // set Customer on service instance + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + // + RequestContext requestContext = new RequestContext(); + RequestParameters requestParameters = new RequestParameters(); + HashMap userParams1 = new HashMap<>(); + userParams1.put("key1", "value1"); + List> userParams = new ArrayList<>(); + userParams.add(userParams1); + + requestParameters.setUserParams(userParams); + requestContext.setRequestParameters(requestParameters); + requestContext.setProductFamilyId("productFamilyId"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("testVnfId"); + vnf.setVnfType("testVnfType"); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); + modelInfoGenericVnf.setModelName("vnfModelName"); + modelInfoGenericVnf.setModelVersion("vnfModelVersion"); + modelInfoGenericVnf.setModelUuid("vnfModelUuid"); + modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); + vnf.setModelInfoGenericVnf(modelInfoGenericVnf); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("testVfModuleId"); + vfModule.setVfModuleName("testVfModuleName"); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); + modelInfoVfModule.setModelName("vfModuleModelName"); + modelInfoVfModule.setModelVersion("vfModuleModelVersion"); + modelInfoVfModule.setModelUUID("vfModuleModelUuid"); + modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); + vfModule.setModelInfoVfModule(modelInfoVfModule); + + CloudRegion cloudRegion = new CloudRegion(); + + GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( + SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, + serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); + + assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("vnfModelCustomizationUuid", + vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("vfModuleModelCustomizationUuid", + vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid()); + } + + @Test + public void reqMapperNoModelInfoTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + // prepare Customer object + Customer customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + customer.setServiceSubscription(new ServiceSubscription()); + // set Customer on service instance + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + // + RequestContext requestContext = new RequestContext(); + Map userParams = new HashMap(); + userParams.put("key1", "value1"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("testVnfId"); + vnf.setVnfType("testVnfType"); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); + modelInfoGenericVnf.setModelName("vnfModelName"); + modelInfoGenericVnf.setModelVersion("vnfModelVersion"); + modelInfoGenericVnf.setModelUuid("vnfModelUuid"); + modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); + vnf.setModelInfoGenericVnf(modelInfoGenericVnf); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("testVfModuleId"); + vfModule.setVfModuleName("testVfModuleName"); + vfModule.setModelInfoVfModule(null); + + CloudRegion cloudRegion = new CloudRegion(); + + expectedException.expect(MapperException.class); + expectedException.expectMessage(ERRORMESSAGE); + + mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, + serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); + } + + @Test + public void reqMapperChangeAssignTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + // prepare Customer object + Customer customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + customer.setServiceSubscription(new ServiceSubscription()); + // set Customer on service instance + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + // + RequestContext requestContext = new RequestContext(); + RequestParameters requestParameters = new RequestParameters(); + HashMap userParams1 = new HashMap<>(); + userParams1.put("key1", "value1"); + List> userParams = new ArrayList<>(); + userParams.add(userParams1); + + requestParameters.setUserParams(userParams); + requestContext.setRequestParameters(requestParameters); + requestContext.setProductFamilyId("productFamilyId"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("testVnfId"); + vnf.setVnfType("testVnfType"); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); + modelInfoGenericVnf.setModelName("vnfModelName"); + modelInfoGenericVnf.setModelVersion("vnfModelVersion"); + modelInfoGenericVnf.setModelUuid("vnfModelUuid"); + modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); + vnf.setModelInfoGenericVnf(modelInfoGenericVnf); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("testVfModuleId"); + vfModule.setVfModuleName("testVfModuleName"); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); + modelInfoVfModule.setModelName("vfModuleModelName"); + modelInfoVfModule.setModelVersion("vfModuleModelVersion"); + modelInfoVfModule.setModelUUID("vfModuleModelUuid"); + modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); + vfModule.setModelInfoVfModule(modelInfoVfModule); + + CloudRegion cloudRegion = new CloudRegion(); + + GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( + SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, + serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); + + assertEquals("vnfModelCustomizationUuid", + vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("vfModuleModelCustomizationUuid", + vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid()); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java new file mode 100644 index 0000000000..a042289281 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.mapper; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GeneralTopologyObjectMapper; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.generalobjects.License; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.client.sdnc.beans.SDNCSvcAction; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation; + +@RunWith(MockitoJUnitRunner.class) +public class VnfTopologyOperationRequestMapperTest { + + @Spy + private GeneralTopologyObjectMapper generalTopologyObjectMapper; + + @InjectMocks + private VnfTopologyOperationRequestMapper mapper = new VnfTopologyOperationRequestMapper(); + + @Test + public void reqMapperTest() throws Exception { + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid"); + modelInfoServiceInstance.setModelName("modelName"); + modelInfoServiceInstance.setModelUuid("modelUuid"); + modelInfoServiceInstance.setModelVersion("modelVersion"); + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + + // prepare VNF + ModelInfoGenericVnf genericVnf = new ModelInfoGenericVnf(); + genericVnf.setModelInvariantUuid("vnfModelInvariantUUID"); + genericVnf.setModelVersion("vnfModelVersion"); + genericVnf.setModelName("vnfModelName"); + genericVnf.setModelUuid("vnfModelUUID"); + genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID"); + + ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup(); + modelL3Network.setType("L3-NETWORK"); + + InstanceGroup instanceGroup1 = new InstanceGroup(); + instanceGroup1.setId("l3-network-ig-111"); + instanceGroup1.setModelInfoInstanceGroup(modelL3Network); + + InstanceGroup instanceGroup2 = new InstanceGroup(); + instanceGroup2.setId("l3-network-ig-222"); + instanceGroup2.setModelInfoInstanceGroup(modelL3Network); + + GenericVnf vnf = new GenericVnf(); + vnf.setModelInfoGenericVnf(genericVnf); + vnf.setVnfId("vnfId"); + vnf.setVnfType("vnfType"); + vnf.getInstanceGroups().add(instanceGroup1); + vnf.getInstanceGroups().add(instanceGroup2); + License license = new License(); + List entitlementPoolUuids = new ArrayList<>(); + entitlementPoolUuids.add("entitlementPoolUuid"); + List licenseKeyGroupUuids = new ArrayList<>(); + licenseKeyGroupUuids.add("licenseKeyGroupUuid"); + license.setEntitlementPoolUuids(entitlementPoolUuids); + license.setLicenseKeyGroupUuids(licenseKeyGroupUuids); + vnf.setLicense(license); + + // prepare Customer object + Customer customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + + ServiceSubscription serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType("productFamilyId"); + customer.setServiceSubscription(serviceSubscription); + + // set Customer on service instance + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + + + // prepare RequestContext + RequestContext requestContext = new RequestContext(); + Map userParams = new HashMap<>(); + userParams.put("key1", "value1"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + requestContext.setMsoRequestId("MsoRequestId"); + + CloudRegion cloudRegion = new CloudRegion(); + + GenericResourceApiVnfOperationInformation vnfOpInformation = + mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, + cloudRegion, requestContext, true, new URI("http://localhost:8080")); + GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = + mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, + GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, + cloudRegion, null, true, new URI("http://localhost:8080")); + + assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("vnfModelCustomizationUUID", + vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals(2, vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().size()); + assertEquals("l3-network-ig-111", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(0) + .getVnfNetworkInstanceGroupId()); + assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1) + .getVnfNetworkInstanceGroupId()); + assertEquals("entitlementPoolUuid", + vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue()); + assertEquals("licenseKeyGroupUuid", + vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue()); + assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId()); + assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId()); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java index 9049fe1965..3429a16f0b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCConfigurationResourcesTest.java @@ -35,6 +35,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.GCTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -45,7 +46,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCConfigurationResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java index 327bae5749..f86a712e33 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCNetworkResourcesTest.java @@ -32,6 +32,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.NetworkTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -42,7 +43,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.NetworkTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCNetworkResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java index ad05ac0072..4282b0d158 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCServiceInstanceResourcesTest.java @@ -35,6 +35,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.ServiceTopologyOperationMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -42,7 +43,6 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.ServiceTopologyOperationMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCServiceInstanceResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java index 14e993281a..813c2f7cd4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java @@ -33,6 +33,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VfModuleTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -43,8 +44,7 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VfModuleTopologyOperationRequestMapper;; +import org.onap.so.client.sdnc.beans.SDNCSvcOperation;; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVfModuleResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java index 0ccf056ddc..f9c380bc84 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java @@ -39,6 +39,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.common.data.TestDataSetup; +import org.onap.so.bpmn.infrastructure.sdnc.mapper.VnfTopologyOperationRequestMapper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -49,7 +50,6 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.client.sdnc.mapper.VnfTopologyOperationRequestMapper; @RunWith(MockitoJUnitRunner.Silent.class) public class SDNCVnfResourcesTest extends TestDataSetup { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java deleted file mode 100644 index a8816e1b04..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java +++ /dev/null @@ -1,104 +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.client.sdn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import java.util.LinkedHashMap; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.SdnCommonTasks; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; - - -public class SdnCommonTasksTest { - - - SdnCommonTasks sdnCommonTasks = new SdnCommonTasks(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void buildJsonRequestTest() throws MapperException { - String jsonStr = sdnCommonTasks.buildJsonRequest(""); - Assert.assertNotNull(jsonStr); - } - - @Test - public void buildJsonRequestTestException() throws MapperException { - expectedException.expect(MapperException.class); - sdnCommonTasks.buildJsonRequest(new Object()); - } - - @Test - public void getHttpHeadersTest() { - HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", true); - - assertEquals("auth", result.getFirst("Authorization")); - assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Content-Type")); - assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept")); - } - - @Test - public void getHttpHeadersGetRequestTest() { - HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", false); - - assertEquals("auth", result.getFirst("Authorization")); - assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept")); - assertFalse(result.containsKey("Content-Type")); - } - - @Test - public void validateSDNResponseTest() throws BadResponseException { - String jsonResponse = "{\"output\":{\"response-code\":\"0\",\"response-message\":\"success\"}}"; - LinkedHashMap responseMap = new LinkedHashMap<>(); - LinkedHashMap output = new LinkedHashMap<>(); - output.put("response-code", "0"); - output.put("response-message", "success"); - responseMap.put("output", output); - assertEquals(jsonResponse, sdnCommonTasks.validateSDNResponse(responseMap)); - } - - @Test - public void validateSDNResponseTestException() throws BadResponseException { - expectedException.expect(BadResponseException.class); - LinkedHashMap responseMap = new LinkedHashMap(); - Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap)); - } - - @Test - public void validateSDNResponseTestRespCodeNot200() throws BadResponseException { - expectedException.expect(BadResponseException.class); - LinkedHashMap responseMap = new LinkedHashMap<>(); - LinkedHashMap output = new LinkedHashMap<>(); - output.put("response-code", "300"); - output.put("response-message", "Failed"); - responseMap.put("output", output); - sdnCommonTasks.validateSDNResponse(responseMap); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java deleted file mode 100644 index 0b338bde1d..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java +++ /dev/null @@ -1,79 +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.client.sdnc; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; -import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; -import org.skyscreamer.jsonassert.JSONAssert; - -public class SDNCClientIT extends BaseIntegrationTest { - private final static String JSON_FILE_LOCATION = "src/test/resources/__files/"; - - @Test - public void getTest() throws BadResponseException, MapperException, IOException { - String responseJson = - new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json"))); - String queryLink = "/topologyQuery"; - - wireMockServer.stubFor(get(urlEqualTo(queryLink)).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); - String response = SPY_sdncClient.get(queryLink); - JSONAssert.assertEquals(responseJson, response, false); - } - - @Test(expected = BadResponseException.class) - public void post404Test() throws BadResponseException, MapperException, IOException { - String responseJson = - new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json"))); - - String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/"; - - wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); - - SPY_sdncClient.post("", SDNCTopology.NETWORK); - } - - @Test - public void post200Test() throws BadResponseException, MapperException, IOException { - String responseJson = - new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json"))); - - String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/"; - - wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn( - aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); - - String response = SPY_sdncClient.post("", SDNCTopology.NETWORK); - JSONAssert.assertEquals(responseJson, response, true); - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java deleted file mode 100644 index 0eb0304cdf..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GCTopologyOperationRequestMapperTest.java +++ /dev/null @@ -1,158 +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.client.sdnc.mapper; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation; -import org.onap.so.bpmn.common.data.TestDataSetup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; - -@RunWith(MockitoJUnitRunner.Silent.class) -public class GCTopologyOperationRequestMapperTest extends TestDataSetup { - - - @Spy - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - @InjectMocks - private GCTopologyOperationRequestMapper genObjMapper = new GCTopologyOperationRequestMapper(); - - @Test - public void deactivateOrUnassignVnrReqMapperTest() throws URISyntaxException { - RequestContext requestContext = new RequestContext(); - requestContext.setMsoRequestId("MsoRequestId"); - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("ServiceInstanceId"); - Configuration Configuration = new Configuration(); - Configuration.setConfigurationId("ConfigurationId"); - Configuration.setConfigurationType("VLAN-NETWORK-RECEPTOR"); - GenericResourceApiGcTopologyOperationInformation genericInfo = - genObjMapper.deactivateOrUnassignVnrReqMapper(SDNCSvcAction.UNASSIGN, serviceInstance, requestContext, - Configuration, "uuid", new URI("http://localhost")); - - Assert.assertNotNull(genericInfo); - Assert.assertNotNull(genericInfo.getRequestInformation()); - Assert.assertNotNull(genericInfo.getSdncRequestHeader()); - Assert.assertNotNull(genericInfo.getClass()); - Assert.assertNotNull(genericInfo.getServiceInformation()); - Assert.assertEquals("ConfigurationId", genericInfo.getConfigurationInformation().getConfigurationId()); - Assert.assertEquals("VLAN-NETWORK-RECEPTOR", genericInfo.getConfigurationInformation().getConfigurationType()); - Assert.assertEquals("uuid", genericInfo.getSdncRequestHeader().getSvcRequestId()); - Assert.assertEquals("http://localhost", genericInfo.getSdncRequestHeader().getSvcNotificationUrl()); - Assert.assertEquals("MsoRequestId", genericInfo.getRequestInformation().getRequestId()); - } - - - - private VpnBondingLink getVpnBondingLink() { - VpnBondingLink vpnBondingLink = new VpnBondingLink(); - Configuration vrfConfiguration = getVRFConfiguration(); - vpnBondingLink.setVrfConfiguration(vrfConfiguration); - Configuration vnrConfiguration = getVNRConfiguration(); - vpnBondingLink.setVnrConfiguration(vnrConfiguration); - vpnBondingLink.setTransportServiceProxy(buildServiceProxy(buildServiceInstance(buildGenericVnf()))); - return vpnBondingLink; - } - - private RequestContext getRequestContext() { - RequestContext requestContext = new RequestContext(); - requestContext.setMsoRequestId("MsoRequestId"); - Map userParams = getUserParams(); - requestContext.setUserParams(userParams); - return requestContext; - } - - private Map getUserParams() { - Map userParams = new HashMap<>(); - userParams.put("lppCustomerId", "lppCustomerId"); - return userParams; - } - - private ServiceProxy buildServiceProxy(ServiceInstance serviceInstance) { - ServiceProxy serviceProxy = new ServiceProxy(); - serviceProxy.setServiceInstance(serviceInstance); - return serviceProxy; - } - - private Configuration getVRFConfiguration() { - Configuration vrfConfiguration = new Configuration(); - vrfConfiguration.setConfigurationId("ConfigurationId"); - vrfConfiguration.setConfigurationName("ConfigurationName"); - vrfConfiguration.setConfigurationSubType("ConfigurationSubType"); - vrfConfiguration.setConfigurationType("VRF-ENTRY"); - return vrfConfiguration; - } - - public Configuration getVNRConfiguration() { - Configuration vnrConfiguration = new Configuration(); - vnrConfiguration.setConfigurationId("ConfigurationId"); - vnrConfiguration.setConfigurationName("ConfigurationName"); - vnrConfiguration.setConfigurationSubType("ConfigurationSubType"); - vnrConfiguration.setConfigurationType("VNRConfiguration"); - L3Network l3Network = getL3Network(); - vnrConfiguration.setNetwork(l3Network); - return vnrConfiguration; - } - - public L3Network getL3Network() { - L3Network l3Network = new L3Network(); - l3Network.setNetworkId("l3NetworkId"); - Subnet ipv4subnet = getSubnet("ipv4CidrMask", "ipv4NetworkStartAddress", "IPV4"); - Subnet ipv6subnet = getSubnet("ipv6CidrMask", "ipv6NetworkStartAddress", "IPV6"); - l3Network.getSubnets().add(ipv4subnet); - l3Network.getSubnets().add(ipv6subnet); - return l3Network; - } - - private Subnet getSubnet(String ipv4CidrMask, String ipv4NetworkStartAddress, String ipv4) { - Subnet ipv4subnet = new Subnet(); - ipv4subnet.setCidrMask(ipv4CidrMask); - ipv4subnet.setNetworkStartAddress(ipv4NetworkStartAddress); - ipv4subnet.setIpVersion(ipv4); - return ipv4subnet; - } - - private ServiceInstance buildServiceInstance(GenericVnf vnf) { - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("ServiceInstanceId"); - List vnfs = serviceInstance.getVnfs(); - vnfs.add(vnf); - return serviceInstance; - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java deleted file mode 100644 index 88a291e68b..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java +++ /dev/null @@ -1,446 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.InjectMocks; -import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; -import org.onap.so.bpmn.common.data.TestDataSetup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; - - -public class GeneralTopologyObjectMapperTest extends TestDataSetup { - @InjectMocks - private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void before() { - - } - - @After - public void after() { - - } - - @Test - public void testBuildServiceInformation() { - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); - modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); - modelInfoServiceInstance.setModelName("serviceModelName"); - modelInfoServiceInstance.setModelUuid("serviceModelUuid"); - modelInfoServiceInstance.setModelVersion("serviceModelVersion"); - - serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - // prepare Customer object - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - ServiceSubscription serviceSubscription = new ServiceSubscription(); - serviceSubscription.setServiceType("productFamilyId"); - customer.setServiceSubscription(serviceSubscription); - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - // - RequestContext requestContext = new RequestContext(); - Map userParams = new HashMap<>(); - userParams.put("key1", "value1"); - requestContext.setUserParams(userParams); - requestContext.setProductFamilyId("productFamilyId"); - - GenericResourceApiServiceinformationServiceInformation serviceInfo = - genObjMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); - - assertEquals("serviceModelInvariantUuid", serviceInfo.getOnapModelInformation().getModelInvariantUuid()); - assertEquals("serviceModelName", serviceInfo.getOnapModelInformation().getModelName()); - assertEquals("serviceModelUuid", serviceInfo.getOnapModelInformation().getModelUuid()); - assertEquals("serviceModelVersion", serviceInfo.getOnapModelInformation().getModelVersion()); - assertNull(serviceInfo.getOnapModelInformation().getModelCustomizationUuid()); - assertEquals("serviceInstanceId", serviceInfo.getServiceInstanceId()); - assertEquals("serviceInstanceId", serviceInfo.getServiceId()); - assertEquals("globalCustomerId", serviceInfo.getGlobalCustomerId()); - assertEquals("productFamilyId", serviceInfo.getSubscriptionServiceType()); - } - - @Test - public void buildSdncRequestHeaderActivateTest() { - GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = - genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ACTIVATE, "sdncReqId"); - - assertEquals(GenericResourceApiSvcActionEnumeration.ACTIVATE, requestHeader.getSvcAction()); - assertEquals("sdncReqId", requestHeader.getSvcRequestId()); - } - - @Test - public void buildSdncRequestHeaderAssignTest() { - GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = - genObjMapper.buildSdncRequestHeader(SDNCSvcAction.ASSIGN, "sdncReqId"); - - assertEquals(GenericResourceApiSvcActionEnumeration.ASSIGN, requestHeader.getSvcAction()); - assertEquals("sdncReqId", requestHeader.getSvcRequestId()); - } - - @Test - public void buildSdncRequestHeaderDeactivateTest() { - GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = - genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DEACTIVATE, "sdncReqId"); - - assertEquals(GenericResourceApiSvcActionEnumeration.DEACTIVATE, requestHeader.getSvcAction()); - assertEquals("sdncReqId", requestHeader.getSvcRequestId()); - } - - @Test - public void buildSdncRequestHeaderDeleteTest() { - GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = - genObjMapper.buildSdncRequestHeader(SDNCSvcAction.DELETE, "sdncReqId"); - - assertEquals(GenericResourceApiSvcActionEnumeration.DELETE, requestHeader.getSvcAction()); - assertEquals("sdncReqId", requestHeader.getSvcRequestId()); - } - - @Test - public void buildSdncRequestHeaderChangeAssignTest() { - GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = - genObjMapper.buildSdncRequestHeader(SDNCSvcAction.CHANGE_ASSIGN, "sdncReqId"); - - assertEquals(GenericResourceApiSvcActionEnumeration.CHANGEASSIGN, requestHeader.getSvcAction()); - assertEquals("sdncReqId", requestHeader.getSvcRequestId()); - } - - @Test - public void buildConfigurationInformationTest_excludesOnapModelInfo() { - Configuration configuration = new Configuration(); - configuration.setConfigurationId("testConfigurationId"); - configuration.setConfigurationType("VNR"); - configuration.setConfigurationName("VNRCONF"); - GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = - genObjMapper.buildConfigurationInformation(configuration, false); - assertEquals(configuration.getConfigurationId(), configurationInformation.getConfigurationId()); - assertEquals(configuration.getConfigurationType(), configurationInformation.getConfigurationType()); - assertEquals(configuration.getConfigurationName(), configurationInformation.getConfigurationName()); - assertNull(configurationInformation.getOnapModelInformation()); - } - - @Test - public void buildConfigurationInformationTest_includesOnapModelInfo() { - Configuration configuration = new Configuration(); - configuration.setConfigurationId("testConfigurationId"); - configuration.setConfigurationType("VNR"); - configuration.setConfigurationName("VNRCONF"); - ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); - modelInfoConfiguration.setModelVersionId("modelVersionId"); - modelInfoConfiguration.setModelInvariantId("modelInvariantId"); - modelInfoConfiguration.setModelCustomizationId("modelCustomizationId"); - configuration.setModelInfoConfiguration(modelInfoConfiguration); - - GenericResourceApiConfigurationinformationConfigurationInformation configurationInformation = - genObjMapper.buildConfigurationInformation(configuration, true); - - assertEquals(configuration.getConfigurationId(), configurationInformation.getConfigurationId()); - assertEquals(configuration.getConfigurationType(), configurationInformation.getConfigurationType()); - assertEquals(configuration.getConfigurationName(), configurationInformation.getConfigurationName()); - assertNotNull(configurationInformation.getOnapModelInformation()); - assertEquals(configuration.getModelInfoConfiguration().getModelVersionId(), - configurationInformation.getOnapModelInformation().getModelUuid()); - assertEquals(configuration.getModelInfoConfiguration().getModelInvariantId(), - configurationInformation.getOnapModelInformation().getModelInvariantUuid()); - assertEquals(configuration.getModelInfoConfiguration().getModelCustomizationId(), - configurationInformation.getOnapModelInformation().getModelCustomizationUuid()); - - } - - @Test - public void buildGcRequestInformationTest() { - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("TestVnfId"); - GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = - genObjMapper.buildGcRequestInformation(vnf, null); - assertNotNull(gcRequestInput); - assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId()); - assertNull(gcRequestInput.getInputParameters()); - } - - @Test - public void buildGcRequestInformationTest_withInputParams() { - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("TestVnfId"); - GenericResourceApiParam genericResourceApiParam = new GenericResourceApiParam(); - genericResourceApiParam.addParamItem(new GenericResourceApiParamParam()); - GenericResourceApiGcrequestinputGcRequestInput gcRequestInput = - genObjMapper.buildGcRequestInformation(vnf, genericResourceApiParam); - assertNotNull(gcRequestInput); - assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId()); - assertNotNull(gcRequestInput.getInputParameters()); - } - - @Test - public void buildVnfInformationTest_withNullData() { - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("TestVnfId"); - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - GenericResourceApiVnfinformationVnfInformation gcRequestInput = - genObjMapper.buildVnfInformation(vnf, serviceInstance, true); - assertNotNull(gcRequestInput); - assertNull(vnf.getModelInfoGenericVnf()); - assertNull(gcRequestInput.getOnapModelInformation()); - assertEquals(vnf.getVnfId(), gcRequestInput.getVnfId()); - assertNotNull(gcRequestInput.getVnfId()); - } - - @Test - public void buildNetworkInformationTest() { - - L3Network network = new L3Network(); - ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); - modelInfoNetwork.setModelInvariantUUID("my-uuid"); - modelInfoNetwork.setModelName("my-model-name"); - modelInfoNetwork.setModelVersion("my-model-version"); - modelInfoNetwork.setModelUUID("my-model-uuid"); - modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid"); - network.setModelInfoNetwork(modelInfoNetwork); - network.setNetworkId("my-network-id"); - network.setNetworkType("my-network-type"); - network.setNetworkTechnology("my-network-technology"); - - GenericResourceApiNetworkinformationNetworkInformation networkInformation = - new GenericResourceApiNetworkinformationNetworkInformation(); - GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = - new GenericResourceApiOnapmodelinformationOnapModelInformation(); - networkInformation.setNetworkId("my-network-id"); - networkInformation.setNetworkType("my-network-type"); - networkInformation.networkTechnology("my-network-technology"); - networkInformation.setFromPreload(null); - onapModelInformation.setModelInvariantUuid("my-uuid"); - onapModelInformation.setModelName("my-model-name"); - onapModelInformation.setModelVersion("my-model-version"); - onapModelInformation.setModelUuid("my-model-uuid"); - onapModelInformation.setModelCustomizationUuid("my-customization-uuid"); - networkInformation.setOnapModelInformation(onapModelInformation); - - assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); - - } - - @Test - public void buildNetworkInformationNoModelTest() { - - L3Network network = new L3Network(); - network.setNetworkId("my-network-id"); - network.setNetworkType("my-network-type"); - network.setNetworkTechnology("my-network-technology"); - - GenericResourceApiNetworkinformationNetworkInformation networkInformation = - new GenericResourceApiNetworkinformationNetworkInformation(); - networkInformation.setNetworkId("my-network-id"); - networkInformation.setNetworkType("my-network-type"); - networkInformation.networkTechnology("my-network-technology"); - networkInformation.setFromPreload(null); - - - assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); - - } - - - @Test - public void buildVfModuleInformationTest_withNoModelIsFromPreload() { - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("TestVfModuleId"); - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setVnfId("TestVnfId"); - RequestContext requestContext = new RequestContext(); - RequestParameters requestParameters = new RequestParameters(); - requestParameters.setUsePreload(true); - requestContext.setRequestParameters(requestParameters); - GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; - try { - gcRequestInput = - genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false); - } catch (MapperException ex) { - - } - assertNotNull(gcRequestInput); - assertNull(vfModule.getModelInfoVfModule()); - assertNull(gcRequestInput.getOnapModelInformation()); - assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); - assertNotNull(gcRequestInput.getVfModuleId()); - assertTrue(gcRequestInput.getFromPreload()); - } - - @Test - public void buildVfModuleInformationTest_withNoModelIsNotFromPreload() { - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("TestVfModuleId"); - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setVnfId("TestVnfId"); - RequestContext requestContext = new RequestContext(); - RequestParameters requestParameters = new RequestParameters(); - requestParameters.setUsePreload(false); - requestContext.setRequestParameters(requestParameters); - GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; - try { - gcRequestInput = - genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false); - } catch (MapperException ex) { - - } - assertNotNull(gcRequestInput); - assertNull(vfModule.getModelInfoVfModule()); - assertNull(gcRequestInput.getOnapModelInformation()); - assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); - assertNotNull(gcRequestInput.getVfModuleId()); - assertFalse(gcRequestInput.getFromPreload()); - } - - @Test - public void buildVfModuleInformationTest_withNoModelNoRequestContext() { - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("TestVfModuleId"); - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setVnfId("TestVnfId"); - GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; - try { - gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, null, false); - } catch (MapperException ex) { - - } - assertNotNull(gcRequestInput); - assertNull(vfModule.getModelInfoVfModule()); - assertNull(gcRequestInput.getOnapModelInformation()); - assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); - assertNotNull(gcRequestInput.getVfModuleId()); - assertTrue(gcRequestInput.getFromPreload()); - } - - @Test - public void buildVfModuleInformationTest_withNoModelNoRequestParameters() { - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("TestVfModuleId"); - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setVnfId("TestVnfId"); - RequestContext requestContext = new RequestContext(); - GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; - try { - gcRequestInput = - genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false); - } catch (MapperException ex) { - - } - assertNotNull(gcRequestInput); - assertNull(vfModule.getModelInfoVfModule()); - assertNull(gcRequestInput.getOnapModelInformation()); - assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); - assertNotNull(gcRequestInput.getVfModuleId()); - assertTrue(gcRequestInput.getFromPreload()); - } - - @Test - public void buildVfModuleInformationTest_withModel() { - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("TestVfModuleId"); - ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); - modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID"); - modelInfoVfModule.setModelName("testModelName"); - modelInfoVfModule.setModelVersion("testModelVersion"); - modelInfoVfModule.setModelUUID("testModelUUID"); - modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID"); - vfModule.setModelInfoVfModule(modelInfoVfModule); - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setVnfId("TestVnfId"); - RequestContext requestContext = new RequestContext(); - RequestParameters requestParameters = new RequestParameters(); - requestParameters.setUsePreload(true); - requestContext.setRequestParameters(requestParameters); - GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null; - try { - gcRequestInput = - genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, true); - } catch (MapperException ex) { - - } - assertNotNull(gcRequestInput); - assertNotNull(vfModule.getModelInfoVfModule()); - assertNotNull(gcRequestInput.getOnapModelInformation()); - assertEquals(modelInfoVfModule.getModelInvariantUUID(), - gcRequestInput.getOnapModelInformation().getModelInvariantUuid()); - assertEquals(modelInfoVfModule.getModelName(), gcRequestInput.getOnapModelInformation().getModelName()); - assertEquals(modelInfoVfModule.getModelVersion(), gcRequestInput.getOnapModelInformation().getModelVersion()); - assertEquals(modelInfoVfModule.getModelUUID(), gcRequestInput.getOnapModelInformation().getModelUuid()); - assertEquals(modelInfoVfModule.getModelCustomizationUUID(), - gcRequestInput.getOnapModelInformation().getModelCustomizationUuid()); - assertEquals(vfModule.getVfModuleId(), gcRequestInput.getVfModuleId()); - assertNotNull(gcRequestInput.getVfModuleId()); - assertTrue(gcRequestInput.getFromPreload()); - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java deleted file mode 100644 index 76e915781f..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapperTest.java +++ /dev/null @@ -1,232 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import com.fasterxml.jackson.databind.ObjectMapper; - -@RunWith(MockitoJUnitRunner.class) -public class NetworkTopologyOperationRequestMapperTest { - - private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; - - private ServiceInstance serviceInstance; - private ServiceInstance serviceInstanceNoCollection; - private Customer customer; - private RequestContext requestContext; - private L3Network network; - private CloudRegion cloudRegion; - - @Spy - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - @InjectMocks - private NetworkTopologyOperationRequestMapper mapper = new NetworkTopologyOperationRequestMapper(); - - @Before - public void before() { - // prepare and set service instance - serviceInstance = new ServiceInstance(); - serviceInstanceNoCollection = new ServiceInstance(); - ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); - modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid"); - modelInfoServiceInstance.setModelName("modelName"); - modelInfoServiceInstance.setModelUuid("modelUuid"); - modelInfoServiceInstance.setModelVersion("modelVersion"); - serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - serviceInstanceNoCollection.setModelInfoServiceInstance(modelInfoServiceInstance); - // prepare Customer object - customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - // serviceInstance.setCustomer(customer); - // set Customer on service instance - ServiceSubscription serviceSubscription = new ServiceSubscription(); - serviceSubscription.setServiceType("productFamilyId"); - customer.setServiceSubscription(serviceSubscription); - - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - customer.getServiceSubscription().getServiceInstances().add(serviceInstanceNoCollection); - // - InstanceGroup networkInstanceGroup = new InstanceGroup(); - networkInstanceGroup.setId("networkInstanceGroupId"); - networkInstanceGroup.setInstanceGroupFunction("instanceGroupFunction"); - Collection networkCollection = new Collection(); - networkCollection.setInstanceGroup(networkInstanceGroup); - serviceInstance.setCollection(networkCollection); - // - requestContext = new RequestContext(); - Map userParams = new HashMap<>(); - userParams.put("key1", "value1"); - requestContext.setUserParams(userParams); - requestContext.setProductFamilyId("productFamilyId"); - requestContext.setMsoRequestId("MsoRequestId"); - - network = new L3Network(); - network.setNetworkId("TEST_NETWORK_ID"); - network.setNetworkName("TEST_NETWORK_NAME"); - ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); - modelInfoNetwork.setModelInvariantUUID("modelInvariantUuid"); - modelInfoNetwork.setModelName("modelName"); - modelInfoNetwork.setModelVersion("modelVersion"); - modelInfoNetwork.setModelUUID("modelUuid"); - modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUUID"); - network.setModelInfoNetwork(modelInfoNetwork); - - cloudRegion = new CloudRegion(); - } - - @Test - public void createGenericResourceApiNetworkOperationInformationTest() throws Exception { - - GenericResourceApiNetworkOperationInformation networkSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, - customer, requestContext, cloudRegion); - - ObjectMapper omapper = new ObjectMapper(); - GenericResourceApiNetworkOperationInformation reqMapper1 = - omapper.readValue(getJson("genericResourceApiNetworkOperationInformation.json"), - GenericResourceApiNetworkOperationInformation.class); - - assertThat(networkSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId") - .ignoring("requestInformation.requestId")); - assertEquals("MsoRequestId", networkSDNCrequest.getRequestInformation().getRequestId()); - } - - @Test - public void createGenericResourceApiNetworkOperationInformationReqContextNullTest() throws Exception { - - RequestContext rc = new RequestContext(); - rc.setMsoRequestId(null); - GenericResourceApiNetworkOperationInformation networkSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, - customer, rc, cloudRegion); - assertNotNull(networkSDNCrequest.getRequestInformation().getRequestId()); - GenericResourceApiNetworkOperationInformation networkSDNCrequest2 = - mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, - customer, null, cloudRegion); - assertNotNull(networkSDNCrequest2.getRequestInformation().getRequestId()); - } - - @Test - public void reqMapperTest() throws Exception { - - GenericResourceApiNetworkOperationInformation networkSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, - customer, requestContext, cloudRegion); - - assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); - assertEquals("modelCustomizationUUID", - networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid()); - } - - @Test - public void reqMapperNoCollectionTest() throws Exception { - GenericResourceApiNetworkOperationInformation networkSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, - serviceInstanceNoCollection, customer, requestContext, cloudRegion); - - assertNull(networkSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); - assertEquals("modelCustomizationUUID", - networkSDNCrequest.getNetworkInformation().getOnapModelInformation().getModelCustomizationUuid()); - } - - @Test - public void createGenericResourceApiNetworkOperationInformation_UnassignTest() throws Exception { - - NetworkTopologyOperationRequestMapper mapperUnassign = mapper; - GenericResourceApiNetworkOperationInformation networkSDNCrequestUnassign = - mapperUnassign.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, - GenericResourceApiRequestActionEnumeration.DELETENETWORKINSTANCE, network, serviceInstance, - customer, requestContext, cloudRegion); - - ObjectMapper omapperUnassign = new ObjectMapper(); - GenericResourceApiNetworkOperationInformation reqMapperUnassign = - omapperUnassign.readValue(getJson("genericResourceApiNetworkOperationInformationUnAssign.json"), - GenericResourceApiNetworkOperationInformation.class); - - assertThat(reqMapperUnassign, sameBeanAs(networkSDNCrequestUnassign).ignoring("sdncRequestHeader.svcRequestId") - .ignoring("requestInformation.requestId")); - assertEquals("MsoRequestId", networkSDNCrequestUnassign.getRequestInformation().getRequestId()); - - } - - @Test - public void createGenericResourceApiNetworkOperationInformationNoNetworkNameTest() throws Exception { - - // set network name NULL - network.setNetworkName(null); - GenericResourceApiNetworkOperationInformation networkSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.NETWORK_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATENETWORKINSTANCE, network, serviceInstance, - customer, requestContext, cloudRegion); - - ObjectMapper omapper = new ObjectMapper(); - GenericResourceApiNetworkOperationInformation reqMapper1 = - omapper.readValue(getJson("genericResourceApiNetworkOperationInformationNoNetworkName.json"), - GenericResourceApiNetworkOperationInformation.class); - - assertThat(reqMapper1, sameBeanAs(networkSDNCrequest).ignoring("sdncRequestHeader.svcRequestId") - .ignoring("requestInformation.requestId")); - } - - /* - * Helper method to load JSON data - */ - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename))); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java deleted file mode 100644 index f4006ab5d5..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapperTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; -import com.fasterxml.jackson.databind.ObjectMapper; - -@RunWith(MockitoJUnitRunner.class) -public class ServiceTopologyOperationMapperTest { - - @Spy - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - @InjectMocks - private ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper(); - - @Test - public void reqMapperTest() throws Exception { - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); - modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid"); - modelInfoServiceInstance.setModelName("modelName"); - modelInfoServiceInstance.setModelUuid("modelUuid"); - modelInfoServiceInstance.setModelVersion("modelVersion"); - serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - - // prepare Customer object - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - - customer.setServiceSubscription(new ServiceSubscription()); - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - - // prepare RequestContext - RequestContext requestContext = new RequestContext(); - Map userParams = new HashMap<>(); - userParams.put("key1", "value1"); - requestContext.setUserParams(userParams); - requestContext.setProductFamilyId("productFamilyId"); - requestContext.setMsoRequestId("MsoRequestId"); - - GenericResourceApiServiceOperationInformation serviceOpInformation = - mapper.reqMapper(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, - requestContext); - GenericResourceApiServiceOperationInformation serviceOpInformationNullReqContext = mapper.reqMapper( - SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer, null); - - String jsonToCompare = new String(Files.readAllBytes( - Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json"))); - - ObjectMapper omapper = new ObjectMapper(); - GenericResourceApiOnapmodelinformationOnapModelInformation reqMapper1 = - omapper.readValue(jsonToCompare, GenericResourceApiOnapmodelinformationOnapModelInformation.class); - - assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation())); - assertEquals("MsoRequestId", serviceOpInformation.getRequestInformation().getRequestId()); - assertNotNull(serviceOpInformationNullReqContext.getRequestInformation().getRequestId()); - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java deleted file mode 100644 index 2fd684e0f0..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ /dev/null @@ -1,402 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; -import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; -import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import com.fasterxml.jackson.databind.ObjectMapper; - -@RunWith(MockitoJUnitRunner.class) -public class VfModuleTopologyOperationRequestMapperTest { - - private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; - private final static String ERRORMESSAGE = "VF Module model info is null for testVfModuleId"; - - @Spy - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - @InjectMocks - private VfModuleTopologyOperationRequestMapper mapper = new VfModuleTopologyOperationRequestMapper(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void assignGenericResourceApiVfModuleInformationTest() throws Exception { - - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); - modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); - modelInfoServiceInstance.setModelName("serviceModelName"); - modelInfoServiceInstance.setModelUuid("serviceModelUuid"); - modelInfoServiceInstance.setModelVersion("serviceModelVersion"); - serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - // prepare Customer object - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - ServiceSubscription serviceSubscription = new ServiceSubscription(); - serviceSubscription.setServiceType("productFamilyId"); - customer.setServiceSubscription(serviceSubscription); - - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - // - RequestContext requestContext = new RequestContext(); - Map userParams = new HashMap<>(); - userParams.put("key1", "value1"); - requestContext.setUserParams(userParams); - requestContext.setProductFamilyId("productFamilyId"); - RequestParameters requestParameters = new RequestParameters(); - requestParameters.setUsePreload(true); - requestContext.setRequestParameters(requestParameters); - requestContext.setMsoRequestId("MsoRequestId"); - - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("testVnfId"); - vnf.setVnfType("testVnfType"); - vnf.setVnfName("testVnfName"); - ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); - modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); - modelInfoGenericVnf.setModelName("vnfModelName"); - modelInfoGenericVnf.setModelVersion("vnfModelVersion"); - modelInfoGenericVnf.setModelUuid("vnfModelUuid"); - modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); - vnf.setModelInfoGenericVnf(modelInfoGenericVnf); - - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("testVfModuleId"); - vfModule.setVfModuleName("testVfModuleName"); - ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); - modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); - modelInfoVfModule.setModelName("vfModuleModelName"); - modelInfoVfModule.setModelVersion("vfModuleModelVersion"); - modelInfoVfModule.setModelUUID("vfModuleModelUuid"); - modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); - vfModule.setModelInfoVfModule(modelInfoVfModule); - HashMap cloudParams = new HashMap(); - cloudParams.put("key2", "value2"); - vfModule.setCloudParams(cloudParams); - - VolumeGroup volumeGroup = new VolumeGroup(); - volumeGroup.setVolumeGroupId("volumeGroupId"); - volumeGroup.setVolumeGroupName("volumeGroupName"); - - CloudRegion cloudRegion = new CloudRegion(); - - GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( - SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, - serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); - - String jsonToCompare = new String(Files.readAllBytes( - Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json"))); - - ObjectMapper omapper = new ObjectMapper(); - GenericResourceApiVfModuleOperationInformation reqMapper1 = - omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class); - - assertThat(vfModuleSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId") - .ignoring("requestInformation.requestId")); - assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId()); - } - - @Test - public void unassignGenericResourceApiVfModuleInformationTest() throws Exception { - - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - - // prepare and set vnf instance - - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("testVnfId"); - vnf.setVnfType("testVnfType"); - - // prepare and set vf module instance - - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("testVfModuleId"); - vfModule.setVfModuleName("testVfModuleName"); - - RequestContext requestContext = new RequestContext(); - requestContext.setMsoRequestId("MsoRequestId"); - - GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, - vnf, serviceInstance, null, null, requestContext, null, new URI("http://localhost:8080")); - - String jsonToCompare = new String(Files.readAllBytes( - Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json"))); - - ObjectMapper omapper = new ObjectMapper(); - GenericResourceApiVfModuleOperationInformation reqMapper1 = - omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class); - - assertThat(vfModuleSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId") - .ignoring("requestInformation.requestId")); - assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId()); - } - - @Test - public void unassignGenericResourceApiVfModuleInformationNullMsoReqIdTest() throws Exception { - - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - - // prepare and set vnf instance - - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("testVnfId"); - vnf.setVnfType("testVnfType"); - - // prepare and set vf module instance - - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("testVfModuleId"); - vfModule.setVfModuleName("testVfModuleName"); - - RequestContext requestContext = new RequestContext(); - - GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, - vnf, serviceInstance, null, null, requestContext, null, new URI("http://localhost:8080")); - - assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId()); - } - - @Test - public void reqMapperTest() throws Exception { - - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); - modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); - modelInfoServiceInstance.setModelName("serviceModelName"); - modelInfoServiceInstance.setModelUuid("serviceModelUuid"); - modelInfoServiceInstance.setModelVersion("serviceModelVersion"); - - serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - // prepare Customer object - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - customer.setServiceSubscription(new ServiceSubscription()); - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - // - RequestContext requestContext = new RequestContext(); - RequestParameters requestParameters = new RequestParameters(); - HashMap userParams1 = new HashMap<>(); - userParams1.put("key1", "value1"); - List> userParams = new ArrayList<>(); - userParams.add(userParams1); - - requestParameters.setUserParams(userParams); - requestContext.setRequestParameters(requestParameters); - requestContext.setProductFamilyId("productFamilyId"); - - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("testVnfId"); - vnf.setVnfType("testVnfType"); - ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); - modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); - modelInfoGenericVnf.setModelName("vnfModelName"); - modelInfoGenericVnf.setModelVersion("vnfModelVersion"); - modelInfoGenericVnf.setModelUuid("vnfModelUuid"); - modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); - vnf.setModelInfoGenericVnf(modelInfoGenericVnf); - - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("testVfModuleId"); - vfModule.setVfModuleName("testVfModuleName"); - ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); - modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); - modelInfoVfModule.setModelName("vfModuleModelName"); - modelInfoVfModule.setModelVersion("vfModuleModelVersion"); - modelInfoVfModule.setModelUUID("vfModuleModelUuid"); - modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); - vfModule.setModelInfoVfModule(modelInfoVfModule); - - CloudRegion cloudRegion = new CloudRegion(); - - GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( - SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, - serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); - - assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); - assertEquals("vnfModelCustomizationUuid", - vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid()); - assertEquals("vfModuleModelCustomizationUuid", - vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid()); - } - - @Test - public void reqMapperNoModelInfoTest() throws Exception { - - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); - modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); - modelInfoServiceInstance.setModelName("serviceModelName"); - modelInfoServiceInstance.setModelUuid("serviceModelUuid"); - modelInfoServiceInstance.setModelVersion("serviceModelVersion"); - - serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - // prepare Customer object - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - customer.setServiceSubscription(new ServiceSubscription()); - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - // - RequestContext requestContext = new RequestContext(); - Map userParams = new HashMap(); - userParams.put("key1", "value1"); - requestContext.setUserParams(userParams); - requestContext.setProductFamilyId("productFamilyId"); - - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("testVnfId"); - vnf.setVnfType("testVnfType"); - ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); - modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); - modelInfoGenericVnf.setModelName("vnfModelName"); - modelInfoGenericVnf.setModelVersion("vnfModelVersion"); - modelInfoGenericVnf.setModelUuid("vnfModelUuid"); - modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); - vnf.setModelInfoGenericVnf(modelInfoGenericVnf); - - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("testVfModuleId"); - vfModule.setVfModuleName("testVfModuleName"); - vfModule.setModelInfoVfModule(null); - - CloudRegion cloudRegion = new CloudRegion(); - - expectedException.expect(MapperException.class); - expectedException.expectMessage(ERRORMESSAGE); - - mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, - serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); - } - - @Test - public void reqMapperChangeAssignTest() throws Exception { - - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - serviceInstance.setServiceInstanceId("serviceInstanceId"); - ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); - modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); - modelInfoServiceInstance.setModelName("serviceModelName"); - modelInfoServiceInstance.setModelUuid("serviceModelUuid"); - modelInfoServiceInstance.setModelVersion("serviceModelVersion"); - - serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - // prepare Customer object - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - customer.setServiceSubscription(new ServiceSubscription()); - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - // - RequestContext requestContext = new RequestContext(); - RequestParameters requestParameters = new RequestParameters(); - HashMap userParams1 = new HashMap<>(); - userParams1.put("key1", "value1"); - List> userParams = new ArrayList<>(); - userParams.add(userParams1); - - requestParameters.setUserParams(userParams); - requestContext.setRequestParameters(requestParameters); - requestContext.setProductFamilyId("productFamilyId"); - - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("testVnfId"); - vnf.setVnfType("testVnfType"); - ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); - modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); - modelInfoGenericVnf.setModelName("vnfModelName"); - modelInfoGenericVnf.setModelVersion("vnfModelVersion"); - modelInfoGenericVnf.setModelUuid("vnfModelUuid"); - modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); - vnf.setModelInfoGenericVnf(modelInfoGenericVnf); - - VfModule vfModule = new VfModule(); - vfModule.setVfModuleId("testVfModuleId"); - vfModule.setVfModuleName("testVfModuleName"); - ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); - modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); - modelInfoVfModule.setModelName("vfModuleModelName"); - modelInfoVfModule.setModelVersion("vfModuleModelVersion"); - modelInfoVfModule.setModelUUID("vfModuleModelUuid"); - modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); - vfModule.setModelInfoVfModule(modelInfoVfModule); - - CloudRegion cloudRegion = new CloudRegion(); - - GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( - SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, - serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); - - assertEquals("vnfModelCustomizationUuid", - vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid()); - assertEquals("vfModuleModelCustomizationUuid", - vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid()); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java deleted file mode 100644 index 00836176f0..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdnc.mapper; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; -import org.onap.so.bpmn.servicedecomposition.generalobjects.License; -import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; -import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; -import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.beans.SDNCSvcOperation; - -@RunWith(MockitoJUnitRunner.class) -public class VnfTopologyOperationRequestMapperTest { - - @Spy - private GeneralTopologyObjectMapper generalTopologyObjectMapper; - - @InjectMocks - private VnfTopologyOperationRequestMapper mapper = new VnfTopologyOperationRequestMapper(); - - @Test - public void reqMapperTest() throws Exception { - // prepare and set service instance - ServiceInstance serviceInstance = new ServiceInstance(); - ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); - modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid"); - modelInfoServiceInstance.setModelName("modelName"); - modelInfoServiceInstance.setModelUuid("modelUuid"); - modelInfoServiceInstance.setModelVersion("modelVersion"); - serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - - // prepare VNF - ModelInfoGenericVnf genericVnf = new ModelInfoGenericVnf(); - genericVnf.setModelInvariantUuid("vnfModelInvariantUUID"); - genericVnf.setModelVersion("vnfModelVersion"); - genericVnf.setModelName("vnfModelName"); - genericVnf.setModelUuid("vnfModelUUID"); - genericVnf.setModelCustomizationUuid("vnfModelCustomizationUUID"); - - ModelInfoInstanceGroup modelL3Network = new ModelInfoInstanceGroup(); - modelL3Network.setType("L3-NETWORK"); - - InstanceGroup instanceGroup1 = new InstanceGroup(); - instanceGroup1.setId("l3-network-ig-111"); - instanceGroup1.setModelInfoInstanceGroup(modelL3Network); - - InstanceGroup instanceGroup2 = new InstanceGroup(); - instanceGroup2.setId("l3-network-ig-222"); - instanceGroup2.setModelInfoInstanceGroup(modelL3Network); - - GenericVnf vnf = new GenericVnf(); - vnf.setModelInfoGenericVnf(genericVnf); - vnf.setVnfId("vnfId"); - vnf.setVnfType("vnfType"); - vnf.getInstanceGroups().add(instanceGroup1); - vnf.getInstanceGroups().add(instanceGroup2); - License license = new License(); - List entitlementPoolUuids = new ArrayList<>(); - entitlementPoolUuids.add("entitlementPoolUuid"); - List licenseKeyGroupUuids = new ArrayList<>(); - licenseKeyGroupUuids.add("licenseKeyGroupUuid"); - license.setEntitlementPoolUuids(entitlementPoolUuids); - license.setLicenseKeyGroupUuids(licenseKeyGroupUuids); - vnf.setLicense(license); - - // prepare Customer object - Customer customer = new Customer(); - customer.setGlobalCustomerId("globalCustomerId"); - - ServiceSubscription serviceSubscription = new ServiceSubscription(); - serviceSubscription.setServiceType("productFamilyId"); - customer.setServiceSubscription(serviceSubscription); - - // set Customer on service instance - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - - - // prepare RequestContext - RequestContext requestContext = new RequestContext(); - Map userParams = new HashMap<>(); - userParams.put("key1", "value1"); - requestContext.setUserParams(userParams); - requestContext.setProductFamilyId("productFamilyId"); - requestContext.setMsoRequestId("MsoRequestId"); - - CloudRegion cloudRegion = new CloudRegion(); - - GenericResourceApiVnfOperationInformation vnfOpInformation = - mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, requestContext, true, new URI("http://localhost:8080")); - GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = - mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, - GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, null, true, new URI("http://localhost:8080")); - - assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); - assertEquals("vnfModelCustomizationUUID", - vnfOpInformation.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid()); - assertEquals(2, vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().size()); - assertEquals("l3-network-ig-111", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(0) - .getVnfNetworkInstanceGroupId()); - assertEquals("l3-network-ig-222", vnfOpInformation.getVnfRequestInput().getVnfNetworkInstanceGroupIds().get(1) - .getVnfNetworkInstanceGroupId()); - assertEquals("entitlementPoolUuid", - vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(1).getValue()); - assertEquals("licenseKeyGroupUuid", - vnfOpInformation.getVnfRequestInput().getVnfInputParameters().getParam().get(2).getValue()); - assertEquals("MsoRequestId", vnfOpInformation.getRequestInformation().getRequestId()); - assertNotNull(vnfOpInformationNullReqContext.getRequestInformation().getRequestId()); - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java deleted file mode 100644 index 750e578558..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno; - -import static org.junit.Assert.assertEquals; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Optional; -import org.junit.Test; -import org.onap.so.client.sdno.beans.SDNO; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class SDNOHealthCheckClientTest { - - - - private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/health-check/"; - private static final String userId = "test-user"; - private static final Optional clliCode = Optional.of("test-clli"); - private static final String requestId = "test-request-id"; - private static final String configurationId = "test-configuration-id"; - private static final String interfaceId = "test-interface-id"; - - @Test - public void verfyLPortMirrorPreCheckRequest() throws IOException { - String content = this.getJson("custom-lport-mirror-pre-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = - client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - @Test - public void verfyLPortMirrorPostCheckRequest() throws IOException { - String content = this.getJson("custom-lport-mirror-post-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = - client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - - @Test - public void verifyPortMirrorPostCheckRequest() throws IOException { - String content = this.getJson("custom-port-mirror-post-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); - - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - - } - - @Test - public void verifyPortMirrorPreCheckRequest() throws IOException { - String content = this.getJson("custom-port-mirror-pre-check-request.json"); - ObjectMapper mapper = new ObjectMapper(); - SDNO expected = mapper.readValue(content, SDNO.class); - SDNOHealthCheckClient client = new SDNOHealthCheckClient(); - String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); - - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } - -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java deleted file mode 100644 index b91f83c1b7..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.UUID; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.so.BaseIntegrationTest; -import org.onap.so.client.dmaap.Consumer; -import org.onap.so.client.dmaap.exceptions.DMaaPConsumerFailure; -import org.onap.so.client.exceptions.SDNOException; -import org.onap.so.client.sdno.beans.SDNO; -import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; -import com.fasterxml.jackson.databind.ObjectMapper; - - - -public class SDNOValidatorIT extends BaseIntegrationTest { - - - @Mock - private Consumer mrConsumer; - private SDNOHealthCheckDmaapConsumer dmaapConsumer; - private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/"; - private final String uuid = "xyz123"; - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUpTests() { - MockitoAnnotations.initMocks(this); - - } - - @Test - public void success() throws IOException, Exception { - dmaapConsumer = spy(new SDNOHealthCheckDmaapConsumer()); - when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); - when(mrConsumer.fetch()) - .thenReturn(Arrays.asList(new String[] {getJson("response.json"), getJson("output-success.json")})); - - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - SDNOValidatorImpl spy = spy(validator); - when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); - doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); - boolean result = spy.pollForResponse("xyz123"); - assertEquals("result is true", result, true); - } - - @Test - public void failure() throws IOException, Exception { - dmaapConsumer = spy(new SDNOHealthCheckDmaapConsumer()); - - when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); - when(mrConsumer.fetch()) - .thenReturn(Arrays.asList(new String[] {getJson("response.json"), getJson("output-failure.json")})); - - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - SDNOValidatorImpl spy = spy(validator); - when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); - doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); - thrown.expect(SDNOException.class); - thrown.expectMessage(containsString("my error message")); - boolean result = spy.pollForResponse("xyz123"); - - } - - @Ignore - @Test - public void run() throws Exception { - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - UUID uuid = UUID.randomUUID(); - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("test"); - vnf.setIpv4OamAddress("1.2.3.4"); - vnf.setNfRole("VPE"); - SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(request); - validator.submitRequest(json); - thrown.expect(DMaaPConsumerFailure.class); - boolean result = validator.pollForResponse(uuid.toString()); - System.out.println(json); - - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java deleted file mode 100644 index c2278c26f9..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.sdno; - -import static org.junit.Assert.assertEquals; -import java.util.UUID; -import org.junit.Test; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; -import org.onap.so.client.sdno.beans.SDNO; - -public class SDNOValidatorImplTest { - - @Test - public void buildRequestDiagnosticTest() throws Exception { - SDNOValidatorImpl validator = new SDNOValidatorImpl(); - UUID uuid = UUID.randomUUID(); - GenericVnf vnf = new GenericVnf(); - vnf.setVnfName("VNFNAME"); - vnf.setVnfId("test"); - vnf.setIpv4OamAddress("1.2.3.4"); - vnf.setNfRole("VPE"); - SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); - assertEquals(request.getNodeType(), "VPE"); - assertEquals(request.getOperation(), "health-diagnostic"); - - RequestHealthDiagnostic innerRequest = request.getBody().getInput().getRequestHealthDiagnostic(); - assertEquals(innerRequest.getRequestClientName(), "MSO"); - assertEquals(innerRequest.getRequestNodeName(), "VNFNAME"); - assertEquals(innerRequest.getRequestNodeUuid(), "test"); - assertEquals(innerRequest.getRequestNodeType(), "VPE"); - assertEquals(innerRequest.getRequestNodeIp(), "1.2.3.4"); - assertEquals(innerRequest.getRequestUserId(), "mechid"); - assertEquals(innerRequest.getRequestId(), uuid.toString()); - assertEquals(innerRequest.getHealthDiagnosticCode(), "default"); - - } -} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json deleted file mode 100644 index 2c46b5a8cb..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000004", - "operation-type": "lport_mirroring_check", - "send-detailed-cmd-response": "false", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - }, - { - "key": "interface-id", - "value": "test-interface-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json deleted file mode 100644 index bf168b0028..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000003", - "operation-type": "lport_mirroring_check", - "send-detailed-cmd-response": "false", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - }, - { - "key": "interface-id", - "value": "test-interface-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json deleted file mode 100644 index 89e505e7d0..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000004", - "operation-type": "mirroring_check", - "send-detailed-cmd-response": "false", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json deleted file mode 100644 index 86897c8a1f..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "body": { - "input": { - "request-hd-custom": { - "request-client-name": "MSO", - "request-user-id": "test-user", - "request-id": "test-request-id", - "health-diagnostic-code": "VROUTER000003", - "operation-type": "mirroring_check", - "send-detailed-cmd-response": "false", - "aai-param-list": [ - { - "key": "configuration-id", - "value": "test-configuration-id" - } - ] - } - } - }, - "operation": "health-diagnostic-custom", - "nodeLoc": "test-clli", - "nodeType": "VROUTER" -} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json deleted file mode 100644 index 8cf0a820cd..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "body": { - "output": { - "response-hd-custom": { - "response-status": "Failure", - "cached-data": "false", - "response-interface-type": "ansible", - "response-id": "191bf423-8473-4f7c-9fbb-e5dcbb40a12b", - "remote_end_time": "2017-10-13T14:51:53.490+0000", - "response-client-name": "MSO", - "user_id": "xxxxxx", - "remote_start_time": "2017-10-13T14:51:53.173+0000", - "error-message": "my error message", - "connection-failure-msg": "SDNO was unable to connect to an Ansible REST API server; Please ensure Ansible REST server is running" - } - } - }, - "result-info": { - "code": "200", - "status": "SUCCESS", - "request-id": "xyz123", - "client-name": "MSO", - "processing-host": "sdno-sdno-mtsnjv9sdno01" - } -} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json deleted file mode 100644 index a6794327d8..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "body": { - "output": { - "response-healthdiagnostic": { - "response-node-ip": "192.20.127.76", - "response-id": "xyz123", - "response-node-name": "mtvnjv9aads11", - "response-status": "Success", - "response-interface-type": "ssh", - "response-details-json": "result", - "cached-data": "false" - } - } - }, - "result-info": { - "client-name": "MSO", - "code": "200", - "processing-host": "sdno1-host01", - "request-id": "xyz123", - "status": "SUCCESS" - } -} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json deleted file mode 100644 index 2355e86938..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - - "result-info": { - - "client-name": "MSO", - - "code": "202", - - "processing-host": "sdno1-host01", - - "request-id": "xyz123", - - "status": "ACCEPTED" - - } - -} \ No newline at end of file diff --git a/common/src/main/java/org/onap/so/client/exception/MapperException.java b/common/src/main/java/org/onap/so/client/exception/MapperException.java new file mode 100644 index 0000000000..354c669d62 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/exception/MapperException.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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; + +public class MapperException extends Exception { + + public MapperException() {} + + public MapperException(String message) { + super(message); + } + +} diff --git a/pom.xml b/pom.xml index 2556f32c56..db097183a1 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,7 @@ adapters asdc-controller so-optimization-clients + so-sdn-clients bpmn cloudify-client cxf-logging diff --git a/so-sdn-clients/pom.xml b/so-sdn-clients/pom.xml new file mode 100644 index 0000000000..c9b417b230 --- /dev/null +++ b/so-sdn-clients/pom.xml @@ -0,0 +1,173 @@ + + + org.onap.so + so + 1.6.0-SNAPSHOT + + 4.0.0 + so-sdn-clients + + 1.5.2 + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + default-test + + test + + + + **/UnitTestSuite.java + + + + + integration-test + + test + + + + **/IntegrationTestSuite.java + + + + + + suites + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [1.0.0,) + + unpack + + + + + + + + + + + + + + + + + + org.springframework.boot + spring-boot-dependencies + ${springboot.version} + pom + import + + + + + + org.camunda.bpm.springboot + camunda-bpm-spring-boot-starter + ${camunda.springboot.version} + test + + + org.springframework.cloud + spring-cloud-contract-wiremock + 1.2.4.RELEASE + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.onap.sdnc.northbound + generic-resource-api-client + ${sdnc.northbound.version} + + + javax.ws.rs + jsr311-api + + + io.swagger + swagger-annotations + + + io.swagger + swagger-models + + + + + ch.vorburger.mariaDB4j + mariaDB4j + 2.2.3 + test + + + commons-lang + commons-lang + 2.6 + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.onap.so + common + ${project.version} + + + org.onap.so + aai-client + ${project.version} + + + org.mariadb.jdbc + mariadb-java-client + + + org.glassfish.jersey.core + jersey-common + + + org.glassfish.jersey.core + jersey-client + + + org.glassfish.jersey.inject + jersey-hk2 + 2.26 + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SDNCClient.java new file mode 100644 index 0000000000..7d2fc10d0b --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications 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. + * 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.sdnc; + +import java.util.LinkedHashMap; +import javax.ws.rs.core.UriBuilder; +import org.onap.so.client.BaseClient; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.beans.SDNCProperties; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Component; + +@Component +public class SDNCClient { + + @Autowired + private SDNCProperties properties; + @Autowired + private SdnCommonTasks sdnCommonTasks; + + /** + * + * @param request - takes in a generated object from sdnc client - creates a json request string and sends it to + * sdnc - receives and validates the linkedhashmap sent back from sdnc + * @throws MapperException + * @throws BadResponseException + */ + public String post(Object request, SDNCTopology topology) throws MapperException, BadResponseException { + String jsonRequest = sdnCommonTasks.buildJsonRequest(request); + String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/"; + BaseClient> STOClient = new BaseClient<>(); + + STOClient.setTargetUrl(targetUrl); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true); + STOClient.setHttpHeader(httpHeader); + LinkedHashMap output = + STOClient.post(jsonRequest, new ParameterizedTypeReference>() {}); + return sdnCommonTasks.validateSDNResponse(output); + } + + + public String post(Object request, String url) throws MapperException, BadResponseException { + String jsonRequest = sdnCommonTasks.buildJsonRequest(request); + BaseClient> STOClient = new BaseClient<>(); + STOClient.setTargetUrl(url); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true); + STOClient.setHttpHeader(httpHeader); + LinkedHashMap output = + STOClient.post(jsonRequest, new ParameterizedTypeReference>() {}); + return sdnCommonTasks.validateSDNResponse(output); + } + + /** + * + * @param queryLink - takes in a link to topology that needs to be queried - creates a json request string and sends + * it to sdnc - receives and validates the linkedhashmap sent back from sdnc * + * @throws MapperException + * @throws BadResponseException + */ + public String get(String queryLink) throws MapperException, BadResponseException { + String request = ""; + String jsonRequest = sdnCommonTasks.buildJsonRequest(request); + String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); + BaseClient> STOClient = new BaseClient<>(); + STOClient.setTargetUrl(targetUrl); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), false); + STOClient.setHttpHeader(httpHeader); + LinkedHashMap output = + STOClient.get(jsonRequest, new ParameterizedTypeReference>() {}); + return sdnCommonTasks.validateSDNGetResponse(output); + } + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java new file mode 100644 index 0000000000..01ac675d83 --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications 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. + * 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.sdnc; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import org.onap.so.logger.LoggingAnchor; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpStatus; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.exception.MapperException; +import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.logger.MessageEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class SdnCommonTasks { + + private static final Logger logger = LoggerFactory.getLogger(SDNCClient.class); + private static final String RESPONSE_CODE = "response-code"; + private static final String RESPONSE_MESSAGE = "response-message"; + private static final String NO_RESPONSE_FROM_SDNC = "Error did not receive a response from SDNC."; + private static final String BAD_RESPONSE_FROM_SDNC = "Error received a bad response from SDNC."; + private static final String SDNC_CODE_NOT_0_OR_IN_200_299 = "Error from SDNC: %s"; + private static final String COULD_NOT_CONVERT_SDNC_POJO_TO_JSON = + "ERROR: Could not convert SDNC pojo to json string."; + private static final String BRACKETS = LoggingAnchor.FIVE; + + /*** + * + * @param request + * @return + * @throws MapperException + */ + public String buildJsonRequest(Object request) throws MapperException { + String jsonRequest; + ObjectMapper objMapper = new ObjectMapper(); + objMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + try { + jsonRequest = objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(request); + } catch (JsonProcessingException e) { + logger.error(BRACKETS, MessageEnum.JAXB_EXCEPTION.toString(), COULD_NOT_CONVERT_SDNC_POJO_TO_JSON, "BPMN", + ErrorCode.DataError.getValue(), e.getMessage()); + throw new MapperException(COULD_NOT_CONVERT_SDNC_POJO_TO_JSON); + } + jsonRequest = "{\"input\":" + jsonRequest + "}"; + logger.info(jsonRequest); + return jsonRequest; + } + + /*** + * + * @param auth + * @return + */ + public HttpHeaders getHttpHeaders(String auth, boolean includeContentType) { + HttpHeaders httpHeader = new HttpHeaders(); + httpHeader.set("Authorization", auth); + if (includeContentType) { + httpHeader.setContentType(MediaType.APPLICATION_JSON); + } + List acceptMediaTypes = new ArrayList<>(); + acceptMediaTypes.add(MediaType.APPLICATION_JSON); + httpHeader.setAccept(acceptMediaTypes); + return httpHeader; + } + + /*** + * + * @param output + * @return + * @throws BadResponseException + */ + public String validateSDNResponse(LinkedHashMap output) throws BadResponseException { + if (CollectionUtils.isEmpty(output)) { + logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", + ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); + throw new BadResponseException(NO_RESPONSE_FROM_SDNC); + } + LinkedHashMap embeddedResponse = (LinkedHashMap) output.get("output"); + String responseCode = ""; + String responseMessage = ""; + if (embeddedResponse != null) { + responseCode = (String) embeddedResponse.get(RESPONSE_CODE); + responseMessage = (String) embeddedResponse.get(RESPONSE_MESSAGE); + } + ObjectMapper objMapper = new ObjectMapper(); + String jsonResponse; + try { + jsonResponse = objMapper.writeValueAsString(output); + logger.debug(jsonResponse); + } catch (JsonProcessingException e) { + logger.warn("Could not convert SDNC Response to String", e); + jsonResponse = ""; + } + logger.info("ResponseCode: {} ResponseMessage: {}", responseCode, responseMessage); + int code = StringUtils.isNotEmpty(responseCode) ? Integer.parseInt(responseCode) : 0; + if (isHttpCodeSuccess(code)) { + logger.info("Successful Response from SDNC"); + return jsonResponse; + } else { + String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage); + logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), errorMessage, "BPMN", + ErrorCode.DataError.getValue(), errorMessage); + throw new BadResponseException(errorMessage); + } + } + + /*** + * + * @param output + * @return + * @throws BadResponseException + */ + public String validateSDNGetResponse(LinkedHashMap output) throws BadResponseException { + if (CollectionUtils.isEmpty(output)) { + logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", + ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); + throw new BadResponseException(NO_RESPONSE_FROM_SDNC); + } + ObjectMapper objMapper = new ObjectMapper(); + logger.debug("Using object mapper"); + String stringOutput = ""; + try { + stringOutput = objMapper.writeValueAsString(output); + } catch (Exception e) { + logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), BAD_RESPONSE_FROM_SDNC, "BPMN", + ErrorCode.UnknownError.getValue(), BAD_RESPONSE_FROM_SDNC); + throw new BadResponseException(BAD_RESPONSE_FROM_SDNC); + } + logger.debug("Received from GET request: {}", stringOutput); + return stringOutput; + } + + + private boolean isHttpCodeSuccess(int code) { + return code >= HttpStatus.SC_OK && code < HttpStatus.SC_MULTIPLE_CHOICES || code == 0; + } +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java new file mode 100644 index 0000000000..15076fa45a --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCProperties.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdnc.beans; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "sdnc") +public class SDNCProperties { + + private String host; + private String path; + private String auth; + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getAuth() { + return auth; + } + + public void setAuth(String auth) { + this.auth = auth; + } +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java new file mode 100644 index 0000000000..2c8bdd931c --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java @@ -0,0 +1,97 @@ +/*- + * ============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.client.sdnc.beans; + +import java.io.Serializable; +import java.util.UUID; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; + +public class SDNCRequest implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 4679678988657593282L; + private String timeOut = "PT1H"; + private SDNCTopology topology; + private String correlationValue = UUID.randomUUID().toString(); + private String correlationName = "SDNCCallback"; + private transient Object sdncPayload; + + + public String getTimeOut() { + return timeOut; + } + + public void setTimeOut(String timeOut) { + this.timeOut = timeOut; + } + + public SDNCTopology getTopology() { + return topology; + } + + public void setTopology(SDNCTopology topology) { + this.topology = topology; + } + + public String getCorrelationValue() { + return correlationValue; + } + + public void setCorrelationValue(String correlationValue) { + this.correlationValue = correlationValue; + } + + public String getCorrelationName() { + return correlationName; + } + + public void setCorrelationName(String correlationName) { + this.correlationName = correlationName; + } + + public Object getSDNCPayload() { + return sdncPayload; + } + + public void setSDNCPayload(Object sDNCPayload) { + this.sdncPayload = sDNCPayload; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof SDNCRequest)) { + return false; + } + SDNCRequest castOther = (SDNCRequest) other; + return new EqualsBuilder().append(correlationValue, castOther.correlationValue) + .append(correlationName, castOther.correlationName).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(correlationValue).append(correlationName).toHashCode(); + } + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java new file mode 100644 index 0000000000..d6216c509d --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdnc.beans; + +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; + +public enum SDNCSvcAction { + ACTIVATE("activate", GenericResourceApiSvcActionEnumeration.ACTIVATE), + DELETE("delete", GenericResourceApiSvcActionEnumeration.DELETE), + ASSIGN("assign", GenericResourceApiSvcActionEnumeration.ASSIGN), + ROLLBACK("rollback", GenericResourceApiSvcActionEnumeration.ROLLBACK), + UNASSIGN("unassign", GenericResourceApiSvcActionEnumeration.UNASSIGN), + DEACTIVATE("deactivate", GenericResourceApiSvcActionEnumeration.DEACTIVATE), + CHANGE_DELETE("changedelete", GenericResourceApiSvcActionEnumeration.CHANGEDELETE), + CHANGE_ASSIGN("changeassign", GenericResourceApiSvcActionEnumeration.CHANGEASSIGN), + CREATE("create", GenericResourceApiSvcActionEnumeration.CREATE), + ENABLE("enable", GenericResourceApiSvcActionEnumeration.ENABLE), + DISABLE("disable", GenericResourceApiSvcActionEnumeration.DISABLE); + + private final String name; + + private GenericResourceApiSvcActionEnumeration sdncApiAction; + + private SDNCSvcAction(String name, GenericResourceApiSvcActionEnumeration sdncApiAction) { + this.name = name; + this.sdncApiAction = sdncApiAction; + } + + public GenericResourceApiSvcActionEnumeration getSdncApiAction() { + return this.sdncApiAction; + } + + @Override + public String toString() { + return name; + } +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java new file mode 100644 index 0000000000..4edbf37bad --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdnc.beans; + +public enum SDNCSvcOperation { + + VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"), + NETWORK_TOPOLOGY_OPERATION("network-topology-operation"), + VNF_TOPOLOGY_OPERATION("vnf-topology-operation"), + CONTRAIL_ROUTE_TOPOLOGY_OPERATION("contrail-route-topology-operation"), + SECURITY_ZONE_TOPOLOGY_OPERATION("security-zone-topology-operation"), + PORT_MIRROR_TOPOLOGY_OPERATION("port-mirror-topology-operation"), + SERVICE_TOPOLOGY_OPERATION("service-topology-operation"), + GENERIC_CONFIGURATION_TOPOLOGY_OPERATION("generic-configuration-topology-operation"); + + private final String name; + + private SDNCSvcOperation(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java new file mode 100644 index 0000000000..ae9fe6ad70 --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdnc.endpoint; + +public enum SDNCTopology { + + SERVICE("service-topology-operation"), + VNF("vnf-topology-operation"), + VFMODULE("vf-module-topology-operation"), + CONTRAILROUTE("contrail-route-topology-operation"), + PORTMIRROR("port-mirror-topology-operation"), + NETWORK("network-topology-operation"), + SECURITYZONE("security-zone-topology-operation"), + CONFIGURATION("generic-configuration-topology-operation"); + + private final String topology; + + private SDNCTopology(String topology) { + this.topology = topology; + } + + @Override + public String toString() { + return this.topology; + } +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java new file mode 100644 index 0000000000..9b857dc08c --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java @@ -0,0 +1,167 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import org.onap.so.client.dmaap.DmaapConsumer; +import org.onap.so.client.dmaap.DmaapPublisher; +import org.onap.so.client.sdno.beans.AAIParamList; +import org.onap.so.client.sdno.beans.Body; +import org.onap.so.client.sdno.beans.Input; +import org.onap.so.client.sdno.beans.RequestHdCustom; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOHealthCheckClient { + + private static final String NODE_TYPE = "VROUTER"; + private static final String API_OPERATION_TYPE = "health-diagnostic-custom"; + private static final String MIRRORING_CHECK = "mirroring_check"; + private static final String CLIENT_NAME = "MSO"; + private static final String PRE_CHECK_CODE = "VROUTER000003"; + private static final String POST_CHECK_CODE = "VROUTER000004"; + private static final String LPORT_MIRRORING_CHECK = "lport_mirroring_check"; + private static final String CONFIGURATION_ID = "configuration-id"; + + + public boolean lPortMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId) throws Exception { + String request = buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); + return this.execute(requestId, request); + } + + public boolean lPortMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId) throws Exception { + String request = buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); + return this.execute(requestId, request); + } + + public boolean portMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, + String configurationId) throws Exception { + final String request = this.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); + return this.execute(requestId, request); + } + + public boolean portMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, + String configurationId) throws Exception { + final String request = this.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); + return this.execute(requestId, request); + } + + protected String buildLPortMirrorCheckPreRequest(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId) throws JsonProcessingException { + return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, + PRE_CHECK_CODE); + } + + protected String buildLPortMirrorCheckPostRequest(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId) throws JsonProcessingException { + return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, + POST_CHECK_CODE); + } + + protected String buildPortMirrorPreCheckRequest(String userId, String requestId, Optional clliCode, + String configurationId) throws JsonProcessingException { + return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, PRE_CHECK_CODE); + } + + protected String buildPortMirrorPostCheckRequest(String userId, String requestId, Optional clliCode, + String configurationId) throws JsonProcessingException { + return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, POST_CHECK_CODE); + } + + protected String buildPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, + String configurationId, String diagnosticCode) throws JsonProcessingException { + final AAIParamList list = new AAIParamList(); + list.setKey(CONFIGURATION_ID); + list.setValue(configurationId); + + return this.buildRequest(userId, requestId, clliCode, diagnosticCode, MIRRORING_CHECK, + Collections.singletonList(list)); + } + + protected String buildLPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId, String diagnosticCode) throws JsonProcessingException { + + final AAIParamList configurationIdParam = new AAIParamList(); + configurationIdParam.setKey(CONFIGURATION_ID); + configurationIdParam.setValue(configurationId); + final AAIParamList interfaceIdParam = new AAIParamList(); + interfaceIdParam.setKey("interface-id"); + interfaceIdParam.setValue(interfaceId); + final List list = new ArrayList<>(); + list.add(configurationIdParam); + list.add(interfaceIdParam); + return this.buildRequest(userId, requestId, clliCode, diagnosticCode, LPORT_MIRRORING_CHECK, list); + } + + + protected String buildRequest(String userId, String requestId, Optional clliCode, String diagnosticCode, + String operationType, List paramList) throws JsonProcessingException { + + final RequestHdCustom hdCustom = new RequestHdCustom(); + hdCustom.withRequestUserId(userId).withRequestId(requestId).withRequestClientName(CLIENT_NAME) + .withHealthDiagnosticCode(diagnosticCode).withOperationType(operationType).withAaiParamList(paramList); + + final Input input = new Input(); + input.setRequestHdCustom(hdCustom); + final Body body = new Body(); + body.setInput(input); + final SDNO request = new SDNO(); + request.withBody(body).withOperation(API_OPERATION_TYPE).withNodeType(NODE_TYPE); + if (clliCode.isPresent()) { + request.setNodeLoc(clliCode.get()); + } + return this.getJson(request); + + } + + protected String getJson(SDNO obj) throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(obj); + } + + protected DmaapPublisher getPublisher() throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapPublisher(); + } + + protected DmaapConsumer getConsumer(String requestId) throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapConsumer(requestId); + } + + protected boolean execute(String requestId, String request) throws Exception { + final DmaapPublisher publisher = this.getPublisher(); + publisher.send(request); + + final DmaapConsumer consumer = this.getConsumer(requestId); + + return consumer.consume(); + } + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidator.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidator.java new file mode 100644 index 0000000000..d4af90267d --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidator.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno; + +import java.io.IOException; +import java.util.UUID; + +public interface SDNOValidator { + + /** + * Issues a health diagnostic request for a given vnf to SDN-O + * + * @param vnfId + * @param uuid + * @param requestingUserId + * @return diagnostic result + * @throws IOException + * @throws Exception + */ + public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception; + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java new file mode 100644 index 0000000000..d2a87db70a --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Optional; +import java.util.UUID; +import javax.ws.rs.NotFoundException; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.dmaap.DmaapConsumer; +import org.onap.so.client.dmaap.DmaapPublisher; +import org.onap.so.client.sdno.beans.Body; +import org.onap.so.client.sdno.beans.Input; +import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOValidatorImpl implements SDNOValidator { + + private final static String clientName = "MSO"; + private final static String HEALTH_DIAGNOSTIC_CODE_DEFAULT = "default"; + + @Override + public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception { + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourcesClient client = new AAIResourcesClient(); + GenericVnf vnf = client.get(GenericVnf.class, uri) + .orElseThrow(() -> new NotFoundException(vnfId + " not found in A&AI")); + + SDNO requestDiagnostic = buildRequestDiagnostic(vnf, uuid, requestingUserId); + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(requestDiagnostic); + this.submitRequest(json); + boolean status = this.pollForResponse(uuid.toString()); + return status; + } + + protected SDNO buildRequestDiagnostic(GenericVnf vnf, UUID uuid, String requestingUserId) { + + Optional nfRole; + if (vnf.getNfRole() == null) { + nfRole = Optional.empty(); + } else { + nfRole = Optional.of(vnf.getNfRole()); + } + Input input = new Input(); + SDNO parentRequest = new SDNO(); + Body body = new Body(); + parentRequest.setBody(body); + parentRequest.setNodeType(nfRole.orElse("NONE").toUpperCase()); + parentRequest.setOperation("health-diagnostic"); + + body.setInput(input); + + RequestHealthDiagnostic request = new RequestHealthDiagnostic(); + + request.setRequestClientName(clientName); + request.setRequestNodeName(vnf.getVnfName()); + request.setRequestNodeUuid(vnf.getVnfId()); + request.setRequestNodeType(nfRole.orElse("NONE").toUpperCase()); + request.setRequestNodeIp(vnf.getIpv4OamAddress()); // generic-vnf oam ip + request.setRequestUserId(requestingUserId); // mech id? + request.setRequestId(uuid.toString()); // something to identify this request by for polling + request.setHealthDiagnosticCode(HEALTH_DIAGNOSTIC_CODE_DEFAULT); + + input.setRequestHealthDiagnostic(request); + + return parentRequest; + } + + protected void submitRequest(String json) throws FileNotFoundException, IOException, InterruptedException { + + DmaapPublisher publisher = new SDNOHealthCheckDmaapPublisher(); + publisher.send(json); + } + + protected boolean pollForResponse(String uuid) throws Exception { + DmaapConsumer consumer = this.getConsumer(uuid); + return consumer.consume(); + } + + + + protected DmaapConsumer getConsumer(String uuid) throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapConsumer(uuid); + } + + + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java new file mode 100644 index 0000000000..7e98355b4d --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"key", "value"}) +public class AAIParamList { + + @JsonProperty("key") + private String key; + @JsonProperty("value") + private String value; + + /** + * No args constructor for use in serialization + * + */ + public AAIParamList() {} + + /** + * + * @param value + * @param key + */ + public AAIParamList(String key, String value) { + super(); + this.key = key; + this.value = value; + } + + @JsonProperty("key") + public String getKey() { + return key; + } + + @JsonProperty("key") + public void setKey(String key) { + this.key = key; + } + + public AAIParamList withKey(String key) { + this.key = key; + return this; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + public AAIParamList withValue(String value) { + this.value = value; + return this; + } + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Body.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Body.java new file mode 100644 index 0000000000..8c40b749a6 --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Body.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno.beans; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"input"}) +public class Body implements Serializable { + + @JsonProperty("input") + private Input input; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + private static final long serialVersionUID = 9101706044452851559L; + + @JsonProperty("input") + public Input getInput() { + return input; + } + + @JsonProperty("input") + public void setInput(Input input) { + this.input = input; + } + + public Body withInput(Input input) { + this.input = input; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public Body withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Input.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Input.java new file mode 100644 index 0000000000..c8122c06f6 --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/Input.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno.beans; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"request-healthdiagnostic", "request-hd-custom"}) +public class Input implements Serializable { + + @JsonProperty("request-healthdiagnostic") + private RequestHealthDiagnostic RequestHealthDiagnostic; + @JsonProperty("request-hd-custom") + private RequestHdCustom requestHdCustom; + + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + private final static long serialVersionUID = 7155546785389227528L; + + @JsonProperty("request-healthdiagnostic") + public RequestHealthDiagnostic getRequestHealthDiagnostic() { + return RequestHealthDiagnostic; + } + + @JsonProperty("request-healthdiagnostic") + public void setRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { + this.RequestHealthDiagnostic = RequestHealthDiagnostic; + } + + @JsonProperty("request-hd-custom") + public RequestHdCustom getRequestHdCustom() { + return requestHdCustom; + } + + @JsonProperty("request-hd-custom") + public void setRequestHdCustom(RequestHdCustom requestHdCustom) { + this.requestHdCustom = requestHdCustom; + } + + public Input withRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { + this.RequestHealthDiagnostic = RequestHealthDiagnostic; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public Input withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java new file mode 100644 index 0000000000..485f64673f --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno.beans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"request-client-name", "request-user-id", "request-id", "health-diagnostic-code", "operation-type", + "send-detailed-cmd-response", "aai-param-list"}) +public class RequestHdCustom implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -206110458275127710L; + @JsonProperty("request-client-name") + private String requestClientName; + @JsonProperty("request-user-id") + private String requestUserId; + @JsonProperty("request-id") + private String requestId; + @JsonProperty("health-diagnostic-code") + private String healthDiagnosticCode; + @JsonProperty("operation-type") + private String operationType; + @JsonProperty("send-detailed-cmd-response") + private String sendDetailedCmdResponse = "false"; + @JsonProperty("aai-param-list") + private List aaiParamList = new ArrayList<>(); + + /** + * No args constructor for use in serialization + * + */ + public RequestHdCustom() {} + + /** + * + * @param requestClientName + * @param operationType + * @param requestId + * @param healthDiagnosticCode + * @param aaiParamList + * @param requestUserId + */ + public RequestHdCustom(String requestClientName, String requestUserId, String requestId, + String healthDiagnosticCode, String operationType, List aaiParamList) { + super(); + this.requestClientName = requestClientName; + this.requestUserId = requestUserId; + this.requestId = requestId; + this.healthDiagnosticCode = healthDiagnosticCode; + this.operationType = operationType; + this.aaiParamList = aaiParamList; + } + + @JsonProperty("request-client-name") + public String getRequestClientName() { + return requestClientName; + } + + @JsonProperty("request-client-name") + public void setRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + } + + public RequestHdCustom withRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + return this; + } + + @JsonProperty("request-user-id") + public String getRequestUserId() { + return requestUserId; + } + + @JsonProperty("request-user-id") + public void setRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + } + + public RequestHdCustom withRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + return this; + } + + @JsonProperty("request-id") + public String getRequestId() { + return requestId; + } + + @JsonProperty("request-id") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public RequestHdCustom withRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + @JsonProperty("health-diagnostic-code") + public String getHealthDiagnosticCode() { + return healthDiagnosticCode; + } + + @JsonProperty("health-diagnostic-code") + public void setHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + } + + public RequestHdCustom withHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + return this; + } + + @JsonProperty("operation-type") + public String getOperationType() { + return operationType; + } + + @JsonProperty("operation-type") + public void setOperationType(String operationType) { + this.operationType = operationType; + } + + public RequestHdCustom withOperationType(String operationType) { + this.operationType = operationType; + return this; + } + + public void setSendDetailedCmdResponse(String sendDetailedCmdResponse) { + this.sendDetailedCmdResponse = sendDetailedCmdResponse; + } + + public String getSendDetailedCmdResponse() { + return sendDetailedCmdResponse; + } + + public RequestHdCustom withSendDetailedCmdResponse(String sendDetailedCmdResponse) { + this.sendDetailedCmdResponse = sendDetailedCmdResponse; + return this; + } + + @JsonProperty("aai-param-list") + public List getAaiParamList() { + return aaiParamList; + } + + @JsonProperty("aai-param-list") + public void setAaiParamList(List aaiParamList) { + this.aaiParamList = aaiParamList; + } + + public RequestHdCustom withAaiParamList(List aaiParamList) { + this.aaiParamList = aaiParamList; + return this; + } + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java new file mode 100644 index 0000000000..b1b75ab412 --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno.beans; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"request-client-name", "request-node-name", "request-node-uuid", "request-node-ip", "request-id", + "request-user-id", "request-node-type", "health-diagnostic-code"}) +public class RequestHealthDiagnostic implements Serializable { + + @JsonProperty("request-client-name") + private String requestClientName; + @JsonProperty("request-node-name") + private String requestNodeName; + @JsonProperty("request-node-uuid") + private String requestNodeUuid; + @JsonProperty("request-node-ip") + private String requestNodeIp; + @JsonProperty("request-id") + private String requestId; + @JsonProperty("request-user-id") + private String requestUserId; + @JsonProperty("request-node-type") + private String requestNodeType; + @JsonProperty("health-diagnostic-code") + private String healthDiagnosticCode; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + private static final long serialVersionUID = 1166788526178388021L; + + @JsonProperty("request-client-name") + public String getRequestClientName() { + return requestClientName; + } + + @JsonProperty("request-client-name") + public void setRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + } + + public RequestHealthDiagnostic withRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + return this; + } + + @JsonProperty("request-node-name") + public String getRequestNodeName() { + return requestNodeName; + } + + @JsonProperty("request-node-name") + public void setRequestNodeName(String requestNodeName) { + this.requestNodeName = requestNodeName; + } + + public RequestHealthDiagnostic withRequestNodeName(String requestNodeName) { + this.requestNodeName = requestNodeName; + return this; + } + + @JsonProperty("request-node-uuid") + public String getRequestNodeUuid() { + return requestNodeUuid; + } + + @JsonProperty("request-node-uuid") + public void setRequestNodeUuid(String requestNodeUuid) { + this.requestNodeUuid = requestNodeUuid; + } + + public RequestHealthDiagnostic withRequestNodeUuid(String requestNodeUuid) { + this.requestNodeUuid = requestNodeUuid; + return this; + } + + @JsonProperty("request-node-ip") + public String getRequestNodeIp() { + return requestNodeIp; + } + + @JsonProperty("request-node-ip") + public void setRequestNodeIp(String requestNodeIp) { + this.requestNodeIp = requestNodeIp; + } + + public RequestHealthDiagnostic withRequestNodeIp(String requestNodeIp) { + this.requestNodeIp = requestNodeIp; + return this; + } + + @JsonProperty("request-id") + public String getRequestId() { + return requestId; + } + + @JsonProperty("request-id") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public RequestHealthDiagnostic withRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + @JsonProperty("request-user-id") + public String getRequestUserId() { + return requestUserId; + } + + @JsonProperty("request-user-id") + public void setRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + } + + public RequestHealthDiagnostic withRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + return this; + } + + @JsonProperty("request-node-type") + public String getRequestNodeType() { + return requestNodeType; + } + + @JsonProperty("request-node-type") + public void setRequestNodeType(String requestNodeType) { + this.requestNodeType = requestNodeType; + } + + public RequestHealthDiagnostic withRequestNodeType(String requestNodeType) { + this.requestNodeType = requestNodeType; + return this; + } + + @JsonProperty("health-diagnostic-code") + public String getHealthDiagnosticCode() { + return healthDiagnosticCode; + } + + @JsonProperty("health-diagnostic-code") + public void setHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + } + + public RequestHealthDiagnostic withHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public RequestHealthDiagnostic withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java new file mode 100644 index 0000000000..8b84cf6659 --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno.beans; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"client-name", "code", "processing-host", "request-id", "status"}) +public class ResultInfo { + + @JsonProperty("client-name") + private String clientName; + @JsonProperty("code") + private String code; + @JsonProperty("processing-host") + private String processingHost; + @JsonProperty("request-id") + private String requestId; + @JsonProperty("status") + private String status; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + + @JsonProperty("client-name") + public String getClientName() { + return clientName; + } + + @JsonProperty("client-name") + public void setClientName(String clientName) { + this.clientName = clientName; + } + + @JsonProperty("code") + public String getCode() { + return code; + } + + @JsonProperty("code") + public void setCode(String code) { + this.code = code; + } + + @JsonProperty("processing-host") + public String getProcessingHost() { + return processingHost; + } + + @JsonProperty("processing-host") + public void setProcessingHost(String processingHost) { + this.processingHost = processingHost; + } + + @JsonProperty("request-id") + public String getRequestId() { + return requestId; + } + + @JsonProperty("request-id") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @JsonProperty("status") + public void setStatus(String status) { + this.status = status; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } +} diff --git a/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/SDNO.java b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/SDNO.java new file mode 100644 index 0000000000..46e2c1d1fc --- /dev/null +++ b/so-sdn-clients/src/main/java/org/onap/so/client/sdno/beans/SDNO.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno.beans; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"operation", "nodeLoc", "nodeType", "body"}) +public class SDNO implements Serializable { + + @JsonProperty("operation") + private String operation; + @JsonProperty("nodeLoc") + private String nodeLoc; + @JsonProperty("nodeType") + private String nodeType; + @JsonProperty("body") + private Body body; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + private static final long serialVersionUID = -5303297382564282650L; + + @JsonProperty("operation") + public String getOperation() { + return operation; + } + + @JsonProperty("operation") + public void setOperation(String operation) { + this.operation = operation; + } + + @JsonProperty("nodeLoc") + public String getNodeLoc() { + return nodeLoc; + } + + @JsonProperty("nodeLoc") + public void setNodeLoc(String nodeLoc) { + this.nodeLoc = nodeLoc; + } + + public SDNO withNodeLoc(String nodeLoc) { + this.nodeLoc = nodeLoc; + return this; + } + + public SDNO withOperation(String operation) { + this.operation = operation; + return this; + } + + @JsonProperty("nodeType") + public String getNodeType() { + return nodeType; + } + + @JsonProperty("nodeType") + public void setNodeType(String nodeType) { + this.nodeType = nodeType; + } + + public SDNO withNodeType(String nodeType) { + this.nodeType = nodeType; + return this; + } + + @JsonProperty("body") + public Body getBody() { + return body; + } + + @JsonProperty("body") + public void setBody(Body body) { + this.body = body; + } + + public SDNO withBody(Body body) { + this.body = body; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public SDNO SDNO(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java b/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java new file mode 100644 index 0000000000..9c25b1f002 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/BaseIntegrationTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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; + +import java.io.IOException; +import java.io.InputStream; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.onap.so.client.sdnc.SDNCClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import com.github.tomakehurst.wiremock.WireMockServer; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public abstract class BaseIntegrationTest { + + @Value("${wiremock.server.port}") + protected String wireMockPort; + + @SpyBean + protected SDNCClient SPY_sdncClient; + + @Autowired + protected WireMockServer wireMockServer; + + @Before + public void baseTestBefore() { + wireMockServer.resetAll(); + } + +} + + diff --git a/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..62d9ecee44 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/EmbeddedMariaDbConfig.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; + +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import javax.sql.DataSource; + +@Configuration +@Profile({"test"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + MariaDB4jSpringService service = new MariaDB4jSpringService(); + + + service.getConfiguration().addArg("--lower_case_table_names=1"); + return service; + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + // Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword) + .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build(); + } +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java b/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java new file mode 100644 index 0000000000..50bbc1845f --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/IntegrationTestSuite.java @@ -0,0 +1,31 @@ +/*- + * ============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; + +import org.junit.runner.RunWith; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/*IT.class"}) +public class IntegrationTestSuite { + +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java b/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java new file mode 100644 index 0000000000..fe965b4444 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/TestApplication.java @@ -0,0 +1,43 @@ +package org.onap.so; +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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========================================================= + */ + + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Profile; + +@SpringBootApplication +@Profile("test") +@ComponentScan(basePackages = {"org.onap.so"}, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) +public class TestApplication { + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + + + } +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java b/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java new file mode 100644 index 0000000000..890c81daeb --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/UnitTestSuite.java @@ -0,0 +1,32 @@ +/*- + * ============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; + + +import org.junit.runner.RunWith; +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/*Test.class"}) +public class UnitTestSuite { + +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java new file mode 100644 index 0000000000..a8816e1b04 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java @@ -0,0 +1,104 @@ +/*- + * ============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.client.sdn.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import java.util.LinkedHashMap; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.SdnCommonTasks; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; + + +public class SdnCommonTasksTest { + + + SdnCommonTasks sdnCommonTasks = new SdnCommonTasks(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Test + public void buildJsonRequestTest() throws MapperException { + String jsonStr = sdnCommonTasks.buildJsonRequest(""); + Assert.assertNotNull(jsonStr); + } + + @Test + public void buildJsonRequestTestException() throws MapperException { + expectedException.expect(MapperException.class); + sdnCommonTasks.buildJsonRequest(new Object()); + } + + @Test + public void getHttpHeadersTest() { + HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", true); + + assertEquals("auth", result.getFirst("Authorization")); + assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Content-Type")); + assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept")); + } + + @Test + public void getHttpHeadersGetRequestTest() { + HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", false); + + assertEquals("auth", result.getFirst("Authorization")); + assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept")); + assertFalse(result.containsKey("Content-Type")); + } + + @Test + public void validateSDNResponseTest() throws BadResponseException { + String jsonResponse = "{\"output\":{\"response-code\":\"0\",\"response-message\":\"success\"}}"; + LinkedHashMap responseMap = new LinkedHashMap<>(); + LinkedHashMap output = new LinkedHashMap<>(); + output.put("response-code", "0"); + output.put("response-message", "success"); + responseMap.put("output", output); + assertEquals(jsonResponse, sdnCommonTasks.validateSDNResponse(responseMap)); + } + + @Test + public void validateSDNResponseTestException() throws BadResponseException { + expectedException.expect(BadResponseException.class); + LinkedHashMap responseMap = new LinkedHashMap(); + Assert.assertNotNull(sdnCommonTasks.validateSDNResponse(responseMap)); + } + + @Test + public void validateSDNResponseTestRespCodeNot200() throws BadResponseException { + expectedException.expect(BadResponseException.class); + LinkedHashMap responseMap = new LinkedHashMap<>(); + LinkedHashMap output = new LinkedHashMap<>(); + output.put("response-code", "300"); + output.put("response-message", "Failed"); + responseMap.put("output", output); + sdnCommonTasks.validateSDNResponse(responseMap); + } + +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java new file mode 100644 index 0000000000..0b338bde1d --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdnc/SDNCClientIT.java @@ -0,0 +1,79 @@ +/*- + * ============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.client.sdnc; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import org.junit.Test; +import org.onap.so.BaseIntegrationTest; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.exception.MapperException; +import org.onap.so.client.sdnc.endpoint.SDNCTopology; +import org.skyscreamer.jsonassert.JSONAssert; + +public class SDNCClientIT extends BaseIntegrationTest { + private final static String JSON_FILE_LOCATION = "src/test/resources/__files/"; + + @Test + public void getTest() throws BadResponseException, MapperException, IOException { + String responseJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientGetResponse.json"))); + String queryLink = "/topologyQuery"; + + wireMockServer.stubFor(get(urlEqualTo(queryLink)).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); + String response = SPY_sdncClient.get(queryLink); + JSONAssert.assertEquals(responseJson, response, false); + } + + @Test(expected = BadResponseException.class) + public void post404Test() throws BadResponseException, MapperException, IOException { + String responseJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut404Response.json"))); + + String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/"; + + wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); + + SPY_sdncClient.post("", SDNCTopology.NETWORK); + } + + @Test + public void post200Test() throws BadResponseException, MapperException, IOException { + String responseJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "SDNCClientPut200Response.json"))); + + String queryLink = "/restconf/operations/GENERIC-RESOURCE-API:network-topology-operation/"; + + wireMockServer.stubFor(post(urlMatching(queryLink)).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(responseJson))); + + String response = SPY_sdncClient.post("", SDNCTopology.NETWORK); + JSONAssert.assertEquals(responseJson, response, true); + } +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java new file mode 100644 index 0000000000..7345b8161b --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno; + +import static org.junit.Assert.assertEquals; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import org.junit.Test; +import org.onap.so.client.sdno.beans.SDNO; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOHealthCheckClientTest { + + + + private final String fileLocation = "src/test/resources/__files/sdno/health-check/"; + private static final String userId = "test-user"; + private static final Optional clliCode = Optional.of("test-clli"); + private static final String requestId = "test-request-id"; + private static final String configurationId = "test-configuration-id"; + private static final String interfaceId = "test-interface-id"; + + @Test + public void verfyLPortMirrorPreCheckRequest() throws IOException { + String content = this.getJson("custom-lport-mirror-pre-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = + client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + } + + @Test + public void verfyLPortMirrorPostCheckRequest() throws IOException { + String content = this.getJson("custom-lport-mirror-post-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = + client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + } + + + @Test + public void verifyPortMirrorPostCheckRequest() throws IOException { + String content = this.getJson("custom-port-mirror-post-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); + + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + + } + + @Test + public void verifyPortMirrorPreCheckRequest() throws IOException { + String content = this.getJson("custom-port-mirror-pre-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); + + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); + } + +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java new file mode 100644 index 0000000000..8d2993ec43 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.UUID; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.BaseIntegrationTest; +import org.onap.so.client.dmaap.Consumer; +import org.onap.so.client.dmaap.exceptions.DMaaPConsumerFailure; +import org.onap.so.client.exceptions.SDNOException; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; +import com.fasterxml.jackson.databind.ObjectMapper; + + + +public class SDNOValidatorIT extends BaseIntegrationTest { + + + @Mock + private Consumer mrConsumer; + private SDNOHealthCheckDmaapConsumer dmaapConsumer; + private final String fileLocation = "src/test/resources/__files/sdno/client/"; + private final String uuid = "xyz123"; + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setUpTests() { + MockitoAnnotations.initMocks(this); + + } + + @Test + public void success() throws IOException, Exception { + dmaapConsumer = spy(new SDNOHealthCheckDmaapConsumer()); + when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); + when(mrConsumer.fetch()) + .thenReturn(Arrays.asList(new String[] {getJson("response.json"), getJson("output-success.json")})); + + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + SDNOValidatorImpl spy = spy(validator); + when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); + doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); + boolean result = spy.pollForResponse("xyz123"); + assertEquals("result is true", result, true); + } + + @Test + public void failure() throws IOException, Exception { + dmaapConsumer = spy(new SDNOHealthCheckDmaapConsumer()); + + when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); + when(mrConsumer.fetch()) + .thenReturn(Arrays.asList(new String[] {getJson("response.json"), getJson("output-failure.json")})); + + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + SDNOValidatorImpl spy = spy(validator); + when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); + doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); + thrown.expect(SDNOException.class); + thrown.expectMessage(containsString("my error message")); + boolean result = spy.pollForResponse("xyz123"); + + } + + @Ignore + @Test + public void run() throws Exception { + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + UUID uuid = UUID.randomUUID(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("test"); + vnf.setIpv4OamAddress("1.2.3.4"); + vnf.setNfRole("VPE"); + SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(request); + validator.submitRequest(json); + thrown.expect(DMaaPConsumerFailure.class); + boolean result = validator.pollForResponse(uuid.toString()); + System.out.println(json); + + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); + } +} diff --git a/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java new file mode 100644 index 0000000000..c2278c26f9 --- /dev/null +++ b/so-sdn-clients/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.sdno; + +import static org.junit.Assert.assertEquals; +import java.util.UUID; +import org.junit.Test; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; +import org.onap.so.client.sdno.beans.SDNO; + +public class SDNOValidatorImplTest { + + @Test + public void buildRequestDiagnosticTest() throws Exception { + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + UUID uuid = UUID.randomUUID(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("VNFNAME"); + vnf.setVnfId("test"); + vnf.setIpv4OamAddress("1.2.3.4"); + vnf.setNfRole("VPE"); + SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); + assertEquals(request.getNodeType(), "VPE"); + assertEquals(request.getOperation(), "health-diagnostic"); + + RequestHealthDiagnostic innerRequest = request.getBody().getInput().getRequestHealthDiagnostic(); + assertEquals(innerRequest.getRequestClientName(), "MSO"); + assertEquals(innerRequest.getRequestNodeName(), "VNFNAME"); + assertEquals(innerRequest.getRequestNodeUuid(), "test"); + assertEquals(innerRequest.getRequestNodeType(), "VPE"); + assertEquals(innerRequest.getRequestNodeIp(), "1.2.3.4"); + assertEquals(innerRequest.getRequestUserId(), "mechid"); + assertEquals(innerRequest.getRequestId(), uuid.toString()); + assertEquals(innerRequest.getHealthDiagnosticCode(), "default"); + + } +} diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json new file mode 100644 index 0000000000..9c50c2f11b --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json @@ -0,0 +1,7 @@ +{ + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json new file mode 100644 index 0000000000..91d64b98ca --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformation.json @@ -0,0 +1,54 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-name" : "TEST_NETWORK_NAME", + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "CreateNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "assign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json new file mode 100644 index 0000000000..95a2af3880 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationNoNetworkName.json @@ -0,0 +1,53 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "CreateNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "assign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json new file mode 100644 index 0000000000..a7cf1e1434 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiNetworkOperationInformationUnAssign.json @@ -0,0 +1,54 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : null, + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : null, + "global-customer-id" : "globalCustomerId", + "service-instance-id" : null + }, + "network-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "network-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + } ] + }, + "network-name" : "TEST_NETWORK_NAME", + "network-instance-group-id" : "networkInstanceGroupId" + }, + "request-information" : { + "notification-url" : null, + "order-version" : null, + "request-action" : "DeleteNetworkInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : null, + "svc-action" : "unassign" + }, + "network-information" : { + "onap-model-information" : { + "model-name" : "modelName", + "model-version" : "modelVersion", + "model-customization-uuid" : "modelCustomizationUUID", + "model-uuid" : "modelUuid", + "model-invariant-uuid" : "modelInvariantUuid" + }, + "from-preload": null, + "network-id" : "TEST_NETWORK_ID", + "network-type" : null + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json new file mode 100644 index 0000000000..53c1997126 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json @@ -0,0 +1,74 @@ +{ + "service-information" : { + "onap-model-information" : { + "model-name" : "serviceModelName", + "model-version" : "serviceModelVersion", + "model-customization-uuid" : null, + "model-uuid" : "serviceModelUuid", + "model-invariant-uuid" : "serviceModelInvariantUuid" + }, + "subscriber-name" : null, + "subscription-service-type" : "productFamilyId", + "service-id" : "serviceInstanceId", + "global-customer-id" : "globalCustomerId", + "service-instance-id" : "serviceInstanceId" + }, + "vf-module-request-input" : { + "aic-clli" : null, + "aic-cloud-region" : null, + "tenant" : null, + "vf-module-input-parameters" : { + "param" : [ { + "name" : "key1", + "value" : "value1" + }, + { + "name" : "key2", + "value" : "value2" + }, + { + "name" : "volume-group-id", + "value" : "volumeGroupId" + } ] + }, + "vf-module-name" : "testVfModuleName" + }, + "request-information" : { + "request-action" : "CreateVfModuleInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null, + "order-version" : null, + "notification-url" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : "http://localhost:8080", + "svc-action" : "assign" + }, + "vf-module-information" : { + "onap-model-information" : { + "model-name" : "vfModuleModelName", + "model-version" : "vfModuleModelVersion", + "model-customization-uuid" : "vfModuleModelCustomizationUuid", + "model-uuid" : "vfModuleModelUuid", + "model-invariant-uuid" : "vfModuleModelInvariantUuid" + }, + "vf-module-id" : "testVfModuleId", + "from-preload" : true, + "vf-module-type": "vfModuleModelName" + + }, + "vnf-information" : { + "onap-model-information" : { + "model-name" : "vnfModelName", + "model-version" : "vnfModelVersion", + "model-customization-uuid" : "vnfModelCustomizationUuid", + "model-uuid" : "vnfModelUuid", + "model-invariant-uuid" : "vnfModelInvariantUuid" + }, + "vnf-id" : "testVnfId", + "vnf-type" : "testVnfType", + "vnf-name" : "testVnfName" + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json new file mode 100644 index 0000000000..9f93c0df1f --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json @@ -0,0 +1,31 @@ +{ + "service-information" : { + "service-instance-id" : "serviceInstanceId", + "service-id" : "serviceInstanceId" + }, + "vf-module-request-input" : { + "vf-module-name" : "testVfModuleName", + "vf-module-input-parameters" : {} + }, + "request-information" : { + "request-action" : "DeleteVfModuleInstance", + "source" : "MSO", + "request-id" : "sdncReqId", + "order-number" : null, + "order-version" : null, + "notification-url" : null + }, + "sdnc-request-header" : { + "svc-request-id" : "svcRequestId", + "svc-notification-url" : "http://localhost:8080", + "svc-action" : "unassign" + }, + "vf-module-information" : { + "vf-module-id" : "testVfModuleId", + "from-preload": true + }, + "vnf-information" : { + "vnf-id" : "testVnfId", + "vnf-type" : "testVnfType" + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json b/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json new file mode 100644 index 0000000000..a18b6aa54e --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientGetResponse.json @@ -0,0 +1,27 @@ +{ + "vnf-topology": { + "tenant": "0422ffb57ba042c0800a29dc85ca70f8", + "vnf-topology-identifier-structure": { + "vnf-id": "66dac89b-2a5b-4cb9-b22e-a7e4488fb3db", + "vnf-type": "InfraMSO_vSAMP10a_Service/InfraMSO_vSAMP10a-2 0", + "vnf-name": "MSO-DEV-VNF-1806HF1-InfraMSO_vSAMP10a-1XXX-GR_21" + }, + "aic-clli": "AUSTTXGR", + "vnf-resource-assignments": { + "availability-zones": { + "availability-zone": [ + "AZ-MN02" + ], + "max-count": 1 + } + }, + "aic-cloud-region": "mtn6", + "onap-model-information": { + "model-customization-uuid": "034226ae-879a-46b5-855c-d02babcb6cb6", + "model-uuid": "cb79c25f-b30d-4d95-afb5-97be4021f3db", + "model-invariant-uuid": "e93d3a7a-446d-486b-ae48-d474a9156064", + "model-name": "InfraMSO_vSAMP10a-2", + "model-version": "1.0" + } + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json new file mode 100644 index 0000000000..0de25616e3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponse.json @@ -0,0 +1,127 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + }, + { + "vnf-parameter-name": "additionalParams", + "vnf-parameter-value": "{\"image_id\": \"DUMMYVNF\",\"instance_type\": \"m1.small\",\"ftp_address\": \"ftp://0.0.0.0:2100/\"}" + }, + { + "vnf-parameter-name": "fsb_admin_gateway_ip_1", + "vnf-parameter-value": "0.0.0.0" + }, + { + "vnf-parameter-name": "availability_zone_1" + }, + { + "vnf-parameter-name": "fsb_admin_gateway_ip_2" + }, + { + "vnf-parameter-name": "fsb_admin_prefix_length", + "vnf-parameter-value": "28" + }, + { + "vnf-parameter-name": "ONAPMME_OMCN_vLC_P4_prefix_length", + "vnf-parameter-value": "28" + }, + { + "vnf-parameter-name": "gpbs", + "vnf-parameter-value": "2" + }, + { + "vnf-parameter-name": "fsb_admin_ip_2", + "vnf-parameter-value": "192.0.0.1" + }, + { + "vnf-parameter-name": "internal_mtu", + "vnf-parameter-value": "1500" + }, + { + "vnf-parameter-name": "storage_drbd_sync_rate", + "vnf-parameter-value": "0" + }, + { + "vnf-parameter-name": "ONAPMME_MEDIA_vLC_P3_net_id", + "vnf-parameter-value": "ONAPMME_MEDIA_vLC_P3" + }, + { + "vnf-parameter-name": "extVirtualLinks", + "vnf-parameter-value": "[{\"id\":\"ac1ed33d-8dc1-4800-8ce8-309b99c38eec\",\"tenant\":{\"cloudOwner\":\"CloudOwner\",\"regionName\":\"RegionOne\",\"tenantId\":\"80c26954-2536-4bca-9e20-10f8a2c9c2ad\"},\"resourceId\":\"8ef8cd54-75fd-4372-a6dd-2e05ea8fbd9b\",\"extCps\":[{\"cpdId\":\"f449292f-2f0f-4656-baa3-a18d86bac80f\",\"cpConfig\":[{\"cpInstanceId\":\"07876709-b66f-465c-99a7-0f4d026197f2\",\"linkPortId\":null,\"cpProtocolData\":null}]}],\"extLinkPorts\":null}]" + }, + { + "vnf-parameter-name": "vnfIpAddress", + "vnf-parameter-value": "127.0.0.0" + }, + { + "vnf-parameter-name": "node_type", + "vnf-parameter-value": "sgsnl" + }, + { + "vnf-parameter-name": "ONAPMME_SIG_vLC_P2_net_id", + "vnf-parameter-value": "ONAPMME_SIG_vLC_P2" + }, + { + "vnf-parameter-name": "updateOss", + "vnf-parameter-value": "false" + }, + { + "vnf-parameter-name": "tmo", + "vnf-parameter-value": "0" + }, + { + "vnf-parameter-name": "ss7", + "vnf-parameter-value": "Not_Applicable" + }, + { + "vnf-parameter-name": "ONAPMME_OMCN_vLC_P4_net_id", + "vnf-parameter-value": "ONAPMME_OMCN_vLC_P4" + }, + { + "vnf-parameter-name": "key_name" + }, + { + "vnf-parameter-name": "fsb_admin_dns_server_ip_2" + }, + { + "vnf-parameter-name": "time_zone", + "vnf-parameter-value": "GMT" + }, + { + "vnf-parameter-name": "enableRollback", + "vnf-parameter-value": "false" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json new file mode 100644 index 0000000000..c2cf2b2f28 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidAdditionalAndExtVmData.json @@ -0,0 +1,47 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + }, + { + "vnf-parameter-name": "additionalParams", + "vnf-parameter-value": "[\"abc\"]" + }, + { + "vnf-parameter-name": "extVirtualLinks", + "vnf-parameter-value": "{\"def\":\"123\"}" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json new file mode 100644 index 0000000000..552adb9125 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidData.json @@ -0,0 +1,39 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "vnf-parameter-name": "extra_console", + "vnf-parameter-value": "ttyS1" + }, + { + "vnf-parameter-name": "vnfUsername", + "vnf-parameter-value": "vnf_user" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json new file mode 100644 index 0000000000..e19ad1c9d3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPrelaodDataResponseWithInvalidVnfParamsTag.json @@ -0,0 +1,34 @@ +{ + "vnf-preload-list": [ + { + "vnf-name": "GENERIC_VNF_NAME", + "vnf-type": "SIMPLE", + "preload-data": + { + "network-topology-information": + { + }, + "vnf-topology-information": + { + "vnf-topology-identifier": + { + "service-type": "vCPE", + "vnf-type": "SIMPLE", + "vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-name": "GENERIC_VNF_NAME", + "generic-vnf-type": "SIMPLE" + }, + "vnf-parameters": [ + { + "hello": "world" + } + ] + }, + "oper-status": + { + "order-status": "PendingAssignment" + } + } + } + ] +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json new file mode 100644 index 0000000000..286ce4c844 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200Response.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "Y" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json new file mode 100644 index 0000000000..deb4de0219 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json @@ -0,0 +1,15 @@ +{ + "output": { + "svc-request-id": "5d24d40e-4c77-4c06-94a3-6d168c47a57c", + "network-response-information": { + "instance-id": "4063e0aa-af13-4872-8473-b40c94f9316b", + "object-path": "restconf/config/GENERIC-RESOURCE-API:services/service/2c9c7996-75a7-4f92-becc-9e13e8bd288a/service-data/networks/network/4063e0aa-af13-4872-8473-b40c94f9316b/network-data/network-topology/" + }, + "response-code": "200", + "service-response-information": { + "instance-id": "2c9c7996-75a7-4f92-becc-9e13e8bd288a" + }, + "response-message": "", + "ack-final-indicator": "N" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json b/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json new file mode 100644 index 0000000000..cf0254886d --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientPut404Response.json @@ -0,0 +1,8 @@ +{ + "output": { + "svc-request-id": "086a7a09-1470-4977-8b3e-307488b8811a", + "response-code": "404", + "response-message": "invalid input: the service-instance does not have any service data in SDNC", + "ack-final-indicator": "Y" + } +} diff --git a/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json b/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json new file mode 100644 index 0000000000..7e263b4465 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/SDNCClientResponseIncorrectPath.json @@ -0,0 +1,29 @@ +{ + "vnf-topology": { + "tenant": "0422ffb57ba042c0800a29dc85ca70f8", + "vnf-topology-identifier-structure": { + "vnf-id": "66dac89b-2a5b-4cb9-b22e-a7e4488fb3db", + "vnf-type": "InfraMSO_vSAMP10a_Service/InfraMSO_vSAMP10a-2 0", + "vnf-name": "MSO-DEV-VNF-1806HF1-InfraMSO_vSAMP10a-1XXX-GR_21" + }, + "aic-clli": "AUSTTXGR", + "vnf-resource-assignments": { + "availability-zones": { + "availability-zone": [ + { + "test":"AZ-MN02" + } + ], + "max-count": 1 + } + }, + "aic-cloud-region": "mtn6", + "onap-model-information": { + "model-customization-uuid": "034226ae-879a-46b5-855c-d02babcb6cb6", + "model-uuid": "cb79c25f-b30d-4d95-afb5-97be4021f3db", + "model-invariant-uuid": "e93d3a7a-446d-486b-ae48-d474a9156064", + "model-name": "InfraMSO_vSAMP10a-2", + "model-version": "1.0" + } + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/sdno/client/output-failure.json b/so-sdn-clients/src/test/resources/__files/sdno/client/output-failure.json new file mode 100644 index 0000000000..8cf0a820cd --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/output-failure.json @@ -0,0 +1,25 @@ +{ + "body": { + "output": { + "response-hd-custom": { + "response-status": "Failure", + "cached-data": "false", + "response-interface-type": "ansible", + "response-id": "191bf423-8473-4f7c-9fbb-e5dcbb40a12b", + "remote_end_time": "2017-10-13T14:51:53.490+0000", + "response-client-name": "MSO", + "user_id": "xxxxxx", + "remote_start_time": "2017-10-13T14:51:53.173+0000", + "error-message": "my error message", + "connection-failure-msg": "SDNO was unable to connect to an Ansible REST API server; Please ensure Ansible REST server is running" + } + } + }, + "result-info": { + "code": "200", + "status": "SUCCESS", + "request-id": "xyz123", + "client-name": "MSO", + "processing-host": "sdno-sdno-mtsnjv9sdno01" + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/sdno/client/output-success.json b/so-sdn-clients/src/test/resources/__files/sdno/client/output-success.json new file mode 100644 index 0000000000..a6794327d8 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/output-success.json @@ -0,0 +1,22 @@ +{ + "body": { + "output": { + "response-healthdiagnostic": { + "response-node-ip": "192.20.127.76", + "response-id": "xyz123", + "response-node-name": "mtvnjv9aads11", + "response-status": "Success", + "response-interface-type": "ssh", + "response-details-json": "result", + "cached-data": "false" + } + } + }, + "result-info": { + "client-name": "MSO", + "code": "200", + "processing-host": "sdno1-host01", + "request-id": "xyz123", + "status": "SUCCESS" + } +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/sdno/client/response.json b/so-sdn-clients/src/test/resources/__files/sdno/client/response.json new file mode 100644 index 0000000000..2355e86938 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/sdno/client/response.json @@ -0,0 +1,17 @@ +{ + + "result-info": { + + "client-name": "MSO", + + "code": "202", + + "processing-host": "sdno1-host01", + + "request-id": "xyz123", + + "status": "ACCEPTED" + + } + +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-post-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-post-check-request.json new file mode 100644 index 0000000000..2c46b5a8cb --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-post-check-request.json @@ -0,0 +1,27 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000004", + "operation-type": "lport_mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + }, + { + "key": "interface-id", + "value": "test-interface-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-pre-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-pre-check-request.json new file mode 100644 index 0000000000..bf168b0028 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-lport-mirror-pre-check-request.json @@ -0,0 +1,27 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000003", + "operation-type": "lport_mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + }, + { + "key": "interface-id", + "value": "test-interface-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-post-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-post-check-request.json new file mode 100644 index 0000000000..89e505e7d0 --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-post-check-request.json @@ -0,0 +1,23 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000004", + "operation-type": "mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-pre-check-request.json b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-pre-check-request.json new file mode 100644 index 0000000000..86897c8a1f --- /dev/null +++ b/so-sdn-clients/src/test/resources/__files/sdno/health-check/custom-port-mirror-pre-check-request.json @@ -0,0 +1,23 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000003", + "operation-type": "mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} diff --git a/so-sdn-clients/src/test/resources/application-test.yaml b/so-sdn-clients/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..b64fc3318b --- /dev/null +++ b/so-sdn-clients/src/test/resources/application-test.yaml @@ -0,0 +1,231 @@ +aai: + auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7 + endpoint: http://localhost:${wiremock.server.port} + pnfEntryNotificationTimeout: P14D +appc: + client: + key: iaEMAfjsVsZnraBP + response: + timeout: '120000' + secret: wcivUjsjXzmGFBfxMmyJu9dz + poolMembers: localhost:3904 + service: ueb + topic: + read: + name: APPC-TEST-AMDOCS2 + timeout: '120000' + write: APPC-TEST-AMDOCS1-DEV3 + sdnc: + read: SDNC-LCM-READ + write: SDNC-LCM-WRITE +log: + debug: + CompleteMsoProcess: 'true' + CreateNetworkInstanceInfra: 'true' + CreateServiceInstanceInfra: 'true' + DeleteNetworkInstanceInfra: 'true' + FalloutHandler: 'true' + UpdateNetworkInstanceInfra: 'true' + VnfAdapterRestV1: 'true' + sdncAdapter: 'true' + vnfAdapterCreateV1: 'true' + vnfAdapterRestV1: 'true' +pnf: + dmaap: + host: hostTest + port: 1234 + protocol: http + uriPathPrefix: events + topicName: pnfReady + consumerGroup: consumerGroup + consumerId: consumerId + topicListenerDelayInSeconds: 5 +mso: + naming: + endpoint: http://localhost:${wiremock.server.port}/web/service/v1/genNetworkElementName + auth: Basic YnBlbDptc28tZGItMTUwNyE= + adapters: + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:8081 + completemsoprocess: + endpoint: http://localhost:${wiremock.server.port}/CompleteMsoProcess + db: + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C + endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter + spring: + endpoint: http://localhost:${wiremock.server.port} + network: + endpoint: http://localhost:${wiremock.server.port}/networks/NetworkAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/networks/rest/v1/networks + openecomp: + db: + endpoint: http://localhost:${wiremock.server.port}/dbadapters/RequestsDbAdapter + po: + auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C + password: 3141634BF7E070AA289CF2892C986C0B + sdnc: + endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/SDNCAdapter/v1/sdnc + timeout: PT60S + tenant: + endpoint: http://localhost:${wiremock.server.port}/tenantAdapterMock + vnf: + endpoint: http://localhost:${wiremock.server.port}/vnfs/VnfAdapter + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs + volume-groups: + rest: + endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/volume-groups + vnf-async: + endpoint: http://localhost:${wiremock.server.port}/vnfs/VnfAdapterAsync + workflow: + message: + endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message + + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 + + bpmn: + optimisticlockingexception: + retrycount: '3' + cloudRegionIdsToSkipAddingVnfEdgesTo: test25Region1,test25Region2,test25Region99 + callbackRetryAttempts: '5' + catalog: + db: + endpoint: http://localhost:${wiremock.server.port}/ + spring: + endpoint: http://localhost:${wiremock.server.port} + correlation: + timeout: 60 + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + default: + adapter: + namespace: http://org.onap.so + healthcheck: + log: + debug: 'false' + infra: + customer: + id: testCustIdInfra + logPath: logs + msoKey: 07a7159d3bf51a0e53be7a8f89699be7 + po: + timeout: PT60S + request: + db: + endpoint: http://localhost:${wiremock.server.port}/ + rollback: 'true' + site-name: localDevEnv + workflow: + default: + aai: + cloud-region: + version: '9' + generic-vnf: + version: '9' + global: + default: + aai: + namespace: http://org.openecomp.aai.inventory/ + version: '8' + message: + endpoint: http://localhost:${wiremock.server.port}/mso/WorkflowMesssage + notification: + name: GenericNotificationService + sdncadapter: + callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService + vnfadapter: + create: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + delete: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + query: + callback: http://localhost:${wiremock.server.port}/mso/services/VNFAdapterQuerCallbackV1 + rollback: + callback: http://localhost:${wiremock.server.port}/mso/vnfAdapterNotify + global: + dmaap: + username: dmaapUsername + password: dmaapPassword + host: http://localhost:28090 + publisher: + topic: com.att.mso.asyncStatusUpdate +policy: + auth: Basic dGVzdHBkcDphbHBoYTEyMw== + client: + auth: Basic bTAzNzQzOnBvbGljeVIwY2sk + endpoint: https://localhost:8081/pdp/api/ + environment: TEST +sdnc: + auth: Basic YWRtaW46YWRtaW4= + host: http://localhost:${wiremock.server.port} + path: /restconf/operations/GENERIC-RESOURCE-API +sniro: + conductor: + enabled: true + host: http://localhost:${wiremock.server.port} + uri: /v1/release-orders + headers.auth: Basic dGVzdDp0ZXN0cHdk + manager: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri.v1: /sniro/api/v2/placement + uri.v2: /sniro/api/placement/v2 + headers.auth: Basic dGVzdDp0ZXN0cHdk + headers.patchVersion: 1 + headers.minorVersion: 1 + headers.latestVersion: 2 +oof: + timeout: PT30M + host: http://localhost:${wiremock.server.port} + uri: /api/oof/v1/placement + headers.auth: Basic dGVzdDp0ZXN0cHdk +org: + onap: + so: + cloud-owner: att-aic +spring: + datasource: + jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialization-mode: always + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: none + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect +sdno: + health-check: + dmaap: + password: password + publisher: + topic: sdno.test-health-diagnostic-v02 + subscriber: + topic: sdno.test-health-diagnostic-v02 + username: username +mariaDB4j: + dataDir: + port: 3307 + databaseName: camundabpmn +camunda: + bpm: + metrics: + enabled: false + db-reporter-activate: false +# CDSProcessingClient +cds: + endpoint: localhost + port: 11012 + auth: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + timeout: 60 diff --git a/so-sdn-clients/src/test/resources/dmaap.properties b/so-sdn-clients/src/test/resources/dmaap.properties new file mode 100644 index 0000000000..5593455da3 --- /dev/null +++ b/so-sdn-clients/src/test/resources/dmaap.properties @@ -0,0 +1,10 @@ +sdno.health-check.dmaap.username=testuser +sdno.health-check.dmaap.password=eHQ1cUJrOUc +sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02 +sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02 +ruby.create-ticket-request.dmaap.username=testuser +ruby.create-ticket-request.dmaap.password=eHQ1cUJrOUc +ruby.create-ticket-request.publisher.topic=com.att.pdas.st1.msoCMFallout-v1 +ruby.create-ticket-request.dmaap.auth=81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 +sdno.health-check.dmaap.auth=81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 +mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7 \ No newline at end of file diff --git a/so-sdn-clients/src/test/resources/schema.sql b/so-sdn-clients/src/test/resources/schema.sql new file mode 100644 index 0000000000..5ae6a2d972 --- /dev/null +++ b/so-sdn-clients/src/test/resources/schema.sql @@ -0,0 +1,1195 @@ + +USE `camundabpmn`; + + +create table ACT_GE_PROPERTY ( + NAME_ varchar(64), + VALUE_ varchar(300), + REV_ integer, + primary key (NAME_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create table ACT_GE_BYTEARRAY ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + BYTES_ LONGBLOB, + GENERATED_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_DEPLOYMENT ( + ID_ varchar(64), + NAME_ varchar(255), + DEPLOY_TIME_ timestamp(3), + SOURCE_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXECUTION ( + ID_ varchar(64), + REV_ integer, + PROC_INST_ID_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + SUPER_EXEC_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + IS_ACTIVE_ TINYINT, + IS_CONCURRENT_ TINYINT, + IS_SCOPE_ TINYINT, + IS_EVENT_SCOPE_ TINYINT, + SUSPENSION_STATE_ integer, + CACHED_ENT_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOB ( + ID_ varchar(64) NOT NULL, + REV_ integer, + TYPE_ varchar(255) NOT NULL, + LOCK_EXP_TIME_ timestamp(3) NULL, + LOCK_OWNER_ varchar(255), + EXCLUSIVE_ boolean, + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + RETRIES_ integer, + EXCEPTION_STACK_ID_ varchar(64), + EXCEPTION_MSG_ varchar(4000), + DUEDATE_ timestamp(3) NULL, + REPEAT_ varchar(255), + HANDLER_TYPE_ varchar(255), + HANDLER_CFG_ varchar(4000), + DEPLOYMENT_ID_ varchar(64), + SUSPENSION_STATE_ integer NOT NULL DEFAULT 1, + JOB_DEF_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_JOBDEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + JOB_TYPE_ varchar(255) NOT NULL, + JOB_CONFIGURATION_ varchar(255), + SUSPENSION_STATE_ integer, + JOB_PRIORITY_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RE_PROCDEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + HAS_START_FORM_KEY_ TINYINT, + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + VERSION_TAG_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_TASK ( + ID_ varchar(64), + REV_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + TASK_DEF_KEY_ varchar(255), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + DELEGATION_ varchar(64), + PRIORITY_ integer, + CREATE_TIME_ timestamp(3), + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + SUSPENSION_STATE_ integer, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_IDENTITYLINK ( + ID_ varchar(64), + REV_ integer, + GROUP_ID_ varchar(255), + TYPE_ varchar(255), + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_VARIABLE ( + ID_ varchar(64) not null, + REV_ integer, + TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + TASK_ID_ varchar(64), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + VAR_SCOPE_ varchar(64) not null, + SEQUENCE_COUNTER_ bigint, + IS_CONCURRENT_LOCAL_ TINYINT, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EVENT_SUBSCR ( + ID_ varchar(64) not null, + REV_ integer, + EVENT_TYPE_ varchar(255) not null, + EVENT_NAME_ varchar(255), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + CONFIGURATION_ varchar(255), + CREATED_ timestamp(3) not null, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_INCIDENT ( + ID_ varchar(64) not null, + REV_ integer not null, + INCIDENT_TIMESTAMP_ timestamp(3) not null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + EXECUTION_ID_ varchar(64), + ACTIVITY_ID_ varchar(255), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_AUTHORIZATION ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ integer not null, + GROUP_ID_ varchar(255), + USER_ID_ varchar(255), + RESOURCE_TYPE_ integer not null, + RESOURCE_ID_ varchar(255), + PERMS_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_FILTER ( + ID_ varchar(64) not null, + REV_ integer not null, + RESOURCE_TYPE_ varchar(255) not null, + NAME_ varchar(255) not null, + OWNER_ varchar(255), + QUERY_ LONGTEXT not null, + PROPERTIES_ LONGTEXT, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_METER_LOG ( + ID_ varchar(64) not null, + NAME_ varchar(64) not null, + REPORTER_ varchar(255), + VALUE_ bigint, + TIMESTAMP_ timestamp(3), + MILLISECONDS_ bigint DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_EXT_TASK ( + ID_ varchar(64) not null, + REV_ integer not null, + WORKER_ID_ varchar(255), + TOPIC_NAME_ varchar(255), + RETRIES_ integer, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + LOCK_EXP_TIME_ timestamp(3) NULL, + SUSPENSION_STATE_ integer, + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + TENANT_ID_ varchar(64), + PRIORITY_ bigint NOT NULL DEFAULT 0, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_RU_BATCH ( + ID_ varchar(64) not null, + REV_ integer not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_CREATED_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + SUSPENSION_STATE_ integer, + CONFIGURATION_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_EXEC_BUSKEY on ACT_RU_EXECUTION(BUSINESS_KEY_); +create index ACT_IDX_EXEC_TENANT_ID on ACT_RU_EXECUTION(TENANT_ID_); +create index ACT_IDX_TASK_CREATE on ACT_RU_TASK(CREATE_TIME_); +create index ACT_IDX_TASK_ASSIGNEE on ACT_RU_TASK(ASSIGNEE_); +create index ACT_IDX_TASK_TENANT_ID on ACT_RU_TASK(TENANT_ID_); +create index ACT_IDX_IDENT_LNK_USER on ACT_RU_IDENTITYLINK(USER_ID_); +create index ACT_IDX_IDENT_LNK_GROUP on ACT_RU_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_EVENT_SUBSCR_CONFIG_ on ACT_RU_EVENT_SUBSCR(CONFIGURATION_); +create index ACT_IDX_EVENT_SUBSCR_TENANT_ID on ACT_RU_EVENT_SUBSCR(TENANT_ID_); +create index ACT_IDX_VARIABLE_TASK_ID on ACT_RU_VARIABLE(TASK_ID_); +create index ACT_IDX_VARIABLE_TENANT_ID on ACT_RU_VARIABLE(TENANT_ID_); +create index ACT_IDX_ATHRZ_PROCEDEF on ACT_RU_IDENTITYLINK(PROC_DEF_ID_); +create index ACT_IDX_INC_CONFIGURATION on ACT_RU_INCIDENT(CONFIGURATION_); +create index ACT_IDX_INC_TENANT_ID on ACT_RU_INCIDENT(TENANT_ID_); +-- CAM-5914 +create index ACT_IDX_JOB_EXECUTION_ID on ACT_RU_JOB(EXECUTION_ID_); +-- this index needs to be limited in mariadb see CAM-6938 +create index ACT_IDX_JOB_HANDLER on ACT_RU_JOB(HANDLER_TYPE_(100),HANDLER_CFG_(155)); +create index ACT_IDX_JOB_PROCINST on ACT_RU_JOB(PROCESS_INSTANCE_ID_); +create index ACT_IDX_JOB_TENANT_ID on ACT_RU_JOB(TENANT_ID_); +create index ACT_IDX_JOBDEF_TENANT_ID on ACT_RU_JOBDEF(TENANT_ID_); + +-- new metric milliseconds column +CREATE INDEX ACT_IDX_METER_LOG_MS ON ACT_RU_METER_LOG(MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_NAME_MS ON ACT_RU_METER_LOG(NAME_, MILLISECONDS_); +CREATE INDEX ACT_IDX_METER_LOG_REPORT ON ACT_RU_METER_LOG(NAME_, REPORTER_, MILLISECONDS_); + +-- old metric timestamp column +CREATE INDEX ACT_IDX_METER_LOG_TIME ON ACT_RU_METER_LOG(TIMESTAMP_); +CREATE INDEX ACT_IDX_METER_LOG ON ACT_RU_METER_LOG(NAME_, TIMESTAMP_); + +create index ACT_IDX_EXT_TASK_TOPIC on ACT_RU_EXT_TASK(TOPIC_NAME_); +create index ACT_IDX_EXT_TASK_TENANT_ID on ACT_RU_EXT_TASK(TENANT_ID_); +create index ACT_IDX_EXT_TASK_PRIORITY ON ACT_RU_EXT_TASK(PRIORITY_); +create index ACT_IDX_EXT_TASK_ERR_DETAILS ON ACT_RU_EXT_TASK(ERROR_DETAILS_ID_); +create index ACT_IDX_AUTH_GROUP_ID ON ACT_RU_AUTHORIZATION(GROUP_ID_); +create index ACT_IDX_JOB_JOB_DEF_ID on ACT_RU_JOB(JOB_DEF_ID_); + +alter table ACT_GE_BYTEARRAY + add constraint ACT_FK_BYTEARR_DEPL + foreign key (DEPLOYMENT_ID_) + references ACT_RE_DEPLOYMENT (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_SUPER + foreign key (SUPER_EXEC_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_EXECUTION + add constraint ACT_FK_EXE_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_TSKASS_TASK + foreign key (TASK_ID_) + references ACT_RU_TASK (ID_); + +alter table ACT_RU_IDENTITYLINK + add constraint ACT_FK_ATHRZ_PROCEDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_BYTEARRAY + foreign key (BYTEARRAY_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_JOB + add constraint ACT_FK_JOB_EXCEPTION + foreign key (EXCEPTION_STACK_ID_) + references ACT_GE_BYTEARRAY (ID_); + +alter table ACT_RU_EVENT_SUBSCR + add constraint ACT_FK_EVENT_EXEC + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION(ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCINST + foreign key (PROC_INST_ID_) + references ACT_RU_EXECUTION (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_PROCDEF + foreign key (PROC_DEF_ID_) + references ACT_RE_PROCDEF (ID_); + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_CAUSE + foreign key (CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_RCAUSE + foreign key (ROOT_CAUSE_INCIDENT_ID_) + references ACT_RU_INCIDENT (ID_) on delete cascade on update cascade; + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_ERROR_DETAILS + foreign key (ERROR_DETAILS_ID_) + references ACT_GE_BYTEARRAY (ID_); + +create index ACT_IDX_INC_JOB_DEF on ACT_RU_INCIDENT(JOB_DEF_ID_); +alter table ACT_RU_INCIDENT + add constraint ACT_FK_INC_JOB_DEF + foreign key (JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_USER + unique (USER_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_AUTHORIZATION + add constraint ACT_UNIQ_AUTH_GROUP + unique (GROUP_ID_,TYPE_,RESOURCE_TYPE_,RESOURCE_ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_UNIQ_VARIABLE + unique (VAR_SCOPE_, NAME_); + +alter table ACT_RU_EXT_TASK + add constraint ACT_FK_EXT_TASK_EXE + foreign key (EXECUTION_ID_) + references ACT_RU_EXECUTION (ID_); + +create index ACT_IDX_BATCH_SEED_JOB_DEF ON ACT_RU_BATCH(SEED_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_SEED_JOB_DEF + foreign key (SEED_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_MONITOR_JOB_DEF ON ACT_RU_BATCH(MONITOR_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_MONITOR_JOB_DEF + foreign key (MONITOR_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +create index ACT_IDX_BATCH_JOB_DEF ON ACT_RU_BATCH(BATCH_JOB_DEF_ID_); +alter table ACT_RU_BATCH + add constraint ACT_FK_BATCH_JOB_DEF + foreign key (BATCH_JOB_DEF_ID_) + references ACT_RU_JOBDEF (ID_); + +-- indexes for deadlock problems - https://app.camunda.com/jira/browse/CAM-2567 -- +create index ACT_IDX_INC_CAUSEINCID on ACT_RU_INCIDENT(CAUSE_INCIDENT_ID_); +create index ACT_IDX_INC_EXID on ACT_RU_INCIDENT(EXECUTION_ID_); +create index ACT_IDX_INC_PROCDEFID on ACT_RU_INCIDENT(PROC_DEF_ID_); +create index ACT_IDX_INC_PROCINSTID on ACT_RU_INCIDENT(PROC_INST_ID_); +create index ACT_IDX_INC_ROOTCAUSEINCID on ACT_RU_INCIDENT(ROOT_CAUSE_INCIDENT_ID_); +-- index for deadlock problem - https://app.camunda.com/jira/browse/CAM-4440 -- +create index ACT_IDX_AUTH_RESOURCE_ID on ACT_RU_AUTHORIZATION(RESOURCE_ID_); +-- index to prevent deadlock on fk constraint - https://app.camunda.com/jira/browse/CAM-5440 -- +create index ACT_IDX_EXT_TASK_EXEC on ACT_RU_EXT_TASK(EXECUTION_ID_); + +-- indexes to improve deployment +create index ACT_IDX_BYTEARRAY_NAME on ACT_GE_BYTEARRAY(NAME_); +create index ACT_IDX_DEPLOYMENT_NAME on ACT_RE_DEPLOYMENT(NAME_); +create index ACT_IDX_DEPLOYMENT_TENANT_ID on ACT_RE_DEPLOYMENT(TENANT_ID_); +create index ACT_IDX_JOBDEF_PROC_DEF_ID ON ACT_RU_JOBDEF(PROC_DEF_ID_); +create index ACT_IDX_JOB_HANDLER_TYPE ON ACT_RU_JOB(HANDLER_TYPE_); +create index ACT_IDX_EVENT_SUBSCR_EVT_NAME ON ACT_RU_EVENT_SUBSCR(EVENT_NAME_); +create index ACT_IDX_PROCDEF_DEPLOYMENT_ID ON ACT_RE_PROCDEF(DEPLOYMENT_ID_); +create index ACT_IDX_PROCDEF_TENANT_ID ON ACT_RE_PROCDEF(TENANT_ID_); +create index ACT_IDX_PROCDEF_VER_TAG ON ACT_RE_PROCDEF(VERSION_TAG_); +-- create case definition table -- +create table ACT_RE_CASE_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case execution table -- +create table ACT_RU_CASE_EXECUTION ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + SUPER_CASE_EXEC_ varchar(64), + SUPER_EXEC_ varchar(64), + BUSINESS_KEY_ varchar(255), + PARENT_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + ACT_ID_ varchar(255), + PREV_STATE_ integer, + CURRENT_STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create case sentry part table -- + +create table ACT_RU_CASE_SENTRY_PART ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CASE_INST_ID_ varchar(64), + CASE_EXEC_ID_ varchar(64), + SENTRY_ID_ varchar(255), + TYPE_ varchar(255), + SOURCE_CASE_EXEC_ID_ varchar(64), + STANDARD_EVENT_ varchar(255), + SOURCE_ varchar(255), + VARIABLE_EVENT_ varchar(255), + VARIABLE_NAME_ varchar(255), + SATISFIED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create index on business key -- +create index ACT_IDX_CASE_EXEC_BUSKEY on ACT_RU_CASE_EXECUTION(BUSINESS_KEY_); + +-- create foreign key constraints on ACT_RU_CASE_EXECUTION -- +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_) on delete cascade on update cascade; + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_PARENT + foreign key (PARENT_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_EXECUTION + add constraint ACT_FK_CASE_EXE_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_VARIABLE -- +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_VARIABLE + add constraint ACT_FK_VAR_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +-- create foreign key constraints on ACT_RU_TASK -- +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_EXE + foreign key (CASE_EXECUTION_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_TASK + add constraint ACT_FK_TASK_CASE_DEF + foreign key (CASE_DEF_ID_) + references ACT_RE_CASE_DEF(ID_); + +-- create foreign key constraints on ACT_RU_CASE_SENTRY_PART -- +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_INST + foreign key (CASE_INST_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +alter table ACT_RU_CASE_SENTRY_PART + add constraint ACT_FK_CASE_SENTRY_CASE_EXEC + foreign key (CASE_EXEC_ID_) + references ACT_RU_CASE_EXECUTION(ID_); + +create index ACT_IDX_CASE_DEF_TENANT_ID on ACT_RE_CASE_DEF(TENANT_ID_); +create index ACT_IDX_CASE_EXEC_TENANT_ID on ACT_RU_CASE_EXECUTION(TENANT_ID_); +-- create decision definition table -- +create table ACT_RE_DECISION_DEF ( + ID_ varchar(64) not null, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) not null, + VERSION_ integer not null, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + HISTORY_TTL_ integer, + VERSION_TAG_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create decision requirements definition table -- +create table ACT_RE_DECISION_REQ_DEF ( + ID_ varchar(64) NOT NULL, + REV_ integer, + CATEGORY_ varchar(255), + NAME_ varchar(255), + KEY_ varchar(255) NOT NULL, + VERSION_ integer NOT NULL, + DEPLOYMENT_ID_ varchar(64), + RESOURCE_NAME_ varchar(4000), + DGRM_RESOURCE_NAME_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_RE_DECISION_DEF + add constraint ACT_FK_DEC_REQ + foreign key (DEC_REQ_ID_) + references ACT_RE_DECISION_REQ_DEF(ID_); + +create index ACT_IDX_DEC_DEF_TENANT_ID on ACT_RE_DECISION_DEF(TENANT_ID_); +create index ACT_IDX_DEC_DEF_REQ_ID on ACT_RE_DECISION_DEF(DEC_REQ_ID_); +create index ACT_IDX_DEC_REQ_DEF_TENANT_ID on ACT_RE_DECISION_REQ_DEF(TENANT_ID_); +create table ACT_HI_PROCINST ( + ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + START_USER_ID_ varchar(255), + START_ACT_ID_ varchar(255), + END_ACT_ID_ varchar(255), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + SUPER_CASE_INSTANCE_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + DELETE_REASON_ varchar(4000), + TENANT_ID_ varchar(64), + STATE_ varchar(255), + primary key (ID_), + unique (PROC_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) not null, + EXECUTION_ID_ varchar(64) not null, + ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + ACT_NAME_ varchar(255), + ACT_TYPE_ varchar(255) not null, + ASSIGNEE_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + ACT_INST_STATE_ integer, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_TASKINST ( + ID_ varchar(64) not null, + TASK_DEF_KEY_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + NAME_ varchar(255), + PARENT_TASK_ID_ varchar(64), + DESCRIPTION_ varchar(4000), + OWNER_ varchar(255), + ASSIGNEE_ varchar(255), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + DELETE_REASON_ varchar(4000), + PRIORITY_ integer, + DUE_DATE_ datetime(3), + FOLLOW_UP_DATE_ datetime(3), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_VARINST ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(100), + REV_ integer, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + STATE_ varchar(20), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_DETAIL ( + ID_ varchar(64) not null, + TYPE_ varchar(255) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + VAR_INST_ID_ varchar(64), + NAME_ varchar(255) not null, + VAR_TYPE_ varchar(255), + REV_ integer, + TIME_ datetime(3) not null, + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + OPERATION_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_IDENTITYLINK ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + TYPE_ varchar(255), + USER_ID_ varchar(255), + GROUP_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + OPERATION_TYPE_ varchar(64), + ASSIGNER_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_COMMENT ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TIME_ datetime(3) not null, + USER_ID_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + ACTION_ varchar(255), + MESSAGE_ varchar(4000), + FULL_MSG_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_ATTACHMENT ( + ID_ varchar(64) not null, + REV_ integer, + USER_ID_ varchar(255), + NAME_ varchar(255), + DESCRIPTION_ varchar(4000), + TYPE_ varchar(255), + TASK_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + URL_ varchar(4000), + CONTENT_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_OP_LOG ( + ID_ varchar(64) not null, + DEPLOYMENT_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + CASE_EXECUTION_ID_ varchar(64), + TASK_ID_ varchar(64), + JOB_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + BATCH_ID_ varchar(64), + USER_ID_ varchar(255), + TIMESTAMP_ timestamp(3) not null, + OPERATION_TYPE_ varchar(64), + OPERATION_ID_ varchar(64), + ENTITY_TYPE_ varchar(30), + PROPERTY_ varchar(64), + ORG_VALUE_ varchar(4000), + NEW_VALUE_ varchar(4000), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_INCIDENT ( + ID_ varchar(64) not null, + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + CREATE_TIME_ timestamp(3) not null, + END_TIME_ timestamp(3) null, + INCIDENT_MSG_ varchar(4000), + INCIDENT_TYPE_ varchar(255) not null, + ACTIVITY_ID_ varchar(255), + CAUSE_INCIDENT_ID_ varchar(64), + ROOT_CAUSE_INCIDENT_ID_ varchar(64), + CONFIGURATION_ varchar(255), + INCIDENT_STATE_ integer, + TENANT_ID_ varchar(64), + JOB_DEF_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_JOB_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + JOB_ID_ varchar(64) not null, + JOB_DUEDATE_ timestamp(3) NULL, + JOB_RETRIES_ integer, + JOB_PRIORITY_ bigint NOT NULL DEFAULT 0, + JOB_EXCEPTION_MSG_ varchar(4000), + JOB_EXCEPTION_STACK_ID_ varchar(64), + JOB_STATE_ integer, + JOB_DEF_ID_ varchar(64), + JOB_DEF_TYPE_ varchar(255), + JOB_DEF_CONFIGURATION_ varchar(255), + ACT_ID_ varchar(255), + EXECUTION_ID_ varchar(64), + PROCESS_INSTANCE_ID_ varchar(64), + PROCESS_DEF_ID_ varchar(64), + PROCESS_DEF_KEY_ varchar(255), + DEPLOYMENT_ID_ varchar(64), + SEQUENCE_COUNTER_ bigint, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_BATCH ( + ID_ varchar(64) not null, + TYPE_ varchar(255), + TOTAL_JOBS_ integer, + JOBS_PER_SEED_ integer, + INVOCATIONS_PER_JOB_ integer, + SEED_JOB_DEF_ID_ varchar(64), + MONITOR_JOB_DEF_ID_ varchar(64), + BATCH_JOB_DEF_ID_ varchar(64), + TENANT_ID_ varchar(64), + START_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_EXT_TASK_LOG ( + ID_ varchar(64) not null, + TIMESTAMP_ timestamp(3) not null, + EXT_TASK_ID_ varchar(64) not null, + RETRIES_ integer, + TOPIC_NAME_ varchar(255), + WORKER_ID_ varchar(255), + PRIORITY_ bigint NOT NULL DEFAULT 0, + ERROR_MSG_ varchar(4000), + ERROR_DETAILS_ID_ varchar(64), + ACT_ID_ varchar(255), + ACT_INST_ID_ varchar(64), + EXECUTION_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + PROC_DEF_ID_ varchar(64), + PROC_DEF_KEY_ varchar(255), + TENANT_ID_ varchar(64), + STATE_ integer, + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_PRO_INST_END on ACT_HI_PROCINST(END_TIME_); +create index ACT_IDX_HI_PRO_I_BUSKEY on ACT_HI_PROCINST(BUSINESS_KEY_); +create index ACT_IDX_HI_PRO_INST_TENANT_ID on ACT_HI_PROCINST(TENANT_ID_); +create index ACT_IDX_HI_PRO_INST_PROC_DEF_KEY on ACT_HI_PROCINST(PROC_DEF_KEY_); + +create index ACT_IDX_HI_ACT_INST_START on ACT_HI_ACTINST(START_TIME_); +create index ACT_IDX_HI_ACT_INST_END on ACT_HI_ACTINST(END_TIME_); +create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); +create index ACT_IDX_HI_ACT_INST_COMP on ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_ACT_INST_STATS on ACT_HI_ACTINST(PROC_DEF_ID_, ACT_ID_, END_TIME_, ACT_INST_STATE_); +create index ACT_IDX_HI_ACT_INST_TENANT_ID on ACT_HI_ACTINST(TENANT_ID_); +create index ACT_IDX_HI_ACT_INST_PROC_DEF_KEY on ACT_HI_ACTINST(PROC_DEF_KEY_); + +create index ACT_IDX_HI_TASK_INST_TENANT_ID on ACT_HI_TASKINST(TENANT_ID_); +create index ACT_IDX_HI_TASK_INST_PROC_DEF_KEY on ACT_HI_TASKINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_TASKINST_PROCINST on ACT_HI_TASKINST(PROC_INST_ID_); +create index ACT_IDX_HI_TASKINSTID_PROCINST on ACT_HI_TASKINST(ID_,PROC_INST_ID_); + +create index ACT_IDX_HI_DETAIL_PROC_INST on ACT_HI_DETAIL(PROC_INST_ID_); +create index ACT_IDX_HI_DETAIL_ACT_INST on ACT_HI_DETAIL(ACT_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_INST on ACT_HI_DETAIL(CASE_INST_ID_); +create index ACT_IDX_HI_DETAIL_CASE_EXEC on ACT_HI_DETAIL(CASE_EXECUTION_ID_); +create index ACT_IDX_HI_DETAIL_TIME on ACT_HI_DETAIL(TIME_); +create index ACT_IDX_HI_DETAIL_NAME on ACT_HI_DETAIL(NAME_); +create index ACT_IDX_HI_DETAIL_TASK_ID on ACT_HI_DETAIL(TASK_ID_); +create index ACT_IDX_HI_DETAIL_TENANT_ID on ACT_HI_DETAIL(TENANT_ID_); +create index ACT_IDX_HI_DETAIL_PROC_DEF_KEY on ACT_HI_DETAIL(PROC_DEF_KEY_); +create index ACT_IDX_HI_DETAIL_BYTEAR on ACT_HI_DETAIL(BYTEARRAY_ID_); + +create index ACT_IDX_HI_IDENT_LNK_USER on ACT_HI_IDENTITYLINK(USER_ID_); +create index ACT_IDX_HI_IDENT_LNK_GROUP on ACT_HI_IDENTITYLINK(GROUP_ID_); +create index ACT_IDX_HI_IDENT_LNK_TENANT_ID on ACT_HI_IDENTITYLINK(TENANT_ID_); +create index ACT_IDX_HI_IDENT_LNK_PROC_DEF_KEY on ACT_HI_IDENTITYLINK(PROC_DEF_KEY_); +create index ACT_IDX_HI_IDENT_LINK_TASK on ACT_HI_IDENTITYLINK(TASK_ID_); + +create index ACT_IDX_HI_PROCVAR_PROC_INST on ACT_HI_VARINST(PROC_INST_ID_); +create index ACT_IDX_HI_PROCVAR_NAME_TYPE on ACT_HI_VARINST(NAME_, VAR_TYPE_); +create index ACT_IDX_HI_CASEVAR_CASE_INST on ACT_HI_VARINST(CASE_INST_ID_); +create index ACT_IDX_HI_VAR_INST_TENANT_ID on ACT_HI_VARINST(TENANT_ID_); +create index ACT_IDX_HI_VAR_INST_PROC_DEF_KEY on ACT_HI_VARINST(PROC_DEF_KEY_); +create index ACT_IDX_HI_VARINST_BYTEAR on ACT_HI_VARINST(BYTEARRAY_ID_); + +create index ACT_IDX_HI_INCIDENT_TENANT_ID on ACT_HI_INCIDENT(TENANT_ID_); +create index ACT_IDX_HI_INCIDENT_PROC_DEF_KEY on ACT_HI_INCIDENT(PROC_DEF_KEY_); +create index ACT_IDX_HI_INCIDENT_PROCINST on ACT_HI_INCIDENT(PROC_INST_ID_); + +create index ACT_IDX_HI_JOB_LOG_PROCINST on ACT_HI_JOB_LOG(PROCESS_INSTANCE_ID_); +create index ACT_IDX_HI_JOB_LOG_PROCDEF on ACT_HI_JOB_LOG(PROCESS_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_TENANT_ID on ACT_HI_JOB_LOG(TENANT_ID_); +create index ACT_IDX_HI_JOB_LOG_JOB_DEF_ID on ACT_HI_JOB_LOG(JOB_DEF_ID_); +create index ACT_IDX_HI_JOB_LOG_PROC_DEF_KEY on ACT_HI_JOB_LOG(PROCESS_DEF_KEY_); +create index ACT_IDX_HI_JOB_LOG_EX_STACK on ACT_HI_JOB_LOG(JOB_EXCEPTION_STACK_ID_); + +create index ACT_HI_EXT_TASK_LOG_PROCINST on ACT_HI_EXT_TASK_LOG(PROC_INST_ID_); +create index ACT_HI_EXT_TASK_LOG_PROCDEF on ACT_HI_EXT_TASK_LOG(PROC_DEF_ID_); +create index ACT_HI_EXT_TASK_LOG_PROC_DEF_KEY on ACT_HI_EXT_TASK_LOG(PROC_DEF_KEY_); +create index ACT_HI_EXT_TASK_LOG_TENANT_ID on ACT_HI_EXT_TASK_LOG(TENANT_ID_); +create index ACT_IDX_HI_EXTTASKLOG_ERRORDET on ACT_HI_EXT_TASK_LOG(ERROR_DETAILS_ID_); + +create index ACT_IDX_HI_OP_LOG_PROCINST on ACT_HI_OP_LOG(PROC_INST_ID_); +create index ACT_IDX_HI_OP_LOG_PROCDEF on ACT_HI_OP_LOG(PROC_DEF_ID_); + +create index ACT_IDX_HI_COMMENT_TASK on ACT_HI_COMMENT(TASK_ID_); +create index ACT_IDX_HI_COMMENT_PROCINST on ACT_HI_COMMENT(PROC_INST_ID_); + +create index ACT_IDX_HI_ATTACHMENT_CONTENT on ACT_HI_ATTACHMENT(CONTENT_ID_); +create index ACT_IDX_HI_ATTACHMENT_PROCINST on ACT_HI_ATTACHMENT(PROC_INST_ID_); +create index ACT_IDX_HI_ATTACHMENT_TASK on ACT_HI_ATTACHMENT(TASK_ID_); +create table ACT_HI_CASEINST ( + ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + BUSINESS_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64) not null, + CREATE_TIME_ datetime(3) not null, + CLOSE_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + CREATE_USER_ID_ varchar(255), + SUPER_CASE_INSTANCE_ID_ varchar(64), + SUPER_PROCESS_INSTANCE_ID_ varchar(64), + TENANT_ID_ varchar(64), + primary key (ID_), + unique (CASE_INST_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_HI_CASEACTINST ( + ID_ varchar(64) not null, + PARENT_ACT_INST_ID_ varchar(64), + CASE_DEF_ID_ varchar(64) not null, + CASE_INST_ID_ varchar(64) not null, + CASE_ACT_ID_ varchar(255) not null, + TASK_ID_ varchar(64), + CALL_PROC_INST_ID_ varchar(64), + CALL_CASE_INST_ID_ varchar(64), + CASE_ACT_NAME_ varchar(255), + CASE_ACT_TYPE_ varchar(255), + CREATE_TIME_ datetime(3) not null, + END_TIME_ datetime(3), + DURATION_ bigint, + STATE_ integer, + REQUIRED_ boolean, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create index ACT_IDX_HI_CAS_I_CLOSE on ACT_HI_CASEINST(CLOSE_TIME_); +create index ACT_IDX_HI_CAS_I_BUSKEY on ACT_HI_CASEINST(BUSINESS_KEY_); +create index ACT_IDX_HI_CAS_I_TENANT_ID on ACT_HI_CASEINST(TENANT_ID_); +create index ACT_IDX_HI_CAS_A_I_CREATE on ACT_HI_CASEACTINST(CREATE_TIME_); +create index ACT_IDX_HI_CAS_A_I_END on ACT_HI_CASEACTINST(END_TIME_); +create index ACT_IDX_HI_CAS_A_I_COMP on ACT_HI_CASEACTINST(CASE_ACT_ID_, END_TIME_, ID_); +create index ACT_IDX_HI_CAS_A_I_CASEINST on ACT_HI_CASEACTINST(CASE_INST_ID_, CASE_ACT_ID_); +create index ACT_IDX_HI_CAS_A_I_TENANT_ID on ACT_HI_CASEACTINST(TENANT_ID_); +-- create history decision instance table -- +create table ACT_HI_DECINST ( + ID_ varchar(64) NOT NULL, + DEC_DEF_ID_ varchar(64) NOT NULL, + DEC_DEF_KEY_ varchar(255) NOT NULL, + DEC_DEF_NAME_ varchar(255), + PROC_DEF_KEY_ varchar(255), + PROC_DEF_ID_ varchar(64), + PROC_INST_ID_ varchar(64), + CASE_DEF_KEY_ varchar(255), + CASE_DEF_ID_ varchar(64), + CASE_INST_ID_ varchar(64), + ACT_INST_ID_ varchar(64), + ACT_ID_ varchar(255), + EVAL_TIME_ datetime(3) not null, + COLLECT_VALUE_ double, + USER_ID_ varchar(255), + ROOT_DEC_INST_ID_ varchar(64), + DEC_REQ_ID_ varchar(64), + DEC_REQ_KEY_ varchar(255), + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision input table -- +create table ACT_HI_DEC_IN ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +-- create history decision output table -- +create table ACT_HI_DEC_OUT ( + ID_ varchar(64) NOT NULL, + DEC_INST_ID_ varchar(64) NOT NULL, + CLAUSE_ID_ varchar(64), + CLAUSE_NAME_ varchar(255), + RULE_ID_ varchar(64), + RULE_ORDER_ integer, + VAR_NAME_ varchar(255), + VAR_TYPE_ varchar(100), + BYTEARRAY_ID_ varchar(64), + DOUBLE_ double, + LONG_ bigint, + TEXT_ LONGBLOB, + TEXT2_ LONGBLOB, + TENANT_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + + +create index ACT_IDX_HI_DEC_INST_ID on ACT_HI_DECINST(DEC_DEF_ID_); +create index ACT_IDX_HI_DEC_INST_KEY on ACT_HI_DECINST(DEC_DEF_KEY_); +create index ACT_IDX_HI_DEC_INST_PI on ACT_HI_DECINST(PROC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_CI on ACT_HI_DECINST(CASE_INST_ID_); +create index ACT_IDX_HI_DEC_INST_ACT on ACT_HI_DECINST(ACT_ID_); +create index ACT_IDX_HI_DEC_INST_ACT_INST on ACT_HI_DECINST(ACT_INST_ID_); +create index ACT_IDX_HI_DEC_INST_TIME on ACT_HI_DECINST(EVAL_TIME_); +create index ACT_IDX_HI_DEC_INST_TENANT_ID on ACT_HI_DECINST(TENANT_ID_); +create index ACT_IDX_HI_DEC_INST_ROOT_ID on ACT_HI_DECINST(ROOT_DEC_INST_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_ID on ACT_HI_DECINST(DEC_REQ_ID_); +create index ACT_IDX_HI_DEC_INST_REQ_KEY on ACT_HI_DECINST(DEC_REQ_KEY_); + + +create index ACT_IDX_HI_DEC_IN_INST on ACT_HI_DEC_IN(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_IN_CLAUSE on ACT_HI_DEC_IN(DEC_INST_ID_, CLAUSE_ID_); + +create index ACT_IDX_HI_DEC_OUT_INST on ACT_HI_DEC_OUT(DEC_INST_ID_); +create index ACT_IDX_HI_DEC_OUT_RULE on ACT_HI_DEC_OUT(RULE_ORDER_, CLAUSE_ID_); + +-- mariadb_identity_7.8.0-ee + +create table ACT_ID_GROUP ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + TYPE_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_MEMBERSHIP ( + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (USER_ID_, GROUP_ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_USER ( + ID_ varchar(64), + REV_ integer, + FIRST_ varchar(255), + LAST_ varchar(255), + EMAIL_ varchar(255), + PWD_ varchar(255), + SALT_ varchar(255), + PICTURE_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_INFO ( + ID_ varchar(64), + REV_ integer, + USER_ID_ varchar(64), + TYPE_ varchar(64), + KEY_ varchar(255), + VALUE_ varchar(255), + PASSWORD_ LONGBLOB, + PARENT_ID_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT ( + ID_ varchar(64), + REV_ integer, + NAME_ varchar(255), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +create table ACT_ID_TENANT_MEMBER ( + ID_ varchar(64) not null, + TENANT_ID_ varchar(64) not null, + USER_ID_ varchar(64), + GROUP_ID_ varchar(64), + primary key (ID_) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +alter table ACT_ID_MEMBERSHIP + add constraint ACT_FK_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_USER + unique (TENANT_ID_, USER_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_UNIQ_TENANT_MEMB_GROUP + unique (TENANT_ID_, GROUP_ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB + foreign key (TENANT_ID_) + references ACT_ID_TENANT (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_USER + foreign key (USER_ID_) + references ACT_ID_USER (ID_); + +alter table ACT_ID_TENANT_MEMBER + add constraint ACT_FK_TENANT_MEMB_GROUP + foreign key (GROUP_ID_) + references ACT_ID_GROUP (ID_); + +ALTER TABLE ACT_GE_BYTEARRAY + ADD TYPE_ integer; + +ALTER TABLE ACT_GE_BYTEARRAY + ADD CREATE_TIME_ datetime(3); + +ALTER TABLE ACT_RE_PROCDEF + ADD STARTABLE_ BOOLEAN NOT NULL DEFAULT TRUE; \ No newline at end of file -- cgit 1.2.3-korg