aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/pom.xml6
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy792
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy42
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameFactory.groovy (renamed from bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AaiPropertiesConfiguration.java)31
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy37
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilFactory.groovy (renamed from bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/RestPropertiesPojoTest.java)36
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy336
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy16
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy5
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy96
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy44
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy7
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java6
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoInstanceGroup.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java141
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java93
-rw-r--r--bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupName.bpmn10
-rw-r--r--bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn241
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy258
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy199
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy107
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java36
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java155
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java142
33 files changed, 1219 insertions, 1654 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml
index c85bcd7522..934aea8241 100644
--- a/bpmn/MSOCommonBPMN/pom.xml
+++ b/bpmn/MSOCommonBPMN/pom.xml
@@ -397,5 +397,11 @@
<version>1.2.4.RELEASE</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.11.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
index d5183ff5bb..103326a693 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
@@ -22,17 +22,12 @@ package org.onap.so.bpmn.common.scripts
import org.json.JSONObject;
import org.json.JSONArray;
-import org.json.XML
import org.onap.logging.ref.slf4j.ONAPLogConstants
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.springframework.web.util.UriUtils;
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
-import groovy.json.JsonBuilder
-import groovy.json.JsonSlurper
-import groovy.util.slurpersupport.GPathResult
-import groovy.xml.QName;
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
@@ -57,365 +52,6 @@ class CatalogDbUtils {
JsonUtils jsonUtils = new JsonUtils()
static private String defaultDbAdapterVersion = "v2"
- public JSONArray getAllNetworksByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- networksList = responseJson.getJSONArray("serviceNetworks")
- }
- else {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- networksList = responseJson.getJSONArray("serviceNetworks")
- }
- else {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- networksList = responseJson.getJSONArray("serviceNetworks")
- }
- else {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByNetworkModelCustomizationUuid(DelegateExecution execution, String networkModelCustomizationUuid) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByNetworkModelCustomizationUuid(DelegateExecution execution, String networkModelCustomizationUuid, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- networksList = responseJson.getJSONArray("serviceNetworks")
- }
- else {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByNetworkType(DelegateExecution execution, String networkType) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
- public JSONArray getAllNetworksByNetworkType(DelegateExecution execution, String networkType, String catalogUtilsVersion) {
- JSONArray networksList = null
- String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- networksList = responseJson.getJSONArray("serviceNetworks")
- }
- else {
- networksList = parseNetworksJson(catalogDbResponse, "serviceNetworks", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return networksList
- }
-
-
- public JSONArray getAllVnfsByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) {
- JSONArray vnfsList = null
- String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
- try {
- msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllVnfsByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
- try {
- msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- vnfsList = responseJson.getJSONArray("serviceVnfs")
- }
- else {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllVnfsByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) {
- JSONArray vnfsList = null
- String endPoint ="/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
- try {
- msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllVnfsByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
- try {
- msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- vnfsList = responseJson.getJSONArray("serviceVnfs")
- }
- else {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
- JSONArray vnfsList = null
- String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
- try {
- msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
- try {
- msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- vnfsList = responseJson.getJSONArray("serviceVnfs")
- }
- else {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
public JSONArray getAllVnfsByVnfModelCustomizationUuid(DelegateExecution execution, String vnfModelCustomizationUuid) {
JSONArray vnfsList = null
String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
@@ -436,33 +72,6 @@ class CatalogDbUtils {
return vnfsList
}
- /**
- * This method gets a all vnfs for a particular
- * service from the catalog database using the
- * service model's model name.
- *
- * @param catalogDbEndpoint
- * @param serviceModelModelName
- * @return vnfsList *
- *
- */
- public JSONArray getAllVnfsByServiceModelModelName(DelegateExecution execution, String serviceModelModelName) {
- JSONArray vnfsList = null
- String endPoint = "/serviceVnfs?serviceModelName=" + UriUtils.encode(serviceModelModelName, "UTF-8")
- try {
- msoLogger.debug("ENDPOINT: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vnfsList = parseVnfsJson(catalogDbResponse, "serviceVnfs", defaultDbAdapterVersion)
- }
- }catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
- return vnfsList
- }
-
public JSONArray getAllVnfsByVnfModelCustomizationUuid(DelegateExecution execution, String vnfModelCustomizationUuid, String catalogUtilsVersion) {
JSONArray vnfsList = null
String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8")
@@ -489,263 +98,6 @@ class CatalogDbUtils {
return vnfsList
}
- /**
- * This method gets a single vf module from
- * the catalog database using the vf module's
- * model name. It returns that vf module as
- * a JSONObject
- *
- * @param catalogDbEndpoint
- * @param vfModuleModelName
- * @return vfModule
- */
- public JSONObject getVfModuleByVfModuleModelName(DelegateExecution execution, String vfModuleModelName) {
- JSONObject vfModule = null
- String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8")
- try{
- msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vfModule = parseVfModuleJson(catalogDbResponse, "vfModules", "v1")
- }
- }
- catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vfModule
- }
-
- /**
- * This method gets a single vf module from
- * the catalog database using the vf module's
- * model name. It returns that vf module as
- * a JSONObject
- *
- * @param catalogDbEndpoint
- * @param vfModuleModelName
- * @param catalogUtilsVersion
- * @return vfModules
- */
- public JSONObject getVfModuleByVfModuleModelName(DelegateExecution execution, String vfModuleModelName, String catalogUtilsVersion) {
- JSONObject vfModule = null
- String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8")
- try{
- msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint)
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vfModule = parseVfModuleJson(catalogDbResponse, "vfModules", "v1")
- }
- }
- catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vfModule
- }
-
-
- public JSONArray getAllottedResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) {
- JSONArray vnfsList = null
- String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllottedResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- vnfsList = responseJson.getJSONArray("serviceAllottedResources")
- }
- else {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllottedResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) {
- JSONArray vnfsList = null
- String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllottedResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- vnfsList = responseJson.getJSONArray()
- }
- else {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getStackTrace());
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
- JSONArray vnfsList = null
- String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- vnfsList = responseJson.getJSONArray("serviceAllottedResources")
- }
- else {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
-
- public JSONArray getAllottedResourcesByArModelCustomizationUuid(DelegateExecution execution, String arModelCustomizationUuid) {
- JSONArray vnfsList = null
- String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONArray getAllottedResourcesByArModelCustomizationUuid(DelegateExecution execution, String arModelCustomizationUuid, String catalogUtilsVersion) {
- JSONArray vnfsList = null
- String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- if (!catalogUtilsVersion.equals("v1")) {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- vnfsList = responseJson.getJSONArray("serviceAllottedResources")
- }
- else {
- vnfsList = parseAllottedResourcesJson(catalogDbResponse, "serviceAllottedResources", catalogUtilsVersion)
- }
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return vnfsList
- }
-
- public JSONObject getServiceResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) {
- JSONObject resources = null
- String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
-
- resources = parseServiceResourcesJson(catalogDbResponse, "v1")
- }
-
- }
- catch (Exception e) {
- utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
- throw e
- }
-
- return resources
- }
-
public JSONObject getServiceResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) {
JSONObject resources = null
String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
@@ -769,26 +121,6 @@ class CatalogDbUtils {
return resources
}
- public JSONObject getServiceResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) {
- JSONObject resources = null
- String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
-
- resources = parseServiceResourcesJson(catalogDbResponse, "v1")
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return resources
- }
-
public String getServiceResourcesByServiceModelInvariantUuidString(DelegateExecution execution, String serviceModelInvariantUuid) {
String resources = null
String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8")
@@ -833,27 +165,6 @@ class CatalogDbUtils {
return resources
}
-
- public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) {
- JSONObject resources = null
- String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
- try {
- String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
- if (catalogDbResponse != null) {
- //TODO this is wrong
- resources = parseServiceResourcesJson(catalogDbResponse)
- }
-
- }
- catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in Querying Catalog DB", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- throw e
- }
-
- return resources
- }
-
public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) {
JSONObject resources = null
String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8")
@@ -878,8 +189,6 @@ class CatalogDbUtils {
return resources
}
-
-
private JSONArray parseNetworksJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
JSONArray modelInfos = null
@@ -982,22 +291,7 @@ class CatalogDbUtils {
vfModuleModelJson.put("modelInfo", vfModuleModelInfo)
String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
vfModuleModelJson.put("vfModuleType", vfModuleType)
- switch(catalogUtilsVersion) {
- case "v1":
- //TODO this does not work, isBase is not a integer.
- Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase")
- if (isBase.intValue() == 1) {
- vfModuleModelJson.put("isBase", "true")
- }
- else {
- vfModuleModelJson.put("isBase", "false")
- }
- break
- default:
- boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
- vfModuleModelJson.put("isBase", isBase)
- break
- }
+ vfModuleModelJson.put("isBase", jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase"))
String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
vfModuleModelJson.put("vfModuleLabel", vfModuleLabel)
Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
@@ -1019,58 +313,6 @@ class CatalogDbUtils {
return modelInfos
}
- /**
- * This method parses a Vf Module from the
- * Vf Modules array
- *
- * @param catalogDbResponse
- * @param arrayName
- * @param catalogUtilsVersion
- * @return vfModulelJson
- */
- private JSONObject parseVfModuleJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
- JSONObject vfModulelJson = new JSONObject()
- msoLogger.debug("Started Parse Vf Module Json")
- try {
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- JSONArray vfModules = responseJson.getJSONArray(arrayName)
- if(vfModules != null){
- JSONObject vfModuleInfo = new JSONObject()
- for (int i = 0; i < vfModules.length(); i++) {
- JSONObject vfModule = vfModules.getJSONObject(i)
- JSONObject vfModuleModelInfo = buildModelInfo("vfModule", vfModule, catalogUtilsVersion)
- vfModulelJson.put("modelInfo", vfModuleModelInfo)
- String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
- vfModulelJson.put("vfModuleType", vfModuleType)
- switch(catalogUtilsVersion) {
- case "v1":
- Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase")
- if (isBase.intValue() == 1) {
- vfModulelJson.put("isBase", "true")
- }
- else {
- vfModulelJson.put("isBase", "false")
- }
- break
- default:
- boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
- vfModulelJson.put("isBase", isBase)
- break
- }
- String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
- vfModulelJson.put("vfModuleLabel", vfModuleLabel)
- Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
- vfModulelJson.put("initialCount", initialCount.intValue())
- }
- }
- msoLogger.debug("Completed Parsing Vf Module: " + vfModulelJson.toString())
- }catch (Exception e){
- msoLogger.debug("Exception while parsing Vf Modules from Catalog DB Response: " + e.message)
- }
-
- return vfModulelJson
- }
-
private JSONArray parseAllottedResourcesJson (String catalogDbResponse, String arrayName, String catalogUtilsVersion) {
JSONArray modelInfos = null
@@ -1123,37 +365,9 @@ class CatalogDbUtils {
return modelInfos
}
- //TODO this is wrong
- private JSONObject parseServiceResourcesJson (String catalogDbResponse) {
- JSONObject serviceResources = new JSONObject()
- String catalogUtilsVersion = "v1"
-
- try {
- // Create array of jsons
-
- JSONObject responseJson = new JSONObject(catalogDbResponse)
- JSONObject serviceResourcesRoot = responseJson.getJSONObject("serviceResources")
- JSONArray vnfsArray = parseVnfsJson(serviceResourcesRoot.toString(), "vnfResources", catalogUtilsVersion)
- serviceResources.put("vnfs", vnfsArray)
- JSONArray networksArray = parseNetworksJson(serviceResourcesRoot.toString(), "networkResourceCustomization", catalogUtilsVersion)
- serviceResources.put("networks", networksArray)
- JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "allottedResourceCustomization", catalogUtilsVersion)
- serviceResources.put("allottedResources", allottedResourcesArray)
-
- String serviceResourcesString = serviceResources.toString()
- msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString)
-
- } catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
- }
-
- return serviceResources
- }
-
private JSONObject parseServiceResourcesJson (String catalogDbResponse, String catalogUtilsVersion) {
JSONObject serviceResources = new JSONObject()
JSONObject serviceResourcesObject = new JSONObject()
- String serviceResourcesString = ""
try {
// Create array of jsons
@@ -1169,9 +383,7 @@ class CatalogDbUtils {
JSONArray allottedResourcesArray = parseAllottedResourcesJson(serviceResourcesRoot.toString(), "serviceAllottedResources", catalogUtilsVersion)
serviceResources.put("serviceAllottedResources", allottedResourcesArray)
serviceResourcesObject.put("serviceResources", serviceResources)
-
- serviceResourcesString = serviceResourcesObject.toString()
- msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesString)
+ msoLogger.debug("Returning serviceResources JSON: " + serviceResourcesObject.toString())
} catch (Exception e) {
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception in parsing Catalog DB Response", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.message);
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
index c309c3bb68..f4e7926c8e 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
* 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
@@ -19,6 +21,11 @@
*/
package org.onap.so.bpmn.common.scripts
+
+import joptsimple.internal.Strings
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.springframework.http.HttpStatus
+
import javax.ws.rs.core.UriBuilder
import org.camunda.bpm.engine.delegate.DelegateExecution
@@ -33,8 +40,12 @@ import org.onap.so.logger.MsoLogger
public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ConfirmVolumeGroupName.class);
- def Prefix="CVGN_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
+ def static final Prefix = "CVGN_"
+ private final ExceptionUtil exceptionUtil
+
+ ConfirmVolumeGroupName(ExceptionUtil exceptionUtil) {
+ this.exceptionUtil = exceptionUtil
+ }
public void initProcessVariables(DelegateExecution execution) {
execution.setVariable("prefix",Prefix)
@@ -74,40 +85,39 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
try {
Optional<VolumeGroup> volumeGroupOp = getAAIClient().get(VolumeGroup.class, resourceUri)
if(volumeGroupOp.isPresent()){
- execution.setVariable("CVGN_queryVolumeGroupResponseCode", 200)
+ execution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.OK.value())
execution.setVariable("CVGN_queryVolumeGroupResponse", volumeGroupOp.get())
}else{
- execution.setVariable("CVGN_queryVolumeGroupResponseCode", 404)
+ execution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.NOT_FOUND.value())
execution.setVariable("CVGN_queryVolumeGroupResponse", "Volume Group not Found!")
}
} catch (Exception ex) {
msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage())
- execution.setVariable("CVGN_queryVolumeGroupResponseCode", 500)
+ execution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.INTERNAL_SERVER_ERROR.value())
execution.setVariable("CVGN_queryVolumeGroupResponse", "AAI GET Failed:" + ex.getMessage())
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "AAI GET Failed")
+ exceptionUtil.buildAndThrowWorkflowException(execution, HttpStatus.INTERNAL_SERVER_ERROR.value(), "AAI GET Failed")
}
}
// process the result from queryAAIVolumeGroupId()
public void checkAAIQueryResult(DelegateExecution execution) {
- def result = execution.getVariable("CVGN_queryVolumeGroupResponse")
-
def actualVolumeGroupName = ""
- if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 404) {
+ if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == HttpStatus.NOT_FOUND.value()) {
msoLogger.debug('volumeGroupId does not exist in AAI')
}
- else if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 200) {
+ else if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == HttpStatus.OK.value()) {
VolumeGroup volumeGroup = execution.getVariable("CVGN_queryVolumeGroupResponse")
- if(volumeGroup.getVolumeGroupName()!=null){
+
+ if (!Strings.isNullOrEmpty(volumeGroup.getVolumeGroupName())) {
actualVolumeGroupName = volumeGroup.getVolumeGroupName()
- }
- msoLogger.debug("volumeGroupId exists in AAI")
+ msoLogger.debug("volumeGroupId exists in AAI")
+ }
}
execution.setVariable("CVGN_volumeGroupNameMatches", false)
def volumeGroupName = execution.getVariable("CVGN_volumeGroupName")
- if (volumeGroupName.equals(actualVolumeGroupName)) {
+ if (!actualVolumeGroupName.isEmpty() && volumeGroupName.equals(actualVolumeGroupName)) {
msoLogger.debug('Volume Group Name Matches AAI records')
execution.setVariable("CVGN_volumeGroupNameMatches", true)
}
@@ -121,8 +131,8 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
// generates a WorkflowException if the volume group name does not match AAI record for this volume group
public void handleVolumeGroupNameNoMatch(DelegateExecution execution) {
- def errorNotAssociated = "Error occurred - volume group id " + execution.getVariable("CVGN_volumeGroupId") +
- " is not associated with " + execution.getVariable("CVGN_volumeGroupName")
+ def errorNotAssociated = "Error occurred - volume group id ${execution.getVariable('CVGN_volumeGroupId')} " +
+ "is not associated with ${execution.getVariable('CVGN_volumeGroupName')}"
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, errorNotAssociated, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, errorNotAssociated)
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AaiPropertiesConfiguration.java b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameFactory.groovy
index b7582922b1..f032d640d5 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AaiPropertiesConfiguration.java
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameFactory.groovy
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Nokia.
* ================================================================================
* 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.
@@ -18,25 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.client.restproperties;
+package org.onap.so.bpmn.common.scripts
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
+import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupName
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
-@Service
-public class AaiPropertiesConfiguration {
+public class ConfirmVolumeGroupNameFactory {
- @Value("${aai.endpoint}")
- private String endpoint;
-
- @Value("${aai.auth}")
- private String auth;
-
- public String getEndpoint() {
- return endpoint;
- }
-
- public String getAuth() {
- return auth;
- }
+ ConfirmVolumeGroupName create() {
+ return new ConfirmVolumeGroupName(new ExceptionUtil());
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy
index 4b701e6a58..e132b411a5 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy
@@ -293,7 +293,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor {
execution.setVariable("WorkflowException", exception);
msoLogger.debug("Outgoing WorkflowException is " + exception)
msoLogger.debug("Throwing MSOWorkflowException")
- throw new BpmnError("MSOWorkflowException")
+ throw new BpmnError(errorCode.toString(), String.format("MSOWorkflowException: %s", errorMessage))
}
/**
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
index 5c935e9081..250cdda0a1 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
@@ -19,29 +19,30 @@
*/
package org.onap.so.bpmn.common.scripts
-import org.camunda.bpm.engine.delegate.BpmnError
+
+
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor;
+import org.onap.logging.ref.slf4j.ONAPLogConstants
import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
import org.onap.so.logger.MsoLogger
-import org.apache.commons.lang3.StringEscapeUtils
-import java.util.regex.Matcher
-import java.util.regex.Pattern
+import org.onap.so.utils.TargetEntity
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
-import org.onap.so.utils.TargetEntity
+import java.util.regex.Matcher
+import java.util.regex.Pattern
class ExternalAPIUtil {
String Prefix="EXTAPI_"
- public MsoUtils utils = new MsoUtils()
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExternalAPIUtil.class)
+ private final HttpClientFactory httpClientFactory;
+ private final MsoUtils utils;
+ private final ExceptionUtil exceptionUtil;
+
public static final String PostServiceOrderRequestsTemplate =
"{\n" +
"\t\"externalId\": <externalId>,\n" +
@@ -85,7 +86,10 @@ class ExternalAPIUtil {
"\t} \n" +
"}"
- public ExternalAPIUtil() {
+ ExternalAPIUtil(HttpClientFactory httpClientFactory, MsoUtils utils, ExceptionUtil exceptionUtil) {
+ this.httpClientFactory = httpClientFactory
+ this.utils = utils
+ this.exceptionUtil = exceptionUtil
}
// public String getUri(DelegateExecution execution, resourceName) {
@@ -137,8 +141,7 @@ class ExternalAPIUtil {
msoLogger.debug( "Generated uuid is: " + uuid)
msoLogger.debug( "URL to be used is: " + url)
- URL Url = new URL(url)
- HttpClient client = new HttpClient(Url, MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL)
+ HttpClient client = httpClientFactory.create(new URL(url), MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL)
client.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey"))
client.addAdditionalHeader("X-FromAppId", "MSO")
client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, uuid)
@@ -166,17 +169,15 @@ class ExternalAPIUtil {
* @return Response
*
*/
- public Response executeExternalAPIPostCall(DelegateExecution execution, String urlString, String payload){
+ public Response executeExternalAPIPostCall(DelegateExecution execution, String url, String payload){
msoLogger.debug( " ======== Started Execute ExternalAPI Post Process ======== ")
Response apiResponse = null
try{
String uuid = utils.getRequestID()
msoLogger.debug( "Generated uuid is: " + uuid)
- msoLogger.debug( "URL to be used is: " + urlString)
-
- URL url = new URL(urlString);
+ msoLogger.debug( "URL to be used is: " + url)
- HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.AAI)
+ HttpClient httpClient = httpClientFactory.create(new URL(url), MediaType.APPLICATION_JSON, TargetEntity.AAI)
httpClient.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey"))
httpClient.addAdditionalHeader("X-FromAppId", "MSO")
httpClient.addAdditionalHeader("X-TransactionId", uuid)
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/RestPropertiesPojoTest.java b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilFactory.groovy
index 863338548e..e7f46464ee 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/RestPropertiesPojoTest.java
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilFactory.groovy
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Nokia.
* ================================================================================
* 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.
@@ -17,31 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+package org.onap.so.bpmn.common.scripts
-package org.onap.so.client.restproperties;
+import org.onap.so.client.HttpClientFactory
-import org.junit.Test;
+class ExternalAPIUtilFactory {
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.NoPrimitivesRule;
-import com.openpojo.validation.rule.impl.NoPublicFieldsRule;
-import com.openpojo.validation.test.impl.GetterTester;
-
-public class RestPropertiesPojoTest {
- @Test
- public void pojoStructure() {
- test(PojoClassFactory.getPojoClass(AaiPropertiesConfiguration.class));
- }
-
- private void test(PojoClass pojoClass) {
- Validator validator = ValidatorBuilder.create()
- .with(new NoPrimitivesRule())
- .with(new NoPublicFieldsRule())
- .with(new GetterTester())
- .build();
- validator.validate(pojoClass);
- }
+ ExternalAPIUtil create() {
+ return new ExternalAPIUtil(new HttpClientFactory(), new MsoUtils(), new ExceptionUtil())
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
index f9ddd0d430..2f240fb70d 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
@@ -287,14 +287,6 @@ class MsoUtils {
return null
}
}
- def getRelationshipVal(node, name){
- try{
- return node.'**'.find {it.'relationship-key'.text() == name}.'relationship-value'.text()
- }catch(Exception e){
- return null
- }
- }
-
def log(logmode,logtxt,isDebugLogEnabled="false"){
if ("INFO"==logmode) {
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
index 27d067dfc1..41db603cdf 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
@@ -26,7 +26,6 @@ import org.onap.aai.domain.yang.L3Network
import org.onap.aai.domain.yang.Subnet
import org.onap.aai.domain.yang.Subnets
import org.onap.so.bpmn.core.UrnPropertiesReader
-import org.onap.so.logger.MsoLogger
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.Node
@@ -44,8 +43,6 @@ import javax.xml.transform.stream.StreamResult
* This groovy class supports the any Network processes that need the methods defined here.
*/
class NetworkUtils {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NetworkUtils.class);
-
public MsoUtils utils = new MsoUtils()
private AbstractServiceTaskProcessor taskProcessor
@@ -283,187 +280,6 @@ class NetworkUtils {
}
/**
- * This method returns the string for Create Volume Request payload
- * @param groupId the volume-group-id
- * @param volumeName the volume-group-name
- * @param vnfType the vnf-type
- * @param tenantId the value of relationship-key 'tenant.tenant-id'
- * @return String request payload
- */
- def String CreateNetworkVolumeRequest(groupId, volumeName, vnfType, tenantId) {
-
- String requestPayload =
- """<volume-group xmlns="http://org.onap.so/v6">
- <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id>
- <volume-group-name>${MsoUtils.xmlEscape(volumeName)}</volume-group-name>
- <heat-stack-id></heat-stack-id>
- <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
- <orchestration-status>Pending</orchestration-status>
- <relationship-list>
- <relationship>
- <related-to>tenant</related-to>
- <relationship-data>
- <relationship-key>tenant.tenant-id</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(tenantId)}</relationship-value>
- </relationship-data>
- </relationship>
- </relationship-list>
- </volume-group>"""
-
- return requestPayload
- }
-
- /**
- * This method returns the string for Update Volume Request payload
- * @param requeryAAIVolGrpNameResponse the response of query volume group name (in AAI)
- * @param heatStackId the value of heat stack id
- * @return String request payload
- */
- def String updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackId, namespace, modelCustomizationId) {
- String requestPayload = ""
- if (requeryAAIVolGrpNameResponse != null) {
- def groupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id")
- def volumeName = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-name")
- def vnfType = utils.getNodeText(requeryAAIVolGrpNameResponse, "vnf-type")
- def resourceVersion = utils.getNodeText(requeryAAIVolGrpNameResponse, "resource-version")
- def relationshipList = ""
- if (utils.nodeExists(requeryAAIVolGrpNameResponse, "relationship")) {
- relationshipList = rebuildRelationship(requeryAAIVolGrpNameResponse)
- }
-
- requestPayload =
- """<volume-group xmlns="${namespace}">
- <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id>
- <volume-group-name>${MsoUtils.xmlEscape(volumeName)}</volume-group-name>
- <heat-stack-id>${MsoUtils.xmlEscape(heatStackId)}</heat-stack-id>
- <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
- <orchestration-status>Active</orchestration-status>
- <resource-version>${MsoUtils.xmlEscape(resourceVersion)}</resource-version>
- <vf-module-model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</vf-module-model-customization-id>
- ${relationshipList}
- </volume-group>"""
- }
-
- return requestPayload
- }
-
-
- /**
- * This method returns the string for Update Volume Request payload
- * @param requeryAAIVolGrpNameResponse the response of query volume group name (in AAI)
- * @param heatStackId the value of heat stack id
- * @return String request payload
- */
- def String UpdateNetworkVolumeRequest(requeryAAIVolGrpNameResponse, heatStackId) {
- String requestPayload = ""
- if (requeryAAIVolGrpNameResponse != null) {
- def groupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id")
- def volumeName = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-name")
- def vnfType = utils.getNodeText(requeryAAIVolGrpNameResponse, "vnf-type")
- def resourceVersion = utils.getNodeText(requeryAAIVolGrpNameResponse, "resource-version")
- def relationshipList = ""
- if (utils.nodeExists(requeryAAIVolGrpNameResponse, "relationship")) {
- relationshipList = rebuildRelationship(requeryAAIVolGrpNameResponse)
- }
-
- requestPayload =
- """<volume-group xmlns="http://org.onap.so/v6">
- <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id>
- <volume-group-name>${MsoUtils.xmlEscape(volumeName)}</volume-group-name>
- <heat-stack-id>${MsoUtils.xmlEscape(heatStackId)}</heat-stack-id>
- <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
- <orchestration-status>Active</orchestration-status>
- <resource-version>${MsoUtils.xmlEscape(resourceVersion)}</resource-version>
- ${relationshipList}
- </volume-group>"""
- }
-
- return requestPayload
- }
-
- /**
- * This method returns the string for Create Contrail Network payload
- * @param requeryIdAAIResponse the response from AAI query by id
- * @param createNetworkResponse the response of create network
- * @return String contrailNetworkCreatedUpdate
- */
- def ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) {
-
- String contrailNetworkCreatedUpdate = ""
- if(requeryIdAAIResponse!=null && createNetworkResponse!=null) {
-
- def l3Network = utils.getNodeXml(requeryIdAAIResponse, "l3-network", false).replace("tag0:","").replace(":tag0","")
- def createNetworkContrailResponse = ""
- if (utils.nodeExists(createNetworkResponse, 'createNetworkResponse')) {
- createNetworkContrailResponse = utils.getNodeXml(createNetworkResponse, "createNetworkResponse", false).replace("tag0:","").replace(":tag0","")
- } else {
- createNetworkContrailResponse = utils.getNodeXml(createNetworkResponse, "updateNetworkContrailResponse", false).replace("tag0:","").replace(":tag0","")
- }
-
- // rebuild network
- def networkList = ["network-id", "network-name", "network-type", "network-role", "network-technology", "neutron-network-id", "is-bound-to-vpn", "service-id", "network-role-instance", "resource-version", "resource-model-uuid", "orchestration-status", "heat-stack-id", "mso-catalog-key", "contrail-network-fqdn",
- "physical-network-name", "is-provider-network", "is-shared-network", "is-external-network"]
- String rebuildNetworkElements = buildNetworkElements(l3Network, createNetworkContrailResponse, networkList)
-
- // rebuild 'subnets'
- def rebuildSubnetList = ""
- if (utils.nodeExists(requeryIdAAIResponse, 'subnet')) {
- rebuildSubnetList = buildSubnets(requeryIdAAIResponse, createNetworkResponse)
- }
-
- // rebuild 'segmentation-assignments'
- def rebuildSegmentationAssignments = ""
- if (utils.nodeExists(requeryIdAAIResponse, 'segmentation-assignments')) {
- List elementList = ["segmentation-id", "resource-version"]
- if (utils.nodeExists(requeryIdAAIResponse, 'segmentation-assignment')) { // new tag
- rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "segmentation-assignments", "segmentation-assignment", elementList)
- } else {
- rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "", "segmentation-assignments", elementList)
- }
- }
-
- // rebuild 'ctag-assignments' / rebuildCtagAssignments
- def rebuildCtagAssignmentsList = ""
- if (utils.nodeExists(requeryIdAAIResponse, 'ctag-assignment')) {
- rebuildCtagAssignmentsList = rebuildCtagAssignments(requeryIdAAIResponse)
- }
-
- // rebuild 'relationship'
- def relationshipList = ""
- if (utils.nodeExists(requeryIdAAIResponse, 'relationship-list')) {
- String rootRelationshipData = getFirstNodeXml(requeryIdAAIResponse, "relationship-list").drop(38).trim().replace("tag0:","").replace(":tag0","")
- if (utils.nodeExists(rootRelationshipData, 'relationship')) {
- relationshipList = rebuildRelationship(rootRelationshipData)
- }
- }
-
- //Check for optional contrail network fqdn within CreateNetworkResponse
- String contrailNetworkFQDN
- if(utils.nodeExists(createNetworkResponse, "contrail-network-fqdn")){
- contrailNetworkFQDN = utils.getNodeXml(createNetworkResponse, "contrail-network-fqdn")
- contrailNetworkFQDN = utils.removeXmlNamespaces(contrailNetworkFQDN)
- contrailNetworkFQDN = utils.removeXmlPreamble(contrailNetworkFQDN)
- }else{
- contrailNetworkFQDN = ""
- }
-
- contrailNetworkCreatedUpdate =
- """<l3-network xmlns="${schemaVersion}">
- ${rebuildNetworkElements}
- ${rebuildSubnetList}
- ${rebuildSegmentationAssignments}
- ${rebuildCtagAssignmentsList}
- ${relationshipList}
- ${contrailNetworkFQDN}
- </l3-network>""".trim()
-
- }
- return contrailNetworkCreatedUpdate
- }
-
-
-
- /**
* This method returns the value for the name paramName.
* Ex: <network-params>
* <param name="shared">1</param>
@@ -570,56 +386,6 @@ class NetworkUtils {
}
/**
- * This method returns the uri value for the vpn bindings.
- * Return the a list of value of vpn binding in the <related-link> string.
- * Ex.
- * <relationship-list>
- * <relationship>
- * <related-to>vpn-binding</related-to>
- * <related-link>https://aai-app-e2e.test.openecomp.com:8443/aai/v6/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link>
- * <relationship-data>
- * <relationship-key>vpn-binding.vpn-id</relationship-key>
- * <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value>
- * </relationship-data>
- * </relationship>
- * <relationship>
- * <related-to>vpn-binding</related-to>
- * <related-link>https://aai-ext1.test.openecomp.com:8443/aai/v6/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/</related-link>
- * <relationship-data>
- * <relationship-key>vpn-binding.vpn-id</relationship-key>
- * <relationship-value>24a4b507-853a-4a38-99aa-05fcc54be24d</relationship-value>
- * </relationship-data>
- * <related-to-property>
- * <property-key>vpn-binding.vpn-name</property-key>
- * <property-value>oam_protected_net_6_MTN5_msotest1</property-value>
- * </related-to-property>
- * </relationship>
- * @param xmlInput the XML document
- * @return a list of vpn binding values
- * ex: ['aai/v6/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', 'aai/v6/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']
- *
- **/
- def getVnfBindingObject(xmlInput) {
- //def rtn = null
- List rtn = []
- if (xmlInput!=null) {
- def relationshipList = getListWithElements(xmlInput, 'relationship')
- def relationshipListSize = relationshipList.size()
- if (relationshipListSize > 0) {
- for (i in 0..relationshipListSize-1) {
- def relationshipXml = XmlUtil.serialize(relationshipList[i])
- if (utils.getNodeText(relationshipXml, 'related-to') == "vpn-binding") {
- def relatedLink = utils.getNodeText(relationshipXml, 'related-link')
- if (relatedLink != null || relatedLink != "") {
- rtn.add(relatedLink.substring(relatedLink.indexOf("/aai/"), relatedLink.length()))
- }
- }
- }
- }
- }
- return rtn
- }
- /**
* similar to VNF bindings method
* @param xmlInput the XML document
* @return a list of network policy values
@@ -845,40 +611,6 @@ class NetworkUtils {
return xmlNetwork
}
- def buildSubnets(requeryIdAAIResponse, createNetworkResponse) {
- def rebuildingSubnets = ""
- if (requeryIdAAIResponse != null && utils.nodeExists(requeryIdAAIResponse, 'subnets')) {
- def subnetIdMapValue = ""
- def subnetsGroup = utils.getNodeXml(requeryIdAAIResponse, "subnets", false)
- def subnetsData = new XmlSlurper().parseText(subnetsGroup)
- rebuildingSubnets += "<subnets>"
- try {
- def subnets = subnetsData.'**'.findAll {it.name() == "subnet"}
- def subnetsSize = subnets.size()
- for (i in 0..subnetsSize-1) {
- def subnet = subnets[i]
- def subnetXml = XmlUtil.serialize(subnet)
- def orchestrationStatus = utils.getNodeText(subnetXml, "orchestration-status")
- if (orchestrationStatus == "PendingDelete" || orchestrationStatus == "pending-delete") {
- // skip, do not include in processing, remove!!!
- } else {
- def subnetList = ["subnet-id", "neutron-subnet-id", "gateway-address", "network-start-address", "cidr-mask", "ip-version", "orchestration-status", "dhcp-enabled", "dhcp-start", "dhcp-end", "subnet-role", "resource-version", "subnet-name", "ip-assignment-direction", "host-routes"]
- rebuildingSubnets += buildSubNetworkElements(subnetXml, createNetworkResponse, subnetList, "subnet")
- }
- }
- if (utils.nodeExists(subnetsData, 'relationship')) {
- rebuildingSubnets = rebuildRelationship(requeryIdAAIResponse)
- }
-
- } catch (Exception ex) {
- // error
- } finally {
- rebuildingSubnets += "</subnets>"
- }
- }
- return rebuildingSubnets
- }
-
def buildSubnets(L3Network network) {
def rebuildingSubnets = ""
Subnets subnets = network.getSubnets()
@@ -1056,74 +788,6 @@ class NetworkUtils {
}
- // rebuild ctag-assignments
- def rebuildCtagAssignments(xmlInput) {
- def rebuildingCtagAssignments = ""
- if (xmlInput!=null) {
- def ctagAssignmentsData = new XmlSlurper().parseText(xmlInput)
- rebuildingCtagAssignments += "<ctag-assignments>"
- def ctagAssignments = ctagAssignmentsData.'**'.findAll {it.name() == "ctag-assignment"}
- def ctagAssignmentsSize = ctagAssignments.size()
- for (i in 0..ctagAssignmentsSize-1) {
- def ctagAssignment = ctagAssignments[i]
- def ctagAssignmentXml = XmlUtil.serialize(ctagAssignment)
- rebuildingCtagAssignments += "<ctag-assignment>"
- List elementList = ["vlan-id-inner", "resource-version"]
- rebuildingCtagAssignments += buildXMLElements(ctagAssignmentXml, "" , "", elementList)
- if (utils.nodeExists(ctagAssignmentXml, 'relationship')) {
- rebuildingCtagAssignments += rebuildRelationship(ctagAssignmentXml)
- }
- rebuildingCtagAssignments += "</ctag-assignment>"
- }
- rebuildingCtagAssignments += "</ctag-assignments>"
- }
- return rebuildingCtagAssignments
- }
-
- // rebuild 'relationship-list'
- def rebuildRelationship(xmlInput) {
- def rebuildingSubnets = ""
- if (xmlInput!=null) {
- def subnetsData = new XmlSlurper().parseText(xmlInput)
- rebuildingSubnets += "<relationship-list>"
- def relationships = subnetsData.'**'.findAll {it.name() == "relationship"}
- def relationshipsSize = relationships.size()
- for (i in 0..relationshipsSize-1) {
- def relationship = relationships[i]
- def relationshipXml = XmlUtil.serialize(relationship)
- rebuildingSubnets += "<relationship>"
- def relationshipList = ["related-to", "related-link"]
- rebuildingSubnets += buildSubNetworkElements(relationshipXml, "", relationshipList, "")
- if (utils.nodeExists(relationshipXml, 'relationship-data')) {
- def relationshipDataXmlData = new XmlSlurper().parseText(relationshipXml)
- def relationshipsData = relationshipDataXmlData.'**'.findAll {it.name() == "relationship-data"}
- def relationshipsDataSize = relationshipsData.size()
- for (j in 0..relationshipsDataSize-1) {
- def relationshipData = relationshipsData[j]
- def relationshipDataXml = XmlUtil.serialize(relationshipData)
- def relationshipDataList = ["relationship-key", "relationship-value"]
- rebuildingSubnets += buildXMLElements(relationshipDataXml, "", "relationship-data", relationshipDataList)
- }
- }
- if (utils.nodeExists(relationshipXml, 'related-to-property')) {
- def relationshipDataXmlData = new XmlSlurper().parseText(relationshipXml)
- def relationshipsData = relationshipDataXmlData.'**'.findAll {it.name() == "related-to-property"}
- def relationshipsDataSize = relationshipsData.size()
- for (j in 0..relationshipsDataSize-1) {
- def relationshipData = relationshipsData[j]
- def relationshipDataXml = XmlUtil.serialize(relationshipData)
- def relationshipDataList = ["property-key", "property-value"]
- rebuildingSubnets += buildXMLElements(relationshipDataXml, "", "related-to-property", relationshipDataList)
- }
- }
-
- rebuildingSubnets += "</relationship>"
- }
- rebuildingSubnets += "</relationship-list>"
- }
- return rebuildingSubnets
- }
-
def buildVlans(queryIdResponse) {
def rebuildingSubnets = "<vlans>"
def subnetsData = new XmlSlurper().parseText(queryIdResponse)
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
index 8f0e481c9a..15f00ac25f 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
@@ -223,7 +223,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
AAIResourcesClient client = new AAIResourcesClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)
client.update(uri, vfModule)
-
+ execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 200)
// Set the output for this flow. The updated VfModule is an output, the generic VNF name, and for
// backward compatibilty, the heat-stack-id is an output
execution.setVariable('PUAAIVfMod_outVfModule', vfModule)
@@ -238,9 +238,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
+ execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500)
throw e;
} catch (Exception e) {
msoLogger.error(e)
+ execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage())
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
index 852f8d75bd..a430cdb715 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy
@@ -28,11 +28,10 @@ import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-
+import static org.apache.commons.lang3.StringUtils.*
// SDNC Adapter Request/Response processing
-
public class SDNCAdapter extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCAdapter.class);
@@ -58,6 +57,11 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
execution.setVariable("SDNCA_SuccessIndicator", false)
execution.setVariable("SDNCA_InterimNotify", false)
+ String requestId = execution.getVariable("mso-request-id")
+ if(isBlank(requestId)){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 400, 'mso-request-id not provided by calling flow')
+ }
+
// Authorization Info
String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution)
@@ -118,8 +122,8 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
msoLogger.debug("source: " + source)
//calling process should pass a generated uuid if sending multiple sdnc requests
- def requestId = utils.getNodeText(requestHeader, "RequestId")
- execution.setVariable(Prefix + "requestId", requestId)
+ def sdncRequestId = utils.getNodeText(requestHeader, "RequestId")
+ execution.setVariable(Prefix + "requestId", sdncRequestId)
// Prepare SDNC Request to the SDNC Adapter
String sdncAdapterRequest = """
@@ -127,7 +131,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
<SOAP-ENV:Body>
<aetgt:SDNCAdapterRequest xmlns:aetgt="http://org.onap/workflow/sdnc/adapter/schema/v1" xmlns:sdncadaptersc="http://org.onap/workflow/sdnc/adapter/schema/v1">
<sdncadapter:RequestHeader xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>"""
+ <sdncadapter:RequestId>${MsoUtils.xmlEscape(sdncRequestId)}</sdncadapter:RequestId>"""
if (sdnca_svcInstanceId != null) {
sdncAdapterRequest += """
@@ -180,7 +184,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor {
callbackHeader = callbackHeader.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
callbackRequestData = callbackRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
-
+
msoLogger.trace("EnhancedCallbackRequestData:\n" + callbackRequestData)
execution.setVariable("enhancedCallbackRequestData", callbackRequestData)
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
index d7fc6ac995..0cefae526e 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
@@ -207,7 +207,10 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
URL url = new URL(sdncAdapterUrl);
- HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SDNC_ADAPTER)
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SDNC_ADAPTER)
+ httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id"))
+ httpClient.addAdditionalHeader("X-ONAP-InvocationID", UUID.randomUUID().toString())
+ httpClient.addAdditionalHeader("X-ONAP-PartnerName", "SO-SDNCAdapter")
httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id"))
httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id"))
httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue"))
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy
index 6691a82352..3c4edd21ca 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy
@@ -174,23 +174,27 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
personaModelVersionEntry = updateVfModuleNode(origRequest, 'persona-model-version')
}
String contrailServiceInstanceFqdnEntry = updateVfModuleNode(origRequest, 'contrail-service-instance-fqdn')
- def payload = """
- { ${orchestrationStatusEntry}
- ${heatStackIdEntry}
- ${personaModelVersionEntry}
- ${contrailServiceInstanceFqdnEntry}
- "vf-module-id": "${vfModuleId}"
- }
- """
+ org.onap.aai.domain.yang.VfModule payload = new org.onap.aai.domain.yang.VfModule();
+ payload.setVfModuleId(vfModuleId)
+ payload.setOrchestrationStatus(orchestrationStatusEntry)
+ payload.setHeatStackId(heatStackIdEntry)
+ payload.setPersonaModelVersion(personaModelVersionEntry)
+ payload.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdnEntry)
try {
AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)
getAAIClient().update(resourceUri, payload)
+ execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 200)
+ execution.setVariable('UAAIVfMod_updateVfModuleResponse', "Success")
}catch(NotFoundException ignored){
msoLogger.debug("VF-Module not found!!")
+ execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 404)
+ execution.setVariable('UAAIVfMod_updateVfModuleResponse', ignored.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "vf-module " + vfModuleId + " not found for under vnf " + vnfId + " in A&AI!")
}
catch(Exception ex){
+ execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 500)
+ execution.setVariable('UAAIVfMod_updateVfModuleResponse', 'AAI PATCH Failed:' + ex.getMessage())
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'Exception occurred while executing AAI PATCH:' + ex.getMessage())
}
} catch (BpmnError e) {
@@ -210,87 +214,19 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
private String updateVfModuleNode(String origRequest, String elementName) {
if (!utils.nodeExists(origRequest, elementName)) {
- return ""
+ return null
}
def elementValue = utils.getNodeText(origRequest, elementName)
if (elementValue.equals('DELETE')) {
- // Set the element being deleted to null
- return """"${elementName}": null,"""
+ // Set the element being deleted to empty string
+ return ""
}
else {
- return """"${elementName}": "${elementValue}","""
+ return elementValue
}
}
-
- /**
- * Check the Volume Group ID from the incoming update request against the Volume Group ID from the
- * given VF Module. If they are equal or if they are both 'null', then that is acceptable and 'null'
- * is returned. Otherwise a message describing how the values are unacceptable/incompatible is returned.
- *
- * @param origRequest Incoming update request with VF Module elements to be updated.
- * @param vfModuleNode VF Module (as a Node) retrieved from AAI.
- * @param isDebugLogEnabled Is DEBUG log enabled?
- * @return 'null' if the Volume Group IDs are acceptable. Otherwise return a message describing how the
- * values are unacceptable/incompatible.
- */
- private String checkVolumeGroupId(String origRequest, Node vfModuleNode, String isDebugLogEnabled) {
- def requestVolumeGroupId = utils.getNodeText(origRequest, 'volume-group-id')
- def currVolumeGroupId = getCurrVolumeGroupId(vfModuleNode)
-
- msoLogger.debug('Check volume-group-id: volume-group-id in original request is \'' + requestVolumeGroupId + '\', volume-group-id from VF Module is \'' + currVolumeGroupId + '\'')
-
- def result = null
-
- if (requestVolumeGroupId == null) {
- if (currVolumeGroupId == null) {
- // This is OK
- } else {
- result = 'Cannot detach a volume group from an existing VF Module'
- }
- } else {
- if (currVolumeGroupId == null) {
- result = 'Cannot add a volume gruop to an existing VF Module'
- } else {
- if (!requestVolumeGroupId.equals(currVolumeGroupId)) {
- result = 'Cannot change the volume group on an existing VF Module'
- }
- }
- }
-
- return result
- }
-
- /**
- * Find and return the value of the Volume Group ID for the specified VF Module. If
- * the value of the Volume Group ID cannot be found for any reason, 'null' is returned.
- *
- * @param vfModuleNode VF Module (as a Node) retrieved from AAI.
- * @return the value of the Volume Group ID for the specified VF Module. If the
- * value of the Volume Group ID cannot be found for any reason, 'null' is returned.
- */
- private String getCurrVolumeGroupId(Node vfModuleNode) {
- def Node relationshipList = utils.getChildNode(vfModuleNode, 'relationship-list')
- if (relationshipList == null) {
- return null
- }
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationshipNode in relationships) {
- def String relatedTo = utils.getChildNodeText(relationshipNode, 'related-to')
- if ((relatedTo != null) && relatedTo.equals('volume-group')) {
- def NodeList relationshipDataList = utils.getIdenticalChildren(relationshipNode, 'relationship-data')
- for (Node relationshipDataNode in relationshipDataList) {
- def String relationshipKey = utils.getChildNodeText(relationshipDataNode, 'relationship-key')
- if ((relationshipKey != null) && relationshipKey.equals('volume-group.volume-group-id')) {
- return utils.getChildNodeText(relationshipDataNode, 'relationship-value')
- }
- }
- }
- }
- return null
- }
-
/**
* Generates a WorkflowException if the AAI query returns a response code other than 200.
*
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy
index fec140da33..c1cd42e893 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy
@@ -20,16 +20,9 @@
package org.onap.so.bpmn.common.scripts;
-import java.io.ObjectInputStream.BlockDataInputStream
-
-import java.io.ObjectInputStream.BlockDataInputStream
-
-//import groovy.util.Node;
-
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
-import org.apache.commons.lang3.*
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.Node
@@ -38,9 +31,6 @@ import org.xml.sax.InputSource
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-
-
-
public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VfModuleBase.class);
@@ -195,39 +185,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor {
}
return entries
}
-
- /**
- * Extract the Tenant Id from the Volume Group information returned by AAI.
- *
- * @param volumeGroupXml Volume Group XML returned by AAI.
- * @return the Tenant Id extracted from the Volume Group information. 'null' is returned if
- * the Tenant Id is missing or could not otherwise be extracted.
- */
- protected String getTenantIdFromVolumeGroup(String volumeGroupXml) {
- def groovy.util.Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def groovy.util.Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def groovy.util.NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (groovy.util.Node relationship in relationships) {
- def groovy.util.Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('tenant'))) {
- def groovy.util.NodeList relationshipDataList = utils.getIdenticalChildren(relationship, 'relationship-data')
- for (groovy.util.Node relationshipData in relationshipDataList) {
- def groovy.util.Node relationshipKey = utils.getChildNode(relationshipData, 'relationship-key')
- if ((relationshipKey != null) && (relationshipKey.text().equals('tenant.tenant-id'))) {
- def groovy.util.Node relationshipValue = utils.getChildNode(relationshipData, 'relationship-value')
- if (relationshipValue != null) {
- return relationshipValue.text()
- }
- }
- }
- }
- }
- }
- return null
- }
-
-
+
/*
* Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response
* and puts them into the format expected by VNF adapter.
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
index 13cc7f8d11..1452a9ad8d 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy
@@ -29,6 +29,8 @@ import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
import org.onap.so.utils.TargetEntity
+import java.util.UUID
+
@@ -311,7 +313,10 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
HttpClient httpClient = new HttpClient(url, "application/xml", TargetEntity.VNF_ADAPTER)
httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue"))
-
+
+ httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id"))
+ httpClient.addAdditionalHeader("X-ONAP-InvocationID", UUID.randomUUID().toString())
+ httpClient.addAdditionalHeader("X-ONAP-PartnerName", "SO-VNFAdapter")
Response response;
if ("GET".equals(vnfAdapterMethod)) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
index 1989ca8cf9..7df9c7bf82 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
@@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.resource;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -261,17 +262,20 @@ public class ResourceRequestBuilder {
String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint");
HttpClient client = new HttpClient(UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_TOSCA_CSAR).queryParam("serviceModelUuid", uuid).build().toURL(), "application/json", TargetEntity.CATALOG_DB);
+ client.addAdditionalHeader("Accept", "application/json");
+// client.addBasicAuthHeader (UrnPropertiesReader.getVariable("mso.adapters.db.auth"), UrnPropertiesReader.getVariable("mso.msoKey"));
+ client.addAdditionalHeader("Authorization", UrnPropertiesReader.getVariable("mso.db.auth"));
Response response = client.get();
String value = response.readEntity(String.class);
HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType());
- String filePath = System.getProperty("mso.config.path") + "/ASDC/" + map.get("version") + "/" + map.get("name");
+ String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", map.get("version"), map.get("name")).normalize().toString();
File csarFile = new File(filePath);
if(!csarFile.exists()) {
- throw new Exception("csar file does not exist.");
+ throw new Exception("csar file does not exist in filePath:" + csarFile.getAbsolutePath());
}
return csarFile.getAbsolutePath();
@@ -283,7 +287,7 @@ public class ResourceRequestBuilder {
try {
return mapper.readValue(jsonstr, type);
} catch(IOException e) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "fail to unMarshal json", e);
+ LOGGER.error("fail to unMarshal json" + e.getMessage ());
}
return null;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java
index 343bd95eaa..781eba3332 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java
@@ -101,6 +101,8 @@ public class L3Network implements Serializable, ShallowCopy<L3Network> {
private ModelInfoNetwork modelInfoNetwork;
@JsonProperty("aggregate-routes")
private List<AggregateRoute> aggregateRoutes = new ArrayList<>();
+ @JsonProperty("vpn-binding")
+ private List<VpnBinding> vpnBindings = new ArrayList<>();
public ModelInfoNetwork getModelInfoNetwork() {
return modelInfoNetwork;
@@ -261,6 +263,10 @@ public class L3Network implements Serializable, ShallowCopy<L3Network> {
return aggregateRoutes;
}
+ public List<VpnBinding> getVpnBindings(){
+ return vpnBindings;
+ }
+
@Override
public boolean equals(final Object other) {
if (!(other instanceof L3Network)) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
index 4662db23a1..9709ccece0 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
@@ -30,5 +30,6 @@ public enum ResourceKey {
CONFIGURATION_ID,
NETWORK_COLLECTION_ID,
VPN_ID,
- VPN_BONDING_LINK_ID;
+ VPN_BONDING_LINK_ID,
+ INSTANCE_GROUP_ID;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoInstanceGroup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoInstanceGroup.java
index 1f02fea071..e03ee358f3 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoInstanceGroup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoInstanceGroup.java
@@ -28,7 +28,6 @@ public class ModelInfoInstanceGroup implements Serializable {
private static final long serialVersionUID = -8279040393230356226L;
public static final String TYPE_L3_NETWORK = "L3-NETWORK";
- public static final String TYPE_NETWORK_INSTANCE_GROUP = "networkInstanceGroup";
public static final String TYPE_VNFC = "VNFC";
@JsonProperty("model-uuid")
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 5296d5995f..0017c4eeb1 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -90,6 +90,7 @@ import org.onap.so.serviceinstancebeans.Vnfs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -112,6 +113,9 @@ public class BBInputSetup implements JavaDelegate {
@Autowired
private BBInputSetupMapperLayer mapperLayer;
+
+ @Autowired
+ private CloudInfoFromAAI cloudInfoFromAAI;
@Autowired
private ExceptionBuilder exceptionUtil;
@@ -121,6 +125,10 @@ public class BBInputSetup implements JavaDelegate {
public BBInputSetupUtils getBbInputSetupUtils() {
return bbInputSetupUtils;
}
+
+ public void setCloudInfoFromAAI(CloudInfoFromAAI cloudInfoFromAAI) {
+ this.cloudInfoFromAAI = cloudInfoFromAAI;
+ }
public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
this.bbInputSetupUtils = bbInputSetupUtils;
@@ -382,16 +390,10 @@ public class BBInputSetup implements JavaDelegate {
ModelInfo vnfModelInfo = new ModelInfo();
vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
this.mapCatalogVnf(tempVnf, vnfModelInfo, service);
- if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) == null) {
- for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) {
- String volumeGroupCustId =
- this.bbInputSetupUtils.getAAIVolumeGroup(cloudConfiguration.getCloudOwner(),
- cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId();
- if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) {
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
- break;
- }
- }
+ Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(tempVnf, modelInfo, cloudConfiguration.getCloudOwner(),
+ cloudConfiguration.getLcpCloudRegionId(), lookupKeyMap);
+ if(volumeGroupIdOp.isPresent()) {
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get());
}
break;
}
@@ -420,6 +422,21 @@ public class BBInputSetup implements JavaDelegate {
throw new Exception("Could not find relevant information for related VNF");
}
}
+
+ protected Optional<String> getVolumeGroupIdRelatedToVfModule(GenericVnf vnf, ModelInfo modelInfo,
+ String cloudOwner, String cloudRegionId, Map<ResourceKey, String> lookupKeyMap) {
+ if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) == null) {
+ for(VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
+ String volumeGroupCustId =
+ bbInputSetupUtils.getAAIVolumeGroup(cloudOwner,
+ cloudRegionId, volumeGroup.getVolumeGroupId()).getModelCustomizationId();
+ if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) {
+ return Optional.of(volumeGroup.getVolumeGroupId());
+ }
+ }
+ }
+ return Optional.empty();
+ }
protected void mapCatalogVfModule(VfModule vfModule, ModelInfo modelInfo, Service service,
String vnfModelCustomizationUUID) {
@@ -592,16 +609,27 @@ public class BBInputSetup implements JavaDelegate {
vnf = createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
resourceId, generatedVnfType, instanceParams);
serviceInstance.getVnfs().add(vnf);
+ mapVnfcCollectionInstanceGroup(vnf, modelInfo, service);
}
if(vnf != null) {
mapCatalogVnf(vnf, modelInfo, service);
- mapVnfcCollectionInstanceGroup(vnf, modelInfo, service);
- if (instanceGroupId != null && instanceGroupModelInfo != null) {
+ if (instanceGroupId != null && instanceGroupModelInfo != null
+ && instanceGroupModelInfo.getModelType().equals(ModelType.networkInstanceGroup)
+ && !instanceGroupInList(vnf, instanceGroupId)) {
mapNetworkCollectionInstanceGroup(vnf, instanceGroupId);
}
}
}
+ protected boolean instanceGroupInList(GenericVnf vnf, String instanceGroupId) {
+ for(InstanceGroup instanceGroup : vnf.getInstanceGroups()) {
+ if(instanceGroup.getId() != null && instanceGroup.getId().equalsIgnoreCase(instanceGroupId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
protected void mapVnfcCollectionInstanceGroup(GenericVnf genericVnf, ModelInfo modelInfo, Service service) {
VnfResourceCustomization vnfResourceCustomization = getVnfResourceCustomizationFromService(modelInfo, service);
if(vnfResourceCustomization != null) {
@@ -609,8 +637,9 @@ public class BBInputSetup implements JavaDelegate {
.getVnfcInstanceGroupCustomizations();
for (VnfcInstanceGroupCustomization vnfcInstanceGroupCust : vnfcInstanceGroups) {
InstanceGroup instanceGroup = this.createInstanceGroup();
- instanceGroup.setModelInfoInstanceGroup(this.mapperLayer
- .mapCatalogInstanceGroupToInstanceGroup(null, vnfcInstanceGroupCust.getInstanceGroup()));
+ org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = bbInputSetupUtils.getCatalogInstanceGroup(vnfcInstanceGroupCust.getModelUUID());
+ instanceGroup.setModelInfoInstanceGroup(this.mapperLayer
+ .mapCatalogInstanceGroupToInstanceGroup(null, catalogInstanceGroup));
instanceGroup.getModelInfoInstanceGroup().setFunction(vnfcInstanceGroupCust.getFunction());
instanceGroup.setDescription(vnfcInstanceGroupCust.getDescription());
genericVnf.getInstanceGroups().add(instanceGroup);
@@ -847,8 +876,13 @@ public class BBInputSetup implements JavaDelegate {
String serviceInstanceId, boolean aLaCarte, String bbName) throws Exception {
ServiceInstance serviceInstance = this.getServiceInstanceHelper(requestDetails, customer, project, owningEntity,
lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = this.bbInputSetupUtils
- .getAAIServiceInstanceById(serviceInstanceId);
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null;
+ if(customer != null && customer.getServiceSubscription() != null) {
+ serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(customer.getGlobalCustomerId(),
+ customer.getServiceSubscription().getServiceType(), serviceInstanceId);
+ } else {
+ serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+ }
if (serviceInstanceAAI != null
&& !serviceInstanceAAI.getModelVersionId().equalsIgnoreCase(service.getModelUUID())) {
Service tempService = this.bbInputSetupUtils
@@ -872,8 +906,20 @@ public class BBInputSetup implements JavaDelegate {
throws Exception {
String bbName = executeBB.getBuildingBlock().getBpmnFlowName();
String key = executeBB.getBuildingBlock().getKey();
+
+ if (requestAction.equalsIgnoreCase("deleteInstance")
+ || requestAction.equalsIgnoreCase("unassignInstance")
+ || requestAction.equalsIgnoreCase("activateInstance")
+ || requestAction.equalsIgnoreCase("activateFabricConfiguration")
+ || requestAction.equalsIgnoreCase("recreateInstance")
+ || requestAction.equalsIgnoreCase("replaceInstance")) {
+ return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, requestAction,
+ requestDetails.getCloudConfiguration());
+ }
+
+ String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
GeneralBuildingBlock gBB = this.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction,
- resourceId);
+ serviceInstanceId);
RequestParameters requestParams = requestDetails.getRequestParameters();
Service service = null;
if (gBB != null && gBB.getServiceInstance() != null
@@ -896,16 +942,10 @@ public class BBInputSetup implements JavaDelegate {
if (requestAction.equalsIgnoreCase("deactivateInstance")) {
return gBB;
} else if (requestAction.equalsIgnoreCase("createInstance")) {
- return getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap, bbName, key, gBB, service);
- } else if (requestAction.equalsIgnoreCase("deleteInstance")
- || requestAction.equalsIgnoreCase("unassignInstance")
- || requestAction.equalsIgnoreCase("activateInstance")
- || requestAction.equalsIgnoreCase("activateFabricConfiguration")) {
- return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, gBB, service, requestAction,
- requestDetails.getCloudConfiguration());
+ return getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap, bbName, key, gBB, service);
} else {
- throw new IllegalArgumentException(
- "No user params on requestAction: assignInstance. Please specify user params.");
+ throw new IllegalArgumentException(
+ "No user params on requestAction: assignInstance. Please specify user params.");
}
}
@@ -977,14 +1017,40 @@ public class BBInputSetup implements JavaDelegate {
}
protected GeneralBuildingBlock getGBBMacroExistingService(ExecuteBuildingBlock executeBB,
- Map<ResourceKey, String> lookupKeyMap, String bbName, GeneralBuildingBlock gBB, Service service,
- String requestAction, CloudConfiguration cloudConfiguration) throws Exception {
+ Map<ResourceKey, String> lookupKeyMap, String bbName, String requestAction, CloudConfiguration cloudConfiguration) throws Exception {
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null;
+ String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
+ RequestDetails requestDetails = executeBB.getRequestDetails();
+ GeneralBuildingBlock gBB = null;
+ if (serviceInstanceId != null) {
+ aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+ }
+ Service service = null;
+ if (aaiServiceInstance != null) {
+ service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ }
+ if (aaiServiceInstance != null && service != null) {
+ ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance);
+ serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service));
+ gBB = populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null);
+ } else {
+ msoLogger.debug("Related Service Instance from AAI: " + aaiServiceInstance);
+ msoLogger.debug("Related Service Instance Model Info from AAI: " + service);
+ throw new Exception("Could not find relevant information for related Service Instance");
+ }
ServiceInstance serviceInstance = gBB.getServiceInstance();
- if (cloudConfiguration != null && requestAction.equalsIgnoreCase("deleteInstance")) {
+ CloudRegion cloudRegion = null;
+ if(cloudConfiguration == null) {
+ Optional<CloudRegion> cloudRegionOp = cloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ if(cloudRegionOp.isPresent()) {
+ cloudRegion = cloudRegionOp.get();
+ }
+ }
+ if (cloudConfiguration != null) {
org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration);
- CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
- gBB.setCloudRegion(cloudRegion);
+ cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
}
+ gBB.setCloudRegion(cloudRegion);
if (bbName.contains(VNF)) {
for (GenericVnf genericVnf : serviceInstance.getVnfs()) {
if (lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID) != null
@@ -1013,6 +1079,13 @@ public class BBInputSetup implements JavaDelegate {
ModelInfo vfModuleModelInfo = new ModelInfo();
vfModuleModelInfo.setModelCustomizationId(vfModuleCustomizationUUID);
this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, vnfModelCustomizationUUID);
+ if(cloudRegion != null) {
+ Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(vnf, vfModuleModelInfo, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), lookupKeyMap);
+ if(volumeGroupIdOp.isPresent()) {
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get());
+ }
+ }
break;
}
}
@@ -1028,9 +1101,9 @@ public class BBInputSetup implements JavaDelegate {
vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
this.mapCatalogVnf(vnf, vnfModelInfo, service);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnf.getVnfId());
- if (cloudConfiguration != null) {
- String volumeGroupCustomizationUUID = this.bbInputSetupUtils.getAAIVolumeGroup(cloudConfiguration.getCloudOwner(),
- cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId())
+ if (cloudRegion != null) {
+ String volumeGroupCustomizationUUID = this.bbInputSetupUtils.getAAIVolumeGroup(cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId())
.getModelCustomizationId();
ModelInfo volumeGroupModelInfo = new ModelInfo();
volumeGroupModelInfo.setModelCustomizationId(volumeGroupCustomizationUUID);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java
new file mode 100644
index 0000000000..37088022bc
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java
@@ -0,0 +1,93 @@
+package org.onap.so.bpmn.servicedecomposition.tasks;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+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.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+@Component
+public class CloudInfoFromAAI {
+
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CloudInfoFromAAI.class);
+ @Autowired
+ private BBInputSetupUtils bbInputSetupUtils;
+
+ public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
+ this.bbInputSetupUtils = bbInputSetupUtils;
+ }
+
+ protected Optional<CloudRegion> getCloudInfoFromAAI(ServiceInstance serviceInstance) throws JsonProcessingException {
+ Optional<Relationships> relationshipsOp = Optional.empty();
+ if(!serviceInstance.getVnfs().isEmpty()) {
+ GenericVnf vnf = serviceInstance.getVnfs().get(0);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId());
+ AAIResultWrapper vnfWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVnf));
+ relationshipsOp = getRelationshipsFromWrapper(vnfWrapper);
+ } else if(!serviceInstance.getNetworks().isEmpty()) {
+ L3Network network = serviceInstance.getNetworks().get(0);
+ org.onap.aai.domain.yang.L3Network aaiL3Network = bbInputSetupUtils.getAAIL3Network(network.getNetworkId());
+ AAIResultWrapper networkWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiL3Network));
+ relationshipsOp = getRelationshipsFromWrapper(networkWrapper);
+ } else {
+ msoLogger.debug("BBInputSetup could not find a cloud region or tenant, since there are no resources under the SI.");
+ return Optional.empty();
+ }
+ if (relationshipsOp.isPresent()) {
+ return getRelatedCloudRegionAndTenant(relationshipsOp.get());
+ } else {
+ msoLogger.debug("BBInputSetup could not find a cloud region or tenant");
+ return Optional.empty();
+ }
+ }
+
+ protected Optional<Relationships> getRelationshipsFromWrapper(AAIResultWrapper wrapper) {
+ Optional<Relationships> relationshipsOp;
+ relationshipsOp = wrapper.getRelationships();
+ if(relationshipsOp.isPresent()) {
+ return relationshipsOp;
+ }
+ return Optional.empty();
+ }
+
+ protected Optional<CloudRegion> getRelatedCloudRegionAndTenant(Relationships relationships) {
+ CloudRegion cloudRegion = new CloudRegion();
+ List<AAIResultWrapper> cloudRegions = relationships.getByType(AAIObjectType.CLOUD_REGION);
+ List<AAIResultWrapper> tenants = relationships.getByType(AAIObjectType.TENANT);
+ if(!cloudRegions.isEmpty()) {
+ AAIResultWrapper cloudRegionWrapper = cloudRegions.get(0);
+ Optional<org.onap.aai.domain.yang.CloudRegion> aaiCloudRegionOp = cloudRegionWrapper
+ .asBean(org.onap.aai.domain.yang.CloudRegion.class);
+ if(aaiCloudRegionOp.isPresent()) {
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = aaiCloudRegionOp.get();
+ cloudRegion.setCloudOwner(aaiCloudRegion.getCloudOwner());
+ cloudRegion.setCloudRegionVersion(aaiCloudRegion.getCloudRegionVersion());
+ cloudRegion.setLcpCloudRegionId(aaiCloudRegion.getCloudRegionId());
+ cloudRegion.setComplex(aaiCloudRegion.getComplexName());
+ }
+ }
+ if(!tenants.isEmpty()) {
+ AAIResultWrapper tenantWrapper = tenants.get(0);
+ Optional<org.onap.aai.domain.yang.Tenant> aaiTenantOp = tenantWrapper
+ .asBean(org.onap.aai.domain.yang.Tenant.class);
+ if(aaiTenantOp.isPresent()) {
+ org.onap.aai.domain.yang.Tenant aaiTenant = aaiTenantOp.get();
+ cloudRegion.setTenantId(aaiTenant.getTenantId());
+ }
+ }
+ return Optional.of(cloudRegion);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupName.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupName.bpmn
index 0e99ce9683..403be98c8e 100644
--- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupName.bpmn
+++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ConfirmVolumeGroupName.bpmn
@@ -13,7 +13,7 @@
<bpmn2:incoming>SequenceFlow_23</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_18</bpmn2:outgoing>
<bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
-def cvgn= new ConfirmVolumeGroupName()
+def cvgn= new ConfirmVolumeGroupNameFactory().create()
cvgn.handleAAIQueryFailure(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_18" name="" sourceRef="AAIQueryFailure" targetRef="EndEvent_7"/>
@@ -25,7 +25,7 @@ cvgn.handleAAIQueryFailure(execution)]]></bpmn2:script>
<bpmn2:incoming>SequenceFlow_38</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_39</bpmn2:outgoing>
<bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
-def cvgn= new ConfirmVolumeGroupName()
+def cvgn= new ConfirmVolumeGroupNameFactory().create()
cvgn.queryAAIForVolumeGroupId(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_39" name="" sourceRef="QueryAAIForVolumeGroupId" targetRef="ExclusiveGateway_3"/>
@@ -33,7 +33,7 @@ cvgn.queryAAIForVolumeGroupId(execution)]]></bpmn2:script>
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_38</bpmn2:outgoing>
<bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
-def cvgn= new ConfirmVolumeGroupName()
+def cvgn= new ConfirmVolumeGroupNameFactory().create()
cvgn.preProcessRequest(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_38" name="" sourceRef="InitializeVariables" targetRef="QueryAAIForVolumeGroupId"/>
@@ -42,7 +42,7 @@ cvgn.preProcessRequest(execution)]]></bpmn2:script>
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>
<bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
-def cvgn= new ConfirmVolumeGroupName()
+def cvgn= new ConfirmVolumeGroupNameFactory().create()
cvgn.checkAAIQueryResult(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="CheckAAIQueryResult" targetRef="ExclusiveGateway_1"/>
@@ -50,7 +50,7 @@ cvgn.checkAAIQueryResult(execution)]]></bpmn2:script>
<bpmn2:incoming>SequenceFlow_7</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing>
<bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
-def cvgn= new ConfirmVolumeGroupName()
+def cvgn= new ConfirmVolumeGroupNameFactory().create()
cvgn.handleVolumeGroupNameNoMatch(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_7">
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn
index 990863ec93..6914e7575f 100644
--- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn
+++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn
@@ -70,6 +70,7 @@ falloutHandler.postProcessResponse(execution)]]></bpmn2:script>
<camunda:map>
<camunda:entry key="content-type">application/soap+xml</camunda:entry>
<camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry>
+ <camunda:entry key="X-ONAP-RequestID">#{FH_request_id}</camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="payload">
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn
index 2ae2ff7f8b..0032b0e0b7 100644
--- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn
+++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_l2hJ8CccEeW3d--PaFJMbg" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.13.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_l2hJ8CccEeW3d--PaFJMbg" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="sdncAdapter" name="SDNC Adapter" isExecutable="true">
<bpmn2:exclusiveGateway id="isResponseOK" name="is Response Ok?" default="badSynchronousResponse">
<bpmn2:incoming>SequenceFlow_15</bpmn2:incoming>
@@ -8,28 +8,29 @@
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="badSynchronousResponse" name="Bad synchronous response" sourceRef="isResponseOK" targetRef="setBadResponse" />
<bpmn2:sequenceFlow id="goodSynchronousResponse" name="Good synchronous response" sourceRef="isResponseOK" targetRef="resetCallbackRequest">
- <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable("SDNCA_ResponseCode")=='200'}</bpmn2:conditionExpression>
+ <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("SDNCA_ResponseCode")=='200'}]]></bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:scriptTask id="setBadResponse" name="Set Bad Response&#10;&#10;Exception" scriptFormat="groovy">
<bpmn2:incoming>badSynchronousResponse</bpmn2:incoming>
<bpmn2:outgoing>Exception</bpmn2:outgoing>
- <bpmn2:script>import org.onap.so.bpmn.common.scripts.*
+ <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
int responseCode = execution.getVariable("SDNCA_ResponseCode")
ExceptionUtil exceptionUtil = new ExceptionUtil()
-exceptionUtil.buildWorkflowException(execution, 7000, "Could not communicate with the SDNC Adapter" )</bpmn2:script>
+exceptionUtil.buildWorkflowException(execution, 7000, "Could not communicate with the SDNC Adapter" )]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="Exception" name="Exception" sourceRef="setBadResponse" targetRef="badResponseEndFlow" />
<bpmn2:serviceTask id="invokeSDNCAdapter" name="Invoke SDNC Adapter" camunda:asyncAfter="true" camunda:class="">
<bpmn2:extensionElements>
<camunda:connector>
<camunda:inputOutput>
- <camunda:inputParameter name="url">${execution.getVariable("mso.adapters.sdnc.endpoint")}</camunda:inputParameter>
+ <camunda:inputParameter name="url"><![CDATA[${execution.getVariable("mso.adapters.sdnc.endpoint")}]]></camunda:inputParameter>
<camunda:inputParameter name="method">POST</camunda:inputParameter>
<camunda:inputParameter name="headers">
<camunda:map>
<camunda:entry key="content-type">application/soap+xml</camunda:entry>
<camunda:entry key="Authorization">#{BasicAuthHeaderValue}</camunda:entry>
+ <camunda:entry key="X-ONAP-RequestID"><![CDATA[#{execution.getVariable("mso-request-id")}]]></camunda:entry>
</camunda:map>
</camunda:inputParameter>
<camunda:inputParameter name="payload">${sdncAdapterRequest}</camunda:inputParameter>
@@ -65,20 +66,18 @@ exceptionUtil.buildWorkflowException(execution, 7000, "Could not communicate wit
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing>
- <bpmn2:script>import org.onap.so.bpmn.common.scripts.*
+ <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
def sdnc= new SDNCAdapter()
-sdnc.preProcessRequest(execution)
-</bpmn2:script>
+sdnc.preProcessRequest(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_8" sourceRef="processMessage" targetRef="invokeSDNCAdapter" />
<bpmn2:scriptTask id="returnWorkflowResult" name="Return workflow result" scriptFormat="groovy">
<bpmn2:incoming>SequenceFlow_9</bpmn2:incoming>
<bpmn2:incoming>SequenceFlow_11ah5pw</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing>
- <bpmn2:script>import org.onap.so.bpmn.common.scripts.*
+ <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
def sdnc= new SDNCAdapter()
-sdnc.postProcessResponse(execution)
-</bpmn2:script>
+sdnc.postProcessResponse(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_14" sourceRef="returnWorkflowResult" targetRef="timeoutError" />
<bpmn2:exclusiveGateway id="timeoutError" name="Did Timeout occur?" default="noTimeoutError">
@@ -88,7 +87,7 @@ sdnc.postProcessResponse(execution)
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="noTimeoutError" name="No Timeout" sourceRef="timeoutError" targetRef="ExclusiveGateway_1" />
<bpmn2:sequenceFlow id="SequenceFlow_19" name="Timeout" sourceRef="timeoutError" targetRef="endEventException">
- <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable("asynchronousResponseTimeout")==true}</bpmn2:conditionExpression>
+ <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("asynchronousResponseTimeout")==true}]]></bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:subProcess id="SubProcess" name="Wait for asynchronous message" camunda:asyncAfter="true">
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
@@ -111,17 +110,17 @@ sdnc.postProcessResponse(execution)
<bpmn2:scriptTask id="setTimeoutEx" name="Set Timeout&#10;and Stop Listening for Callback" scriptFormat="groovy">
<bpmn2:incoming>SequenceFlow_0mzs1ze</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_11ah5pw</bpmn2:outgoing>
- <bpmn2:script>import org.onap.so.bpmn.common.scripts.*
+ <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
def sdnc= new SDNCAdapter()
-sdnc.setTimeout(execution)</bpmn2:script>
+sdnc.setTimeout(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:scriptTask id="resetCallbackRequest" name="Reset callback request and set timer value" scriptFormat="groovy">
<bpmn2:incoming>goodSynchronousResponse</bpmn2:incoming>
<bpmn2:incoming>SequenceFlow_26</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
- <bpmn2:script>import org.onap.so.bpmn.common.scripts.*
+ <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
def sdnc= new SDNCAdapter()
-sdnc.resetCallbackRequest(execution)</bpmn2:script>
+sdnc.resetCallbackRequest(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="resetCallbackRequest" targetRef="SubProcess" />
<bpmn2:exclusiveGateway id="ExclusiveGateway_1" name="Check final indicator" default="Done">
@@ -131,14 +130,14 @@ sdnc.resetCallbackRequest(execution)</bpmn2:script>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="Done" name="Done" sourceRef="ExclusiveGateway_1" targetRef="ResetInterimNotificationFlag" />
<bpmn2:sequenceFlow id="SequenceFlow_30" name="Not Done" sourceRef="ExclusiveGateway_1" targetRef="ParallelGateway_3">
- <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable("continueListening")==true}</bpmn2:conditionExpression>
+ <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("continueListening")==true}]]></bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:scriptTask id="toggleSuccessIndicator" name="Toggle Success Indicator" scriptFormat="groovy">
<bpmn2:incoming>SequenceFlow_1w1za5m</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_17</bpmn2:outgoing>
- <bpmn2:script>import org.onap.so.bpmn.common.scripts.*
+ <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
def sdnc= new SDNCAdapter()
-sdnc.toggleSuccessIndicator(execution)</bpmn2:script>
+sdnc.toggleSuccessIndicator(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_17" name="" sourceRef="toggleSuccessIndicator" targetRef="endEventFlow" />
<bpmn2:endEvent id="endEventFlow" name="End Event Flow">
@@ -168,9 +167,9 @@ sdnc.toggleSuccessIndicator(execution)</bpmn2:script>
<bpmn2:scriptTask id="assignError" name="Assign Error" scriptFormat="groovy">
<bpmn2:incoming>SequenceFlow_22</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_27</bpmn2:outgoing>
- <bpmn2:script>import org.onap.so.bpmn.common.scripts.*
+ <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
def sdnc= new SDNCAdapter()
-sdnc.assignError(execution)</bpmn2:script>
+sdnc.assignError(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_27" name="" sourceRef="assignError" targetRef="EndEvent_5" />
<bpmn2:endEvent id="EndEvent_5">
@@ -183,7 +182,7 @@ sdnc.assignError(execution)</bpmn2:script>
<bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="SequenceFlow_4" name="Yes" sourceRef="ExclusiveGateway_2" targetRef="SetInterimNotificationFlag">
- <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{execution.getVariable("serviceConfigActivate")==true}</bpmn2:conditionExpression>
+ <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("serviceConfigActivate")==true}]]></bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="SequenceFlow_23" name="No" sourceRef="ExclusiveGateway_2" targetRef="EndEvent_1" />
<bpmn2:endEvent id="EndEvent_1">
@@ -215,7 +214,7 @@ sdnc.assignError(execution)</bpmn2:script>
<bpmn2:scriptTask id="SetInterimNotificationFlag" name="Set Interim Notification Flag" scriptFormat="groovy">
<bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_193cb6p</bpmn2:outgoing>
- <bpmn2:script>execution.setVariable("SDNCA_InterimNotify", true)</bpmn2:script>
+ <bpmn2:script><![CDATA[execution.setVariable("SDNCA_InterimNotify", true)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_193cb6p" sourceRef="SetInterimNotificationFlag" targetRef="CallActivity_11xgv33" />
<bpmn2:endEvent id="EndEvent_18rq0b6">
@@ -225,9 +224,27 @@ sdnc.assignError(execution)</bpmn2:script>
<bpmn2:scriptTask id="ResetInterimNotificationFlag" name="Reset Interim Notification Flag" scriptFormat="groovy">
<bpmn2:incoming>Done</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_1w1za5m</bpmn2:outgoing>
- <bpmn2:script>execution.setVariable("SDNCA_InterimNotify", false)</bpmn2:script>
+ <bpmn2:script><![CDATA[execution.setVariable("SDNCA_InterimNotify", false)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_1w1za5m" sourceRef="ResetInterimNotificationFlag" targetRef="toggleSuccessIndicator" />
+ <bpmn2:subProcess id="SubProcess_1j2zu8s" name="Java Exception Handling Sub Process" triggeredByEvent="true">
+ <bpmn2:startEvent id="StartEvent_10rxj2o">
+ <bpmn2:outgoing>SequenceFlow_1cnxq0j</bpmn2:outgoing>
+ <bpmn2:errorEventDefinition errorRef="Error_2" camunda:errorCodeVariable="BPMN_javaExpCode" camunda:errorMessageVariable="BPMN_javaExpMsg" />
+ </bpmn2:startEvent>
+ <bpmn2:endEvent id="EndEvent_0tzire9">
+ <bpmn2:incoming>SequenceFlow_1j9sip1</bpmn2:incoming>
+ </bpmn2:endEvent>
+ <bpmn2:sequenceFlow id="SequenceFlow_1cnxq0j" sourceRef="StartEvent_10rxj2o" targetRef="Task_1damf23" />
+ <bpmn2:sequenceFlow id="SequenceFlow_1j9sip1" sourceRef="Task_1damf23" targetRef="EndEvent_0tzire9" />
+ <bpmn2:scriptTask id="Task_1damf23" name="Process Error" scriptFormat="groovy">
+ <bpmn2:incoming>SequenceFlow_1cnxq0j</bpmn2:incoming>
+ <bpmn2:outgoing>SequenceFlow_1j9sip1</bpmn2:outgoing>
+ <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.*
+ExceptionUtil ex = new ExceptionUtil()
+ex.processJavaException(execution)]]></bpmn2:script>
+ </bpmn2:scriptTask>
+ </bpmn2:subProcess>
</bpmn2:process>
<bpmn2:message id="Message_1" name="sdncAdapterWorkflowRequest" />
<bpmn2:message id="Message_2" name="sdncAdapterCallbackRequest" />
@@ -264,23 +281,23 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="badSynchronousResponse" sourceElement="_BPMNShape_ExclusiveGateway_29" targetElement="_BPMNShape_ScriptTask_24">
- <di:waypoint x="544" y="153" />
- <di:waypoint x="544" y="122" />
- <di:waypoint x="600" y="122" />
+ <di:waypoint xsi:type="dc:Point" x="544" y="153" />
+ <di:waypoint xsi:type="dc:Point" x="544" y="122" />
+ <di:waypoint xsi:type="dc:Point" x="600" y="122" />
<bpmndi:BPMNLabel>
<dc:Bounds x="441" y="99" width="164" height="22" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_33" targetElement="_BPMNShape_ScriptTask_3">
- <di:waypoint x="147" y="179" />
- <di:waypoint x="194" y="179" />
+ <di:waypoint xsi:type="dc:Point" x="147" y="179" />
+ <di:waypoint xsi:type="dc:Point" x="194" y="179" />
<bpmndi:BPMNLabel>
<dc:Bounds x="171" y="179" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="goodSynchronousResponse" sourceElement="_BPMNShape_ExclusiveGateway_29" targetElement="_BPMNShape_ScriptTask_27">
- <di:waypoint x="544" y="203" />
- <di:waypoint x="544" y="246" />
+ <di:waypoint xsi:type="dc:Point" x="544" y="203" />
+ <di:waypoint xsi:type="dc:Point" x="544" y="246" />
<bpmndi:BPMNLabel>
<dc:Bounds x="459" y="208" width="172" height="22" />
</bpmndi:BPMNLabel>
@@ -292,24 +309,24 @@ sdnc.assignError(execution)</bpmn2:script>
<dc:Bounds x="194" y="139" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_3" targetElement="_BPMNShape_ServiceTask_62">
- <di:waypoint x="294" y="179" />
- <di:waypoint x="342" y="179" />
+ <di:waypoint xsi:type="dc:Point" x="294" y="179" />
+ <di:waypoint xsi:type="dc:Point" x="342" y="179" />
<bpmndi:BPMNLabel>
<dc:Bounds x="300" y="153" width="30" height="22" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_ServiceTask_68" targetElement="_BPMNShape_ExclusiveGateway_53">
- <di:waypoint x="1204" y="277" />
- <di:waypoint x="1248" y="276" />
+ <di:waypoint xsi:type="dc:Point" x="1204" y="277" />
+ <di:waypoint xsi:type="dc:Point" x="1248" y="276" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1211" y="251" width="37" height="22" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_15" bpmnElement="SequenceFlow_15" sourceElement="_BPMNShape_ServiceTask_62" targetElement="_BPMNShape_ExclusiveGateway_29">
- <di:waypoint x="442" y="179" />
- <di:waypoint x="480" y="179" />
- <di:waypoint x="480" y="178" />
- <di:waypoint x="519" y="178" />
+ <di:waypoint xsi:type="dc:Point" x="442" y="179" />
+ <di:waypoint xsi:type="dc:Point" x="480" y="179" />
+ <di:waypoint xsi:type="dc:Point" x="480" y="178" />
+ <di:waypoint xsi:type="dc:Point" x="519" y="178" />
<bpmndi:BPMNLabel>
<dc:Bounds x="468" y="153" width="37" height="22" />
</bpmndi:BPMNLabel>
@@ -330,8 +347,8 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_SubProcess_11">
- <di:waypoint x="998" y="278" />
- <di:waypoint x="1104" y="277" />
+ <di:waypoint xsi:type="dc:Point" x="998" y="278" />
+ <di:waypoint xsi:type="dc:Point" x="1104" y="277" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1051" y="262.5" width="0" height="0" />
</bpmndi:BPMNLabel>
@@ -340,8 +357,8 @@ sdnc.assignError(execution)</bpmn2:script>
<dc:Bounds x="600" y="82" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="Exception" sourceElement="_BPMNShape_ScriptTask_24" targetElement="_BPMNShape_EndEvent_65">
- <di:waypoint x="700" y="122" />
- <di:waypoint x="762" y="122" />
+ <di:waypoint xsi:type="dc:Point" x="700" y="122" />
+ <di:waypoint xsi:type="dc:Point" x="762" y="122" />
<bpmndi:BPMNLabel>
<dc:Bounds x="699" y="99" width="64" height="22" />
</bpmndi:BPMNLabel>
@@ -350,8 +367,8 @@ sdnc.assignError(execution)</bpmn2:script>
<dc:Bounds x="941" y="372" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_16" bpmnElement="SequenceFlow_16" sourceElement="_BPMNShape_IntermediateCatchEvent_16">
- <di:waypoint x="817" y="275" />
- <di:waypoint x="926" y="275" />
+ <di:waypoint xsi:type="dc:Point" x="817" y="275" />
+ <di:waypoint xsi:type="dc:Point" x="926" y="275" />
<bpmndi:BPMNLabel>
<dc:Bounds x="872" y="260" width="0" height="0" />
</bpmndi:BPMNLabel>
@@ -363,16 +380,16 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_17" bpmnElement="noTimeoutError" sourceElement="_BPMNShape_ExclusiveGateway_53" targetElement="_BPMNShape_ExclusiveGateway_54">
- <di:waypoint x="1273" y="301" />
- <di:waypoint x="1273" y="359" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="301" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="359" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1280" y="324" width="72" height="22" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_19" bpmnElement="SequenceFlow_19" sourceElement="_BPMNShape_ExclusiveGateway_53" targetElement="_BPMNShape_ScriptTask_25">
- <di:waypoint x="1273" y="251" />
- <di:waypoint x="1273" y="95" />
- <di:waypoint x="1560" y="95" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="251" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="95" />
+ <di:waypoint xsi:type="dc:Point" x="1560" y="95" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1301" y="169.45283018867923" width="39" height="12" />
</bpmndi:BPMNLabel>
@@ -384,8 +401,8 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="Done" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ScriptTask_247">
- <di:waypoint x="1298" y="384" />
- <di:waypoint x="1386" y="385" />
+ <di:waypoint xsi:type="dc:Point" x="1298" y="384" />
+ <di:waypoint xsi:type="dc:Point" x="1386" y="385" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1322" y="384.219838851959" width="27" height="13" />
</bpmndi:BPMNLabel>
@@ -394,17 +411,17 @@ sdnc.assignError(execution)</bpmn2:script>
<dc:Bounds x="494" y="246" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_27" targetElement="_BPMNShape_SubProcess_11">
- <di:waypoint x="594" y="286" />
- <di:waypoint x="607" y="286" />
- <di:waypoint x="607" y="275" />
- <di:waypoint x="619" y="275" />
+ <di:waypoint xsi:type="dc:Point" x="594" y="286" />
+ <di:waypoint xsi:type="dc:Point" x="607" y="286" />
+ <di:waypoint xsi:type="dc:Point" x="607" y="275" />
+ <di:waypoint xsi:type="dc:Point" x="619" y="275" />
<bpmndi:BPMNLabel>
<dc:Bounds x="622" y="280.5" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_30" sourceElement="_BPMNShape_ExclusiveGateway_54" targetElement="_BPMNShape_ParallelGateway_14">
- <di:waypoint x="1273" y="409" />
- <di:waypoint x="1273" y="467" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="409" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="467" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1273" y="423" width="60" height="22" />
</bpmndi:BPMNLabel>
@@ -416,8 +433,8 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ExclusiveGateway_55" targetElement="CallActivity_11xgv33_di">
- <di:waypoint x="1273" y="602" />
- <di:waypoint x="1273" y="664" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="602" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="664" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1237" y="635.9906427957554" width="18" height="13" />
</bpmndi:BPMNLabel>
@@ -429,8 +446,8 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_28" bpmnElement="SequenceFlow_21" sourceElement="_BPMNShape_ParallelGateway_14">
- <di:waypoint x="1272" y="516" />
- <di:waypoint x="1273" y="552" />
+ <di:waypoint xsi:type="dc:Point" x="1272" y="516" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="552" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1273" y="519" width="0" height="0" />
</bpmndi:BPMNLabel>
@@ -442,17 +459,17 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_30" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_55" targetElement="_BPMNShape_EndEvent_96">
- <di:waypoint x="1298" y="577" />
- <di:waypoint x="1330" y="577" />
- <di:waypoint x="1440" y="577" />
+ <di:waypoint xsi:type="dc:Point" x="1298" y="577" />
+ <di:waypoint xsi:type="dc:Point" x="1330" y="577" />
+ <di:waypoint xsi:type="dc:Point" x="1440" y="577" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1309" y="590.5" width="14" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_33" bpmnElement="SequenceFlow_26" sourceElement="_BPMNShape_ParallelGateway_14" targetElement="_BPMNShape_ScriptTask_27">
- <di:waypoint x="1248" y="492" />
- <di:waypoint x="544" y="492" />
- <di:waypoint x="544" y="326" />
+ <di:waypoint xsi:type="dc:Point" x="1248" y="492" />
+ <di:waypoint xsi:type="dc:Point" x="544" y="492" />
+ <di:waypoint xsi:type="dc:Point" x="544" y="326" />
<bpmndi:BPMNLabel>
<dc:Bounds x="782" y="467" width="73" height="48" />
</bpmndi:BPMNLabel>
@@ -461,47 +478,47 @@ sdnc.assignError(execution)</bpmn2:script>
<dc:Bounds x="1540" y="344" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_26" bpmnElement="SequenceFlow_17" sourceElement="_BPMNShape_ScriptTask_247" targetElement="_BPMNShape_EndEvent_64">
- <di:waypoint x="1640" y="384" />
- <di:waypoint x="1699" y="384" />
+ <di:waypoint xsi:type="dc:Point" x="1640" y="384" />
+ <di:waypoint xsi:type="dc:Point" x="1699" y="384" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1670" y="369" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_SubProcess_19" bpmnElement="errorHandlingSubProcess" isExpanded="true">
- <dc:Bounds x="207" y="692" width="353" height="193" />
+ <dc:Bounds x="250" y="598" width="353" height="193" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_63" bpmnElement="catchErrors">
- <dc:Bounds x="242" y="771" width="36" height="36" />
+ <dc:Bounds x="285" y="677" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="245" y="812" width="29" height="12" />
+ <dc:Bounds x="288" y="718" width="29" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_213" bpmnElement="EndEvent_5">
- <dc:Bounds x="482" y="771" width="36" height="36" />
+ <dc:Bounds x="525" y="677" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="455" y="812" width="90" height="0" />
+ <dc:Bounds x="498" y="718" width="90" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_ScriptTask_249" bpmnElement="assignError">
- <dc:Bounds x="326" y="749" width="100" height="80" />
+ <dc:Bounds x="369" y="655" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_22" sourceElement="_BPMNShape_StartEvent_63" targetElement="_BPMNShape_ScriptTask_249">
- <di:waypoint x="278" y="789" />
- <di:waypoint x="326" y="789" />
+ <di:waypoint xsi:type="dc:Point" x="321" y="695" />
+ <di:waypoint xsi:type="dc:Point" x="369" y="695" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="263" y="789" width="90" height="0" />
+ <dc:Bounds x="306" y="695" width="90" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_34" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_ScriptTask_249" targetElement="_BPMNShape_EndEvent_213">
- <di:waypoint x="426" y="789" />
- <di:waypoint x="482" y="789" />
+ <di:waypoint xsi:type="dc:Point" x="469" y="695" />
+ <di:waypoint xsi:type="dc:Point" x="525" y="695" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="409" y="789" width="90" height="0" />
+ <dc:Bounds x="452" y="695" width="90" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1eciucn_di" bpmnElement="SequenceFlow_1eciucn">
- <di:waypoint x="691" y="275" />
- <di:waypoint x="781" y="275" />
+ <di:waypoint xsi:type="dc:Point" x="691" y="275" />
+ <di:waypoint xsi:type="dc:Point" x="781" y="275" />
<bpmndi:BPMNLabel>
<dc:Bounds x="736" y="260" width="0" height="0" />
</bpmndi:BPMNLabel>
@@ -519,17 +536,17 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0mzs1ze_di" bpmnElement="SequenceFlow_0mzs1ze">
- <di:waypoint x="800" y="364" />
- <di:waypoint x="800" y="412" />
- <di:waypoint x="941" y="412" />
+ <di:waypoint xsi:type="dc:Point" x="800" y="364" />
+ <di:waypoint xsi:type="dc:Point" x="800" y="412" />
+ <di:waypoint xsi:type="dc:Point" x="941" y="412" />
<bpmndi:BPMNLabel>
<dc:Bounds x="815" y="388" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_11ah5pw_di" bpmnElement="SequenceFlow_11ah5pw">
- <di:waypoint x="1041" y="412" />
- <di:waypoint x="1154" y="412" />
- <di:waypoint x="1154" y="317" />
+ <di:waypoint xsi:type="dc:Point" x="1041" y="412" />
+ <di:waypoint xsi:type="dc:Point" x="1154" y="412" />
+ <di:waypoint xsi:type="dc:Point" x="1154" y="317" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1098" y="397" width="0" height="0" />
</bpmndi:BPMNLabel>
@@ -547,8 +564,8 @@ sdnc.assignError(execution)</bpmn2:script>
<dc:Bounds x="1223" y="666" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_193cb6p_di" bpmnElement="SequenceFlow_193cb6p">
- <di:waypoint x="1273" y="746" />
- <di:waypoint x="1273" y="795" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="746" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="795" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1288" y="770.5" width="0" height="0" />
</bpmndi:BPMNLabel>
@@ -560,8 +577,8 @@ sdnc.assignError(execution)</bpmn2:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1em7gys_di" bpmnElement="SequenceFlow_1em7gys">
- <di:waypoint x="1273" y="875" />
- <di:waypoint x="1273" y="920" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="875" />
+ <di:waypoint xsi:type="dc:Point" x="1273" y="920" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1288" y="897.5" width="0" height="0" />
</bpmndi:BPMNLabel>
@@ -570,12 +587,44 @@ sdnc.assignError(execution)</bpmn2:script>
<dc:Bounds x="1386" y="345" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1w1za5m_di" bpmnElement="SequenceFlow_1w1za5m">
- <di:waypoint x="1486" y="385" />
- <di:waypoint x="1540" y="384" />
+ <di:waypoint xsi:type="dc:Point" x="1486" y="385" />
+ <di:waypoint xsi:type="dc:Point" x="1540" y="384" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1513" y="369.5" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="SubProcess_009jbzr_di" bpmnElement="SubProcess_1j2zu8s" isExpanded="true">
+ <dc:Bounds x="252" y="817" width="350" height="200" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="StartEvent_1cwwku2_di" bpmnElement="StartEvent_10rxj2o">
+ <dc:Bounds x="288" y="904" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="306" y="944" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_0tzire9_di" bpmnElement="EndEvent_0tzire9">
+ <dc:Bounds x="530" y="904" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="548" y="944" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1cnxq0j_di" bpmnElement="SequenceFlow_1cnxq0j">
+ <di:waypoint xsi:type="dc:Point" x="324" y="922" />
+ <di:waypoint xsi:type="dc:Point" x="378" y="922" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="351" y="901" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_1j9sip1_di" bpmnElement="SequenceFlow_1j9sip1">
+ <di:waypoint xsi:type="dc:Point" x="478" y="922" />
+ <di:waypoint xsi:type="dc:Point" x="530" y="922" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="504" y="901" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ScriptTask_1n6d3r0_di" bpmnElement="Task_1damf23">
+ <dc:Bounds x="378" y="882" width="100" height="80" />
+ </bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy
index a96127aa2d..79aacdfbe9 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
* 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.
@@ -20,64 +22,216 @@
package org.onap.so.bpmn.common.scripts
-import static org.mockito.Mockito.*
-
-import javax.ws.rs.core.UriBuilder
-
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake
-import org.junit.Assert
import org.junit.Before
import org.junit.Test
-import org.mockito.ArgumentCaptor
-import org.mockito.Captor
-import org.mockito.Mockito
+import org.mockito.Mock
import org.mockito.MockitoAnnotations
-import org.mockito.Spy
+import org.onap.aai.domain.yang.RelationshipList
import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupName
+import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupNameFactory
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.constants.Defaults
+import org.springframework.http.HttpStatus
+
+import javax.ws.rs.core.UriBuilder
+
+import static org.assertj.core.api.Assertions.catchThrowableOfType
+import static org.junit.Assert.assertEquals
+import static org.junit.Assert.assertFalse
+import static org.junit.Assert.assertTrue
+import static org.mockito.Mockito.spy
+import static org.mockito.Mockito.when
+
+class ConfirmVolumeGroupNameTest {
+
+ private static final AAIResourceUri RESOURCE_URI = AAIUriFactory.createResourceFromExistingURI(
+ AAIObjectType.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build())
+
+ private ConfirmVolumeGroupName confirmVolumeGroupName
+ @Mock
+ private VolumeGroup volumeGroup
+ @Mock
+ private AAIResourcesClient client
+ private ExceptionUtilFake exceptionUtilFake
+
+ private DelegateExecution delegateExecution
+
+ @Before
+ public void init() throws IOException {
+ exceptionUtilFake = new ExceptionUtilFake()
+ confirmVolumeGroupName = spy(new ConfirmVolumeGroupName(exceptionUtilFake))
+ MockitoAnnotations.initMocks(this)
+ delegateExecution = new DelegateExecutionFake()
+ volumeGroup = createVolumeGroup()
+ when(confirmVolumeGroupName.getAAIClient()).thenReturn(client)
+ }
+
+ @Test
+ public void preProcessRequest_shouldSetUpVariables() {
+ String volumeGroupId = "volume-group-id-1"
+ String volumeGroupName = "volume-group-name-1"
+ String aicCloudRegion = "aic-cloud-region-1"
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER, aicCloudRegion, volumeGroupId)
+
+ delegateExecution.setVariable("ConfirmVolumeGroupName_volumeGroupId", volumeGroupId)
+ delegateExecution.setVariable("ConfirmVolumeGroupName_volumeGroupName", volumeGroupName)
+ delegateExecution.setVariable("ConfirmVolumeGroupName_aicCloudRegion", aicCloudRegion)
+ delegateExecution.setVariable("CVGN_volumeGroupGetEndpoint", uri)
+
+ confirmVolumeGroupName.preProcessRequest(delegateExecution)
+
+ assertEquals(ConfirmVolumeGroupName.Prefix, delegateExecution.getVariable("prefix"))
+
+ assertEquals(volumeGroupId, delegateExecution.getVariable("CVGN_volumeGroupId"))
+ assertEquals(volumeGroupName, delegateExecution.getVariable("CVGN_volumeGroupName"))
+ assertEquals(aicCloudRegion, delegateExecution.getVariable("CVGN_aicCloudRegion"))
+ }
+
+ @Test
+ public void queryAAIForVolumeGroupId_shouldSucceed_whenVolumeGroupExists() {
+ delegateExecution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.OK)
+ delegateExecution.setVariable("CVGN_queryVolumeGroupResponse", volumeGroup)
+ delegateExecution.setVariable("CVGN_volumeGroupGetEndpoint", RESOURCE_URI)
+ when(client.get(VolumeGroup.class, RESOURCE_URI)).thenReturn(Optional.of(volumeGroup))
+
+ confirmVolumeGroupName.queryAAIForVolumeGroupId(delegateExecution)
+
+ assertEquals(HttpStatus.OK.value(), delegateExecution.getVariable("CVGN_queryVolumeGroupResponseCode"))
+ assertEquals(volumeGroup, delegateExecution.getVariable("CVGN_queryVolumeGroupResponse"))
+ }
+
+ @Test
+ public void queryAAIForVolumeGroupId_shouldFailWith404_whenVolumeGroupDoesNotExist() {
+ delegateExecution.setVariable("CVGN_volumeGroupGetEndpoint", RESOURCE_URI)
+ when(client.get(VolumeGroup.class, RESOURCE_URI)).thenReturn(Optional.empty())
+
+ confirmVolumeGroupName.queryAAIForVolumeGroupId(delegateExecution)
+
+ assertEquals(HttpStatus.NOT_FOUND.value(), delegateExecution.getVariable("CVGN_queryVolumeGroupResponseCode"))
+ assertEquals("Volume Group not Found!", delegateExecution.getVariable("CVGN_queryVolumeGroupResponse"))
+ }
+
+ @Test
+ public void queryAAIForVolumeGroupId_shouldThrowWorkflowException_whenRuntimeExceptionIsThrown() throws BpmnError {
+ delegateExecution.setVariable("CVGN_volumeGroupGetEndpoint", RESOURCE_URI)
+ delegateExecution.setVariable("testProcessKey", "process-key1")
+
+ def errorMsg = "my runtime exception"
+ when(client.get(VolumeGroup.class, RESOURCE_URI)).thenThrow(new RuntimeException(errorMsg))
+
+ def exceptionMsg = "AAI GET Failed"
+
+ BpmnError error = catchThrowableOfType(
+ { -> confirmVolumeGroupName.queryAAIForVolumeGroupId(delegateExecution) }, BpmnError.class)
+
+ assertEquals(String.format("MSOWorkflowException: %s", exceptionMsg), error.getMessage())
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value().toString(), error.getErrorCode())
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), delegateExecution.getVariable("CVGN_queryVolumeGroupResponseCode"))
+ assertEquals(String.format("AAI GET Failed:%s", errorMsg), delegateExecution.getVariable("CVGN_queryVolumeGroupResponse"))
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), exceptionUtilFake.getErrorCode())
+ assertEquals(exceptionMsg, exceptionUtilFake.getErrorMessage())
+ assertEquals(delegateExecution, exceptionUtilFake.getDelegateExecution())
+ }
+
+ @Test
+ public void checkAAIQueryResult_shouldSetVolumeGroupNameMatchesToFalse_whenResponseCodeIs404() {
+ delegateExecution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.NOT_FOUND)
+ delegateExecution.setVariable("CVGN_volumeGroupName", "")
+
+ confirmVolumeGroupName.checkAAIQueryResult(delegateExecution)
+
+ assertFalse(delegateExecution.getVariable("CVGN_volumeGroupNameMatches"))
+ }
+
+ @Test
+ public void checkAAIQueryResult_shouldSetVolumeGroupNameMatchesToTrue_whenResponseCodeIs200AndVolumeGroupNameExists() {
+ delegateExecution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.OK.value())
+ delegateExecution.setVariable("CVGN_queryVolumeGroupResponse", volumeGroup)
+ delegateExecution.setVariable("CVGN_volumeGroupName", volumeGroup.getVolumeGroupName())
+
+ confirmVolumeGroupName.checkAAIQueryResult(delegateExecution)
+
+ assertTrue(delegateExecution.getVariable("CVGN_volumeGroupNameMatches"))
+ }
+
+ @Test
+ public void handleVolumeGroupNameNoMatch_shouldThrowBpmnErrorException() {
+ def volumeGroupId = "volume-group-id"
+ def volumeGroupName = "volume-group-name"
+
+ delegateExecution.setVariable("CVGN_volumeGroupId", volumeGroupId)
+ delegateExecution.setVariable("CVGN_volumeGroupName", volumeGroupName)
+
+ def errorMessage = String.format("Error occurred - volume group id %s is not associated with %s",
+ delegateExecution.getVariable('CVGN_volumeGroupId'), delegateExecution.getVariable('CVGN_volumeGroupName'))
+
+ BpmnError error = catchThrowableOfType(
+ { -> confirmVolumeGroupName.handleVolumeGroupNameNoMatch(delegateExecution) }, BpmnError.class)
+
+ assertEquals(String.format("MSOWorkflowException: %s", errorMessage), error.getMessage())
+ assertEquals("1002", error.getErrorCode())
+
+ assertEquals(1002, exceptionUtilFake.getErrorCode())
+ assertEquals(errorMessage, exceptionUtilFake.getErrorMessage())
+ assertEquals(delegateExecution, exceptionUtilFake.getDelegateExecution())
+ }
+
+ @Test
+ public void reportSuccess_shouldSetWorkflowResponseToEmptyString() {
+ confirmVolumeGroupName.reportSuccess(delegateExecution)
+ assertEquals("", delegateExecution.getVariable("WorkflowResponse"))
+ }
+
+ private VolumeGroup createVolumeGroup() {
+ VolumeGroup volumeGroup = new VolumeGroup()
+
+ volumeGroup.setVolumeGroupId("volume-group-id")
+ volumeGroup.setVolumeGroupName("volume-group-name")
+ volumeGroup.setHeatStackId("heat-stack-id")
+ volumeGroup.setVnfType("vnf-type")
+ volumeGroup.setOrchestrationStatus("orchestration-status")
+ volumeGroup.setModelCustomizationId("model-customization-id")
+ volumeGroup.setVfModuleModelCustomizationId("vf-module-model-customization-id")
+ volumeGroup.setResourceVersion("resource-version")
+ volumeGroup.setRelationshipList(new RelationshipList())
+
+ return volumeGroup
+ }
+
+ private static class ExceptionUtilFake extends ExceptionUtil {
+
+ private int errorCode
+ private String errorMessage
+ private DelegateExecution execution
+
+ @Override
+ public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) {
+ this.errorCode = errorCode
+ this.errorMessage = errorMessage
+ this.execution = execution
+ throw new BpmnError(errorCode.toString(), "MSOWorkflowException: ${errorMessage}")
+ }
+
+ public int getErrorCode() {
+ return errorCode
+ }
+
+ public String getErrorMessage() {
+ return errorMessage
+ }
+
+ public DelegateExecution getDelegateExecution() {
+ return execution
+ }
+ }
-class ConfirmVolumeGroupNameTest extends MsoGroovyTest {
-
- @Spy
- private ConfirmVolumeGroupName confirmVolumeGroupName;
-
- @Before
- public void init() throws IOException {
- super.init("ConfirmVolumeGroupName")
- MockitoAnnotations.initMocks(this);
- when(confirmVolumeGroupName.getAAIClient()).thenReturn(client)
-
- }
-
- @Test
- public void testQueryAAIForVolumeGroupId() {
-
- AAIResourceUri resourceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build());
- when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn(resourceUri)
- VolumeGroup volumeGroup = new VolumeGroup()
- volumeGroup.setVolumeGroupId("Test")
- when(client.get(VolumeGroup.class,resourceUri)).thenReturn(Optional.of(volumeGroup))
- confirmVolumeGroupName.queryAAIForVolumeGroupId(mockExecution)
- Mockito.verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode",200)
- Mockito.verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse",volumeGroup)
- }
-
- @Test
- public void testQueryAAIForVolumeGroupId_404() {
- AAIResourceUri resourceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build());
- when(client.get(VolumeGroup.class, resourceUri)).thenReturn(Optional.empty())
- DelegateExecution execution = new DelegateExecutionFake()
- try {
- execution.setVariable("CVGN_volumeGroupGetEndpoint", resourceUri)
- confirmVolumeGroupName.queryAAIForVolumeGroupId(execution)
- }
- catch(Exception ex){}
- Assert.assertEquals(404, execution.getVariable("CVGN_queryVolumeGroupResponseCode"))
- Assert.assertEquals("Volume Group not Found!", execution.getVariable("CVGN_queryVolumeGroupResponse"))
-
- }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy
new file mode 100644
index 0000000000..5f428f1f9f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilTest.groovy
@@ -0,0 +1,199 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.common.scripts
+
+import org.assertj.core.api.AbstractAssert
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.junit.Test
+import org.onap.logging.ref.slf4j.ONAPLogConstants
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.utils.TargetEntity
+import org.springframework.http.HttpStatus
+
+import javax.ws.rs.core.MediaType
+import javax.ws.rs.core.Response
+
+import static org.assertj.core.api.Assertions.assertThat
+import static org.assertj.core.api.Assertions.catchThrowableOfType
+import static org.mockito.BDDMockito.given
+import static org.mockito.BDDMockito.then
+import static org.mockito.BDDMockito.willThrow
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.times
+
+class ExternalAPIUtilTest {
+
+ private static final String URL = "http://someUrl"
+ private static final String UUID_STR = UUID.nameUUIDFromBytes("deterministic_uuid".getBytes())
+ private static final String BODY_PAYLOAD = "payload"
+
+ @Test
+ void executeExternalAPIGetCall_shouldPerformRestGetCall_withAuthorizationHeaderSet() {
+ // GIVEN
+ Response expectedResponse = createExpectedResponse(HttpStatus.ACCEPTED, BODY_PAYLOAD)
+ HttpClient httpClient = mock(HttpClient.class)
+ given(httpClient.get()).willReturn(expectedResponse)
+ HttpClientFactory httpClientFactory = mock(HttpClientFactory.class)
+ given(httpClientFactory.create(new URL(URL), MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL)).willReturn(httpClient)
+
+ // WHEN
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(httpClientFactory, new DummyMsoUtils(UUID_STR), new ExceptionUtil())
+ Response apiResponse = externalAPIUtil.executeExternalAPIGetCall(createDelegateExecution(), URL)
+
+ // THEN
+ then(httpClient).should(times(1)).addBasicAuthHeader("value_externalapi_auth", "value_mso_msoKey")
+ then(httpClient).should(times(1)).addAdditionalHeader("X-FromAppId", "MSO")
+ then(httpClient).should(times(1)).addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, UUID_STR)
+ then(httpClient).should(times(1)).addAdditionalHeader("Accept", MediaType.APPLICATION_JSON)
+ ResponseAssert.assertThat(apiResponse)
+ .hasStatusCode(HttpStatus.ACCEPTED)
+ .hasBody(BODY_PAYLOAD)
+ }
+
+ @Test
+ void executeExternalAPIGetCall_shouldHandleExceptionsThrownByGetCall_andRethrowAsBpmnError() {
+ // GIVEN
+ HttpClient httpClient = mock(HttpClient.class)
+ willThrow(new RuntimeException("error occurred")).given(httpClient).get()
+ HttpClientFactory httpClientFactory = mock(HttpClientFactory.class)
+ given(httpClientFactory.create(new URL(URL), MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL)).willReturn(httpClient)
+ DelegateExecution delegateExecution = createDelegateExecution()
+ DummyExceptionUtil exceptionUtil = new DummyExceptionUtil()
+
+ // WHEN
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(httpClientFactory, new DummyMsoUtils(UUID_STR), exceptionUtil)
+ BpmnError bpmnError = catchThrowableOfType({ -> externalAPIUtil.executeExternalAPIGetCall(delegateExecution, URL)
+ }, BpmnError.class)
+
+ // THEN
+ assertThat(exceptionUtil.getDelegateExecution()).isSameAs(delegateExecution)
+ assertThat(bpmnError.getMessage()).isEqualTo("error occurred")
+ assertThat(bpmnError.getErrorCode()).isEqualTo("9999")
+ }
+
+ @Test
+ void executeExternalAPIPostCall_shouldHandleExceptionsThrownByPostCall_andRethrowAsBpmnError() {
+ // GIVEN
+ HttpClient httpClient = mock(HttpClient.class)
+ willThrow(new RuntimeException("error occurred")).given(httpClient).post(BODY_PAYLOAD)
+ HttpClientFactory httpClientFactory = mock(HttpClientFactory.class)
+ given(httpClientFactory.create(new URL(URL), MediaType.APPLICATION_JSON, TargetEntity.AAI)).willReturn(httpClient)
+ DelegateExecution delegateExecution = createDelegateExecution()
+ DummyExceptionUtil exceptionUtil = new DummyExceptionUtil()
+
+ // WHEN
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(httpClientFactory, new DummyMsoUtils(UUID_STR), exceptionUtil)
+ BpmnError bpmnError = catchThrowableOfType({ ->
+ externalAPIUtil.executeExternalAPIPostCall(delegateExecution, URL, BODY_PAYLOAD)
+ }, BpmnError.class)
+
+ // THEN
+ assertThat(exceptionUtil.getDelegateExecution()).isSameAs(delegateExecution)
+ assertThat(bpmnError.getMessage()).isEqualTo("error occurred")
+ assertThat(bpmnError.getErrorCode()).isEqualTo("9999")
+ }
+
+ @Test
+ void executeExternalAPIPostCall_shouldPerformRestPostCall_withPayloadAndAuthorizationHeaderSet() {
+ // GIVEN
+ Response expectedResponse = createExpectedResponse(HttpStatus.ACCEPTED, BODY_PAYLOAD)
+ HttpClient httpClient = mock(HttpClient.class)
+ given(httpClient.post(BODY_PAYLOAD)).willReturn(expectedResponse)
+ HttpClientFactory httpClientFactory = mock(HttpClientFactory.class)
+ given(httpClientFactory.create(new URL(URL), MediaType.APPLICATION_JSON, TargetEntity.AAI)).willReturn(httpClient)
+
+ // WHEN
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(httpClientFactory, new DummyMsoUtils(UUID_STR), new ExceptionUtil())
+ Response apiResponse = externalAPIUtil.executeExternalAPIPostCall(createDelegateExecution(), URL, BODY_PAYLOAD)
+
+ // THEN
+ then(httpClient).should(times(1)).addBasicAuthHeader("value_externalapi_auth", "value_mso_msoKey")
+ then(httpClient).should(times(1)).addAdditionalHeader("X-FromAppId", "MSO")
+ then(httpClient).should(times(1)).addAdditionalHeader("X-TransactionId", UUID_STR)
+ ResponseAssert.assertThat(apiResponse)
+ .hasStatusCode(HttpStatus.ACCEPTED)
+ .hasBody(BODY_PAYLOAD)
+ }
+
+ private Response createExpectedResponse(HttpStatus httpStatus, String body) {
+ Response expectedResponse = mock(Response.class)
+ given(expectedResponse.getStatus()).willReturn(httpStatus.value())
+ given(expectedResponse.getEntity()).willReturn(body)
+ return expectedResponse
+ }
+
+ private DelegateExecution createDelegateExecution() {
+ DelegateExecution delegateExecution = mock(DelegateExecution.class)
+ given(delegateExecution.getVariable("URN_externalapi_auth")).willReturn("value_externalapi_auth")
+ given(delegateExecution.getVariable("URN_mso_msoKey")).willReturn("value_mso_msoKey")
+ return delegateExecution
+ }
+
+ private static class ResponseAssert extends AbstractAssert<ResponseAssert, Response> {
+
+ ResponseAssert(Response response) {
+ super(response, ResponseAssert.class)
+ }
+
+ static ResponseAssert assertThat(Response response) {
+ return new ResponseAssert(response)
+ }
+
+ ResponseAssert hasStatusCode(HttpStatus httpStatus) {
+ assertThat(actual.getStatus()).isEqualTo(httpStatus.value())
+ return this
+ }
+
+ ResponseAssert hasBody(String responseBody) {
+ assertThat(actual.getEntity()).isEqualTo(responseBody)
+ return this
+ }
+ }
+
+ private static class DummyMsoUtils extends MsoUtils {
+
+ private final String uuid
+
+ DummyMsoUtils(String uuid) {
+ this.uuid = uuid
+ }
+
+ String getRequestID() {
+ return uuid
+ }
+ }
+
+ private static class DummyExceptionUtil extends ExceptionUtil {
+
+ private DelegateExecution delegateExecution
+
+ @Override
+ void buildAndThrowWorkflowException(DelegateExecution delegateExecution, int errorCode, String errorMessage) {
+ this.delegateExecution = delegateExecution
+ throw new BpmnError(String.valueOf(errorCode), errorMessage)
+ }
+
+ DelegateExecution getDelegateExecution() {
+ return delegateExecution
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy
index bf0f2d20c0..e351210586 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy
@@ -1,22 +1,22 @@
-/*-
- * ============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=========================================================
- */
+/*-
+ * ============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.common.scripts
@@ -39,7 +39,7 @@ import org.onap.so.bpmn.mock.FileUtil
@RunWith(MockitoJUnitRunner.Silent.class)
public class SDNCAdapterTest {
-
+
@Before
public void init()
{
@@ -47,7 +47,7 @@ public class SDNCAdapterTest {
System.setProperty("jboss.qualified.host.name","myhost.com")
}
-
+
String workflowResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -423,7 +423,7 @@ public class SDNCAdapterTest {
</service-request>
</rest:payload>
</sdncadaptersc:RequestData></aetgt:SDNCAdapterRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>"""
-
+
def sdncAdapterResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
<sdncadapterworkflow:response-data>
<tag0:CallbackHeader xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1">
@@ -453,7 +453,7 @@ String workflowErrorResponse1 = """<aetgt:WorkflowException xmlns:aetgt="http://
<aetgt:ErrorMessage>Invalid Callback Response from SDNC Adapter</aetgt:ErrorMessage>
<aetgt:ErrorCode>5300</aetgt:ErrorCode>
</aetgt:WorkflowException>"""
-
+
String enhancedCallbackRequestData =
"""<tag0:RequestData xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -536,7 +536,7 @@ String enhancedCallbackRequestData =
<excluded-v4-address>192.168.1.7</excluded-v4-address>
</excluded-v4-addresses>
<v4-dhcp-pool-prefix>192.155.2.4</v4-dhcp-pool-prefix>
- </v4-dhcp-pools>
+ </v4-dhcp-pools>
<use-v4-default-pool>Y</use-v4-default-pool>
<excluded-v6-dhcp-addresses-from-default-pool>
<excluded-v6-address>1:5</excluded-v6-address>
@@ -567,7 +567,7 @@ String enhancedCallbackRequestData =
<excluded-v6-address>2:2</excluded-v6-address>
</excluded-v6-addresses>
<v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix>
- </v6-dhcp-pools>
+ </v6-dhcp-pools>
</dhcp>
<firewall-lite>
<stateful-firewall-lite-v6-enabled>N</stateful-firewall-lite-v6-enabled>
@@ -694,7 +694,7 @@ String enhancedCallbackRequestData =
</vr-lan-interface>
<routing-protocol>none</routing-protocol>
</vr-lan>
-<ucpe-vms-service-information>
+<ucpe-vms-service-information>
<transport-service-information>
<transport-service-type>AVPN</transport-service-type>
<access-circuit-info>
@@ -704,7 +704,7 @@ String enhancedCallbackRequestData =
<access-circuit-info>
<access-circuit-id>2</access-circuit-id>
<dual-mode>Standby</dual-mode>
- </access-circuit-info>
+ </access-circuit-info>
</transport-service-information>
<ucpe-information>
<ucpe-host-name>hostname</ucpe-host-name>
@@ -712,8 +712,8 @@ String enhancedCallbackRequestData =
<out-of-band-management-modem>OOB</out-of-band-management-modem>
</ucpe-information>
<vnf-list>
- <vnf-information>
- <vnf-instance-id>1</vnf-instance-id>
+ <vnf-information>
+ <vnf-instance-id>1</vnf-instance-id>
<vnf-sequence-number>1</vnf-sequence-number>
<vnf-type>ZZ</vnf-type>
<vnf-vendor>JUNIPER</vnf-vendor>
@@ -724,8 +724,8 @@ String enhancedCallbackRequestData =
<orchestration-status>1</orchestration-status>
<equipment-role>1</equipment-role>
</vnf-information>
- <vnf-information>
- <vnf-instance-id>2</vnf-instance-id>
+ <vnf-information>
+ <vnf-instance-id>2</vnf-instance-id>
<vnf-sequence-number>2</vnf-sequence-number>
<vnf-type>HY</vnf-type>
<vnf-vendor>JUNIPER</vnf-vendor>
@@ -735,9 +735,9 @@ String enhancedCallbackRequestData =
<operational-state>2</operational-state>
<orchestration-status>2</orchestration-status>
<equipment-role>2</equipment-role>
- </vnf-information>
+ </vnf-information>
</vnf-list>
- </ucpe-vms-service-information>
+ </ucpe-vms-service-information>
<request-information>
<request-action>Layer3ServiceActivateRequest</request-action>
<order-number>4281555</order-number>
@@ -815,7 +815,7 @@ def sdncAdapterResponseError =
</sdncadapterworkflow:response-data>
</sdncadapterworkflow:SDNCAdapterWorkflowResponse>"""
-
+
@Test
public void testPreProcessRequest() {
@@ -823,34 +823,35 @@ def sdncAdapterResponseError =
ExecutionEntity mockExecution = mock(ExecutionEntity.class)
when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C")
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("testReqId")
when(mockExecution.getVariable("sdncAdapterWorkflowRequest")).thenReturn(sdncAdapterWorkflowRequest)
when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://someurl.someting.com:28080/mso/sdncAdapterCallbackServiceImpl")
when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true")
when(mockExecution.getProcessInstanceId()).thenReturn("745b1b50-e39e-4685-9cc8-c71f0bde8bf0")
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
-
+
SDNCAdapter sdncAdapter = new SDNCAdapter()
sdncAdapter.preProcessRequest(mockExecution)
-
+
MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
debugger.printInvocations(mockExecution)
-
+
verify(mockExecution).setVariable("prefix","SDNCA_")
verify(mockExecution).setVariable("sdncAdapterResponse","")
verify(mockExecution).setVariable("asynchronousResponseTimeout",false)
verify(mockExecution).setVariable("continueListening",false)
verify(mockExecution).setVariable("serviceConfigActivate",false)
- verify(mockExecution).setVariable("SDNCA_requestId", "745b1b50-e39e-4685-9cc8-c71f0bde8bf0")
verify(mockExecution).setVariable("SDNCA_SuccessIndicator",false)
verify(mockExecution).setVariable("SDNCA_InterimNotify",false)
verify(mockExecution).setVariable("BasicAuthHeaderValue","Basic dGVzdDp0ZXN0")
verify(mockExecution).setVariable("source","")
+ verify(mockExecution).setVariable("SDNCA_requestId", "745b1b50-e39e-4685-9cc8-c71f0bde8bf0")
verify(mockExecution).setVariable("sdncAdapterRequest", sdncAdapterRequest)
}
-
+
@Test
public void testProcessResponse()
{
@@ -859,17 +860,17 @@ def sdncAdapterResponseError =
when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(sdncAdapterCallbackResponse)
SDNCAdapter sdncAdapter = new SDNCAdapter()
sdncAdapter.postProcessResponse(mockExecution)
-
+
// MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
// debugger.printInvocations(mockExecution)
-
+
verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest")
- verify(mockExecution).setVariable("enhancedCallbackRequestData",enhancedCallbackRequestData)
+ // verify(mockExecution).setVariable("enhancedCallbackRequestData",enhancedCallbackRequestData)
verify(mockExecution).setVariable("sdncAdapterResponse",workflowResponse)
verify(mockExecution).setVariable("continueListening",false)
- }
-
+ }
+
@Test
public void testProcessResponse_ErrorCase_404()
{
@@ -878,14 +879,14 @@ def sdncAdapterResponseError =
when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(sdncAdapterCallbackErrorResponse)
SDNCAdapter sdncAdapter = new SDNCAdapter()
sdncAdapter.postProcessResponse(mockExecution)
-
+
verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest")
verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponseError)
verify(mockExecution).setVariable("enhancedCallbackRequestData", "")
verify(mockExecution).setVariable("continueListening",false)
-
+
}
-
+
@Test
public void testProcessResponse_ErrorCase_InvalidCallback()
{
@@ -893,19 +894,19 @@ def sdncAdapterResponseError =
when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn("<h1>Service Unavailable</h1>")
SDNCAdapter sdncAdapter = new SDNCAdapter()
sdncAdapter.postProcessResponse(mockExecution)
-
+
verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest")
verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponseEmpty)
verify(mockExecution).setVariable("enhancedCallbackRequestData", "")
verify(mockExecution).setVariable("continueListening",false)
}
-
+
@Test
public void postProcessResponse()
{
-
- String SDNCAdapterCallbackRequest =
+
+ String SDNCAdapterCallbackRequest =
"""<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SDNCAdapterCallbackRequest
xmlns="http://org.onap/workflow/sdnc/adapter/schema/v1">
@@ -919,7 +920,7 @@ def sdncAdapterResponseError =
data model content does not exist ]</ResponseMessage>
</CallbackHeader>
</SDNCAdapterCallbackRequest>"""
-
+
String sdncAdapterResponse =
"""<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1">
@@ -940,7 +941,7 @@ def sdncAdapterResponseError =
when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(SDNCAdapterCallbackRequest)
SDNCAdapter sdncAdapter = new SDNCAdapter()
sdncAdapter.postProcessResponse(mockExecution)
-
+
verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest")
verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponse)
verify(mockExecution).setVariable("enhancedCallbackRequestData", "")
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
index cb9bb5c541..2d2f58b415 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
@@ -113,6 +113,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest {
when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule)
doNothing().when(client).update(isA(AAIResourceUri.class), anyObject())
updateAAIVfModule.updateVfModule(mockExecution)
+ verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 200)
}
@Test
@@ -128,6 +129,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest {
doThrow(new NotFoundException("Vf Module not found")).when(client).update(isA(AAIResourceUri.class), anyObject())
thrown.expect(BpmnError.class)
updateAAIVfModule.updateVfModule(mockExecution)
+ verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 404)
}
@@ -144,6 +146,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest {
doThrow(new IllegalStateException("Error in AAI client")).when(client).update(isA(AAIResourceUri.class), anyObject())
thrown.expect(BpmnError.class)
updateAAIVfModule.updateVfModule(mockExecution)
+ verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 500)
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
index 0398c87d69..d5b5cde99b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
@@ -290,7 +290,7 @@ public class BuildingBlockTestDataSetup{
customer.setSubscriberType("testSubscriberType" + customerCounter);
customer.setServiceSubscription(buildServiceSubscription());
-
+
return customer;
}
@@ -341,50 +341,50 @@ public class BuildingBlockTestDataSetup{
customer.setServiceSubscription(buildServiceSubscription());
gBBInput.setCustomer(customer);
-
+
return customer;
}
-
+
public Collection setCollection() {
Collection collection = new Collection();
collection.setId("testId");
-
+
ServiceInstance serviceInstance = null;
-
+
try {
serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
} catch(BBObjectNotFoundException e) {
serviceInstance = setServiceInstance();
}
-
+
serviceInstance.setCollection(collection);
-
+
return collection;
}
-
+
public InstanceGroup setInstanceGroup() {
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setId("testId");
instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
-
+
Collection collection = null;
-
+
try {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
collection = serviceInstance.getCollection();
-
+
if (collection == null) {
collection = setCollection();
}
} catch(BBObjectNotFoundException e) {
collection = setCollection();
}
-
+
collection.setInstanceGroup(instanceGroup);
-
+
return instanceGroup;
}
-
+
public VpnBinding buildVpnBinding() {
vpnBindingCounter++;
@@ -664,12 +664,12 @@ public class BuildingBlockTestDataSetup{
modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
modelInfo.setModelInstanceName("testAllottedInstanceName" + uniqueIdentifier);
-
+
ar.setModelInfoAllottedResource(modelInfo);
-
+
return ar;
}
-
+
public Configuration setConfiguration () {
Configuration config = new Configuration();
config.setConfigurationId("testConfigurationId");
@@ -679,7 +679,7 @@ public class BuildingBlockTestDataSetup{
modelInfoConfig.setModelInvariantId("modelInvariantId");
modelInfoConfig.setPolicyName("policyName");
config.setModelInfoConfiguration(modelInfoConfig);
-
+
List<Configuration> configurations = new ArrayList<>();
configurations.add(config);
ServiceInstance serviceInstance = new ServiceInstance();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java
index d1559c2ed1..11309914ef 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java
@@ -20,7 +20,6 @@
package org.onap.so;
-import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -31,7 +30,6 @@ import org.springframework.context.annotation.Profile;
@SpringBootApplication
@Profile("test")
-@EnableProcessApplication("MSO CommonBPMN Test Application")
@ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {
@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
public class TestApplication {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java
index 45bbe9e5d8..a513acc952 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java
@@ -27,8 +27,6 @@ import org.camunda.bpm.application.PostDeploy;
import org.camunda.bpm.application.PreUndeploy;
import org.camunda.bpm.application.ProcessApplicationInfo;
import org.camunda.bpm.engine.ProcessEngine;
-import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
-import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator;
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
@@ -46,7 +44,6 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
*/
@SpringBootApplication
-@EnableProcessApplication("MSO Common Application")
@EnableAsync
@ComponentScan(basePackages = { "org.onap" }, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {
@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index e32362d1b0..78238f0271 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -40,6 +40,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Before;
@@ -84,6 +85,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.constants.Defaults;
@@ -99,6 +101,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
@@ -128,6 +131,9 @@ public class BBInputSetupTest {
@Mock
private BBInputSetupUtils SPY_bbInputSetupUtils;
+ @Mock
+ private CloudInfoFromAAI SPY_cloudInfoFromAAI;
+
@Spy
private BBInputSetupMapperLayer bbInputSetupMapperLayer;
@@ -135,8 +141,33 @@ public class BBInputSetupTest {
public void setup(){
SPY_bbInputSetup.setBbInputSetupUtils(SPY_bbInputSetupUtils);
SPY_bbInputSetup.setMapperLayer(bbInputSetupMapperLayer);
+ SPY_bbInputSetup.setCloudInfoFromAAI(SPY_cloudInfoFromAAI);
}
-
+
+ @Test
+ public void testGetVolumeGroupIdRelatedToVfModule() {
+ String expected = "volumeGroupId";
+ String modelCustomizationId = "modelCustomizationId";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(modelCustomizationId);
+ String cloudOwner = "cloudOwner";
+ String cloudRegionId = "cloudRegionId";
+ String volumeGroupId = "volumeGroupId";
+ GenericVnf vnf = new GenericVnf();
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId(expected);
+ vnf.getVolumeGroups().add(volumeGroup);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, null);
+ org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
+ aaiVolumeGroup.setModelCustomizationId(modelCustomizationId);
+ doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudOwner, cloudRegionId, volumeGroupId);
+
+ Optional<String> actual = SPY_bbInputSetup.getVolumeGroupIdRelatedToVfModule(vnf, modelInfo, cloudOwner, cloudRegionId, lookupKeyMap);
+
+ assertEquals(expected, actual.get());
+ }
+
@Test
public void testGetAlaCarteServiceInstance() throws Exception {
ServiceInstance expected = mapper.readValue(
@@ -1203,6 +1234,31 @@ public class BBInputSetupTest {
}
@Test
+ public void testMapVnfcCollectionInstanceGroup() {
+ VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
+ GenericVnf genericVnf = new GenericVnf();
+ ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
+ Service service = Mockito.mock(Service.class);
+ List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
+ vnfcInstanceGroupCust.setModelUUID("modelUUID");
+ vnfcInstanceGroupCust.setFunction("function");
+ vnfcInstanceGroupCust.setDescription("description");
+ vnfcInstanceGroups.add(vnfcInstanceGroupCust);
+ org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
+ instanceGroup.setModelUUID("modelUUID");
+ ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+ modelInfoInstanceGroup.setModelUUID("modelUUID");
+ doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
+ doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
+ doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
+ doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null, instanceGroup);
+
+ SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
+
+ assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
+ }
+ @Test
public void testPopulateGenericVnfWhereVnfTypeIsNull()
throws JsonParseException, JsonMappingException, IOException {
org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
@@ -1258,12 +1314,11 @@ public class BBInputSetupTest {
doReturn(vnf2AAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf2.getVnfId());
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service);
doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
- doNothing().when(SPY_bbInputSetup).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null);
verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
- verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
+ verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
}
@Test
@@ -1688,8 +1743,10 @@ public class BBInputSetupTest {
configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
executeBB.setConfigurationResourceKeys(configResourceKeys);
+
+ executeBB.setRequestDetails(requestDetails);
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
@@ -1698,6 +1755,7 @@ public class BBInputSetupTest {
doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
@@ -1806,8 +1864,9 @@ public class BBInputSetupTest {
String vnfType = "vnfType";
Service service = Mockito.mock(Service.class);
String requestAction = "createInstance";
+
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
@@ -1832,9 +1891,7 @@ public class BBInputSetupTest {
String vnfType = "vnfType";
Service service = Mockito.mock(Service.class);
String requestAction = "createInstance";
- doReturn(null).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
-
+
executeBB.getBuildingBlock().setBpmnFlowName("Network");
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
@@ -1861,8 +1918,11 @@ public class BBInputSetupTest {
String vnfType = null;
Service service = Mockito.mock(Service.class);
String requestAction = "createInstance";
+
+
+ executeBB.setRequestDetails(requestDetails);
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
@@ -1922,8 +1982,10 @@ public class BBInputSetupTest {
String vnfType = "vnfType";
Service service = Mockito.mock(Service.class);
String requestAction = "createInstance";
+
+ executeBB.setRequestDetails(requestDetails);
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
@@ -1984,7 +2046,7 @@ public class BBInputSetupTest {
Service service = Mockito.mock(Service.class);
String requestAction = "deactivateInstance";
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
String generatedId = "12131";
@@ -2027,8 +2089,9 @@ public class BBInputSetupTest {
Service service = Mockito.mock(Service.class);
String requestAction = "createInstance";
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
@@ -2089,12 +2152,17 @@ public class BBInputSetupTest {
String vnfType = "vnfType";
Service service = Mockito.mock(Service.class);
String requestAction = "deleteInstance";
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- //doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
-
+
+ executeBB.setRequestDetails(requestDetails);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+
CloudConfiguration cloudConfig = new CloudConfiguration();
cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
requestDetails.setCloudConfiguration(cloudConfig);
@@ -2104,37 +2172,37 @@ public class BBInputSetupTest {
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), any(GeneralBuildingBlock.class), isA(Service.class), isA(String.class),
+ any(String.class), isA(String.class),
isA(CloudConfiguration.class));
requestAction = "activateInstance";
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
executeBB.getBuildingBlock().setBpmnFlowName("ActivateNetworkBB");
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(2)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), any(GeneralBuildingBlock.class), isA(Service.class), isA(String.class),
+ any(String.class), isA(String.class),
isA(CloudConfiguration.class));
requestAction = "unassignInstance";
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
executeBB.getBuildingBlock().setBpmnFlowName("UnassignNetworkBB");
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(3)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), any(GeneralBuildingBlock.class), isA(Service.class), isA(String.class),
+ any(String.class), isA(String.class),
isA(CloudConfiguration.class));
requestAction = "activateFabricConfiguration";
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
executeBB.getBuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-134534656234");
SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(4)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), any(GeneralBuildingBlock.class), isA(Service.class), isA(String.class),
+ any(String.class), isA(String.class),
isA(CloudConfiguration.class));
}
@@ -2160,7 +2228,7 @@ public class BBInputSetupTest {
Service service = Mockito.mock(Service.class);
String requestAction = "assignInstance";
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils)
.getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
String generatedId = "12131";
@@ -2188,6 +2256,7 @@ public class BBInputSetupTest {
CloudConfiguration cloudConfiguration = new CloudConfiguration();
cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
String requestAction = "unassignInstance";
+ executeBB.setRequestDetails(requestDetails);
ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
@@ -2195,6 +2264,15 @@ public class BBInputSetupTest {
configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
executeBB.setConfigurationResourceKeys(configResourceKeys);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+
L3Network network = new L3Network();
network.setNetworkId("networkId");
gBB.getServiceInstance().getNetworks().add(network);
@@ -2207,7 +2285,7 @@ public class BBInputSetupTest {
executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB");
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), gBB, service, requestAction, cloudConfiguration);
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class),
any(Service.class));
@@ -2223,7 +2301,7 @@ public class BBInputSetupTest {
executeBB.getBuildingBlock().setBpmnFlowName("ActivateVnfBB");
executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), gBB, service, requestAction, cloudConfiguration);
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
any(Service.class));
@@ -2237,25 +2315,28 @@ public class BBInputSetupTest {
executeBB.getBuildingBlock().setBpmnFlowName("UnassignVfModuleBB");
executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), gBB, service, requestAction, cloudConfiguration);
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
any(Service.class));
verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(any(VfModule.class), any(ModelInfo.class),
any(Service.class), any(String.class));
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setCloudOwner("CloudOwner");
+ doReturn(Optional.of(cloudRegion)).when(SPY_cloudInfoFromAAI).getCloudInfoFromAAI(gBB.getServiceInstance());
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup);
org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
aaiVolumeGroup.setModelCustomizationId("modelCustId");
- doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(Defaults.CLOUD_OWNER.toString(),
- cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
executeBB.getBuildingBlock().setBpmnFlowName("UnassignVolumeGroupBB");
executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), gBB, service, requestAction, cloudConfiguration);
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
verify(SPY_bbInputSetup, times(3)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
any(Service.class));
verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(isA(VolumeGroup.class), isA(ModelInfo.class),
@@ -2272,7 +2353,7 @@ public class BBInputSetupTest {
executeBB.getBuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), gBB, service, requestAction, cloudConfiguration);
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(any(Configuration.class), any(ModelInfo.class),
any(Service.class), isA(ConfigurationResourceKeys.class));
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
new file mode 100644
index 0000000000..ccaa97b735
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
@@ -0,0 +1,142 @@
+package org.onap.so.bpmn.servicedecomposition.tasks;
+
+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.assertNull;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.doReturn;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+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.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CloudInfoFromAAITest {
+
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+
+ @Spy
+ private CloudInfoFromAAI SPY_CloudInfoFromAAI = new CloudInfoFromAAI();
+
+ protected ObjectMapper mapper = new ObjectMapper();
+
+ @Mock
+ private BBInputSetupUtils SPY_bbInputSetupUtils;
+
+ @Before
+ public void setup(){
+ SPY_CloudInfoFromAAI.setBbInputSetupUtils(SPY_bbInputSetupUtils);
+ }
+
+ @Test
+ public void testGetCloudInfoFromAAI() throws JsonParseException, JsonMappingException, IOException {
+ //Test vnfs
+ ServiceInstance serviceInstance = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ CloudRegion expected = new CloudRegion();
+ GenericVnf vnf = new GenericVnf();
+ String vnfId = "vnfId";
+ vnf.setVnfId(vnfId);
+ serviceInstance.getVnfs().add(vnf);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setVnfId(vnfId);
+ Relationships relationships = Mockito.mock(Relationships.class);
+ Optional<Relationships> relationshipsOp= Optional.of(relationships);
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doReturn(relationshipsOp).when(SPY_CloudInfoFromAAI).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
+ doReturn(Optional.of(expected)).when(SPY_CloudInfoFromAAI).getRelatedCloudRegionAndTenant(relationships);
+ Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertThat(actual.get(), sameBeanAs(expected));
+
+ //Test networks
+ serviceInstance = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ L3Network l3Network = new L3Network();
+ String networkId = "networkId";
+ l3Network.setNetworkId(networkId);
+ serviceInstance.getNetworks().add(l3Network);
+ org.onap.aai.domain.yang.L3Network aaiL3Network = new org.onap.aai.domain.yang.L3Network();
+ aaiL3Network.setNetworkId(networkId);
+ doReturn(aaiL3Network).when(SPY_bbInputSetupUtils).getAAIL3Network(l3Network.getNetworkId());
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertThat(actual.get(), sameBeanAs(expected));
+
+ //Test no relationships
+
+ doReturn(Optional.empty()).when(SPY_CloudInfoFromAAI).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertEquals(actual, Optional.empty());
+
+ //Test null
+ serviceInstance = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertEquals(actual, Optional.empty());
+ }
+
+ @Test
+ public void testGetRelatedCloudRegionAndTenant() throws JsonProcessingException {
+ String cloudOwner = "cloudOwner";
+ String cloudRegionId = "cloudRegionId";
+ String cloudRegionVersion = "cloudRegionVersion";
+ String cloudRegionComplexName = "cloudRegionComplexName";
+ String tenantId = "tenantId";
+ CloudRegion expected = new CloudRegion();
+ expected.setCloudOwner(cloudOwner);
+ expected.setCloudRegionVersion(cloudRegionVersion);
+ expected.setComplex(cloudRegionComplexName);
+ expected.setLcpCloudRegionId(cloudRegionId);
+ expected.setTenantId(tenantId);
+
+ Relationships relationships = Mockito.mock(Relationships.class);
+ List<AAIResultWrapper> cloudRegions = new ArrayList<>();
+ org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
+ cloudRegion.setCloudOwner(cloudOwner);
+ cloudRegion.setCloudRegionId(cloudRegionId);
+ cloudRegion.setCloudRegionVersion(cloudRegionVersion);
+ cloudRegion.setComplexName(cloudRegionComplexName);
+ AAIResultWrapper cloudRegionWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(cloudRegion));
+ cloudRegions.add(cloudRegionWrapper);
+
+ doReturn(cloudRegions).when(relationships).getByType(AAIObjectType.CLOUD_REGION);
+ List<AAIResultWrapper> tenants = new ArrayList<>();
+ org.onap.aai.domain.yang.Tenant tenant = new org.onap.aai.domain.yang.Tenant();
+ tenant.setTenantId(tenantId);
+ AAIResultWrapper tenantWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(tenant));
+ tenants.add(tenantWrapper);
+ doReturn(tenants).when(relationships).getByType(AAIObjectType.TENANT);
+
+ Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getRelatedCloudRegionAndTenant(relationships);
+
+ assertThat(actual.get(), sameBeanAs(expected));
+ }
+}