aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-09-29 10:41:54 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-11-05 10:22:41 -0500
commit6fa3d2b80d2384b830e3231fe69a8daf7884a35e (patch)
tree565014596071f8b57919d762dc4d9733de7ea92f /bpmn/so-bpmn-infrastructure-common
parent6b4910cc194286bccb2a63f63d12bfefcdb7fb3f (diff)
Springboot 2.0 upgrade
corrected typo in CloudConfiguration class removed files which should not have been merged updated gr api test cases with dynamic cloud owner updated groovy files to allow for dynamic cloud owner values moved VFModularity folder to mso-infrastructure bpmn updated GR API layer to include cloud owner added enum for default cloud owner - fixing junit test cases for using catalogDb client r2 - fixing junit test cases for using catalogDb client - Internal review comments incorporated for merging mocking into BaseTest - Internal review comments incorporated for removing direct repo calls - CLONE - Key Management Hardcoded encryption key | fixing junits - CLONE - Key Management Hardcoded encryption key Updated builder to use String.format Added exception specifically for issues interacting with requestdbadapter Updated exception message and added junit test case removed useless error handling test case from workflow changed method name and added junit coverage to errors added max retry and success status after completed bb Added case to handle when homing is not called during assign vnf. Fixing fortify issues | Implementing review comments - Key Management Hardcoded encryption key - fixing prop files - Key Management Hardcoded encryption key include network ID for completion handler Added exception handling for saving to requestdb - Adding a check on the predicate availability on the repository before firing the query with default conditions. This ensures that the api returns data only when there is an input against which it was able to form some conditions Modify UT to show that the API does not behave - adding negative test case for checkInstanceNameDuplicate added assertion that global count var was reset to 0 updated rollback to reset current sequence count var workflowaction calls rollback is complete before error workflowaction will set failure on successful rollback added check for isrollback to know which complete to call removed file which should not have been added add fabric check before running vf module a la carte Enhance UCPEMigrateService junits and add them to Jenkins build.. Added back removed test case for ManualTasks Added test case for response error Added rainy day test cases for ManualTasks revert the other change and fix the rollback logic instead fixed current sequence and updated rollback code added network cloud heat template parameters to mapper Generate a unique subRequestId for each request to APP-C. reverted conditional logic for determining fabric Fix Bean scanning so it picks up the resttemplate removed unnecessary RestTemplate Bean configurations removed file which should not have been added workflowaction calls rollback is complete before error workflowaction will set failure on successful rollback added check for isrollback to know which complete to call add fabric check before running vf module a la carte added assertion that global count var was reset to 0 updated rollback to reset current sequence count var include network ID for completion handler Revert Application.yaml change accidentally checked in Added exception handling for saving to requestdb Added case to handle when homing is not called during assign vnf. removed useless error handling test case from workflow changed method name and added junit coverage to errors ... add cloud owner variable to camunda in mapping Revert "Pass cloudOwner to subflow DoCreateVfModuleVolumeV2. Added juint test to verify variables are set in the execution. Set default cloudOwner in main module CreateVfModuleVolumeInfraV2" updated cloud configuration pojo to inlcude defaults Revert "Test to verify ServiceInstance object mapping" Test to verify ServiceInstance object mapping Pass cloudOwner to subflow DoCreateVfModuleVolumeV2. Added juint test to verify variables are set in the execution. Set default cloudOwner in main module CreateVfModuleVolumeInfraV2 Pass cloudOwner to subflow DoCreateVfModuleVolumeV2. Set default cloudOwner 'att-aic' if null per old requirements. removed references to att-aic from BBInputSetup Changes done in encryption decryption logic | used DelegateExecutionFake in Tests Changes done in encryption decryption logic | used DelegateExecutionFake in Tests Changes done in encryption decryption logic Changes done in encryption decryption logic | removed Default Auth Constant as per the comments Changes done in encryption decryption logic | Fixed UT Changes done in encryption decryption logic | Added XmlComparator assertion for verifying XML Changes done in encryption decryption logic | Reverted as per the review comment Changes done in encryption decryption logic | Fixed UTs Changes done in encryption decryption logic | Fixed UTs Changes done in encryption decryption logic | modified related encrypted properties in test yaml files Changes done in encryption decryption logic for fortify issue resolution | Fixed UTs Changes done in encryption decryption logic | modified related encrypted properties in yaml files Changes done in encryption decryption logic for fortify issue resolution. Fixed Property fetching issue in required file Added TasksBeansTest using openpojo Removed renamed test file from tasksbeans Updated imports on TasksBeansTest Added openpojo test to replace the individual tests Removed tests that provided no coverage script clean up -Update reference data to support distinct recreate and replace requests with their own sequences Update reference data to support distinct recreate and replace requests with their own sequences- Fix seq number Update reference data to support distinct recreate and replace requests with their own sequences added null check to mdc and interceptors to sdnc cxf validations can now match against multiple BBs reverted changes to BBInputSetup class added support for pre and post validation for BBs initial commit of generic building block validator converted test to no longer be a springboot test Remove cosmetic changes from BPMN files to be consistent. Remove minor changes that are not related to functionality. Rework to implement the functionality as part of Validator Combine the verification methods into one based on the flow's name; change the logging. Add verification of status of other VF Modules in the VNF for the delete/deactivate/unassign. added network-technology validation for CreateNetworkBB Sonar Issue Fix | Changes done in encryption decryption logic | Refactoring Changes done in encryption decryption logic| Used AES/GCM/NoPadding algorithm | fixed sonar issues added network-type and network-technology to mapper Continue the fight to make JUNITS work properly Update ASDC ATT to be springboot 2.0 compliant Continue to fix Unit tests for springboot 2.0 port removed autowired from workflowactionbbtaskstest fixed workflowactiontest and reduced size by 500 lines Update last of UT for mockito upgrade to 2.0 Fix more JUNITS due to mockito 2.0 upgrade Unit Test fixes to use proper mockito not spring Update Base Test to import proper packages for compile Additional Springboot 2.0 changes, for tests Additional springboot 2.0 fixes and upgrades Update Migration to be Flyway 5 Compliant Fix MSOBPMN Infrastructure common tests Fix Groovy Unit Tests in CommonBPMN Project Update MSO common BPMN to Springboot 2.0 Upgrade ASDC controller to SpringBoot 2.0 Port Openstack adapters to springboot 2.0 Fix VFC Adapter to be springboot 2 compatible Port CatalogDB adapter code to springboot 2 Port SDNC Adapter to Springboot 2.0 ... added update scripts to macro data instead of v12 sql added secondarypolicy to rainy day handling table confirm subnet map is not null in adapter response shallow copy subnet before AAI udpate update AAIObjectType to use uriTemplate extract subnet data from adapter response update correct AAIObjectType for subnet query update subnet(s) in AAI on network create completion confirm subnet map is not null in adapter response shallow copy subnet before AAI udpate update AAIObjectType to use uriTemplate extract subnet data from adapter response update correct AAIObjectType for subnet query update subnet(s) in AAI on network create completion fixed test http entity unit test to remove testing appid and transaction id added unit test for querySubsystemHealth method. also added resttemplate mock to implement healthcheck endpoint fixed unit test to use mock instead of actually goes out to health check endpoint added code to extend globalhealthcheck to include pinging other components and consolidate the responses converted test to no longer be a springboot test Remove cosmetic changes from BPMN files to be consistent. Remove minor changes that are not related to functionality. added update scripts to macro data instead of v12 sql Rework to implement the functionality as part of Validator added secondarypolicy to rainy day handling table added network-type and network-technology to mapper Combine the verification methods into one based on the flow's name; change the logging. Add verification of status of other VF Modules in the VNF for the delete/deactivate/unassign. updated how request db is set to failure in workflowA corrected code to match existing unit tests corrected tests after springboot 2 upgrade Added Required UTs in UpdateConfigurationStateTest and also fixed some UTs. added in missing parenthesis on method call added back execution variable for allotted uri addressed comments on pull request refactor AAI Rest calls from groovy files - Changes as per review comments checkin to refactor AAI rest | Fixing AAIResourceClient.update call refactor AAI Rest calls from groovy files - UpdateConfiguration refactor AAI Rest calls from groovy file - DeleteConfiguration refactor AAI Rest calls from groovy file - UpdateConfiguration refactor AAI Rest calls from groovy file - CreateConfiguration & ConfigurationUtils refactor AAI Rest calls from groovy files - Fix getARByID issue checkin to refactor AAI rest | Adding Junits checkin to refactor AAI rest | Adding few more classes checkin to refactor AAI rest of DoCreateVfModuleVolumeV2 checkin to refactor AAI rest | Update junit checkin to refactor AAI rest of DoCreateVfModuleVolumeV2 | Adding junits checkin to refactor AAI rest of DoCreateVfModuleVolumeV2 | Adding junits checkin to refactor AAI rest of DoCreateVfModuleVolumeV2.groovy ... updated in and out mapping to be generalBuildingBlock change source out mapping to generalBuildingBlock Change-Id: I122f1ebe3e15b77da0a55af201d89d47e326bf83 Issue-ID: SO-1098 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/pom.xml31
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy64
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy44
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy175
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy57
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy63
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy60
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy120
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy111
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy234
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy45
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy125
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy74
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy155
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy179
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy210
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy69
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy10
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy52
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy100
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy803
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy151
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy33
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy123
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy14
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy49
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy48
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java8
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy81
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy36
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy146
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy80
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy78
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy91
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy101
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy63
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy144
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy62
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy162
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy73
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy81
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy75
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy131
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy43
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceTest.groovy83
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy24
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy147
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy106
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy52
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy158
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy65
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy70
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy44
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java8
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java23
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java20
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java18
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/GenericVnfVfModule.json62
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/ServiceInstanceWithAR.json36
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroup.json10
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroupWithTenant.json29
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroupWithVfModule.json26
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml574
68 files changed, 3160 insertions, 3065 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml
index d485c8a32d..7510c20d35 100644
--- a/bpmn/so-bpmn-infrastructure-common/pom.xml
+++ b/bpmn/so-bpmn-infrastructure-common/pom.xml
@@ -7,10 +7,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>so-bpmn-infrastructure-common</artifactId>
- <packaging>jar</packaging>
- <properties>
- <camunda.version>7.8.0</camunda.version>
- </properties>
+ <packaging>jar</packaging>
<build>
<plugins>
<plugin>
@@ -163,19 +160,15 @@
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter</artifactId>
- <version>2.3.0</version>
+ <version>${camunda.springboot.version}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
+ <groupId>org.camunda.bpm.springboot</groupId>
+ <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
+ <version>${camunda.springboot.version}</version>
<scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- <optional>true</optional>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
@@ -197,6 +190,10 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
</dependency>
@@ -206,8 +203,7 @@
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.4</version>
+ <artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.onap.so</groupId>
@@ -263,8 +259,7 @@
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
- <artifactId>javax.annotation-api</artifactId>
- <version>1.3</version>
+ <artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.onap.msb.java-sdk</groupId>
@@ -315,7 +310,7 @@
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
- <version>2.3.0</version>
+ <version>${camunda.springboot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
index 26f12831bd..409b8dfd1c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
@@ -18,17 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.scripts;
+package org.onap.so.bpmn.infrastructure.scripts
-import static org.apache.commons.lang3.StringUtils.*;
-
-import org.apache.commons.lang3.*
-import org.camunda.bpm.engine.delegate.BpmnError
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+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.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
import org.onap.so.rest.APIResponse
@@ -232,53 +232,17 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
String globalSubscriberId = execution.getVariable("globalSubscriberId")
String serviceType = execution.getVariable("serviceType")
String serviceId = execution.getVariable("serviceInstanceId")
- String addRelationPayload = """<relationship xmlns="http://org.openecomp.aai.inventory/v11">
- <related-to>service-instance</related-to>
- <related-link>/aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId}</related-link>
- <relationship-data>
- <relationship-key>customer.global-customer-id</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(globalSubscriberId)}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-subscription.service-type</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(serviceType)}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-instance.service-instance-id</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(nsInstanceId)}</relationship-value>
- </relationship-data>
- </relationship>"""
- String endpoint = execution.getVariable("URN_aai_endpoint")
- msoLogger.info("Add Relationship req:\n" + addRelationPayload)
- String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship"
- APIResponse aaiRsp = executeAAIPutCall(execution, url, addRelationPayload)
- msoLogger.info("aai response status code:" + aaiRsp.getStatusCode())
- msoLogger.info("aai response content:" + aaiRsp.getResponseBodyAsString())
- msoLogger.info(" *****Exit addNSRelationship *****")
- }
-
- public APIResponse executeAAIPutCall(DelegateExecution execution, String url, String payload){
- msoLogger.trace("Started Execute AAI Put Process ")
- APIResponse apiResponse = null
+
+ AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,nsInstanceId)
+ AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,serviceId)
+
try{
- String uuid = utils.getRequestID()
- msoLogger.info("Generated uuid is: " + uuid)
- msoLogger.info("URL to be used is: " + url)
- String userName = execution.getVariable("URN_aai_auth")
- String password = execution.getVariable("URN_mso_msoKey")
- String basicAuthCred = utils.getBasicAuth(userName,password)
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPut(payload)
- msoLogger.trace("Completed Execute AAI Put Process ")
+ getAAIClient().connect(nsUri,relatedServiceUri)
+ msoLogger.info("NS relationship to Service added successfully")
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Put Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while Creating NS relationship.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getMessage(),e);
throw new BpmnError("MSOWorkflowException")
}
- return apiResponse
}
/**
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy
index 965d178cce..05c8246311 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy
@@ -20,21 +20,26 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.apache.commons.lang3.*
+import org.apache.commons.collections.CollectionUtils
import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.onap.so.bpmn.common.scripts.AaiUtil;
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.SearchResults
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor;
import org.onap.so.bpmn.common.scripts.ExceptionUtil;
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
+
class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVfModuleVolumeInfraV1.class);
@@ -314,34 +319,21 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor {
def request = execution.getVariable(prefix+"Request")
def serviceInstanceId = utils.getNodeText(request, "service-instance-id")
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getSearchNodesQueryEndpoint(execution)
-
- def String queryAAIRequest = aaiEndpoint + "?search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId
- msoLogger.debug("AAI query service instance request: " + queryAAIRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query service instance return code: " + returnCode)
- msoLogger.debug("AAI query service instance response: " + aaiResponseAsString)
-
ExceptionUtil exceptionUtil = new ExceptionUtil()
+ try {
- if (returnCode=='200') {
- msoLogger.debug('Service instance ' + serviceInstanceId + ' found in AAI.')
- } else {
- if (returnCode=='404') {
+ AAIResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectType.SERVICE_INSTANCE,serviceInstanceId)
+ if(getAAIClient().exists(uri)){
+ msoLogger.debug('Service instance ' + serviceInstanceId + ' found in AAI.')
+ }else{
def message = 'Service instance ' + serviceInstanceId + ' was not found in AAI. Return code: 404.'
msoLogger.debug(message)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message)
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
}
+ }catch(BpmnError bpmnError){
+ throw bpmnError
+ }catch(Exception ex){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, ex.getMessage())
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
index 83f2fe04db..7cbbac5fbf 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
@@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.scripts;
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.VolumeGroup
import org.onap.so.bpmn.common.scripts.AaiUtil;
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor;
import org.onap.so.bpmn.common.scripts.ExceptionUtil;
@@ -30,9 +31,11 @@ import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.VidUtils;
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
+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.client.aai.AAIObjectType
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
@@ -42,6 +45,8 @@ import org.springframework.web.util.UriUtils
import groovy.json.JsonSlurper
+import javax.ws.rs.NotFoundException
+
/**
* This groovy class supports the <class>DeleteVfModuleVolume.bpmn</class> process.
*/
@@ -233,52 +238,39 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor {
}
String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion')
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId)
- def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query volume group by id return code: " + returnCode)
- msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString)
-
- execution.setVariable("DELVfModVol_queryAAIVolGrpResponse", aaiResponseAsString)
-
- if (returnCode=='200' || returnCode == '204') {
-
- def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id')
- execution.setVariable('DELVfModVol_volumeGroupHeatStackId', heatStackId)
-
- if(hasVfModuleRelationship(aaiResponseAsString)){
- msoLogger.debug('Volume Group ' + volumeGroupId + ' currently in use')
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.")
- }
-
- def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString)
- if (volumeGroupTenantId == null) {
- msoLogger.debug("Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
- }
-
- execution.setVariable('DELVfModVol_volumeGroupTenantId', volumeGroupTenantId)
- msoLogger.debug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId )
- }
- else {
- if (returnCode=='404') {
- msoLogger.debug("Volume Group ${volumeGroupId} not found in AAI")
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} not found in AAI. Response code: 404")
- }
- else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId)
+ AAIResultWrapper volumeGroupWrapper = getAAIClient().get(uri)
+
+ if (!volumeGroupWrapper.isEmpty()) {
+ Optional<VolumeGroup> volumeGroupOp = volumeGroupWrapper.asBean(VolumeGroup.class)
+ execution.setVariable("DELVfModVol_queryAAIVolGrpResponse", volumeGroupOp.get())
+ def heatStackId = volumeGroupOp.get().getHeatStackId() ?: ""
+ execution.setVariable('DELVfModVol_volumeGroupHeatStackId', heatStackId)
+
+ if ( volumeGroupWrapper.getRelationships().isPresent() && !volumeGroupWrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.VF_MODULE).isEmpty()) {
+ msoLogger.debug('Volume Group ' + volumeGroupId + ' currently in use')
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.")
+ }
+
+ def volumeGroupTenantId = getTenantIdFromVolumeGroup(volumeGroupWrapper)
+ if (volumeGroupTenantId == null) {
+ msoLogger.debug("Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
+ }
+
+ execution.setVariable('DELVfModVol_volumeGroupTenantId', volumeGroupTenantId)
+ msoLogger.debug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId)
+ } else {
+ msoLogger.debug("Volume Group ${volumeGroupId} not found in AAI")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} not found in AAI. Response code: 404")
+ }
+ }catch (BpmnError e){
+ throw e
+ }catch (Exception e){
+ WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(e.getMessage(), execution)
+ throw new BpmnError("MSOWorkflowException")
+ }
}
/**
@@ -288,27 +280,13 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor {
* @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.
*/
- private String getTenantIdFromVolumeGroup(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('tenant'))) {
- def NodeList relationshipDataList = utils.getIdenticalChildren(relationship, 'relationship-data')
- for (Node relationshipData in relationshipDataList) {
- def Node relationshipKey = utils.getChildNode(relationshipData, 'relationship-key')
- if ((relationshipKey != null) && (relationshipKey.text().equals('tenant.tenant-id'))) {
- def Node relationshipValue = utils.getChildNode(relationshipData, 'relationship-value')
- if (relationshipValue != null) {
- return relationshipValue.text()
- }
- }
- }
- }
- }
- }
+ private String getTenantIdFromVolumeGroup(AAIResultWrapper wrapper) {
+ if(wrapper.getRelationships().isPresent()) {
+ List<AAIResourceUri> tenantURIList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.TENANT)
+ if(!tenantURIList.isEmpty()){
+ return tenantURIList.get(0).getURIKeys().get("tenant-id")
+ }
+ }
return null
}
@@ -330,24 +308,6 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor {
return false
}
- private boolean hasVfModuleRelationship(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('vf-module'))) {
- def Node relatedLink = utils.getChildNode(relationship, 'related-link')
- if (relatedLink !=null && relatedLink.text() != null){
- return true
- }
- }
- }
- }
- return false
- }
-
public void prepareVnfAdapterDeleteRequest(DelegateExecution execution, isDebugLogEnabled) {
def cloudRegion = execution.getVariable('DELVfModVol_cloudRegion')
def tenantId = execution.getVariable('DELVfModVol_tenantId')
@@ -387,38 +347,21 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor {
public void deleteVolGrpId(DelegateExecution execution, isDebugEnabled) {
// get variables
- String queryAAIVolGrpIdResponse = execution.getVariable("DELVfModVol_queryAAIVolGrpResponse")
- String groupId = utils.getNodeText(queryAAIVolGrpIdResponse, "volume-group-id")
- String resourceVersion = utils.getNodeText(queryAAIVolGrpIdResponse, "resource-version")
- String messageId = execution.getVariable('DELVfModVol_messageId')
+ VolumeGroup volumeGroup = execution.getVariable("DELVfModVol_queryAAIVolGrpResponse")
+ String groupId = volumeGroup.getVolumeGroupId()
String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion')
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, groupId).resourceVersion(resourceVersion)
- def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug("Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest)
-
- APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI delete volume group return code: " + returnCode)
- msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- if (returnCode=='200' || (returnCode == '204')) {
- msoLogger.debug("Volume group $groupId deleted.")
- } else {
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $groupId not found for delete in AAI Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, groupId)
+ getAAIClient().delete(uri)
+ msoLogger.debug("Volume group $groupId deleted.")
+ }catch(NotFoundException e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $groupId not found for delete in AAI Response code: 404")
+ }catch(Exception e1){
+ WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(e1.getMessage(), execution)
+ throw new BpmnError("MSOWorkflowException")
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
index ebd622ca51..d43a19624e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
@@ -28,7 +28,6 @@ import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.CatalogDbUtils;
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -38,6 +37,7 @@ import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.domain.Resource
import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.AAIResultWrapper
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
index 6d41923bdf..08dc38cd2a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
@@ -291,70 +291,19 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor {
public void getAAICustomerById (DelegateExecution execution) {
// https://{aaiEP}/aai/v8/business/customers/customer/{globalCustomerId}
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- String msg = ""
try {
String globalCustomerId = execution.getVariable("globalSubscriberId") //VID to AAI name map
msoLogger.debug(" ***** getAAICustomerById ***** globalCustomerId:" + globalCustomerId)
- AaiUtil aaiUriUtil = new AaiUtil(this)
-
AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalCustomerId)
- String getAAICustomerUrl = aaiUriUtil.createAaiUri(uri)
-
- if (isBlank(getAAICustomerUrl))
- {
- msg = "AAI URL is invalid. Endpoint:" + getAAICustomerUrl
- msoLogger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ if(!getAAIClient().exists(uri)){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "GlobalCustomerId:" + globalCustomerId + " not found (404) in AAI")
}
-
- msoLogger.debug("getAAICustomerById Url:" + getAAICustomerUrl)
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getAAICustomerUrl)
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msg = "getAAICustomerById ResponseCode:" + returnCode + " ResponseString:" + aaiResponseAsString
- msoLogger.debug(msg)
-
- if (returnCode=='200') {
- // Customer found by ID. FLow to proceed.
- msoLogger.debug(msg)
-
- //TODO Deferred
- //we might verify that service-subscription with matching name exists
- //and throw error if not. If not checked, we will get exception in subsequent step on Create call
- //in 1610 we assume both customer & service subscription were pre-created
-
- } else {
- if (returnCode=='404') {
- msg = "GlobalCustomerId:" + globalCustomerId + " not found (404) in AAI"
- msoLogger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, aaiResponseAsString, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
- WorkflowException workflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", workflowException)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- msg = "Error in getAAICustomerById ResponseCode:" + returnCode
- msoLogger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
- }
- }
- }
-
} catch (BpmnError e) {
throw e;
} catch (Exception ex) {
- msg = "Exception in getAAICustomerById. " + ex.getMessage()
- msoLogger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in getAAICustomerById. " + ex.getMessage())
}
msoLogger.trace("Exit getAAICustomerById")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
index 10f6acd403..2663ba7aa7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
@@ -18,18 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.scripts;
+package org.onap.so.bpmn.infrastructure.scripts
-import static org.apache.commons.lang3.StringUtils.*;
-
-import org.apache.commons.lang3.*
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
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.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
import org.onap.so.rest.APIResponse
@@ -209,53 +208,17 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
String globalSubscriberId = execution.getVariable("globalSubscriberId")
String serviceType = execution.getVariable("serviceType")
String serviceId = execution.getVariable("serviceId")
- String addRelationPayload = """<relationship xmlns="http://org.openecomp.aai.inventory/v11">
- <related-to>service-instance</related-to>
- <related-link>/aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId}</related-link>
- <relationship-data>
- <relationship-key>customer.global-customer-id</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(globalSubscriberId)}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-subscription.service-type</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(serviceType)}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-instance.service-instance-id</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(nsInstanceId)}</relationship-value>
- </relationship-data>
- </relationship>"""
- String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
- msoLogger.debug("Add Relationship req:\n" + addRelationPayload)
- String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship"
- APIResponse aaiRsp = executeAAIPutCall(execution, url, addRelationPayload)
- msoLogger.debug("aai response status code:" + aaiRsp.getStatusCode())
- msoLogger.debug("aai response content:" + aaiRsp.getResponseBodyAsString())
- msoLogger.trace("Exit addNSRelationship")
- }
-
- public APIResponse executeAAIPutCall(DelegateExecution execution, String url, String payload){
- msoLogger.trace("Started Execute AAI Put Process")
- APIResponse apiResponse = null
+
+ AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,nsInstanceId)
+ AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,globalSubscriberId,serviceType,serviceId)
+
try{
- String uuid = utils.getRequestID()
- msoLogger.debug("Generated uuid is: " + uuid)
- msoLogger.debug("URL to be used is: " + url)
- String userName = UrnPropertiesReader.getVariable("aai.auth", execution)
- String password = UrnPropertiesReader.getVariable("mso.msoKey", execution)
- String basicAuthCred = utils.getBasicAuth(userName,password)
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPut(payload)
- msoLogger.trace("Completed Execute AAI Put Process")
+ getAAIClient().connect(nsUri,relatedServiceUri)
+ msoLogger.info("NS relationship to Service added successfully")
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Put Call", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Put Call", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
throw new BpmnError("MSOWorkflowException")
}
- return apiResponse
}
/**
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
index 58b90a1bf2..6917a97887 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
@@ -28,6 +28,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.json.JSONArray
import org.json.JSONObject
import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.NetworkPolicy
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.CatalogDbUtils
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -38,11 +39,9 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
-
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.DecomposeJsonUtil
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient
@@ -50,13 +49,13 @@ import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
import org.onap.so.rest.APIResponse
import org.onap.so.rest.RESTClient
import org.onap.so.rest.RESTConfig
-import org.springframework.web.util.UriUtils
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.NamedNodeMap
@@ -1861,50 +1860,17 @@ public class DoCreateVfModule extends VfModuleBase {
def networkPolicyId = UUID.randomUUID().toString()
msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId)
- String aaiNamespace = aaiUriUtil.getNamespace()
- msoLogger.debug('AAI namespace is: ' + aaiNamespace)
- String payload = """<network-policy xmlns="${aaiNamespace}">
- <network-policy-id>${MsoUtils.xmlEscape(networkPolicyId)}</network-policy-id>
- <network-policy-fqdn>${MsoUtils.xmlEscape(fqdn)}</network-policy-fqdn>
- <heat-stack-id>${MsoUtils.xmlEscape(execution.getVariable("DCVFM_heatStackId"))}</heat-stack-id>
- </network-policy>""" as String
-
- execution.setVariable("DCVFM_addNetworkPolicyAAIRequestBody", payload)
-
- AAIResourceUri addUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId)
- String addNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(addUri)
-
- msoLogger.debug("AAI request endpoint: " + addNetworkPolicyAAIRequest)
-
- def aaiRequestIdPut = UUID.randomUUID().toString()
- RESTConfig configPut = new RESTConfig(addNetworkPolicyAAIRequest);
- RESTClient clientPut = new RESTClient(configPut).addHeader("X-TransactionId", aaiRequestIdPut)
- .addHeader("X-FromAppId", "MSO")
- .addHeader("Content-Type", "application/xml")
- .addHeader("Accept","application/xml");
- msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload)
- APIResponse responsePut = clientPut.httpPut(payload)
- int returnCodePut = responsePut.getStatusCode()
- execution.setVariable("DCVFM_aaiAddNetworkPolicyReturnCode", returnCodePut)
- msoLogger.debug(" ***** AAI add network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodePut)
-
- String aaiResponseAsStringPut = responsePut.getResponseBodyAsString()
- if (isOneOf(returnCodePut, 200, 201)) {
- msoLogger.debug("The return code from adding network policy is: " + returnCodePut)
- // This network policy was created in AAI successfully
- execution.setVariable("DCVFM_addNetworkPolicyAAIResponse", aaiResponseAsStringPut)
- msoLogger.debug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut)
- rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true")
- rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn)
- execution.setVariable("rollbackData", rollbackData)
-
- } else {
- // aai all errors
- String putErrorMessage = "Unable to add network-policy to AAI createNetworkPoliciesInAAI - " + returnCodePut
- msoLogger.debug(putErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, putErrorMessage)
- }
-
+ NetworkPolicy policy = new NetworkPolicy()
+ policy.setNetworkPolicyId(networkPolicyId)
+ policy.setNetworkPolicyFqdn(fqdn)
+ policy.setHeatStackId(execution.getVariable("DCVFM_heatStackId"))
+
+ AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId)
+ resourceClient.create(netUri, policy)
+
+ rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true")
+ rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn)
+ execution.setVariable("rollbackData", rollbackData)
}
} // end loop
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
index a553127c5c..38858d20f7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
@@ -21,6 +21,8 @@
package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.NetworkPolicies
+import org.onap.aai.domain.yang.NetworkPolicy
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -37,6 +39,7 @@ import org.onap.so.logger.MsoLogger
import org.onap.so.rest.APIResponse
import org.springframework.web.util.UriUtils
+import javax.ws.rs.NotFoundException
public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
@@ -490,81 +493,48 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
int counting = i+1
String fqdn = fqdnList[i]
- // Query AAI for this network policy FQDN
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
- uri.queryParam("network-policy-fqdn", fqdn)
- String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest)
-
- def aaiRequestId = UUID.randomUUID().toString()
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest)
- int returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", returnCode)
- msoLogger.debug("AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- if (isOneOf(returnCode, 200, 201)) {
- msoLogger.debug("The return code is: " + returnCode)
- // This network policy FQDN exists in AAI - need to delete it now
- execution.setVariable(Prefix + "queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString)
- msoLogger.debug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString)
- // Retrieve the network policy id for this FQDN
- def networkPolicyId = utils.getNodeText(aaiResponseAsString, "network-policy-id")
- msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId)
-
- // Retrieve the resource version for this network policy
- def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version")
- msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion)
-
- AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId)
- delUri.resourceVersion(resourceVersion)
- String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri)
-
- msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest)
-
- def aaiRequestIdDel = UUID.randomUUID().toString()
- msoLogger.debug("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest)
-
- APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest)
-
- int returnCodeDel = responseDel.getStatusCode()
- execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", returnCodeDel)
- msoLogger.debug("AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel)
-
- if (isOneOf(returnCodeDel, 200, 201, 204)) {
- msoLogger.debug("The return code from deleting network policy is: " + returnCodeDel)
- // This network policy was deleted from AAI successfully
- msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ")
-
- } else {
- // aai all errors
- String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel
- msoLogger.debug(delErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
- }
- } else if (returnCode == 404) {
- // This network policy FQDN is not in AAI. No need to delete.
- msoLogger.debug("The return code is: " + returnCode)
- msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
-
-
-
+ try {
+ // Query AAI for this network policy FQDN
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ uri.queryParam("network-policy-fqdn", fqdn)
+ Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri)
+
+ if (networkPolicies.isPresent() && !networkPolicies.get().getNetworkPolicy().isEmpty()) {
+ execution.setVariable(Prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", 200)
+ NetworkPolicy networkPolicy = networkPolicies.get().getNetworkPolicy().get(0)
+
+ try{
+ AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId())
+ getAAIClient().delete(delUri)
+ execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", 200)
+ msoLogger.debug("AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + 200)
+ msoLogger.debug("The return code from deleting network policy is: " + 200)
+ // This network policy was deleted from AAI successfully
+ msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ")
+ }catch(NotFoundException ne){
+ // This network policy FQDN is not in AAI. No need to delete.
+ execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", 404)
+ msoLogger.debug("The return code is: " + 404)
+ msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
+ }catch(Exception e){
+ // aai all errors
+ String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + e.getMessage()
+ msoLogger.debug(delErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
+ }
+ } else {
+ // This network policy FQDN is not in AAI. No need to delete.
+ msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
+ }
+ }catch (BpmnError e){
+ throw e
+ }
+ catch (Exception e) {
+ // aai all errors
+ String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + e.getMessage()
+ msoLogger.debug(dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+ }
} // end loop
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
index 8968c751c5..f61d2b98e3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy
@@ -18,36 +18,24 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.scripts;
+package org.onap.so.bpmn.infrastructure.scripts
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.onap.so.bpmn.common.scripts.AaiUtil
+import org.onap.aai.domain.yang.VolumeGroups
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.client.aai.AAIObjectType
-import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.constants.Defaults
-import org.onap.so.rest.APIResponse
-import org.springframework.web.util.UriUtils
import org.onap.so.logger.MsoLogger
-import org.onap.so.logger.MessageEnum
+import javax.ws.rs.NotFoundException
public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleVolumeRollback.class);
@@ -129,95 +117,46 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor
/**
* Query AAI volume group by name
* @param execution
- * @param isDebugEnabled
+ * @param cloudRegion
+ * @return
*/
- public void callRESTQueryAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
+ private String callRESTQueryAAIVolGrpName(DelegateExecution execution, String cloudRegion) {
def volumeGroupName = execution.getVariable('DCVFMODVOLRBK_volumeGroupName')
- def cloudRegion = execution.getVariable('DCVFMODVOLRBK_lcpCloudRegionId')
- // This is for stub testing
def testVolumeGroupName = execution.getVariable('test-volume-group-name')
if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) {
volumeGroupName = testVolumeGroupName
}
- AaiUtil aaiUtil = new AaiUtil(this)
-
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName)
- def queryAAIVolumeNameRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query volume group by name return code: " + returnCode)
- msoLogger.debug("AAI query volume group by name response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString)
- execution.setVariable(prefix+'AaiReturnCode', returnCode)
-
- if (returnCode=='200') {
- // @TODO: verify error code
- // @TODO: create class of literals representing error codes
- execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString)
- msoLogger.debug("Volume Group Name $volumeGroupName exists in AAI.")
- } else {
- if (returnCode=='404') {
- msoLogger.debug("Volume Group Name $volumeGroupName does not exist in AAI.")
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404")
+ try {
+ Optional<VolumeGroups> volumeGroups = getAAIClient().get(VolumeGroups.class, uri)
+ if (volumeGroups.isPresent()) {
+ return volumeGroups.get().getVolumeGroup().get(0).getVolumeGroupId()
} else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404")
}
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, e.getMessage())
}
+ return null
}
public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) {
- callRESTQueryAAIVolGrpName(execution, isDebugEnabled)
-
- def queryAaiVolumeGroupResponse = execution.getVariable(prefix+'queryAAIVolGrpNameResponse')
-
- def volumeGroupId = utils.getNodeText(queryAaiVolumeGroupResponse, "volume-group-id")
- def resourceVersion = utils.getNodeText(queryAaiVolumeGroupResponse, "resource-version")
-
- def cloudRegion = execution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId")
-
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId).resourceVersion(resourceVersion)
- def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest)
+ String cloudRegion = execution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId")
+ String volumeGroupId = callRESTQueryAAIVolGrpName(execution, cloudRegion)
- APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI delete volume group return code: " + returnCode)
- msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- def volumeGroupNameFound = prefix+'volumeGroupNameFound'
- if (returnCode=='200' || returnCode=='204' ) {
- msoLogger.debug("Volume group $volumeGroupId deleted.")
- } else {
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupId not found for delete in AAI Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId)
+ try {
+ getAAIClient().delete(uri)
+ }catch(NotFoundException ignored){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupId not found for delete in AAI Response code: 404")
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500,e.getMessage())
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy
index cf5c214d3f..93379c72be 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy
@@ -20,37 +20,35 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.VolumeGroup
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.common.scripts.NetworkUtils
-import org.onap.so.bpmn.common.scripts.VfModuleBase;
+import org.onap.so.bpmn.common.scripts.VfModuleBase
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.bpmn.core.json.JsonUtils;
-import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
-import org.springframework.web.util.UriUtils
-import org.onap.so.client.aai.AAIResourcesClient
-import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.aai.AAIObjectPlurals
-import org.onap.so.client.aai.entities.AAIResultWrapper
-import org.onap.so.client.aai.entities.Relationships
+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.json.JSONObject
+import org.onap.so.db.catalog.beans.OrchestrationStatus
+import org.onap.so.logger.MsoLogger
+
import javax.ws.rs.NotFoundException
class DoCreateVfModuleVolumeV2 extends VfModuleBase {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleVolumeV2.class);
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleVolumeV2.class)
String prefix='DCVFMODVOLV2_'
JsonUtils jsonUtil = new JsonUtils()
+ private ExceptionUtil exceptionUtil = new ExceptionUtil()
/**
@@ -156,7 +154,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
}
}catch(BpmnError e) {
- throw e;
+ throw e
}catch (Exception ex){
String msg = "Exception in getServiceInstance. " + ex.getMessage()
msoLogger.debug(msg)
@@ -216,43 +214,22 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
def volumeGroupName = execution.getVariable('volumeGroupName')
def cloudRegion = execution.getVariable('lcpCloudRegionId')
- // This is for stub testing
- def testVolumeGroupName = execution.getVariable('test-volume-group-name')
- if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) {
- volumeGroupName = testVolumeGroupName
- }
-
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName)
- def queryAAIVolumeNameRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query volume group by name return code: " + returnCode)
- msoLogger.debug("AAI query volume group by name response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString)
- execution.setVariable(prefix+'AaiReturnCode', returnCode)
-
- if (returnCode=='200') {
- execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString)
- msoLogger.debug("Volume Group Name $volumeGroupName exists in AAI.")
- } else {
- if (returnCode=='404') {
- msoLogger.debug("Volume Group Name $volumeGroupName does not exist in AAI.")
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName)
+ Optional<VolumeGroup> volumeGroup = getAAIClient().get(VolumeGroup.class,uri)
+ if(volumeGroup.isPresent()){
+ execution.setVariable(prefix+'AaiReturnCode', 200)
+ execution.setVariable("queriedVolumeGroupId",volumeGroup.get().getVolumeGroupId())
+ msoLogger.debug("Volume Group Name $volumeGroupName exists in AAI.")
+ }else{
+ execution.setVariable(prefix+'AaiReturnCode', 404)
+ exceptionUtil.buildAndThrowWorkflowException(execution,25000, "Volume Group Name $volumeGroupName does not exist in AAI.")
}
+ }catch(BpmnError error){
+ throw error
+ }catch(Exception e){
+ execution.setVariable(prefix+'AaiReturnCode', 500)
+ exceptionUtil.buildAndThrowWorkflowException(execution,25000, "Exception in get volume group by name: " + e.getMessage())
}
}
@@ -297,7 +274,6 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
def tenantId = execution.getVariable("tenantId")
def cloudRegion = execution.getVariable('lcpCloudRegionId')
def cloudOwner = execution.getVariable('cloudOwner')
- msoLogger.debug("volumeGroupId: " + volumeGroupId)
def testGroupId = execution.getVariable('test-volume-group-id')
if (testGroupId != null && testGroupId.trim() != '') {
@@ -306,62 +282,43 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
}
- msoLogger.debug("volumeGroupId to be used: " + volumeGroupId)
-
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId)
- def createAAIVolumeGrpNameUrlRequest = aaiUtil.createAaiUri(uri)
+ VolumeGroup volumeGroup = new VolumeGroup()
+ volumeGroup.setVolumeGroupId(volumeGroupId)
+ volumeGroup.setVolumeGroupName(volumeName)
+ volumeGroup.setVnfType(vnfType)
+ volumeGroup.setOrchestrationStatus(OrchestrationStatus.PENDING.toString())
+ volumeGroup.setModelCustomizationId(modelCustomizationId)
- String namespace = aaiUtil.getNamespaceFromUri(createAAIVolumeGrpNameUrlRequest)
- msoLogger.debug("AAI namespace is: " + namespace)
-
- msoLogger.debug("Request URL for PUT: " + createAAIVolumeGrpNameUrlRequest)
-
- NetworkUtils networkUtils = new NetworkUtils()
- String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudOwner, cloudRegion, namespace, modelCustomizationId)
- String payloadXml = utils.formatXml(payload)
- msoLogger.debug("Request payload for PUT: " + payloadXml)
-
- APIResponse response = aaiUtil.executeAAIPutCall(execution, createAAIVolumeGrpNameUrlRequest, payloadXml)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI create volume group return code: " + returnCode)
- msoLogger.debug("AAI create volume group response: " + aaiResponseAsString)
-
- execution.setVariable(prefix+"createAAIVolumeGrpNameReturnCode", returnCode)
- execution.setVariable(prefix+"createAAIVolumeGrpNameResponse", aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
+ msoLogger.debug("volumeGroupId to be used: " + volumeGroupId)
- if (returnCode =='201') {
+ AAIResourceUri volumeGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, cloudRegion, volumeGroupId)
+ AAIResourceUri tenantUri = AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegion, tenantId)
+ AAIResourceUri vnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ try {
+ getAAIClient().create(volumeGroupUri, volumeGroup)
+ getAAIClient().connect(volumeGroupUri, vnfUri)
+ getAAIClient().connect(volumeGroupUri, tenantUri)
RollbackData rollbackData = execution.getVariable("rollbackData")
rollbackData.put("DCVFMODULEVOL", "isAAIRollbackNeeded", "true")
- } else {
- execution.setVariable(prefix+"isErrorMessageException", true)
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- msoLogger.debug(" AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException)
- throw new BpmnError("MSOWorkflowException")
- }
+ } catch (NotFoundException ignored) {
+ execution.setVariable(prefix + "isErrorMessageException", true)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404")
+ } catch (Exception ex) {
+ execution.setVariable(prefix + "isErrorMessageException", true)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, ex.getMessage())
}
}
-
/**
* Prepare VNF adapter create request XML
* @param execution
*/
public void prepareVnfAdapterCreateRequest(DelegateExecution execution, isDebugEnabled) {
- def aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse')
- def vnfId = utils.getNodeText(aaiGenericVnfResponse, 'vnf-id')
- def vnfName = utils.getNodeText(aaiGenericVnfResponse, 'vnf-name')
- def vnfType = utils.getNodeText(aaiGenericVnfResponse, "vnf-type")
+ GenericVnf aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse')
+ def vnfId = aaiGenericVnfResponse.getVnfId()
+ def vnfName = aaiGenericVnfResponse.getVnfName()
+ def vnfType = aaiGenericVnfResponse.getVnfType()
def requestId = execution.getVariable('msoRequestId')
def serviceId = execution.getVariable('serviceInstanceId')
@@ -392,7 +349,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
Map<String, String> paramsMap = execution.getVariable("vfModuleInputParams")
for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
String paramsXml
- String paramName = entry.getKey();
+ String paramName = entry.getKey()
String paramValue = entry.getValue()
paramsXml =
""" <entry>
@@ -539,54 +496,30 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
* @param isDebugEnabled
*/
public void callRESTUpdateCreatedVolGrpName(DelegateExecution execution, isDebugEnabled) {
-
- String requeryAAIVolGrpNameResponse = execution.getVariable(prefix+"queryAAIVolGrpNameResponse")
- String volumeGroupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id")
+ String volumeGroupId = execution.getVariable("queriedVolumeGroupId")
String modelCustomizationId = execution.getVariable("modelCustomizationId")
String cloudRegion = execution.getVariable("lcpCloudRegionId")
-
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId)
- def updateAAIVolumeGroupUrlRequest = aaiUtil.createAaiUri(uri)
-
- String namespace = aaiUtil.getNamespaceFromUri(updateAAIVolumeGroupUrlRequest)
-
- msoLogger.debug("updateAAIVolumeGroupUrlRequest - " + updateAAIVolumeGroupUrlRequest)
-
+ String cloudOwner = execution.getVariable('cloudOwner')
String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
def heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId")
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwner, cloudRegion, volumeGroupId)
execution.setVariable(prefix+"heatStackId", heatStackID)
- NetworkUtils networkUtils = new NetworkUtils()
- String payload = networkUtils.updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackID, namespace, modelCustomizationId)
- String payloadXml = utils.formatXml(payload)
-
- msoLogger.debug("Payload to Update Created VolumeGroupName - " + "\n" + payloadXml)
-
- APIResponse response = aaiUtil.executeAAIPutCall(execution, updateAAIVolumeGroupUrlRequest, payloadXml)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI create volume group return code: " + returnCode)
- msoLogger.debug("AAI create volume group response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if (returnCode =='200') {
- execution.setVariable(prefix+"updateCreatedAAIVolumeGrpNameResponse", aaiResponseAsString)
+ VolumeGroup volumeGroup = new VolumeGroup()
+ volumeGroup.setHeatStackId(heatStackID)
+ volumeGroup.setModelCustomizationId(modelCustomizationId)
+ try {
+ getAAIClient().update(uri, volumeGroup)
execution.setVariable(prefix+"isPONR", true)
- } else {
+ }catch(NotFoundException ignored){
execution.setVariable(prefix+"isErrorMessageException", true)
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- msoLogger.debug(" AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException)
- throw new BpmnError("MSOWorkflowException")
- }
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404")
+ }catch(BpmnError error){
+ throw error
+ }catch(Exception e){
+ execution.setVariable(prefix+"isErrorMessageException", true)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Adapter Query Failed. "+ e.getMessage())
}
}
@@ -599,35 +532,16 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase {
public void callRESTQueryAAIGenericVnf(DelegateExecution execution, isDebugEnabled) {
def vnfId = execution.getVariable('vnfId')
-
- AaiUtil aaiUtil = new AaiUtil(this)
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
- String queryAAIRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug("AAI query generic vnf endpoint: " + queryAAIRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query generic vnf return code: " + returnCode)
- msoLogger.debug("AAI query generic vnf response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if (returnCode=='200') {
- msoLogger.debug('Generic vnf ' + vnfId + ' found in AAI.')
- execution.setVariable(prefix+'AAIQueryGenericVfnResponse', aaiResponseAsString)
- } else {
- if (returnCode=='404') {
- def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.'
- msoLogger.debug(message)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message)
+ try {
+ Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class, uri)
+ if (genericVnf.isPresent()) {
+ execution.setVariable(prefix + 'AAIQueryGenericVfnResponse', genericVnf.get())
} else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.')
}
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Exception in get generic VNF: " + e.getMessage())
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
index 21bf0f2c5c..7e9b4f47ab 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
@@ -20,18 +20,20 @@
*/
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.aai.domain.yang.AllottedResource
+
+import javax.ws.rs.core.UriBuilder
+
import static org.apache.commons.lang3.StringUtils.*;
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.json.JSONArray;
-import org.json.JSONObject;
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
@@ -40,7 +42,6 @@ import org.springframework.web.util.UriUtils;
import org.onap.so.client.aai.AAIResourcesClient
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.json.JSONObject
@@ -371,19 +372,15 @@ public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProce
if (StringUtils.equalsIgnoreCase(relatedTo, "allotted-resource")) {
msoLogger.info("allotted-resource exists ")
- String aaiArRsp = getAaiAr(execution, relatedLink)
+ Optional<AllottedResource> aaiArRsp = getAaiAr(execution, relatedLink)
msoLogger.info("aaiArRsp: " + aaiArRsp)
- if (! isBlank(aaiArRsp)) {
- def type = utils.getNodeText(aaiArRsp, "type")
- def id = utils.getNodeText(aaiArRsp, "id")
- def role = utils.getNodeText(aaiArRsp, "role")
- def resourceVersion = utils.getNodeText(aaiArRsp, "resource-version")
+ if (aaiArRsp.isPresent()) {
JSONObject jObject = new JSONObject()
- jObject.put("resourceType", type)
- jObject.put("resourceInstanceId", id)
- jObject.put("resourceRole", role)
- jObject.put("resourceVersion", resourceVersion)
+ jObject.put("resourceType", aaiArRsp.get().getType())
+ jObject.put("resourceInstanceId", aaiArRsp.get().getId())
+ jObject.put("resourceRole", aaiArRsp.get().getRole())
+ jObject.put("resourceVersion", aaiArRsp.get().getResourceVersion())
allResources.put(jObject)
msoLogger.info("allResources: " + allResources)
@@ -577,27 +574,11 @@ public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProce
msoLogger.info("Exited " + method)
}
- private String getAaiAr(DelegateExecution execution, String relink) {
+ private Optional<AllottedResource> getAaiAr(DelegateExecution execution, String relink) {
def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
msoLogger.info("Entered " + method)
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink
-
- msoLogger.debug("get AR info " + aaiEndpoint)
- APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint)
-
- int responseCode = response.getStatusCode()
- msoLogger.debug("get AR info responseCode:" + responseCode)
-
- String aaiResponse = response.getResponseBodyAsString()
- msoLogger.debug("get AR info " + aaiResponse)
-
- if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) {
- return null
- }
-
- msoLogger.info("Exited " + method)
- return aaiResponse
+ AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(relink).build())
+ return getAAIClient().get(AllottedResource.class,uri)
}
/**
* prepare Decompose next resource to create request
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
index 3812c081f5..1333c1f4c4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.scripts;
+package org.onap.so.bpmn.infrastructure.scripts
-import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.L3Network
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -34,18 +34,20 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
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.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse;
+import org.onap.so.rest.APIResponse
import org.onap.so.rest.RESTClient
import org.onap.so.rest.RESTConfig
import org.springframework.web.util.UriUtils
-import groovy.json.*
+import groovy.json.JsonOutput
public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteNetworkInstance.class);
@@ -71,7 +73,6 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
execution.setVariable(Prefix + "networkInputs", "")
execution.setVariable(Prefix + "tenantId", "")
- execution.setVariable(Prefix + "queryAAIRequest","")
execution.setVariable(Prefix + "queryAAIResponse", "")
execution.setVariable(Prefix + "aaiReturnCode", "")
execution.setVariable(Prefix + "isAAIGood", false)
@@ -246,85 +247,52 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
String networkInputs = execution.getVariable(Prefix + "networkInputs")
String networkId = utils.getNodeText(networkInputs, "network-id")
networkId = UriUtils.encode(networkId,"UTF-8")
-
- // Prepare AA&I url
- AaiUtil aaiUriUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
- uri.depth(Depth.ALL)
-
- String queryAAIRequest = aaiUriUtil.createAaiUri(uri)
- msoLogger.debug(queryAAIRequest)
- execution.setVariable(Prefix + "queryAAIRequest", queryAAIRequest)
- msoLogger.debug(Prefix + "AAIRequest - " + "\n" + queryAAIRequest)
-
- RESTConfig config = new RESTConfig(queryAAIRequest);
-
ExceptionUtil exceptionUtil = new ExceptionUtil()
Boolean isVfRelationshipExist = false
try {
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiReturnCode", returnCode)
-
- msoLogger.debug(" ***** AAI Response Code : " + returnCode)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
- execution.setVariable(Prefix + "queryAAIResponse", aaiResponseAsString)
-
- if (returnCode=='200' || returnCode=='204') {
- msoLogger.debug(aaiResponseAsString)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL)
+ Optional<L3Network> l3Network = getAAIClient().get(L3Network.class,uri);
+ AAIResultWrapper wrapper = getAAIClient().get(uri);
+ Optional<Relationships> relationships = wrapper.getRelationships()
+
+ if (l3Network.isPresent()) {
+ execution.setVariable(Prefix + "aaiReturnCode", 200)
+ execution.setVariable(Prefix + "queryAAIResponse", l3Network.get())
execution.setVariable(Prefix + "isAAIGood", true)
- msoLogger.debug(" AAI Query Success REST Response - " + "\n" + aaiResponseAsString)
- // verify if vf or vnf relationship exist
- if (utils.nodeExists(aaiResponseAsString, "relationship")) {
- NetworkUtils networkUtils = new NetworkUtils()
- isVfRelationshipExist = networkUtils.isVfRelationshipExist(aaiResponseAsString)
- execution.setVariable(Prefix + "isVfRelationshipExist", isVfRelationshipExist)
- if (isVfRelationshipExist == true) {
+ if (relationships.isPresent()){
+ if(relationships.get().getRelatedAAIUris(AAIObjectType.VF_MODULE).isEmpty()){
+ execution.setVariable(Prefix + "isVfRelationshipExist", true)
+ isVfRelationshipExist = true
String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId
exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage)
-
- } else {
- // verify if lcpCloudRegion was sent as input, if not get value from AAI Response
- if (execution.getVariable(Prefix + "lcpCloudRegion") == null ) {
- String lcpCloudRegion = networkUtils.getCloudRegion(aaiResponseAsString)
- execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion)
- msoLogger.debug(" Get AAI getCloudRegion() : " + lcpCloudRegion)
+ }else{
+ List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)
+ for(AAIResourceUri tenantURI: tenantURIList){
+ if(execution.getVariable(Prefix + "tenantId") == null) {
+ String tenantId = tenantURI.getURIKeys().get("tenant-id")
+ execution.setVariable(Prefix + "tenantId", tenantId)
+ msoLogger.debug(" Get AAI getTenantId() : " + tenantId)
+ }
}
- if (execution.getVariable(Prefix + "tenantId") == null ) {
- String tenantId = networkUtils.getTenantId(aaiResponseAsString)
- execution.setVariable(Prefix + "tenantId", tenantId)
- msoLogger.debug(" Get AAI getTenantId() : " + tenantId)
+ List<AAIResourceUri> cloudRegionURIList = relationships.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION)
+ for(AAIResourceUri tenantURI: cloudRegionURIList){
+ if(execution.getVariable(Prefix + "lcpCloudRegion") == null) {
+ String lcpCloudRegion = tenantURI.getURIKeys().get("cloud-region-id")
+ execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion)
+ msoLogger.debug(" Get AAI getCloudRegion() : " + lcpCloudRegion)
+ }
}
-
}
}
msoLogger.debug(Prefix + "isVfRelationshipExist - " + isVfRelationshipExist)
-
} else {
+ // not found // empty aai response
+ execution.setVariable(Prefix + "aaiReturnCode", 404)
execution.setVariable(Prefix + "isAAIGood", false)
- if (returnCode=='404' || aaiResponseAsString == "" || aaiResponseAsString == null) {
- // not found // empty aai response
- execution.setVariable(Prefix + "isSilentSuccess", true)
- msoLogger.debug(" AAI Query is Silent Success")
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Error Response from callRESTQueryAAI() - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
+ execution.setVariable(Prefix + "isSilentSuccess", true)
+ msoLogger.debug(" AAI Query is Silent Success")
}
-
msoLogger.debug(" AAI Query call, isAAIGood? : " + execution.getVariable(Prefix + "isAAIGood"))
-
} catch (Exception ex) {
// caught exception
String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, callRESTQueryAAI() - " + ex.getMessage()
@@ -392,13 +360,12 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
String cloudSiteId = execution.getVariable(Prefix + "cloudRegionPo")
String tenantId = execution.getVariable(Prefix + "tenantId")
- String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
- String networkType = utils.getNodeText(queryAAIResponse, "network-type")
- String networkId = utils.getNodeText(queryAAIResponse, "network-id")
- String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled")
+ L3Network l3Network = execution.getVariable(Prefix + "queryAAIResponse")
+ String networkType = l3Network.getNetworkType()
+ String networkId = l3Network.getNetworkId()
String networkStackId = ""
- networkStackId = utils.getNodeText(queryAAIResponse, "heat-stack-id")
+ networkStackId = l3Network.getHeatStackId()
if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) {
networkStackId = "force_delete"
}
@@ -531,8 +498,8 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
}
execution.setVariable(Prefix + "requestId", requestId)
msoLogger.debug(Prefix + "requestId " + requestId)
- String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
-
+ L3Network queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
+
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
// 1. prepare delete topology via SDNC Adapter SUBFLOW call
@@ -1005,9 +972,9 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
requestId = execution.getVariable("mso-request-id")
}
execution.setVariable(Prefix + "requestId", requestId)
-
- String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
-
+
+ L3Network queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
+
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
// 1. prepare delete topology via SDNC Adapter SUBFLOW call
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
index 0069bf4f0a..da2d14f060 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
@@ -18,25 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.scripts;
+package org.onap.so.bpmn.infrastructure.scripts
-import static org.apache.commons.lang3.StringUtils.*
-
-import org.apache.commons.lang3.*
-import org.camunda.bpm.engine.delegate.BpmnError
+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.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTClient
import org.onap.so.rest.RESTConfig
-import groovy.json.*
-
/**
* This groovy class supports the <class>DoDeleteVFCNetworkServiceInstance.bpmn</class> process.
* flow for E2E ServiceInstance Delete
@@ -110,55 +107,14 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
String globalSubscriberId = execution.getVariable("globalSubscriberId")
String serviceType = execution.getVariable("serviceType")
String serviceId = execution.getVariable("serviceId")
- String deleteRelationPayload = """<relationship xmlns="http://org.openecomp.aai.inventory/v11">
- <related-to>service-instance</related-to>
- <related-link>/aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId}</related-link>
- <relationship-data>
- <relationship-key>customer.global-customer-id</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(globalSubscriberId)}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-subscription.service-type</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(serviceType)}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-instance.service-instance-id</relationship-key>
- <relationship-value>${MsoUtils.xmlEscape(nsInstanceId)}</relationship-value>
- </relationship-data>
- </relationship>"""
- String endpoint = execution.getVariable("URN_aai_endpoint")
- utils.log("INFO","Delete Relationship req:\n" + deleteRelationPayload, isDebugEnabled)
- String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship"
-
- APIResponse aaiRsp = executeAAIDeleteCall(execution, url, deleteRelationPayload)
- utils.log("INFO","aai response status code:" + aaiRsp.getStatusCode(), isDebugEnabled)
- utils.log("INFO","aai response content:" + aaiRsp.getResponseBodyAsString(), isDebugEnabled)
- utils.log("INFO"," *****Exit deleteNSRelationship *****", isDebugEnabled)
- }
-
- public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url, String payload){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)
- APIResponse apiResponse = null
- try{
- String uuid = utils.getRequestID()
- utils.log("INFO","Generated uuid is: " + uuid, isDebugEnabled)
- utils.log("INFO","URL to be used is: " + url, isDebugEnabled)
- String userName = execution.getVariable("URN_aai_auth")
- String password = execution.getVariable("URN_mso_msoKey")
- String basicAuthCred = utils.getBasicAuth(userName,password)
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpDelete(payload)
- utils.log("INFO","======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceId)
+ AAIResourceUri nsServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nsInstanceId)
+ try {
+ getAAIClient().disconnect(serviceInstanceUri, nsServiceInstanceUri)
}catch(Exception e){
- utils.log("ERROR","Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
+ exceptionUtil.buildAndThrowWorkflowException(execution,25000,"Exception occured while NS disconnect call: " + e.getMessage())
}
- return apiResponse
+ utils.log("INFO"," *****Exit deleteNSRelationship *****", isDebugEnabled)
}
/**
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
index 85e67c51a7..d6ca08d816 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
@@ -20,6 +20,9 @@
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.aai.domain.yang.NetworkPolicies
+import org.onap.aai.domain.yang.NetworkPolicy
+
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
@@ -474,99 +477,50 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
execution.setVariable("DoDVfMod_networkPolicyFqdnCount", fqdnCount)
msoLogger.debug("DoDVfMod_networkPolicyFqdnCount - " + fqdnCount)
- AaiUtil aaiUriUtil = new AaiUtil(this)
-
if (fqdnCount > 0) {
// AII loop call over contrail network policy fqdn list
for (i in 0..fqdnCount-1) {
-
- int counting = i+1
String fqdn = fqdnList[i]
-
// Query AAI for this network policy FQDN
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", fqdn)
- String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri)
- msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest)
-
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest)
- int returnCode = response.getStatusCode()
- execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode)
- msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- if (isOneOf(returnCode, 200, 201)) {
- msoLogger.debug("The return code is: " + returnCode)
- // This network policy FQDN exists in AAI - need to delete it now
- msoLogger.debug(aaiResponseAsString)
- execution.setVariable("DoDVfMod_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString)
- msoLogger.debug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString)
- // Retrieve the network policy id for this FQDN
- def networkPolicyId = utils.getNodeText(aaiResponseAsString, "network-policy-id")
- msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId)
-
- // Retrieve the resource version for this network policy
- def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version")
- msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion)
-
- AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId)
- delUri.resourceVersion(resourceVersion)
- String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri)
-
- msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest)
-
- msoLogger.debug("invoking DELETE call to AAI")
- msoLogger.debug("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest)
- APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest)
- int returnCodeDel = responseDel.getStatusCode()
- execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", returnCodeDel)
- msoLogger.debug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel)
-
- if (isOneOf(returnCodeDel, 200, 201, 204)) {
- msoLogger.debug("The return code from deleting network policy is: " + returnCodeDel)
- // This network policy was deleted from AAI successfully
- msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ")
-
+ try {
+ Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri)
+ if (networkPolicies.isPresent() && !networkPolicies.get().getNetworkPolicy().isEmpty()) {
+ // This network policy FQDN exists in AAI - need to delete it now
+ NetworkPolicy networkPolicy = networkPolicies.get().getNetworkPolicy().get(0)
+ execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200)
+ // Retrieve the network policy id for this FQDN
+ def networkPolicyId = networkPolicy.getNetworkPolicyId()
+ msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId)
+ try {
+ AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId)
+ getAAIClient().delete(delUri)
+ execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", 200)
+ } catch (Exception e) {
+ execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", 500)
+ String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + e.getMessage()
+ msoLogger.debug(delErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
+ }
} else {
- // aai all errors
- String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel
- msoLogger.debug(delErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
+ execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 404)
+ // This network policy FQDN is not in AAI. No need to delete.
+ msoLogger.debug("The return code is: " + 404)
+ msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
+ msoLogger.debug("Network policy FQDN is not in AAI")
}
- } else if (returnCode == 404) {
- // This network policy FQDN is not in AAI. No need to delete.
- msoLogger.debug("The return code is: " + returnCode)
- msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
- msoLogger.debug("Network policy FQDN is not in AAI")
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
+ }catch(Exception e ) {
// aai all errors
- String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + returnCode
+ String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + e.getMessage()
msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
}
-
-
-
} // end loop
-
-
} else {
msoLogger.debug("No contrail network policies to query/create")
-
}
-
} catch (BpmnError e) {
throw e;
-
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage()
msoLogger.debug(exceptionMessage)
@@ -646,51 +600,18 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
def vnfId = execution.getVariable('vnfId')
def vfModuleId = execution.getVariable('vfModuleId')
- AaiUtil aaiUriUtil = new AaiUtil(this)
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)
- String endPoint = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug("AAI endPoint: " + endPoint)
try {
- RESTConfig config = new RESTConfig(endPoint);
- def responseData = ''
- def aaiRequestId = UUID.randomUUID().toString()
- RESTClient client = new RESTClient(config).
- addHeader('X-TransactionId', aaiRequestId).
- addHeader('X-FromAppId', 'MSO').
- addHeader('Content-Type', 'application/xml').
- addHeader('Accept','application/xml');
- msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
- APIResponse response = client.httpGet()
- msoLogger.debug("createVfModule - invoking httpGet() to AAI")
-
- responseData = response.getResponseBodyAsString()
- if (responseData != null) {
- msoLogger.debug("Received generic VNF data: " + responseData)
-
- }
-
- msoLogger.debug("deleteVfModule - queryAAIVfModule Response: " + responseData)
- msoLogger.debug("deleteVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
-
- execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponseCode', response.getStatusCode())
- execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponse', responseData)
- msoLogger.debug('Response code:' + response.getStatusCode())
- msoLogger.debug('Response:' + System.lineSeparator() + responseData)
+ Optional<org.onap.aai.domain.yang.VfModule> vfModule = getAAIClient().get(org.onap.aai.domain.yang.VfModule.class, uri);
// Retrieve VF Module info and its orchestration status; if not found, do nothing
- if (response.getStatusCode() == 200) {
- // Parse the VNF record from A&AI to find base module info
- msoLogger.debug('Parsing the VNF data to find orchestration status')
- if (responseData != null) {
- def vfModuleText = utils.getNodeXml(responseData, "vf-module")
- //def xmlVfModule= new XmlSlurper().parseText(vfModuleText)
- def orchestrationStatus = utils.getNodeText(vfModuleText, "orchestration-status")
- execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus)
- msoLogger.debug("Received orchestration status from A&AI: " + orchestrationStatus)
-
- }
- }
+ if (vfModule.isPresent()) {
+ execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponseCode', 200)
+ execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponse', vfModule.get())
+ def orchestrationStatus = vfModule.get().getOrchestrationStatus()
+ execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus)
+ msoLogger.debug("Received orchestration status from A&AI: " + orchestrationStatus)
+ }
} catch (Exception ex) {
ex.printStackTrace()
msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
@@ -709,4 +630,4 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
index d90c316832..abc83b2784 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy
@@ -20,15 +20,18 @@
package org.onap.so.bpmn.infrastructure.scripts
-import static org.apache.commons.lang3.StringUtils.*
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.NetworkPolicies
+import org.onap.aai.domain.yang.NetworkPolicy
+import org.onap.aai.domain.yang.VfModule
+import static org.apache.commons.lang3.StringUtils.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
-import org.onap.so.bpmn.common.scripts.VfModule
import org.onap.so.bpmn.common.scripts.VfModuleBase
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
@@ -40,8 +43,6 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
-import org.springframework.web.util.UriUtils
public class DoDeleteVfModuleFromVnf extends VfModuleBase {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVfModuleFromVnf.class);
@@ -133,27 +134,17 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
try {
def vnfId = execution.getVariable('vnfId')
- AaiUtil aaiUriUtil = new AaiUtil(this)
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
-
- String endPoint = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug("DoDeleteVfModuleFromVnf: AAI endPoint : " + endPoint)
-
try {
- msoLogger.debug("DoDeleteVfModuleFromVnf: - invoking httpGet to AAI")
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
-
- def responseData = response.getResponseBodyAsString()
- execution.setVariable('DDVMFV_getVnfResponseCode', response.getStatusCode())
- execution.setVariable('DDVMFV_getVnfResponse', responseData)
-
- msoLogger.debug("DoDeleteVfModuleFromVnf: AAI Response : " + responseData)
- msoLogger.debug("DoDeleteVfModuleFromVnf: AAI ResponseCode : " + response.getStatusCode())
-
- msoLogger.debug('Response code:' + response.getStatusCode())
- msoLogger.debug('Response:' + System.lineSeparator() + responseData)
-
+ Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri)
+
+ if(genericVnf.isPresent()){
+ execution.setVariable('DDVMFV_getVnfResponseCode', 200)
+ execution.setVariable('DDVMFV_getVnfResponse', genericVnf.get())
+ }else{
+ execution.setVariable('DDVMFV_getVnfResponseCode', 404)
+ execution.setVariable('DDVMFV_getVnfResponse', "Generic Vnf not found!")
+ }
} catch (Exception ex) {
ex.printStackTrace()
msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
@@ -185,31 +176,32 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
msoLogger.trace('Entered ' + method)
try {
- def genericVnf = execution.getVariable('DDVMFV_getVnfResponse')
+ GenericVnf genericVnf = execution.getVariable('DDVMFV_getVnfResponse')
def vnfId = execution.getVariable('_vnfId')
- def vfModuleId = execution.getVariable('vfModuleId')
- def VfModule vfModule = findVfModule(genericVnf, vfModuleId)
- if (vfModule == null) {
- def String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\''
+ def vfModuleId = execution.getVariable('vfModuleId')
+ Optional<VfModule> vfModule = Optional.empty()
+ if(genericVnf.getVfModules()!=null && ! genericVnf.getVfModules().getVfModule().isEmpty()) {
+ vfModule = genericVnf.getVfModules().getVfModule().stream().filter { v -> v.getVfModuleId().equals(vfModuleId) }.findFirst()
+ }
+ if (!vfModule.isPresent()) {
+ String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\''
msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, msg)
} else {
-
+ Boolean isOnlyVfModule = (genericVnf.getVfModules().getVfModule().size() == 1)
if (isDebugLogEnabled) {
- msoLogger.debug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.isBaseVfModule() + ', isOnlyVfModule=' + vfModule.isOnlyVfModule())
+ msoLogger.debug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.get().isIsBaseVfModule() + ', isOnlyVfModule=' + isOnlyVfModule)
}
- if (vfModule.isBaseVfModule() && !vfModule.isOnlyVfModule()) {
- def String msg = 'Cannot delete VF Module \'' + vfModuleId +
- '\'since it is the base VF Module and it\'s not the only VF Module in Generic VNF \'' + vnfId + '\''
- msoLogger.debug("Received a BAD Response from VNF Adapter for CREATE_VF_MODULE Call.")
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error")
+ if (vfModule.get().isIsBaseVfModule() && !isOnlyVfModule) {
+ String msg = 'Cannot delete VF Module \'' + vfModuleId +
+ '\'since it is the base VF Module and it\'s not the only VF Module in Generic VNF \'' + vnfId + '\''
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002,msg)
}
-
- def heatStackId = vfModule.getElementText('heat-stack-id')
+ def heatStackId = vfModule.get().getHeatStackId()
execution.setVariable('DDVMFV_heatStackId', heatStackId)
msoLogger.debug('VF Module heatStackId retrieved from AAI: ' + heatStackId)
}
-
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
@@ -507,80 +499,45 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
uri.queryParam("network-policy-fqdn", fqdn)
- String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest)
-
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest)
- int returnCode = response.getStatusCode()
- execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode)
- msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- if (isOneOf(returnCode, 200, 201)) {
- msoLogger.debug("The return code is: " + returnCode)
- // This network policy FQDN exists in AAI - need to delete it now
- msoLogger.debug(aaiResponseAsString)
- execution.setVariable("DDVFMV_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString)
- msoLogger.debug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString)
- // Retrieve the network policy id for this FQDN
- def networkPolicyId = utils.getNodeText(aaiResponseAsString, "network-policy-id")
- msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId)
-
- // Retrieve the resource version for this network policy
- def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version")
- msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion)
-
- AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId)
- delUri.resourceVersion(resourceVersion)
- String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri)
-
- msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest)
-
- msoLogger.debug("invoking DELETE call to AAI")
- msoLogger.debug("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest)
- APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest)
- int returnCodeDel = responseDel.getStatusCode()
- execution.setVariable("DDVFMV_aaiDeleteNetworkPolicyReturnCode", returnCodeDel)
- msoLogger.debug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel)
-
- if (isOneOf(returnCodeDel, 200, 201, 204)) {
- msoLogger.debug("The return code from deleting network policy is: " + returnCodeDel)
- // This network policy was deleted from AAI successfully
- msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ")
-
- } else {
- // aai all errors
- String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel
- msoLogger.debug(delErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
- }
- } else if (returnCode == 404) {
- // This network policy FQDN is not in AAI. No need to delete.
- msoLogger.debug("The return code is: " + returnCode)
- msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
- msoLogger.debug("Network policy FQDN is not in AAI")
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
-
-
-
- } // end loop
-
+ try {
+ Optional<NetworkPolicies> networkPolicies = getAAIClient().get(NetworkPolicies.class, uri)
+
+ if (networkPolicies.isPresent() && !networkPolicies.get().getNetworkPolicy().isEmpty()) {
+ NetworkPolicy networkPolicy = networkPolicies.get().getNetworkPolicy().get(0)
+ execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200)
+ // This network policy FQDN exists in AAI - need to delete it now
+ // Retrieve the network policy id for this FQDN
+ def networkPolicyId = networkPolicy.getNetworkPolicyId()
+ msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId)
+
+ // Retrieve the resource version for this network policy
+ try {
+ AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId)
+ getAAIClient().delete(delUri)
+ execution.setVariable("DDVFMV_aaiDeleteNetworkPolicyReturnCode", 200)
+ msoLogger.debug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + 200)
+ // This network policy was deleted from AAI successfully
+ msoLogger.debug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ")
+ } catch (Exception e) {
+ // aai all errors
+ String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + e.getMessage()
+ msoLogger.debug(delErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
+ }
+ } else {
+ execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 404)
+ // This network policy FQDN is not in AAI. No need to delete.
+ msoLogger.debug("This network policy FQDN is not in AAI: " + fqdn)
+ msoLogger.debug("Network policy FQDN is not in AAI")
+ }
+ } catch (Exception e) {
+ // aai all errors
+ String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + e.getMessage()
+ msoLogger.debug(dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+ }
+ } // end loop
} else {
msoLogger.debug("No contrail network policies to query/create")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy
index 73fd78f0c0..710d13470f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy
@@ -20,9 +20,12 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.apache.commons.lang3.*
+import org.apache.commons.lang3.StringUtils
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipData
+import org.onap.aai.domain.yang.VolumeGroup
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -30,13 +33,14 @@ import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
+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.client.aai.AAIObjectType
import org.onap.so.constants.Defaults
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
-import org.springframework.web.util.UriUtils
+import javax.ws.rs.NotFoundException
class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVfModuleVolumeV2.class);
@@ -153,62 +157,52 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{
}
String cloudRegion = execution.getVariable(prefix+'aicCloudRegion')
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId)
- def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
- msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query volume group by id return code: " + returnCode)
- msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString)
- msoLogger.debug('AAI query volume group by id return code: ' + returnCode)
- msoLogger.debug('AAI query volume group by id response: ' + aaiResponseAsString)
-
- execution.setVariable(prefix+"queryAAIVolGrpResponse", aaiResponseAsString)
-
- if (returnCode=='200' || returnCode == '204') {
-
- def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id')
- execution.setVariable(prefix+'volumeGroupHeatStackId', heatStackId)
-
- msoLogger.debug('Heat stack id from AAI response: ' + heatStackId)
-
- if(hasVfModuleRelationship(aaiResponseAsString)){
- msoLogger.debug('Volume Group ' + volumeGroupId + ' currently in use')
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.")
- }
-
- def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString)
- msoLogger.debug('Tenant ID from AAI response: ' + volumeGroupTenantId)
-
- if (volumeGroupTenantId == null) {
- msoLogger.debug("Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
- }
+ try {
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP , Defaults.CLOUD_OWNER.toString(), cloudRegion,volumeGroupId)
+ Optional<VolumeGroup> volumeGroupOps = getAAIClient().get(VolumeGroup.class,resourceUri)
+ if(volumeGroupOps.present) {
+ VolumeGroup volumeGroup = volumeGroupOps.get()
+ execution.setVariable(prefix + "queryAAIVolGrpResponse", volumeGroup)
+ def heatStackId = volumeGroup.getHeatStackId()==null ? '' : volumeGroup.getHeatStackId()
+ execution.setVariable(prefix+'volumeGroupHeatStackId', heatStackId)
+
+ msoLogger.debug('Heat stack id from AAI response: ' + heatStackId)
+ AAIResultWrapper wrapper = getAAIClient().get(uri);
+ Optional<Relationships> relationships = wrapper.getRelationships()
+ String volumeGroupTenantId = null
+
+ if(relationships.isPresent()){
+ if(relationships.get().getRelatedAAIUris(AAIObjectType.VF_MODULE)){
+ msoLogger.debug('Volume Group ' + volumeGroupId + ' currently in use')
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.")
+ }
+ for(AAIResourceUri aaiResourceUri: relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)){
+ volumeGroupTenantId = aaiResourceUri.getURIKeys().get("tenant-id")
+ }
+ }
- if (volumeGroupTenantId != tenantId) {
- def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId + ' retrieved from AAI for Volume Group Id ' + volumeGroupId
- msoLogger.debug("Error in DeleteVfModuleVolume: " + errorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 5000, errorMessage)
- }
- msoLogger.debug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId )
- }
- else {
- if (returnCode=='404') {
- msoLogger.debug("Volume Group ${volumeGroupId} not found in AAI")
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} not found in AAI. Response code: 404")
- }
- else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
+ msoLogger.debug('Tenant ID from AAI response: ' + volumeGroupTenantId)
+
+ if (volumeGroupTenantId == null) {
+ msoLogger.debug("Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
+ }
+
+ if (volumeGroupTenantId != tenantId) {
+ def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId + ' retrieved from AAI for Volume Group Id ' + volumeGroupId
+ msoLogger.debug("Error in DeleteVfModuleVolume: " + errorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 5000, errorMessage)
+ }
+ msoLogger.debug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId )
+ }else{
+ execution.setVariable(prefix + "queryAAIVolGrpResponse", "Volume Group ${volumeGroupId} not found in AAI. Response code: 404")
+ msoLogger.debug("Volume Group ${volumeGroupId} not found in AAI")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} not found in AAI. Response code: 404")
+ }
+ }catch (Exception ex) {
+ execution.setVariable(prefix+"queryAAIVolGrpResponse", ex.getMessage())
+ WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(ex.getMessage(), execution)
+ throw new BpmnError("MSOWorkflowException")
}
}
@@ -262,94 +256,20 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{
public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) {
// get variables
- String queryAAIVolGrpIdResponse = execution.getVariable(prefix+"queryAAIVolGrpResponse")
- String groupId = utils.getNodeText(queryAAIVolGrpIdResponse, "volume-group-id")
- String resourceVersion = utils.getNodeText(queryAAIVolGrpIdResponse, "resource-version")
-
- String messageId = UUID.randomUUID().toString()
+ VolumeGroup volumeGroupResponse = execution.getVariable(prefix+"queryAAIVolGrpResponse")
+ String volumeGroupId = volumeGroupResponse.getVolumeGroupId()
String cloudRegion = execution.getVariable(prefix+'aicCloudRegion')
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, groupId).resourceVersion(resourceVersion)
- def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest)
- msoLogger.debug("Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest)
-
- APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI delete volume group return code: " + returnCode)
- msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- if (returnCode=='200' || (returnCode == '204')) {
- msoLogger.debug("Volume group $groupId deleted.")
- } else {
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $groupId not found for delete in AAI Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
-
- /**
- * Check if volume group has a relationship to vf-module
- * @param volumeGroupXml
- * @return
- */
- private boolean hasVfModuleRelationship(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('vf-module'))) {
- def Node relatedLink = utils.getChildNode(relationship, 'related-link')
- if (relatedLink !=null && relatedLink.text() != null){
- return true
- }
- }
- }
- }
- return false
+ try {
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId)
+ getAAIClient().delete(resourceUri)
+ msoLogger.debug("Volume group $volumeGroupId deleted.")
+ }catch (NotFoundException ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupId not found for delete in AAI Response code: 404")
+ }catch (Exception ex) {
+ WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(ex.getMessage(), execution)
+ throw new BpmnError("MSOWorkflowException")
+ }
}
-
- /**
- * 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.
- */
- private String getTenantIdFromVolumeGroup(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('tenant'))) {
- def NodeList relationshipDataList = utils.getIdenticalChildren(relationship, 'relationship-data')
- for (Node relationshipData in relationshipDataList) {
- def Node relationshipKey = utils.getChildNode(relationshipData, 'relationship-key')
- if ((relationshipKey != null) && (relationshipKey.text().equals('tenant.tenant-id'))) {
- def Node relationshipValue = utils.getChildNode(relationshipData, 'relationship-value')
- if (relationshipValue != null) {
- return relationshipValue.text()
- }
- }
- }
- }
- }
- }
- return null
- }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
index ddf2706635..6e0c6bb002 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy
@@ -20,13 +20,12 @@
package org.onap.so.bpmn.infrastructure.scripts
-import static org.apache.commons.lang3.StringUtils.*;
-
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.VfModule
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.json.JSONArray;
-import org.json.JSONObject;
-import org.onap.so.bpmn.common.scripts.AaiUtil
+import org.json.JSONObject
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
@@ -45,8 +44,6 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
-import org.springframework.web.util.UriUtils;
/**
* This class supports the macro VID Flow
@@ -258,61 +255,34 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
try {
def vnfId = execution.getVariable('vnfId')
- AaiUtil aaiUriUtil = new AaiUtil(this)
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
- String endPoint = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug("AAI endPoint: " + endPoint)
try {
- msoLogger.debug("createVfModule - invoking httpGet() to AAI")
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
-
- def responseData = response.getResponseBodyAsString()
- if (responseData != null) {
- msoLogger.debug("Received generic VNF data: " + responseData)
-
- }
-
- msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData)
- msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
-
- execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode())
- execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData)
- msoLogger.debug('Response code:' + response.getStatusCode())
- msoLogger.debug('Response:' + System.lineSeparator() + responseData)
+ Optional<GenericVnf> genericVnfOp = getAAIClient().get(GenericVnf.class,uri)
//Map<String, String>[] vfModules = new HashMap<String,String>[]
List<ModuleResource> vfModulesFromDecomposition = execution.getVariable("DDVAM_vfModulesFromDecomposition")
def vfModulesList = new ArrayList<Map<String,String>>()
- def vfModules = null
def vfModuleBaseEntry = null
- if (response.getStatusCode() == 200) {
+ if (genericVnfOp.isPresent()) {
+ execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', 200)
+ execution.setVariable('DCVFM_queryAAIVfModuleResponse', genericVnfOp.get())
+
// Parse the VNF record from A&AI to find base module info
- msoLogger.debug('Parsing the VNF data to find base module info')
- if (responseData != null) {
- def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
- msoLogger.debug("vModulesText: " + vfModulesText)
- if (vfModulesText != null && !vfModulesText.trim().isEmpty()) {
- def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
- vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
+ if (genericVnfOp.get().getVfModules()!= null && !genericVnfOp.get().getVfModules().getVfModule().isEmpty() ) {
+ List<VfModule> vfModules = genericVnfOp.get().getVfModules().getVfModule()
execution.setVariable("DDVAM_moduleCount", vfModules.size())
- int vfModulesSize = 0
ModelInfo vfModuleModelInfo = null
- for (i in 0..vfModules.size()-1) {
- def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
-
+ for (VfModule vfModule : vfModules) {
Map<String, String> vfModuleEntry = new HashMap<String, String>()
- def vfModuleId = utils.getNodeText(vfModuleXml, "vf-module-id")
- vfModuleEntry.put("vfModuleId", vfModuleId)
- def vfModuleName = utils.getNodeText(vfModuleXml, "vf-module-name")
- vfModuleEntry.put("vfModuleName", vfModuleName)
+ vfModuleEntry.put("vfModuleId", vfModule.getVfModuleId())
+ vfModuleEntry.put("vfModuleName", vfModule.getVfModuleName())
// Find the model for this vf module in decomposition if specified
if (vfModulesFromDecomposition != null) {
msoLogger.debug("vfModulesFromDecomposition is not null")
- def vfModuleUuid = utils.getNodeText(vfModuleXml, "model-version-id")
+ def vfModuleUuid = vfModule.getModelVersionId()
if (vfModuleUuid == null) {
- vfModuleUuid = utils.getNodeText(vfModuleXml, "persona-model-version")
+ vfModuleUuid = vfModule.getPersonaModelVersion()
}
msoLogger.debug("vfModule UUID is: " + vfModuleUuid)
for (j in 0..vfModulesFromDecomposition.size()-1) {
@@ -335,9 +305,8 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
}
- def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
// Save base vf module for last
- if (isBaseVfModule == "true") {
+ if (vfModule.isIsBaseVfModule()) {
vfModuleBaseEntry = vfModuleEntry
}
else {
@@ -348,8 +317,10 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
vfModulesList.add(vfModuleBaseEntry)
}
}
-
- }
+ }else{
+ execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', 404)
+ execution.setVariable('DCVFM_queryAAIVfModuleResponse', "Generic Vnf not found")
+
}
execution.setVariable("DDVAM_vfModules", vfModulesList)
} catch (Exception ex) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy
index 5b7fdb2c22..58ee260c25 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy
@@ -17,14 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.scripts;
+package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import static org.apache.commons.lang3.StringUtils.*;
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.so.bpmn.common.scripts.AaiUtil
+import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
@@ -308,8 +310,8 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor {
try {
org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData")
- AAIResourcesClient client = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
client.update(uri, si)
} catch (BpmnError e) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
index 33cb6d4760..c4711411d3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
@@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.GenericVnf
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.CatalogDbUtils
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -982,55 +983,26 @@ public class DoUpdateVfModule extends VfModuleBase {
try {
def vnfId = execution.getVariable('DOUPVfMod_vnfId')
- def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
-
- AaiUtil aaiUriUtil = new AaiUtil(this)
-
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
- String endPoint = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug("AAI endPoint: " + endPoint)
try {
- def aaiRequestId = UUID.randomUUID().toString()
- msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
- msoLogger.debug("createVfModule - invoking httpGet() to AAI")
-
- def responseData = response.getResponseBodyAsString()
- if (responseData != null) {
- msoLogger.debug("Received generic VNF data: " + responseData)
-
- }
-
- msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData)
- msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
-
- execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())
- execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)
- msoLogger.debug('Response code:' + response.getStatusCode())
- msoLogger.debug('Response:' + System.lineSeparator() + responseData)
- if (response.getStatusCode() == 200) {
- // Parse the VNF record from A&AI to find base module info
+ Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri)
+ if (genericVnf.isPresent()) {
+ execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', 200)
+ execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', genericVnf.get())
+ // Parse the VNF record from A&AI to find base module info
msoLogger.debug('Parsing the VNF data to find base module info')
- if (responseData != null) {
- def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
- def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
- def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
- int vfModulesSize = 0
- for (i in 0..vfModules.size()-1) {
- def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
- def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
-
- if (isBaseVfModule == "true") {
- String baseModuleId = utils.getNodeText(vfModuleXml, "vf-module-id")
+ if (genericVnf.get().getVfModules()!=null && !genericVnf.get().getVfModules().getVfModule().isEmpty()) {
+ Optional<org.onap.aai.domain.yang.VfModule> vfmodule = genericVnf.get().getVfModules().getVfModule().stream().
+ filter{v-> v.isIsBaseVfModule()}.findFirst()
+ if (vfmodule.isPresent()) {
+ String baseModuleId = vfmodule.get().getVfModuleId()
execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
msoLogger.debug('Received baseVfModuleId: ' + baseModuleId)
- String baseModuleHeatStackId = utils.getNodeText(vfModuleXml, "heat-stack-id")
+ String baseModuleHeatStackId = vfmodule.get().getHeatStackId()
execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
}
- }
}
}
} catch (Exception ex) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy
index 0f9a0ad292..5b1270a947 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy
@@ -20,25 +20,27 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.apache.commons.lang3.*
+import org.apache.commons.collections.CollectionUtils
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.so.bpmn.common.scripts.AaiUtil
+import org.onap.aai.domain.yang.VolumeGroup
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.VfModuleBase
-import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
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
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
+import static org.apache.commons.lang.StringUtils.isEmpty
class UpdateVfModuleVolume extends VfModuleBase {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolume.class);
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolume.class)
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -103,7 +105,7 @@ class UpdateVfModuleVolume extends VfModuleBase {
} catch (BpmnError bpmnError) {
throw bpmnError
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
}
}
@@ -152,9 +154,9 @@ class UpdateVfModuleVolume extends VfModuleBase {
sendWorkflowResponse(execution, 200, synchResponse)
msoLogger.debug("UpdateVfModuleVolume Synch Response: " + synchResponse)
} catch (BpmnError e) {
- throw e;
+ throw e
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendSynchResponse(): ' + e.getMessage())
}
}
@@ -175,45 +177,35 @@ class UpdateVfModuleVolume extends VfModuleBase {
try {
def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId)
- String endPoint = aaiUtil.createAaiUri(uri)
-
-
- msoLogger.debug('Sending GET to AAI endpoint \'' + endPoint + '\'')
- msoLogger.debug("UpdateVfModuleVolume sending GET for quering AAI endpoint: " + endPoint)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint)
- def int statusCode = response.getStatusCode()
- def responseData = response.getResponseBodyAsString()
- msoLogger.debug('Response code:' + statusCode)
- msoLogger.debug('Response:' + System.lineSeparator() + responseData)
- msoLogger.debug("UpdateVfModuleVolume response data: " + responseData)
-
- def volumeGroup = responseData
- def heatStackId = getNodeTextForce(volumeGroup, 'heat-stack-id')
- execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId)
- if ((statusCode == 200) || (statusCode == 204)) {
- def volumeGroupTenantId = getTenantIdFromVolumeGroup(volumeGroup)
- if (volumeGroupTenantId == null) {
- throw new Exception('Could not find Tenant Id element in Volume Group with Volume Group Id \'' + volumeGroupId + '\''
- + '\', AIC Cloud Region \'' + aicCloudRegion + '\'')
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(),aicCloudRegion,volumeGroupId)
+ AAIResultWrapper wrapper = getAAIClient().get(uri)
+ Optional<VolumeGroup> volumeGroup = wrapper.asBean(VolumeGroup.class)
+ if(volumeGroup.isPresent()){
+ def heatStackId = volumeGroup.get().getHeatStackId()
+ execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId)
+ Optional<Relationships> relationships = wrapper.getRelationships()
+ if(relationships.isPresent()){
+ List<AAIResourceUri> resourceUriList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)
+ if(CollectionUtils.isNotEmpty(resourceUriList)){
+ AAIResourceUri tenantUri = resourceUriList.get(0)
+ String volumeGroupTenantId = tenantUri.getURIKeys().get("tenant-id")
+ if( isEmpty(volumeGroupTenantId)){
+ exceptionUtil.buildAndThrowWorkflowException(execution,2500,"Could not find Tenant Id element in Volume Group with Volume Group Id" + volumeGroupId + ", AIC Cloud Region" + aicCloudRegion)
+ }
+ execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId)
+ msoLogger.debug("Received Tenant Id: " + volumeGroupTenantId + "from AAI for Volume Group with Volume Group Id: " + volumeGroupId + ", AIC Cloud Region" + aicCloudRegion)
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution,2500,"Could not find Tenant Id element in Volume Group with Volume Group Id" + volumeGroupId + ", AIC Cloud Region" + aicCloudRegion)
+ }
}
- execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId)
- msoLogger.debug('Received Tenant Id \'' + volumeGroupTenantId + '\' from AAI for Volume Group with Volume Group Id \'' + volumeGroupId + '\''
- + '\', AIC Cloud Region \'' + aicCloudRegion + '\'')
- } else if (statusCode == 404) {
- throw new Exception('Volume Group \'' + volumeGroupId + '\' not found at AAI')
- } else {
- throw new Exception('Bad status code ' + statusCode + ' received from AAI; Response data: ' + responseData)
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution,2500,"Volume Group" + volumeGroupId + " not found at AAI")
}
-
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
- throw e;
+ throw e
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVolumeGroup(): ' + e.getMessage())
}
}
@@ -279,9 +271,9 @@ class UpdateVfModuleVolume extends VfModuleBase {
msoLogger.debug("UpdateVfModuleVolume Request for VNFAdapter Rest: " + vnfAdapterRestRequest)
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
- throw e;
+ throw e
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
}
}
@@ -323,9 +315,9 @@ class UpdateVfModuleVolume extends VfModuleBase {
msoLogger.debug("UpdateVfModuleVolume Request for Updating DB for Infra: " + updateInfraRequest)
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
- throw e;
+ throw e
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
exceptionUtil.buildWorkflowException(execution, 1002, 'Error in prepDbInfraDbRequest(): ' + e.getMessage())
}
}
@@ -360,9 +352,9 @@ class UpdateVfModuleVolume extends VfModuleBase {
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
- throw e;
+ throw e
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepCompletionHandlerRequest(): ' + e.getMessage())
}
}
@@ -409,9 +401,9 @@ class UpdateVfModuleVolume extends VfModuleBase {
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
- throw e;
+ throw e
} catch (Exception e) {
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
exceptionUtil.buildWorkflowException(execution, 1002, 'Error in prepFalloutHandler(): ' + e.getMessage())
}
}
@@ -429,7 +421,7 @@ class UpdateVfModuleVolume extends VfModuleBase {
msoLogger.trace('Entered ' + method)
- String processKey = getProcessKey(execution);
+ String processKey = getProcessKey(execution)
def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
def tenantId = execution.getVariable('UPDVfModVol_tenantId')
@@ -438,10 +430,10 @@ class UpdateVfModuleVolume extends VfModuleBase {
def String errorMessage = 'TenantId \'' + tenantId + '\' in incoming request does not match Tenant Id \'' + volumeGroupTenantId +
'\' retrieved from AAI for Volume Group Id \'' + volumeGroupId + '\', AIC Cloud Region \'' + aicCloudRegion + '\''
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception");
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception")
- WorkflowException exception = new WorkflowException(processKey, 5000, errorMessage);
- execution.setVariable("WorkflowException", exception);
+ WorkflowException exception = new WorkflowException(processKey, 5000, errorMessage)
+ execution.setVariable("WorkflowException", exception)
msoLogger.trace('Exited ' + method)
msoLogger.debug("UpdateVfModuleVolume workflowException in Tenant Mismatch: " + errorMessage)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
index ce93db522e..49da398a87 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy
@@ -7,9 +7,9 @@
* 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,142 +20,147 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.apache.commons.lang3.*
+import groovy.json.JsonException
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.so.bpmn.common.scripts.AaiUtil;
-import org.onap.so.bpmn.common.scripts.ExceptionUtil;
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.VfModule
+import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.common.scripts.VfModuleBase;
-import org.onap.so.bpmn.common.scripts.VidUtils;
+import org.onap.so.bpmn.common.scripts.VfModuleBase
+import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient
+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.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
-import org.springframework.web.util.UriUtils
+import static org.apache.cxf.common.util.CollectionUtils.isEmpty
import groovy.json.JsonSlurper
+import javax.ws.rs.core.UriBuilder
+
class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolumeInfraV1.class);
-
- /**
- * Initialize the flow's variables.
- *
- * @param execution The flow's execution instance.
- */
- private void initProcessVariables(DelegateExecution execution) {
- execution.setVariable('prefix', 'UPDVfModVol_')
- execution.setVariable('UPDVfModVol_Request', null)
- execution.setVariable('UPDVfModVol_requestInfo', null)
- execution.setVariable('UPDVfModVol_requestId', null)
- execution.setVariable('UPDVfModVol_source', null)
- execution.setVariable('UPDVfModVol_volumeInputs', null)
- execution.setVariable('UPDVfModVol_volumeGroupId', null)
- execution.setVariable('UPDVfModVol_vnfType', null)
- execution.setVariable('UPDVfModVol_serviceId', null)
- execution.setVariable('UPDVfModVol_aicCloudRegion', null)
- execution.setVariable('UPDVfModVol_tenantId', null)
- execution.setVariable('UPDVfModVol_volumeParams', null)
- execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', null)
- execution.setVariable('UPDVfModVol_volumeGroupTenantId', null)
- execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false)
- }
-
-
- /**
- * Perform initial processing, such as request validation, initialization of variables, etc.
- * * @param execution
- */
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- preProcessRequest(execution, isDebugEnabled)
- }
-
- public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) {
-
- initProcessVariables(execution)
- String jsonRequest = validateRequest(execution)
-
- def request = ""
-
- try {
- def jsonSlurper = new JsonSlurper()
- Map reqMap = jsonSlurper.parseText(jsonRequest)
-
- def serviceInstanceId = execution.getVariable('serviceInstanceId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- //def vnfId = execution.getVariable('vnfId')
-
- def vidUtils = new VidUtils(this)
- request = vidUtils.createXmlVolumeRequest(reqMap, 'UPDATE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId)
-
- execution.setVariable('UPDVfModVol_Request', request)
- execution.setVariable("UPDVfModVol_isVidRequest", true)
-
- //need to get persona-model-id aka model-invariantId to use later to validate vf-module relation in AAI
-
- def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantUuid ?: ''
- execution.setVariable('UPDVfModVol_modelInvariantId', modelInvariantId)
-
- msoLogger.debug("modelInvariantId from request: " + modelInvariantId)
- msoLogger.debug("XML request:\n" + request)
- }
- catch(groovy.json.JsonException je) {
- msoLogger.debug(" Request is in XML format.")
- // assume request is in XML format - proceed as usual to process XML request
- }
-
- def requestId = execution.getVariable('mso-request-id')
-
- def requestInfo = getRequiredNodeXml(execution, request, 'request-info')
- execution.setVariable('UPDVfModVol_requestInfo', requestInfo)
- execution.setVariable('UPDVfModVol_requestId', requestId)
- //execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
- execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source'))
-
- def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs')
- execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs)
- execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id'))
- execution.setVariable('UPDVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type'))
- execution.setVariable('UPDVfModVol_vnfVersion', getRequiredNodeText(execution, volumeInputs, 'asdc-service-model-version'))
- execution.setVariable('UPDVfModVol_serviceId', utils.getNodeText(volumeInputs, 'service-id'))
- execution.setVariable('UPDVfModVol_aicCloudRegion', getRequiredNodeText(execution, volumeInputs, 'aic-cloud-region'))
- execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id'))
- //execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id'))
-
- setBasicDBAuthHeader(execution, isDebugLogEnabled)
-
- def volumeParams = utils.getNodeXml(request, 'volume-params')
- execution.setVariable('UPDVfModVol_volumeParams', volumeParams)
- }
-
- /**
- * Prepare and send the synchronous response.
- *
- * @param execution The flow's execution instance.
- */
- public void sendSynchResponse(DelegateExecution execution, isDebugLogEnabled) {
-
- def requestInfo = execution.getVariable('UPDVfModVol_requestInfo')
- def requestId = execution.getVariable('UPDVfModVol_requestId')
- def source = execution.getVariable('UPDVfModVol_source')
- def progress = getNodeTextForce(requestInfo, 'progress')
- if (progress.isEmpty()) {
- progress = '0'
- }
- def startTime = getNodeTextForce(requestInfo, 'start-time')
- if (startTime.isEmpty()) {
- startTime = System.currentTimeMillis()
- }
- def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs')
-
- String xmlSyncResponse = """
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolumeInfraV1.class)
+ private ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ /**
+ * Initialize the flow's variables.
+ *
+ * @param execution The flow's execution instance.
+ */
+ private void initProcessVariables(DelegateExecution execution) {
+ execution.setVariable('prefix', 'UPDVfModVol_')
+ execution.setVariable('UPDVfModVol_Request', null)
+ execution.setVariable('UPDVfModVol_requestInfo', null)
+ execution.setVariable('UPDVfModVol_requestId', null)
+ execution.setVariable('UPDVfModVol_source', null)
+ execution.setVariable('UPDVfModVol_volumeInputs', null)
+ execution.setVariable('UPDVfModVol_volumeGroupId', null)
+ execution.setVariable('UPDVfModVol_vnfType', null)
+ execution.setVariable('UPDVfModVol_serviceId', null)
+ execution.setVariable('UPDVfModVol_aicCloudRegion', null)
+ execution.setVariable('UPDVfModVol_tenantId', null)
+ execution.setVariable('UPDVfModVol_volumeParams', null)
+ execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', null)
+ execution.setVariable('UPDVfModVol_volumeGroupTenantId', null)
+ execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false)
+ }
+
+ /**
+ * Perform initial processing, such as request validation, initialization of variables, etc.
+ * * @param execution
+ */
+ public void preProcessRequest(DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ preProcessRequest(execution, isDebugEnabled)
+ }
+
+ public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) {
+
+ initProcessVariables(execution)
+ String jsonRequest = validateRequest(execution)
+
+ def request = ""
+
+ try {
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(jsonRequest)
+
+ def serviceInstanceId = execution.getVariable('serviceInstanceId')
+ def volumeGroupId = execution.getVariable('volumeGroupId')
+ //def vnfId = execution.getVariable('vnfId')
+
+ def vidUtils = new VidUtils(this)
+ request = vidUtils.createXmlVolumeRequest(reqMap, 'UPDATE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId)
+
+ execution.setVariable('UPDVfModVol_Request', request)
+ execution.setVariable("UPDVfModVol_isVidRequest", true)
+
+ //need to get persona-model-id aka model-invariantId to use later to validate vf-module relation in AAI
+
+ def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantUuid ?: ''
+ execution.setVariable('UPDVfModVol_modelInvariantId', modelInvariantId)
+
+ msoLogger.debug("modelInvariantId from request: " + modelInvariantId)
+ msoLogger.debug("XML request:\n" + request)
+ }
+ catch (JsonException je) {
+ msoLogger.debug(" Request is in XML format.")
+ // assume request is in XML format - proceed as usual to process XML request
+ }
+
+ def requestId = execution.getVariable('mso-request-id')
+
+ def requestInfo = getRequiredNodeXml(execution, request, 'request-info')
+ execution.setVariable('UPDVfModVol_requestInfo', requestInfo)
+ execution.setVariable('UPDVfModVol_requestId', requestId)
+ //execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
+ execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source'))
+
+ def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs')
+ execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs)
+ execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id'))
+ execution.setVariable('UPDVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type'))
+ execution.setVariable('UPDVfModVol_vnfVersion', getRequiredNodeText(execution, volumeInputs, 'asdc-service-model-version'))
+ execution.setVariable('UPDVfModVol_serviceId', utils.getNodeText(volumeInputs, 'service-id'))
+ execution.setVariable('UPDVfModVol_aicCloudRegion', getRequiredNodeText(execution, volumeInputs, 'aic-cloud-region'))
+ execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id'))
+ //execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id'))
+
+ setBasicDBAuthHeader(execution, isDebugLogEnabled)
+
+ def volumeParams = utils.getNodeXml(request, 'volume-params')
+ execution.setVariable('UPDVfModVol_volumeParams', volumeParams)
+ }
+
+ /**
+ * Prepare and send the synchronous response.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void sendSynchResponse(DelegateExecution execution, isDebugLogEnabled) {
+
+ def requestInfo = execution.getVariable('UPDVfModVol_requestInfo')
+ def requestId = execution.getVariable('UPDVfModVol_requestId')
+ def source = execution.getVariable('UPDVfModVol_source')
+ def progress = getNodeTextForce(requestInfo, 'progress')
+ if (progress.isEmpty()) {
+ progress = '0'
+ }
+ def startTime = getNodeTextForce(requestInfo, 'start-time')
+ if (startTime.isEmpty()) {
+ startTime = System.currentTimeMillis()
+ }
+ def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs')
+
+ String xmlSyncResponse = """
<volume-request xmlns="http://org.onap/so/infra/vnf-request/v1">
<request-info>
<request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
@@ -169,223 +174,153 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
</volume-request>
"""
- def syncResponse = ''
- def isVidRequest = execution.getVariable('UPDVfModVol_isVidRequest')
-
- if(isVidRequest) {
- def volumeGroupId = execution.getVariable('volumeGroupId')
- syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim()
- }
- else {
- syncResponse = utils.formatXml(xmlSyncResponse)
- }
-
- msoLogger.debug('Sync response: ' + syncResponse)
- execution.setVariable('UPDVfModVol_syncResponseSent', true)
- sendWorkflowResponse(execution, 200, syncResponse)
- }
-
- /**
- * Prepare a Request for querying AAI for Volume Group information using the
- * Volume Group Id and Aic Cloud Region.
- * @param execution The flow's execution instance.
- */
- public void queryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) {
-
- def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
- def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
-
- AaiUtil aaiUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId)
- def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
- msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query volume group by id return code: " + returnCode)
- msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString)
-
- msoLogger.debug("AAI Volume Group return code: " + returnCode)
- msoLogger.debug("AAI Volume Group response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if ((returnCode == '200') || (returnCode == '204')) {
-
- execution.setVariable('UPDVfModVol_aaiVolumeGroupResponse', aaiResponseAsString)
- //def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id')
- //execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId)
-
- def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString)
- if (volumeGroupTenantId == null) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId
- + ", AIC Cloud Region " + aicCloudRegion)
- }
- execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId)
- msoLogger.debug("Received Tenant Id " + volumeGroupTenantId + " from AAI for Volume Group with Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion)
-
- def relatedVfModuleLink = getRelatedVfModuleRelatedLink(aaiResponseAsString)
- msoLogger.debug("Related VF Module link: " + relatedVfModuleLink)
- execution.setVariable('UPDVfModVol_relatedVfModuleLink', relatedVfModuleLink)
-
- }
- else if (returnCode == '404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group " + volumeGroupId + " not found at AAI")
- }
- else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
-
- /**
- * Query AAI service instance
- * @param execution
- * @param isDebugEnabled
- */
- public void queryAAIForGenericVnf(DelegateExecution execution, isDebugEnabled) {
-
- def vnfId = execution.getVariable('vnfId')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
- String queryAAIRequest = aaiUtil.createAaiUri(uri)
-
- msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query generic vnf return code: " + returnCode)
- msoLogger.debug("AAI query generic vnf response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if (returnCode=='200') {
- msoLogger.debug('Generic vnf ' + vnfId + ' found in AAI.')
- execution.setVariable('UPDVfModVol_AAIQueryGenericVfnResponse', aaiResponseAsString)
- } else {
- if (returnCode=='404') {
- def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.'
- msoLogger.debug(message)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message)
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
- /**
- * Query AAI for VF Module using vf-module-id
- * @param execution
- * @param isDebugLogEnabled
- */
- public void queryAAIForVfModule(DelegateExecution execution, isDebugLogEnabled) {
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String queryAAIVfModuleRequest = execution.getVariable('UPDVfModVol_relatedVfModuleLink')
- execution.setVariable('UPDVfModVol_personaModelId', '')
-
- msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest)
- msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest)
-
- def aaiUrl = UrnPropertiesReader.getVariable("aai.endpoint", execution)
- msoLogger.debug('A&AI URL: ' + aaiUrl)
-
- def requestEndpoint = aaiUrl + queryAAIVfModuleRequest
- msoLogger.debug('A&AI request endpoint: ' + requestEndpoint)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, requestEndpoint)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- msoLogger.debug("AAI query vf-module: " + returnCode)
- msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString)
-
- msoLogger.debug("AAI query vf-module:: " + returnCode)
- msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if ((returnCode == '200') || (returnCode == '204')) {
- def personaModelId = utils.getNodeText(aaiResponseAsString, 'model-invariant-id')
- if(personaModelId == null) {
- //check old attribute name
- personaModelId = utils.getNodeText(aaiResponseAsString, 'persona-model-id')
- }
- msoLogger.debug("vfModule personaModelId: " + personaModelId)
- execution.setVariable('UPDVfModVol_personaModelId', personaModelId)
- }
- else if (returnCode == '404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "VF Module not found at AAI")
- }
- else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- /**
- *
- */
- public String getRelatedVfModuleRelatedLink(xml) {
- def list = new XmlSlurper().parseText(xml)
- def vfModuleRelationship = list.'**'.find { node -> node.'related-to'.text() == 'vf-module' }
- return vfModuleRelationship?.'related-link'?.text() ?: ''
- }
-
- /**
- * Prepare a Request for invoking the VnfAdapterRest subflow to do
- * a Volume Group update.
- *
- * @param execution The flow's execution instance.
- */
- public void prepVnfAdapterRest(DelegateExecution execution, isDebugLogEnabled) {
-
- def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
- def tenantId = execution.getVariable('UPDVfModVol_tenantId')
- def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
-
- def aaiVolumeGroupResponse = execution.getVariable('UPDVfModVol_aaiVolumeGroupResponse')
- def volumeGroupHeatStackId = getNodeTextForce(aaiVolumeGroupResponse, 'heat-stack-id')
- def volumeGroupName = getNodeTextForce(aaiVolumeGroupResponse, 'volume-group-name')
- def modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-model-customization-id')
- if(modelCustomizationId == null) {
- // Check old attribute name
- modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-persona-model-customization-id')
- }
-
- def vnfType = execution.getVariable('UPDVfModVol_vnfType')
- def vnfVersion = execution.getVariable('UPDVfModVol_vnfVersion')
-
- def aaiGenericVnfResponse = execution.getVariable('UPDVfModVol_AAIQueryGenericVfnResponse')
- def vnfId = utils.getNodeText(aaiGenericVnfResponse, 'vnf-id')
- def vnfName = utils.getNodeText(aaiGenericVnfResponse, 'vnf-name')
-
-
- def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams')
- def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml)
-
- def requestId = execution.getVariable('UPDVfModVol_requestId')
- def serviceId = execution.getVariable('UPDVfModVol_serviceId')
-
- def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
- def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
- def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
- if ('true'.equals(useQualifiedHostName)) {
- notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
- }
-
- String vnfAdapterRestRequest = """
+ def syncResponse = ''
+ def isVidRequest = execution.getVariable('UPDVfModVol_isVidRequest')
+
+ if (isVidRequest) {
+ def volumeGroupId = execution.getVariable('volumeGroupId')
+ syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${
+ requestId
+ }"}}""".trim()
+ } else {
+ syncResponse = utils.formatXml(xmlSyncResponse)
+ }
+
+ msoLogger.debug('Sync response: ' + syncResponse)
+ execution.setVariable('UPDVfModVol_syncResponseSent', true)
+ sendWorkflowResponse(execution, 200, syncResponse)
+ }
+
+ /**
+ * Prepare a Request for querying AAI for Volume Group information using the
+ * Volume Group Id and Aic Cloud Region.
+ * @param execution The flow's execution instance.
+ */
+ public void queryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) {
+
+ def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
+ def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
+
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId)
+ AAIResultWrapper wrapper = getAAIClient().get(uri)
+ Optional<VolumeGroup> volumeGroup = wrapper.asBean(VolumeGroup.class)
+ if (volumeGroup.isPresent()) {
+ execution.setVariable('UPDVfModVol_aaiVolumeGroupResponse', volumeGroup.get())
+ Optional<Relationships> relationships = wrapper.getRelationships()
+ if (relationships.isPresent()) {
+ List<AAIResourceUri> tenantURIList = relationships.get().getRelatedAAIUris(AAIObjectType.TENANT)
+ if (!isEmpty(tenantURIList)) {
+ String volumeGroupTenantId = tenantURIList.get(0).getURIKeys().get("tenant-id")
+ execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId)
+ msoLogger.debug("Received Tenant Id " + volumeGroupTenantId + " from AAI for Volume Group with Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion)
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId
+ + ", AIC Cloud Region " + aicCloudRegion)
+ }
+ execution.setVariable('UPDVfModVol_relatedVfModuleLink', relationships.get().getRelatedLinks(AAIObjectType.VF_MODULE).get(0))
+
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId
+ + ", AIC Cloud Region " + aicCloudRegion)
+ }
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group " + volumeGroupId + " not found at AAI")
+ }
+ }catch(BpmnError bpmnError){
+ throw bpmnError
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During queryAAIForGenericVnf"+e.getMessage())
+ }
+ }
+
+ /**
+ * Query AAI service instance
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void queryAAIForGenericVnf(DelegateExecution execution, isDebugEnabled) {
+
+ def vnfId = execution.getVariable('vnfId')
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ try {
+ Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class, uri)
+ if (genericVnf.isPresent()) {
+ execution.setVariable('UPDVfModVol_AAIQueryGenericVfnResponse', genericVnf.get())
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.')
+ }
+ }catch(BpmnError bpmnError){
+ throw bpmnError
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During queryAAIForGenericVnf"+e.getMessage())
+ }
+ }
+
+ /**
+ * Query AAI for VF Module using vf-module-id
+ * @param execution
+ * @param isDebugLogEnabled
+ */
+ public void queryAAIForVfModule(DelegateExecution execution, isDebugLogEnabled) {
+
+ String queryAAIVfModuleRequest = execution.getVariable('UPDVfModVol_relatedVfModuleLink')
+ execution.setVariable('UPDVfModVol_personaModelId', '')
+ AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VF_MODULE, UriBuilder.fromPath(queryAAIVfModuleRequest).build())
+ try{
+ Optional<VfModule> vfModule = getAAIClient().get(VfModule.class,uri)
+ if(vfModule.isPresent()){
+ execution.setVariable('UPDVfModVol_personaModelId',vfModule.get().getModelInvariantId())
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "VF Module not found at AAI")
+ }
+ }catch(BpmnError bpmnError){
+ throw bpmnError
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error in queryAAIForVfModule: "+e.getMessage())
+ }
+ }
+
+ /**
+ * Prepare a Request for invoking the VnfAdapterRest subflow to do
+ * a Volume Group update.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepVnfAdapterRest(DelegateExecution execution, isDebugLogEnabled) {
+
+ def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
+ def tenantId = execution.getVariable('UPDVfModVol_tenantId')
+ def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
+
+ VolumeGroup aaiVolumeGroupResponse = execution.getVariable('UPDVfModVol_aaiVolumeGroupResponse')
+ def volumeGroupHeatStackId = aaiVolumeGroupResponse.getHeatStackId()
+ def volumeGroupName = aaiVolumeGroupResponse.getVolumeGroupName()
+ def modelCustomizationId = aaiVolumeGroupResponse.getModelCustomizationId()
+
+ def vnfType = execution.getVariable('UPDVfModVol_vnfType')
+ def vnfVersion = execution.getVariable('UPDVfModVol_vnfVersion')
+
+ GenericVnf aaiGenericVnfResponse = execution.getVariable('UPDVfModVol_AAIQueryGenericVfnResponse')
+ def vnfId = aaiGenericVnfResponse.getVnfId()
+ def vnfName = aaiGenericVnfResponse.getVnfName()
+
+
+ def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams')
+ def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml)
+
+ def requestId = execution.getVariable('UPDVfModVol_requestId')
+ def serviceId = execution.getVariable('UPDVfModVol_serviceId')
+
+ def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
+ def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
+ def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host", execution)
+ if ('true'.equals(useQualifiedHostName)) {
+ notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
+ }
+
+ String vnfAdapterRestRequest = """
<updateVolumeGroupRequest>
<cloudSiteId>${MsoUtils.xmlEscape(aicCloudRegion)}</cloudSiteId>
<tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
@@ -426,22 +361,21 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
<notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
</updateVolumeGroupRequest>
"""
- vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
- execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest)
- msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
- }
-
- /**
- * Prepare a Request for updating the DB for this Infra request.
- *
- * @param execution The flow's execution instance.
- */
- public void prepDbInfraDbRequest(DelegateExecution execution, isDebugLogEnabled) {
-
- def requestId = execution.getVariable('UPDVfModVol_requestId')
- ExceptionUtil exceptionUtil = new ExceptionUtil();
-
- String updateInfraRequest = """
+ vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
+ execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest)
+ msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
+ }
+
+ /**
+ * Prepare a Request for updating the DB for this Infra request.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepDbInfraDbRequest(DelegateExecution execution, isDebugLogEnabled) {
+
+ def requestId = execution.getVariable('UPDVfModVol_requestId')
+
+ String updateInfraRequest = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:req="http://org.onap.so/requestsdb">
<soapenv:Header/>
@@ -456,18 +390,18 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
</soapenv:Envelope>
"""
- updateInfraRequest = utils.formatXml(updateInfraRequest)
- execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest)
- msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest)
- }
+ updateInfraRequest = utils.formatXml(updateInfraRequest)
+ execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest)
+ msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest)
+ }
- /**
- * Build a "CompletionHandler" request.
- * @param execution The flow's execution instance.
- */
- public void prepCompletionHandlerRequest(DelegateExecution execution, requestId, action, source, isDebugLogEnabled) {
+ /**
+ * Build a "CompletionHandler" request.
+ * @param execution The flow's execution instance.
+ */
+ public void prepCompletionHandlerRequest(DelegateExecution execution, requestId, action, source, isDebugLogEnabled) {
- String content = """
+ String content = """
<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
xmlns:ns="http://org.onap/so/request/types/v1">
<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
@@ -476,91 +410,90 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
<source>${MsoUtils.xmlEscape(source)}</source>
</request-info>
<aetgt:mso-bpel-name>BPMN VF Module Volume action: UPDATE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>
+ </aetgt:MsoCompletionRequest>
"""
- content = utils.formatXml(content)
- msoLogger.debug('Request for Completion Handler:\n' + content)
- execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content)
- }
-
+ content = utils.formatXml(content)
+ msoLogger.debug('Request for Completion Handler:\n' + content)
+ execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content)
+ }
- /**
- * Build a "FalloutHandler" request.
- * @param execution The flow's execution instance.
- */
- public void prepFalloutHandler(DelegateExecution execution, isDebugLogEnabled) {
- def requestId = execution.getVariable('UPDVfModVol_requestId')
- def source = execution.getVariable('UPDVfModVol_source')
+ /**
+ * Build a "FalloutHandler" request.
+ * @param execution The flow's execution instance.
+ */
+ public void prepFalloutHandler(DelegateExecution execution, isDebugLogEnabled) {
+ def requestId = execution.getVariable('UPDVfModVol_requestId')
+ def source = execution.getVariable('UPDVfModVol_source')
- String requestInfo = """
+ String requestInfo = """
<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
<request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
<action>UPDATE</action>
<source>${MsoUtils.xmlEscape(source)}</source>
</request-info>"""
- def WorkflowException workflowException = execution.getVariable("WorkflowException")
- def errorResponseCode = workflowException.getErrorCode()
- def errorResponseMsg = workflowException.getErrorMessage()
- def encErrorResponseMsg = ""
- if (errorResponseMsg != null) {
- encErrorResponseMsg = errorResponseMsg
- }
+ WorkflowException workflowException = execution.getVariable("WorkflowException")
+ def errorResponseCode = workflowException.getErrorCode()
+ def errorResponseMsg = workflowException.getErrorMessage()
+ def encErrorResponseMsg = ""
+ if (errorResponseMsg != null) {
+ encErrorResponseMsg = errorResponseMsg
+ }
- String content = """
+ String content = """
<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
xmlns:reqtype="http://org.onap/so/request/types/v1"
xmlns:msoservtypes="http://org.onap/so/request/types/v1"
- xmlns:structuredtypes="http://org.onap/so/structured/types/v1">
+ xmlns:structuredtypes="http://org.onap/so/structured/types/v1">
${requestInfo}
<sdncadapterworkflow:WorkflowException>
<sdncadapterworkflow:ErrorMessage>${MsoUtils.xmlEscape(encErrorResponseMsg)}</sdncadapterworkflow:ErrorMessage>
<sdncadapterworkflow:ErrorCode>${MsoUtils.xmlEscape(errorResponseCode)}</sdncadapterworkflow:ErrorCode>
- </sdncadapterworkflow:WorkflowException>
+ </sdncadapterworkflow:WorkflowException>
</sdncadapterworkflow:FalloutHandlerRequest>
"""
- content = utils.formatXml(content)
- msoLogger.debug('Request for Fallout Handler:\n' + content)
- execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content)
- }
-
- /**
- * Create a WorkflowException for the error case where the Tenant Id from
- * AAI did not match the Tenant Id in the incoming request.
- * @param execution The flow's execution instance.
- */
- public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
-
- def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
- def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
- def tenantId = execution.getVariable('UPDVfModVol_tenantId')
- def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId')
-
- def String errorMessage = "TenantId " + tenantId + " in incoming request does not match Tenant Id " + volumeGroupTenantId +
- " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception");
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
-
- /**
- * Create a WorkflowException for the error case where the Personal Model Id from
- * AAI did not match the model invariant ID in the incoming request.
- * @param execution The flow's execution instance.
- */
- public void handlePersonaModelIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
-
- def modelInvariantId = execution.getVariable('UPDVfModVol_modelInvariantId')
- def personaModelId = execution.getVariable('UPDVfModVol_personaModelId')
-
- def String errorMessage = "Model Invariant ID " + modelInvariantId + " in incoming request does not match persona model ID " + personaModelId +
- " retrieved from AAI for Volume Group Id "
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception");
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
+ content = utils.formatXml(content)
+ msoLogger.debug('Request for Fallout Handler:\n' + content)
+ execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content)
+ }
+
+ /**
+ * Create a WorkflowException for the error case where the Tenant Id from
+ * AAI did not match the Tenant Id in the incoming request.
+ * @param execution The flow's execution instance.
+ */
+ public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
+
+ def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
+ def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
+ def tenantId = execution.getVariable('UPDVfModVol_tenantId')
+ def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId')
+
+ String errorMessage = "TenantId " + tenantId + " in incoming request does not match Tenant Id " + volumeGroupTenantId +
+ " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
+ }
+
+ /**
+ * Create a WorkflowException for the error case where the Personal Model Id from
+ * AAI did not match the model invariant ID in the incoming request.
+ * @param execution The flow's execution instance.
+ */
+ public void handlePersonaModelIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
+
+ def modelInvariantId = execution.getVariable('UPDVfModVol_modelInvariantId')
+ def personaModelId = execution.getVariable('UPDVfModVol_personaModelId')
+
+ String errorMessage = "Model Invariant ID " + modelInvariantId + " in incoming request does not match persona model ID " + personaModelId +
+ " retrieved from AAI for Volume Group Id "
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
index 3c08779513..e7baccd460 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy
@@ -18,33 +18,28 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.vcpe.scripts;
+package org.onap.so.bpmn.vcpe.scripts
-import org.onap.so.bpmn.common.scripts.*;
-import org.onap.so.bpmn.common.scripts.AaiUtil
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.AllottedResource
+import org.onap.so.bpmn.common.scripts.*
import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.rest.APIResponse
-
-import java.util.UUID;
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.springframework.web.util.UriUtils;
-import static org.apache.commons.lang3.StringUtils.*
-
-import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
-import org.onap.so.client.aai.AAIResourcesClient
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.AAIResourcesClient
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
-import org.json.JSONObject
+import org.onap.so.logger.MessageEnum
+import org.onap.so.logger.MsoLogger
+
import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.UriBuilder
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
/**
* This groovy class supports the <class>DoCreateAllottedResourceBRG.bpmn</class> process.
*
@@ -233,19 +228,13 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
String serviceInstanceId = execution.getVariable('parentServiceInstanceId')
AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.NODES_QUERY, "").queryParam("search-node-type", "service-instance").queryParam("filter", "service-instance-id:EQUALS:" + serviceInstanceId)
- String json = resourceClient.get(uri).getJson()
-
- JSONObject obj = new JSONObject(json)
- if(obj.has("result-data")){
- JSONObject ob = obj.getJSONArray("result-data").getJSONObject(0)
- String resourceLink = ob.getString("resource-link")
-
- String[] split = resourceLink.split("/aai/")
- String siRelatedLink = "/aai/" + split[1]
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
- execution.setVariable("PSI_resourceLink", resourceLink)
- }else{
+ try {
+ //just to make sure the serviceInstance exists
+ uri.build()
+ execution.setVariable("PSI_resourceLink", uri)
+ } catch (NotFoundException e) {
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
}
@@ -264,7 +253,6 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
msoLogger.trace("start createAaiAR")
- String msg = ""
String allottedResourceId = execution.getVariable("allottedResourceId")
if (isBlank(allottedResourceId))
@@ -272,100 +260,32 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
allottedResourceId = UUID.randomUUID().toString()
execution.setVariable("allottedResourceId", allottedResourceId)
}
- String arUrl = ""
try {
- //AAI PUT
- AaiUtil aaiUriUtil = new AaiUtil(this)
- String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
- String siResourceLink= execution.getVariable("PSI_resourceLink")
-
- String siUri = ""
- msoLogger.debug("PSI_resourceLink:" + siResourceLink)
-
- if(!isBlank(siResourceLink)) {
- msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink)
- String[] split = siResourceLink.split("/aai/")
- siUri = "/aai/" + split[1]
- }
- else
- {
- msg = "Parent Service Link in AAI is null"
- msoLogger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
- execution.setVariable("aaiARPath", arUrl)
- msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl)
+ AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink")
- String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(siResourceLink, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId)
+ execution.setVariable("aaiARPath", allottedResourceUri.build().toString());
String arType = execution.getVariable("allottedResourceType")
String arRole = execution.getVariable("allottedResourceRole")
String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
+
String arModelInfo = execution.getVariable("allottedResourceModelInfo")
String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
- String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
- if (modelInvariantId == null) {
- modelInvariantId = ""
- }
- if (modelVersionId == null) {
- modelVersionId = ""
- }
- if (modelCustomizationId == null) {
- modelCustomizationId = ""
- }
-
- String payload =
- """<allotted-resource xmlns="${namespace}">
- <id>${MsoUtils.xmlEscape(allottedResourceId)}</id>
- <description></description>
- <type>${MsoUtils.xmlEscape(arType)}</type>
- <role>${MsoUtils.xmlEscape(arRole)}</role>
- <selflink></selflink>
- <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantId)}</model-invariant-id>
- <model-version-id>${MsoUtils.xmlEscape(modelVersionId)}</model-version-id>
- <model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</model-customization-id>
- <orchestration-status>PendingCreate</orchestration-status>
- <operation-status></operation-status>
- <relationship-list>
- <relationship>
- <related-to>service-instance</related-to>
- <related-link>${MsoUtils.xmlEscape(CSI_resourceLink)}</related-link>
- </relationship>
- </relationship-list>
- </allotted-resource>""".trim()
-
- execution.setVariable("AaiARPayload", payload)
- msoLogger.debug(" payload to create AllottedResource in AAI:" + "\n" + payload)
-
- APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
- int responseCode = response.getStatusCode()
- msoLogger.debug("AllottedResource AAI PUT responseCode:" + responseCode)
-
- String aaiResponse = response.getResponseBodyAsString()
- msoLogger.debug("AllottedResource AAI PUT responseStr:" + aaiResponse)
-
- //200 OK 201 CREATED 202 ACCEPTED
- if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
- {
- msoLogger.debug("AAI PUT AllottedResource received a Good Response")
- }
- else{
- msoLogger.debug("AAI Put AllottedResouce received a Bad Response Code: " + responseCode)
- exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
- throw new BpmnError("MSOWorkflowException")
- }
- }catch(BpmnError b){
- msoLogger.debug("Rethrowing MSOWorkflowException")
- throw b
- } catch (Exception ex) {
- msg = "Exception in createAaiAR " + ex.getMessage()
- msoLogger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ AllottedResource resource = new AllottedResource()
+ resource.setId(allottedResourceId)
+ resource.setType(arType)
+ resource.setRole(arRole)
+ resource.setModelInvariantId(modelInvariantId)
+ resource.setModelVersionId(modelVersionId)
+ getAAIClient().create(allottedResourceUri, resource)
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(CSI_resourceLink).build())
+ getAAIClient().connect(allottedResourceUri,serviceInstanceUri)
+ }catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage())
}
//start rollback set up
@@ -376,7 +296,6 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
- rollbackData.put(Prefix, "aaiARPath", arUrl)
execution.setVariable("rollbackData", rollbackData)
msoLogger.trace("end createAaiAR")
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
index 4d4f11c3e5..856c893b47 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy
@@ -18,27 +18,21 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.vcpe.scripts;
+package org.onap.so.bpmn.vcpe.scripts
-import org.onap.so.bpmn.common.scripts.*;
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.AllottedResource
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.common.scripts.AllottedResourceUtils
import org.onap.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
-import org.onap.so.rest.APIResponse
-
-import java.util.UUID;
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.springframework.web.util.UriUtils;
-import static org.apache.commons.lang3.StringUtils.*
-
+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.isBlank
+
/**
* This groovy class supports the <class>CreateAllottedResourceBRGRollback.bpmn</class> process.
*
@@ -141,12 +135,12 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc
AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
String aaiARPath = execution.getVariable("aaiARPath")
msoLogger.debug(" aaiARPath:" + aaiARPath)
- String ar = null; //need this for getting resourceVersion for delete
+ Optional<AllottedResource> ar = Optional.empty(); //need this for getting resourceVersion for delete
if (!isBlank(aaiARPath))
{
ar = arUtils.getARbyLink(execution, aaiARPath, "")
}
- if (isBlank(ar))
+ if(!ar.isPresent())
{
msg = "AR not found in AAI at:" + aaiARPath
msoLogger.debug(msg)
@@ -202,13 +196,8 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc
try{
msoLogger.trace("start deleteAaiAR")
AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
- String ar = null //need to get resource-version
String arLink = execution.getVariable("aaiARPath")
- if (!isBlank(arLink))
- {
- ar = arUtils.getARbyLink(execution, arLink, "")
- }
- arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8"))
+ arUtils.deleteAR(execution, arLink )
} catch (BpmnError e) {
throw e;
}catch(Exception ex){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
index 5f9b4b8ecd..56fa3a6730 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy
@@ -18,26 +18,25 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.vcpe.scripts;
+package org.onap.so.bpmn.vcpe.scripts
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.AllottedResource
import org.onap.so.bpmn.common.scripts.*;
-import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.rest.APIResponse
-
-import java.util.UUID;
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.springframework.web.util.UriUtils;
-import static org.apache.commons.lang3.StringUtils.*
-
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import javax.ws.rs.core.UriBuilder
+import static org.apache.commons.lang3.StringUtils.isBlank
+
/**
* This groovy class supports the <class>DoCreateAllottedResourceTXC.bpmn</class> process.
*
@@ -191,7 +190,6 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
msoLogger.trace("start createAaiAR")
- String msg = ""
String allottedResourceId = execution.getVariable("allottedResourceId")
if (isBlank(allottedResourceId))
@@ -199,35 +197,13 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
allottedResourceId = UUID.randomUUID().toString()
execution.setVariable("allottedResourceId", allottedResourceId)
}
- String arUrl = ""
try {
- //AAI PUT
- AaiUtil aaiUriUtil = new AaiUtil(this)
- String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
- String siResourceLink= execution.getVariable("PSI_resourceLink")
-
- String siUri = ""
- msoLogger.debug("PSI_resourceLink:" + siResourceLink)
-
- if(!isBlank(siResourceLink)) {
- msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink)
- String[] split = siResourceLink.split("/aai/")
- siUri = "/aai/" + split[1]
- }
- else
- {
- msg = "Parent Service Link in AAI is null"
- msoLogger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
- execution.setVariable("aaiARPath", arUrl)
- msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl)
+ AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink")
- String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(siResourceLink, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId)
+ execution.setVariable("aaiARPath", allottedResourceUri.build().toString());
String arType = execution.getVariable("allottedResourceType")
String arRole = execution.getVariable("allottedResourceRole")
String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
@@ -235,65 +211,19 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
msoLogger.debug("arModelInfo is:\n" + arModelInfo)
String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
- String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
-
- if (modelInvariantId == null) {
- modelInvariantId = ""
- }
- if (modelVersionId == null) {
- modelVersionId = ""
- }
- if (modelCustomizationId == null) {
- modelCustomizationId = ""
- }
- String payload =
- """<allotted-resource xmlns="${namespace}">
- <id>${MsoUtils.xmlEscape(allottedResourceId)}</id>
- <description></description>
- <type>${MsoUtils.xmlEscape(arType)}</type>
- <role>${MsoUtils.xmlEscape(arRole)}</role>
- <selflink></selflink>
- <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantId)}</model-invariant-id>
- <model-version-id>${MsoUtils.xmlEscape(modelVersionId)}</model-version-id>
- <model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</model-customization-id>
- <orchestration-status>PendingCreate</orchestration-status>
- <operation-status></operation-status>
- <relationship-list>
- <relationship>
- <related-to>service-instance</related-to>
- <related-link>${MsoUtils.xmlEscape(CSI_resourceLink)}</related-link>
- </relationship>
- </relationship-list>
- </allotted-resource>""".trim()
-
- execution.setVariable("AaiARPayload", payload)
- msoLogger.debug(" payload to create AllottedResource in AAI:" + "\n" + payload)
-
- APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
- int responseCode = response.getStatusCode()
- msoLogger.debug("AllottedResource AAI PUT responseCode:" + responseCode)
-
- String aaiResponse = response.getResponseBodyAsString()
- msoLogger.debug("AllottedResource AAI PUT responseStr:" + aaiResponse)
-
- //200 OK 201 CREATED 202 ACCEPTED
- if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
- {
- msoLogger.debug("AAI PUT AllottedResource received a Good Response")
- }
- else{
- msoLogger.debug("AAI Put AllottedResouce received a Bad Response Code: " + responseCode)
- exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
- throw new BpmnError("MSOWorkflowException")
- }
- }catch(BpmnError b){
- msoLogger.debug("Rethrowing MSOWorkflowException")
- throw b
- } catch (Exception ex) {
- msg = "Exception in createAaiAR " + ex.getMessage()
- msoLogger.debug(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ AllottedResource resource = new AllottedResource()
+ resource.setId(allottedResourceId)
+ resource.setType(arType)
+ resource.setRole(arRole)
+ resource.setModelInvariantId(modelInvariantId)
+ resource.setModelVersionId(modelVersionId)
+ getAAIClient().create(allottedResourceUri, resource)
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(CSI_resourceLink).build())
+ getAAIClient().connect(allottedResourceUri,serviceInstanceUri)
+
+ }catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage())
}
//start rollback set up
@@ -304,7 +234,6 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
- rollbackData.put(Prefix, "aaiARPath", arUrl)
execution.setVariable("rollbackData", rollbackData)
msoLogger.trace("end createAaiAR")
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
index 24b919524f..aa88c2ac68 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
@@ -18,8 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.vcpe.scripts;
+package org.onap.so.bpmn.vcpe.scripts
+import org.onap.aai.domain.yang.AllottedResource;
import org.onap.so.bpmn.common.scripts.*;
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.core.WorkflowException
@@ -141,12 +142,12 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc
AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
String aaiARPath = execution.getVariable("aaiARPath")
msoLogger.debug(" aaiARPath:" + aaiARPath)
- String ar = null; //need this for getting resourceVersion for delete
+ Optional<AllottedResource> ar = Optional.empty(); //need this for getting resourceVersion for delete
if (!isBlank(aaiARPath))
{
ar = arUtils.getARbyLink(execution, aaiARPath, "")
}
- if (isBlank(ar))
+ if (!ar.isPresent())
{
msg = "AR not found in AAI at:" + aaiARPath
msoLogger.debug(msg)
@@ -202,13 +203,8 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc
try{
msoLogger.trace("start deleteAaiAR")
AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
- String ar = null //need to get resource-version
String arLink = execution.getVariable("aaiARPath")
- if (!isBlank(arLink))
- {
- ar = arUtils.getARbyLink(execution, arLink, "")
- }
- arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8"))
+ arUtils.deleteAR(execution, arLink)
} catch (BpmnError e) {
throw e;
}catch(Exception ex){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
index a5125fea73..e39edffe68 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy
@@ -18,28 +18,22 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.vcpe.scripts;
+package org.onap.so.bpmn.vcpe.scripts
-import org.onap.so.bpmn.common.scripts.*;
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.onap.so.bpmn.core.WorkflowException
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.bpmn.common.scripts.AllottedResourceUtils
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.common.scripts.AaiUtil
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
-import org.onap.so.rest.APIResponse
-
-import java.util.UUID;
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.springframework.web.util.UriUtils;
-import static org.apache.commons.lang3.StringUtils.*
-import org.onap.so.bpmn.core.UrnPropertiesReader;
-
+import org.onap.so.bpmn.core.UrnPropertiesReader
+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.isBlank
+
/**
* This groovy class supports the <class>DoDeleteAllottedResourceBRG.bpmn</class> process.
*
@@ -116,20 +110,18 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{
String allottedResourceId = execution.getVariable("allottedResourceId")
- AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
- String ar = arUtils.getARbyId(execution, allottedResourceId)
+ AllottedResourceUtils arUtils = getAllottedResourceUtils()
+ boolean ifExistsAR = arUtils.ifExistsAR(execution, allottedResourceId)
String errorMsg = ""
- if (isBlank(ar)) // AR was !found
- {
- errorMsg = "Allotted resource not found in AAI with AllottedResourceId:" + allottedResourceId
- }
- else
- {
+ if (ifExistsAR){
String aaiARPath = execution.getVariable("aaiARPath")
String parentServiceInstanceId = arUtils.getPSIFmARLink(execution, aaiARPath)
execution.setVariable("parentServiceInstanceId", parentServiceInstanceId)
}
+ else{
+ errorMsg = "Allotted resource not found in AAI with AllottedResourceId:" + allottedResourceId
+ }
if (!isBlank(errorMsg)) {
msoLogger.debug(errorMsg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
@@ -349,13 +341,8 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{
try{
AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
- String ar = null //need to get resource-version again
String arLink = execution.getVariable("aaiARPath")
- if (!isBlank(arLink))
- {
- ar = arUtils.getARbyLink(execution, arLink, "")
- }
- arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8"))
+ arUtils.deleteAR(execution, arLink)
} catch (BpmnError e) {
throw e;
}catch(Exception ex){
@@ -365,4 +352,8 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{
msoLogger.trace("end deleteAaiAR")
}
+ public AllottedResourceUtils getAllottedResourceUtils(){
+ return new AllottedResourceUtils(this)
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
index 7ce606e685..f305a7ad0d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy
@@ -18,27 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.vcpe.scripts;
+package org.onap.so.bpmn.vcpe.scripts
-import org.onap.so.bpmn.common.scripts.*;
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.onap.so.bpmn.core.WorkflowException
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.bpmn.common.scripts.AllottedResourceUtils
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.common.scripts.AaiUtil
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
-import org.onap.so.rest.APIResponse
-
-import java.util.UUID;
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.springframework.web.util.UriUtils;
-import static org.apache.commons.lang3.StringUtils.*
-import org.onap.so.bpmn.core.UrnPropertiesReader;
-
+import org.onap.so.bpmn.core.UrnPropertiesReader
+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.isBlank
/**
* This groovy class supports the <class>DoDeleteAllottedResourceTXC.bpmn</class> process.
@@ -116,20 +109,18 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{
String allottedResourceId = execution.getVariable("allottedResourceId")
- AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
- String ar = arUtils.getARbyId(execution, allottedResourceId)
+ AllottedResourceUtils arUtils = getAllottedResourceUtils()
+ boolean ifExistsAR = arUtils.ifExistsAR(execution, allottedResourceId)
String errorMsg = ""
- if (isBlank(ar)) // AR was !found
- {
- errorMsg = "Allotted resource not found in AAI with AllottedResourceId:" + allottedResourceId
- }
- else
- {
+ if (ifExistsAR){
String aaiARPath = execution.getVariable("aaiARPath")
String parentServiceInstanceId = arUtils.getPSIFmARLink(execution, aaiARPath)
execution.setVariable("parentServiceInstanceId", parentServiceInstanceId)
}
+ else{
+ errorMsg = "Allotted resource not found in AAI with AllottedResourceId:" + allottedResourceId
+ }
if (!isBlank(errorMsg)) {
msoLogger.debug(errorMsg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
@@ -138,6 +129,10 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{
}
+ public AllottedResourceUtils getAllottedResourceUtils(){
+ return new AllottedResourceUtils(this)
+ }
+
// aaiARPath set during query (existing AR)
public void updateAaiAROrchStatus(DelegateExecution execution, String status){
msoLogger.trace("start updateAaiAROrchStatus")
@@ -349,13 +344,8 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{
try{
AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
- String ar = null //need to get resource-version again
String arLink = execution.getVariable("aaiARPath")
- if (!isBlank(arLink))
- {
- ar = arUtils.getARbyLink(execution, arLink, "")
- }
- arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8"))
+ arUtils.deleteAR(execution, arLink)
} catch (BpmnError e) {
throw e;
}catch(Exception ex){
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
index e753f79ebd..7f1c2fd9b1 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.infrastructure.workflow.service;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -236,12 +235,7 @@ public class ServicePluginFactory {
@SuppressWarnings("unchecked")
private List<Object> queryAccessTPbyLocationFromInventoryOSS(String locationAddress) {
String url = getInventoryOSSEndPoint();
- try {
- url += "/oss/inventory?location=" + UriUtils.encode(locationAddress,"UTF-8");
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ url += "/oss/inventory?location=" + UriUtils.encode(locationAddress,"UTF-8");
String responseContent = sendRequest(url, "GET", "");
List<Object> accessTPs = new ArrayList<Object>();
if (null != responseContent) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy
new file mode 100644
index 0000000000..2eb4c9c408
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResourceTest.groovy
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.junit.Before
+import org.junit.Test
+import org.mockito.Mockito
+import org.mockito.MockitoAnnotations
+import org.mockito.Spy
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.NotFoundException
+
+import static org.junit.Assert.assertEquals
+import static org.mockito.Matchers.isA
+import static org.mockito.Mockito.doNothing
+import static org.mockito.Mockito.doThrow
+import static org.mockito.Mockito.when
+
+class CreateVFCNSResourceTest extends MsoGroovyTest{
+
+ @Spy
+ CreateVFCNSResource createVFCNSResource
+
+ @Before
+ void init() throws IOException {
+ super.init("CreateVFCNSResource")
+ MockitoAnnotations.initMocks(this);
+ when(createVFCNSResource.getAAIClient()).thenReturn(client)
+ }
+
+ @Test
+ void testaddNSRelationship(){
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalSubscriberId1")
+ when(mockExecution.getVariable("serviceType")).thenReturn("serviceType")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("serviceInstanceId")
+ when(mockExecution.getVariable("nsInstanceId")).thenReturn("nsInstanceId")
+ doNothing().when(client).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class))
+ createVFCNSResource.addNSRelationship(mockExecution)
+ AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,"globalSubscriberId1","serviceType","nsInstanceId")
+ AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,"globalSubscriberId1","serviceType","serviceInstanceId")
+ Mockito.verify(client).connect(nsUri,relatedServiceUri)
+ }
+
+ @Test
+ void testaddNSRelationshipError(){
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalSubscriberId1")
+ when(mockExecution.getVariable("serviceType")).thenReturn("serviceType")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("serviceInstanceId")
+ when(mockExecution.getVariable("nsInstanceId")).thenReturn("nsInstanceId")
+ doThrow(new NotFoundException("Error creating relationship")).when(client).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class))
+ try {
+ createVFCNSResource.addNSRelationship(mockExecution)
+ } catch (BpmnError ex) {
+ assertEquals(ex.getErrorCode(),"MSOWorkflowException")
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy
index 2b437d875e..161075f66e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy
@@ -20,22 +20,33 @@
package org.onap.so.bpmn.infrastructure.scripts
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.junit.Before
import org.junit.Ignore
+import org.junit.Rule
import org.junit.Test
+import org.junit.rules.ExpectedException
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.MockitoAnnotations
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.ResultData
+import org.onap.aai.domain.yang.SearchResults
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
import static org.junit.Assert.assertEquals
import static org.mockito.Mockito.*
-@RunWith(MockitoJUnitRunner.class)
class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
def jsonRequest = """
{
"requestDetails": {
@@ -154,6 +165,7 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest {
@Before
public void init()
{
+ super.init("CreateVfModuleVolumeInfraV1")
MockitoAnnotations.initMocks(this)
}
@@ -162,8 +174,6 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest {
@Ignore
public void testPreProcessRequest() {
- ExecutionEntity mockExecution = setupMock('CreateVfModuleVolumeInfraV1')
-
when(mockExecution.getVariable("prefix")).thenReturn('CVMVINFRAV1_')
when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonRequest)
when(mockExecution.getVariable("serviceInstanceId")).thenReturn('')
@@ -191,7 +201,6 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest {
@Test
public void testPostProcessResponse() {
- ExecutionEntity mockExecution = setupMock('CreateVfModuleVolumeInfraV1')
when(mockExecution.getVariable("dbReturnCode")).thenReturn('000')
when(mockExecution.getVariable("CVMVINFRAV1_createDBResponse")).thenReturn('')
when(mockExecution.getVariable("mso-request-id")).thenReturn('1234')
@@ -203,6 +212,23 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest {
verify(mockExecution).setVariable('CVMVINFRAV1_Success', true)
verify(mockExecution).setVariable('CVMVINFRAV1_CompleteMsoProcessRequest', completeMsoRequestXml)
}
-
+ @Test
+ public void testcallRESTQueryAAIServiceInstance() {
+ CreateVfModuleVolumeInfraV1 createVfModuleVolumeInfraV1 = spy(CreateVfModuleVolumeInfraV1.class)
+ when(createVfModuleVolumeInfraV1.getAAIClient()).thenReturn(client)
+ AAIResultWrapper resultWrapper = new AAIResultWrapper(SEARCH_RESULT_AAI_WITH_RESULTDATA)
+ when(client.get(isA(AAIResourceUri.class))).thenReturn(resultWrapper)
+ createVfModuleVolumeInfraV1.callRESTQueryAAIServiceInstance(mockExecution,true)
+ }
+
+ @Test
+ public void testcallRESTQueryAAIServiceInstance_NoData() {
+ CreateVfModuleVolumeInfraV1 createVfModuleVolumeInfraV1 = spy(CreateVfModuleVolumeInfraV1.class)
+ when(createVfModuleVolumeInfraV1.getAAIClient()).thenReturn(client)
+ AAIResultWrapper resultWrapper = new AAIResultWrapper("{}")
+ when(client.get(isA(AAIResourceUri.class))).thenReturn(resultWrapper)
+ thrown.expect(BpmnError.class)
+ createVfModuleVolumeInfraV1.callRESTQueryAAIServiceInstance(mockExecution,true)
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy
index 0bce32716f..6ed5bfe89a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy
@@ -21,20 +21,50 @@
package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.so.bpmn.common.scripts.DeleteAAIVfModule
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException
+import javax.ws.rs.NotFoundException
+
+import static org.mockito.Matchers.eq
+import static org.mockito.Mockito.doNothing
+import static org.mockito.Mockito.doThrow
+import static org.mockito.Mockito.times
import static org.mockito.Mockito.verify
import static org.mockito.Mockito.when
-@RunWith(MockitoJUnitRunner.class)
class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest {
+ @Spy
+ DeleteVfModuleVolumeInfraV1 deleteVfModuleVolumeInfraV1 ;
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Before
+ void init() throws IOException {
+ super.init("DeleteVfModuleVolumeInfraV1")
+ MockitoAnnotations.initMocks(this);
+ when(deleteVfModuleVolumeInfraV1.getAAIClient()).thenReturn(client)
+ }
+
def deleteVnfAdapterRequestXml = """<deleteVolumeGroupRequest>
<cloudSiteId>RDM2WAGPLCP</cloudSiteId>
<tenantId>fba1bd1e195a404cacb9ce17a9b2b421</tenantId>
@@ -90,13 +120,7 @@ class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest {
</aetgt:WorkflowException>
</aetgt:FalloutHandlerRequest>"""
- @Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- }
-
-
+
@Test
public void testPrepareVnfAdapterDeleteRequest() {
@@ -164,4 +188,110 @@ class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest {
verify(mockExecution).setVariable("DELVfModVol_Success", false)
verify(mockExecution).setVariable("DELVfModVol_FalloutHandlerRequest", falloutHandlerRequestXml)
}
+
+ @Test
+ void testQueryAAIForVolumeGroup(){
+ when(mockExecution.getVariable("DELVfModVol_volumeGroupId")).thenReturn("volumeGroupId1")
+ when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1")
+ AAIResultWrapper wrapper = mockVolumeGroupWrapper("region1", "volumeGroupId1", "__files/AAI/VolumeGroupWithTenant.json")
+ Optional<VolumeGroup> volumeGroupOp = wrapper.asBean(VolumeGroup.class)
+ deleteVfModuleVolumeInfraV1.queryAAIForVolumeGroup(mockExecution, true)
+ verify(mockExecution).setVariable("DELVfModVol_volumeGroupTenantId", "Tenant123")
+ }
+
+ @Test
+ void testQueryAAIForVolumeGroupWithVfModule(){
+ when(mockExecution.getVariable("DELVfModVol_volumeGroupId")).thenReturn("volumeGroupId1")
+ when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1")
+ AAIResultWrapper wrapper = mockVolumeGroupWrapper("region1", "volumeGroupId1", "__files/AAI/VolumeGroupWithVfModule.json")
+ try {
+ deleteVfModuleVolumeInfraV1.queryAAIForVolumeGroup(mockExecution, true)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(2500, workflowException.getErrorCode())
+ Assert.assertEquals("Volume Group volumeGroupId1 currently in use - found vf-module relationship.", workflowException.getErrorMessage())
+ }
+
+ @Test
+ void testQueryAAIForVolumeGroupNoTenant(){
+ when(mockExecution.getVariable("DELVfModVol_volumeGroupId")).thenReturn("volumeGroupId1")
+ when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1")
+ AAIResultWrapper wrapper = mockVolumeGroupWrapper("region1", "volumeGroupId1", "__files/AAI/VolumeGroup.json")
+ try {
+ deleteVfModuleVolumeInfraV1.queryAAIForVolumeGroup(mockExecution, true)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(2500, workflowException.getErrorCode())
+ Assert.assertEquals( "Could not find Tenant Id element in Volume Group with Volume Group Id volumeGroupId1", workflowException.getErrorMessage())
+ }
+
+ @Test
+ void testQueryAAIForVolumeGroupNoId(){
+ when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1")
+ try {
+ deleteVfModuleVolumeInfraV1.queryAAIForVolumeGroup(mockExecution, true)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(2500, workflowException.getErrorCode())
+ Assert.assertEquals("volume-group-id is not provided in the request", workflowException.getErrorMessage())
+ }
+
+ @Test
+ void testDeleteVolGrpId(){
+ VolumeGroup volumeGroup = new VolumeGroup()
+ volumeGroup.setVolumeGroupId("volumeGroupId1")
+ when(mockExecution.getVariable("DELVfModVol_queryAAIVolGrpResponse")).thenReturn(volumeGroup)
+ when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "region1","volumeGroupId1")
+ doNothing().when(client).delete(resourceUri)
+ deleteVfModuleVolumeInfraV1.deleteVolGrpId(mockExecution, true)
+ verify(client).delete(resourceUri)
+ }
+
+ @Test
+ void testDeleteVolGrpIdNotFound(){
+ VolumeGroup volumeGroup = new VolumeGroup()
+ volumeGroup.setVolumeGroupId("volumeGroupId1")
+ when(mockExecution.getVariable("DELVfModVol_queryAAIVolGrpResponse")).thenReturn(volumeGroup)
+ when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "region1","volumeGroupId1")
+ doThrow(new NotFoundException("Not Found")).when(client).delete(resourceUri)
+ try {
+ deleteVfModuleVolumeInfraV1.deleteVolGrpId(mockExecution, true)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(2500, workflowException.getErrorCode())
+ Assert.assertEquals("Volume group volumeGroupId1 not found for delete in AAI Response code: 404", workflowException.getErrorMessage())
+ }
+
+ @Test
+ void testDeleteVolGrpIdError(){
+ VolumeGroup volumeGroup = new VolumeGroup()
+ volumeGroup.setVolumeGroupId("volumeGroupId1")
+ when(mockExecution.getVariable("DELVfModVol_queryAAIVolGrpResponse")).thenReturn(volumeGroup)
+ when(mockExecution.getVariable("DELVfModVol_aicCloudRegion")).thenReturn("region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "region1","volumeGroupId1")
+ doThrow(new GraphInventoryUriComputationException("Error")).when(client).delete(resourceUri)
+ try {
+ deleteVfModuleVolumeInfraV1.deleteVolGrpId(mockExecution, true)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(5000, workflowException.getErrorCode())
+ Assert.assertEquals("Received error from A&AI ()", workflowException.getErrorMessage())
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy
index d8a82acfa7..fc8bd0da8a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy
@@ -20,53 +20,54 @@
package org.onap.so.bpmn.infrastructure.scripts
-import com.github.tomakehurst.wiremock.junit.WireMockRule
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+import static com.shazam.shazamcrest.MatcherAssert.assertThat
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Before
-import org.junit.Rule
import org.junit.Test
-import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
-import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
-import org.onap.so.bpmn.common.scripts.utils.XmlComparator
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
-import static org.mockito.Mockito.*
/**
* @author sushilma
* @since January 10, 2018
*/
-@RunWith(MockitoJUnitRunner.class)
-class DoCreateE2EServiceInstanceTest {
+class DoCreateE2EServiceInstanceTest extends MsoGroovyTest{
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
@Before
- public void init() throws IOException {
- MockitoAnnotations.initMocks(this);
+ public void init() {
+ super.init("DoCreateE2EServiceInstance")
}
-
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
-
- String expectedServiceInstanceData = """ <service-instance xmlns="http://org.openecomp.aai.inventory/v8">
- <service-instance-id>1234</service-instance-id>
- <service-instance-name>volte-service</service-instance-name>
- <service-type>voLTE type</service-type>
- <service-role>voLTE role</service-role>
- <orchestration-status>Created</orchestration-status>
- <model-invariant-id>c1d4305f-cdbd-4bbe-9069-a2f4978fd89e</model-invariant-id>
- <model-version-id>d4df5c27-98a1-4812-a8aa-c17f055b7a3f</model-version-id>
- </service-instance>"""
@Test
public void testPreProcessRequest(){
- ExecutionEntity mockExecution = setupMock()
+ mockData()
+ ServiceInstance expectedServiceInstanceData = getExpectedServiceInstance()
+ DoCreateE2EServiceInstance serviceInstance = new DoCreateE2EServiceInstance()
+ serviceInstance.preProcessRequest(mockExecution)
+ Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture())
+ assertThat(captor.getValue(), sameBeanAs(expectedServiceInstanceData))
+ }
+
+ private ServiceInstance getExpectedServiceInstance() {
+ ServiceInstance expectedServiceInstanceData = new ServiceInstance()
+ expectedServiceInstanceData.setServiceInstanceId("1234")
+ expectedServiceInstanceData.setServiceInstanceName("volte-service")
+ expectedServiceInstanceData.setServiceType("E2E Service")
+ expectedServiceInstanceData.setServiceRole("E2E Service")
+ expectedServiceInstanceData.setOrchestrationStatus("Created")
+ return expectedServiceInstanceData
+ }
+
+ private void mockData() {
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345")
when(mockExecution.getVariable("serviceType")).thenReturn("TRANSPORT")
@@ -76,27 +77,8 @@ class DoCreateE2EServiceInstanceTest {
when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/")
when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8")
- DoCreateE2EServiceInstance obj = new DoCreateE2EServiceInstance()
- obj.preProcessRequest(mockExecution)
- Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture())
- XmlComparator.assertXMLEquals(expectedServiceInstanceData, captor.getValue())
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer')
+ when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn('/testUrl')
}
- private ExecutionEntity setupMock() {
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn("DoCreateE2EServiceInstance")
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateE2EServiceInstance")
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getId()).thenReturn("100")
- when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateE2EServiceInstance")
- when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateE2EServiceInstance")
- when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
- when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
- return mockExecution
- }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy
index 587abbee52..b246caf40e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy
@@ -21,41 +21,35 @@
package org.onap.so.bpmn.infrastructure.scripts
import com.github.tomakehurst.wiremock.junit.WireMockRule
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.ArgumentCaptor
-import org.mockito.Captor
-import org.mockito.Mockito
+import org.junit.rules.ExpectedException
import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
-import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.core.domain.ModelInfo
import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.domain.ServiceInstance
import org.onap.so.bpmn.mock.StubResponseAAI
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
import static org.mockito.Mockito.*
-@RunWith(MockitoJUnitRunner.class)
-class DoCreateServiceInstanceTest {
+class DoCreateServiceInstanceTest extends MsoGroovyTest{
def prefix = "DCRESI_"
@Rule
public WireMockRule wireMockRule = new WireMockRule(28090)
- @Captor
- static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+ @Rule
+ public ExpectedException thrown = ExpectedException.none()
@Before
void init() throws IOException {
- MockitoAnnotations.initMocks(this);
+ super.init("DoCreateServiceInstance")
+ MockitoAnnotations.initMocks(this)
}
@Test
@@ -96,7 +90,6 @@ class DoCreateServiceInstanceTest {
@Test
void testGetAAICustomerById() {
- ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("prefix")).thenReturn(prefix)
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345")
@@ -104,30 +97,41 @@ class DoCreateServiceInstanceTest {
when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
when(mockExecution.getVariable("mso.workflow.custom.DoCreateServiceInstance.aai.version")).thenReturn('8')
StubResponseAAI.MockGetCustomer("12345", "")
- DoCreateServiceInstance obj = new DoCreateServiceInstance()
+ DoCreateServiceInstance obj = spy(DoCreateServiceInstance.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(isA(AAIResourceUri.class))).thenReturn(true)
obj.getAAICustomerById(mockExecution)
+ }
- verify(mockExecution, times(1)).getVariable("aai.endpoint")
+ @Test
+ void testGetAAICustomerById_NoCustFound() {
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.DoCreateServiceInstance.aai.version")).thenReturn('8')
+ StubResponseAAI.MockGetCustomer("12345", "")
+ DoCreateServiceInstance obj = spy(DoCreateServiceInstance.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(isA(AAIResourceUri.class))).thenReturn(false)
+ thrown.expect(BpmnError.class)
+ obj.getAAICustomerById(mockExecution)
}
- private static ExecutionEntity setupMock() {
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn("DoCreateServiceInstance")
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateServiceInstance")
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- // Initialize prerequisite variables
- when(mockExecution.getId()).thenReturn("100")
- when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateServiceInstance")
- when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateServiceInstance")
- when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
- when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
-
- return mockExecution
+ @Test
+ void testGetAAICustomerById_Exception() {
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.DoCreateServiceInstance.aai.version")).thenReturn('8')
+ StubResponseAAI.MockGetCustomer("12345", "")
+ DoCreateServiceInstance obj = spy(DoCreateServiceInstance.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ when(client.exists(isA(AAIResourceUri.class))).thenThrow(Exception.class)
+ thrown.expect(Exception.class)
+ obj.getAAICustomerById(mockExecution)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy
index 6d9d5e5356..52b54a48e8 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy
@@ -21,40 +21,37 @@
package org.onap.so.bpmn.infrastructure.scripts
import com.github.tomakehurst.wiremock.junit.WireMockRule
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Before
import org.junit.Rule
import org.junit.Test
-import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
+import org.mockito.Mockito
import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
-import static com.github.tomakehurst.wiremock.client.WireMock.put
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
-import static org.mockito.Mockito.mock
-import static org.mockito.Mockito.times
-import static org.mockito.Mockito.verify
+import org.mockito.Spy
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import javax.ws.rs.NotFoundException
+import static org.junit.Assert.assertEquals
+import static org.mockito.Matchers.isA
+import static org.mockito.Mockito.doNothing
+import static org.mockito.Mockito.doThrow
import static org.mockito.Mockito.when
-/**
- * @author sushilma
- * @since January 10, 2018
- */
-@RunWith(MockitoJUnitRunner.class)
-class DoCreateVFCNetworkServiceInstanceTest {
+class DoCreateVFCNetworkServiceInstanceTest extends MsoGroovyTest {
+
+ @Spy
+ DoCreateVFCNetworkServiceInstance doCreateVFCNetworkServiceInstance
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090)
@Before
public void init() throws IOException {
- MockitoAnnotations.initMocks(this);
+ super.init("CreateVFCNSResource")
+ MockitoAnnotations.initMocks(this)
+ when(doCreateVFCNetworkServiceInstance.getAAIClient()).thenReturn(client)
}
@Captor
@@ -62,45 +59,29 @@ class DoCreateVFCNetworkServiceInstanceTest {
@Test
public void testAddNSRelationship(){
- ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
when(mockExecution.getVariable("nsInstanceId")).thenReturn("NS12345")
when(mockExecution.getVariable("globalSubscriberId")).thenReturn("MSO_dev")
when(mockExecution.getVariable("serviceType")).thenReturn("MSO-dev-service-type")
when(mockExecution.getVariable("serviceId")).thenReturn("SER12345")
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
- when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC")
- MockPutServiceInstance("MSO_dev", "MSO-dev-service-type", "SER12345");
- DoCreateVFCNetworkServiceInstance DoCreateVFCNetworkServiceInstance = new DoCreateVFCNetworkServiceInstance()
- DoCreateVFCNetworkServiceInstance.addNSRelationship(mockExecution);
- verify(mockExecution, times(1)).getVariable("aai.endpoint")
- verify(mockExecution, times(1)).getVariable("mso.msoKey")
- verify(mockExecution, times(1)).getVariable("aai.auth")
+ doNothing().when(client).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class))
+ doCreateVFCNetworkServiceInstance.addNSRelationship(mockExecution);
+ AAIResourceUri nsUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,"MSO_dev","MSO-dev-service-type","NS12345")
+ AAIResourceUri relatedServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,"MSO_dev","MSO-dev-service-type","SER12345")
+ Mockito.verify(client).connect(nsUri,relatedServiceUri)
}
- private ExecutionEntity setupMock() {
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn("DoCreateVFCNetworkServiceInstance")
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVFCNetworkServiceInstance")
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getId()).thenReturn("100")
- when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateVFCNetworkServiceInstance")
- when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVFCNetworkServiceInstance")
- when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
- when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
- return mockExecution
+ @Test
+ void testaddNSRelationshipError(){
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalSubscriberId1")
+ when(mockExecution.getVariable("serviceType")).thenReturn("serviceType")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("serviceInstanceId")
+ when(mockExecution.getVariable("nsInstanceId")).thenReturn("nsInstanceId")
+ doThrow(new NotFoundException("Error creating relationship")).when(client).connect(isA(AAIResourceUri.class),isA(AAIResourceUri.class))
+ try {
+ doCreateVFCNetworkServiceInstance.addNSRelationship(mockExecution)
+ } catch (BpmnError ex) {
+ assertEquals(ex.getErrorCode(),"MSOWorkflowException")
+ }
}
- public static void MockPutServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId) {
- stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId+"/relationship-list/relationship"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml").withBody("")
- ));
- }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
index c5c6187648..e7ebe23e75 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy
@@ -34,20 +34,34 @@ import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.NetworkPolicies
+import org.onap.aai.domain.yang.NetworkPolicy
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.common.scripts.utils.XmlComparator
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException
+
+import javax.ws.rs.NotFoundException
import static com.github.tomakehurst.wiremock.client.WireMock.*
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
-class DoCreateVfModuleRollbackTest {
+class DoCreateVfModuleRollbackTest extends MsoGroovyTest{
def prefix = "DCVFMR_"
+ @Spy
+ DoCreateVfModuleRollback doCreateVfModuleRollback
+
@Rule
public WireMockRule wireMockRule = new WireMockRule(28090)
@@ -56,7 +70,9 @@ class DoCreateVfModuleRollbackTest {
@Before
void init() throws IOException {
- MockitoAnnotations.initMocks(this);
+ super.init("CreateVFCNSResource")
+ MockitoAnnotations.initMocks(this)
+ when(doCreateVfModuleRollback.getAAIClient()).thenReturn(client)
}
@Test
@@ -149,23 +165,90 @@ class DoCreateVfModuleRollbackTest {
when(mockExecution.getVariable("prefix")).thenReturn(prefix)
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345")
- when(mockExecution.getVariable("mso.workflow.DoCreateVfModuleRollback.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy")
- when(mockExecution.getVariable("mso.workflow.custom.DoCreateVfModuleRollback.aai.version")).thenReturn("8")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
when(mockExecution.getVariable("rollbackData")).thenReturn(new RollbackData())
List fqdnList = new ArrayList()
fqdnList.add("test")
when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList)
- mockData()
- DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback()
- obj.deleteNetworkPoliciesFromAAI(mockExecution)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ uri.queryParam("network-policy-fqdn", "test")
+ NetworkPolicies networkPolicies = new NetworkPolicies();
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("NP1")
+ networkPolicies.getNetworkPolicy().add(networkPolicy)
+ when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies))
+
+ AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId())
+ doNothing().when(client).delete(delUri)
+
+ doCreateVfModuleRollback.deleteNetworkPoliciesFromAAI(mockExecution)
Mockito.verify(mockExecution).setVariable("prefix", prefix)
Mockito.verify(mockExecution).setVariable(prefix + "networkPolicyFqdnCount", 1)
Mockito.verify(mockExecution).setVariable(prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", 200)
}
+ @Test
+ void testDeleteNetworkPoliciesFromAAINotFound() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345")
+ when(mockExecution.getVariable("rollbackData")).thenReturn(new RollbackData())
+ List fqdnList = new ArrayList()
+ fqdnList.add("test")
+ when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ uri.queryParam("network-policy-fqdn", "test")
+ NetworkPolicies networkPolicies = new NetworkPolicies();
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("NP1")
+ networkPolicies.getNetworkPolicy().add(networkPolicy)
+ when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies))
+
+ AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId())
+ doThrow(new NotFoundException("Not Found!")).when(client).delete(delUri)
+
+ doCreateVfModuleRollback.deleteNetworkPoliciesFromAAI(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable("prefix", prefix)
+ Mockito.verify(mockExecution).setVariable(prefix + "networkPolicyFqdnCount", 1)
+ Mockito.verify(mockExecution).setVariable(prefix + "aaiDeleteNetworkPolicyReturnCode", 404)
+ }
+
+ @Test
+ void testDeleteNetworkPoliciesFromAAIError() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345")
+ when(mockExecution.getVariable("rollbackData")).thenReturn(new RollbackData())
+ List fqdnList = new ArrayList()
+ fqdnList.add("test")
+ when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ uri.queryParam("network-policy-fqdn", "test")
+ NetworkPolicies networkPolicies = new NetworkPolicies();
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("NP1")
+ networkPolicies.getNetworkPolicy().add(networkPolicy)
+ when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies))
+
+ AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId())
+ doThrow(new GraphInventoryUriComputationException("Error!")).when(client).delete(delUri)
+ try {
+ doCreateVfModuleRollback.deleteNetworkPoliciesFromAAI(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(2500, workflowException.getErrorCode())
+ Assert.assertEquals("Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - Error!", workflowException.getErrorMessage())
+ }
+
private static ExecutionEntity setupMock() {
ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy
new file mode 100644
index 0000000000..5c68cc7fc1
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollbackTest.groovy
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts;
+
+import org.junit.Before;
+import org.junit.Test
+import org.onap.aai.domain.yang.VfModule
+import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.aai.domain.yang.VolumeGroups;
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.client.aai.AAIObjectPlurals
+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 static org.mockito.Mockito.spy
+import static org.mockito.Mockito.when;
+
+public class DoCreateVfModuleVolumeRollbackTest extends MsoGroovyTest {
+
+ private DoCreateVfModuleVolumeRollback doCreateVfModuleVolumeRollback;
+ @Before
+ public void init(){
+ super.init("DoCreateVfModuleVolumeRollback");
+ doCreateVfModuleVolumeRollback = spy(DoCreateVfModuleVolumeRollback.class);
+ when(doCreateVfModuleVolumeRollback.getAAIClient()).thenReturn(client)
+ }
+
+ @Test
+ void callRESTDeleteAAIVolumeGroupTest(){
+ String volumeGroupName = "volumeGroupName"
+ String cloudRegionId = "cloudRegionId"
+ when(mockExecution.getVariable("DCVFMODVOLRBK_volumeGroupName")).thenReturn(volumeGroupName)
+ when(mockExecution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId")).thenReturn(cloudRegionId)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegionId).queryParam("volume-group-name", volumeGroupName)
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId")
+ VolumeGroups groups = new VolumeGroups();
+ groups.getVolumeGroup().add(volumeGroup)
+ when(client.get(VolumeGroups.class,uri)).thenReturn(Optional.of(groups))
+
+ doCreateVfModuleVolumeRollback.callRESTDeleteAAIVolumeGroup(mockExecution,null)
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy
index 91e7086bd3..26d3ab8d9d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy
@@ -20,26 +20,42 @@
package org.onap.so.bpmn.infrastructure.scripts
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.junit.Before
+import org.junit.Rule
import org.junit.Test
+import org.junit.rules.ExpectedException
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.Volume
+import org.onap.aai.domain.yang.VolumeGroup
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.RollbackData
+import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.AAIObjectType
+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 static org.junit.Assert.assertEquals
import static org.junit.Assert.assertNotNull
+import static org.mockito.Matchers.anyObject
+import static org.mockito.Mockito.spy
import static org.mockito.Mockito.times
+import static org.mockito.Mockito.verify
import static org.mockito.Mockito.when
-@RunWith(MockitoJUnitRunner.class)
class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest {
+ private DoCreateVfModuleVolumeV2 doCreateVfModuleVolumeV2;
+
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
@@ -86,6 +102,9 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest {
@Before
public void init()
{
+ super.init("DoCreateVfModuleVolumeV2")
+ doCreateVfModuleVolumeV2 = spy(DoCreateVfModuleVolumeV2.class)
+ when(doCreateVfModuleVolumeV2.getAAIClient()).thenReturn(client)
MockitoAnnotations.initMocks(this)
}
@@ -117,6 +136,7 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest {
ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV2')
when(mockExecution.getVariable("prefix")).thenReturn('DCVFMODVOLV2_')
+ when(mockExecution.getVariable("DCVFMODVOLV2_AAIQueryGenericVfnResponse")).thenReturn(new GenericVnf())
when(mockExecution.getVariable("serviceInstanceId")).thenReturn('')
when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id')
when(mockExecution.getVariable("mso-request-id")).thenReturn('1234')
@@ -132,4 +152,126 @@ class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest {
String DCVFMODVOLV2_createVnfARequest = captor.getValue();
assertNotNull(DCVFMODVOLV2_createVnfARequest)
}
+
+ @Test
+ void testcallRESTQueryAAIVolGrpName(){
+ String volumeGroupName = "volumeGroupName"
+ String lcpCloudRegionId = "lcpCloudRegionId"
+ when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName)
+ when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName)
+ VolumeGroup volumeGroup = new VolumeGroup()
+ volumeGroup.setVolumeGroupId("volumeGroupId")
+ when(client.get(VolumeGroup.class,uri)).thenReturn(Optional.of(volumeGroup))
+ doCreateVfModuleVolumeV2.callRESTQueryAAIVolGrpName(mockExecution,null)
+ verify(mockExecution).setVariable("DCVFMODVOLV2_AaiReturnCode",200)
+ }
+
+ @Test
+ void testcallRESTQueryAAIVolGrpName_NoData(){
+ String volumeGroupName = "volumeGroupName"
+ String lcpCloudRegionId = "lcpCloudRegionId"
+ when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName)
+ when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), lcpCloudRegionId).queryParam("volume-group-name", volumeGroupName)
+ when(client.get(VolumeGroup.class,uri)).thenReturn(Optional.empty())
+ thrown.expect(BpmnError.class)
+ doCreateVfModuleVolumeV2.callRESTQueryAAIVolGrpName(mockExecution,null)
+ }
+
+ @Test
+ void testcallRESTUpdateCreatedVolGrpName(){
+ String queriedVolumeGroupId = "queriedVolumeGroupId"
+ String modelCustomizationId = "modelCustomizationId"
+ String lcpCloudRegionId = "lcpCloudRegionId"
+ when(mockExecution.getVariable(queriedVolumeGroupId)).thenReturn(queriedVolumeGroupId)
+ when(mockExecution.getVariable(modelCustomizationId)).thenReturn(modelCustomizationId)
+ when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId)
+ when(mockExecution.getVariable("DCVFMODVOLV2_createVnfAResponse")).thenReturn("<createVnfAResponse><volumeGroupStackId>volumeGroupStackId</volumeGroupStackId></createVnfAResponse>")
+ doCreateVfModuleVolumeV2.callRESTUpdateCreatedVolGrpName(mockExecution,null)
+ verify(mockExecution).setVariable("DCVFMODVOLV2_heatStackId","volumeGroupStackId")
+ }
+
+ @Test
+ void testcallRESTUpdateCreatedVolGrpNameException(){
+ String queriedVolumeGroupId = "queriedVolumeGroupId"
+ String modelCustomizationId = "modelCustomizationId"
+ String lcpCloudRegionId = "lcpCloudRegionId"
+ when(mockExecution.getVariable(queriedVolumeGroupId)).thenReturn(queriedVolumeGroupId)
+ when(mockExecution.getVariable(modelCustomizationId)).thenReturn(modelCustomizationId)
+ when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId)
+ when(mockExecution.getVariable("DCVFMODVOLV2_createVnfAResponse")).thenReturn("<createVnfAResponse><volumeGroupStackId>volumeGroupStackId</volumeGroupStackId></createVnfAResponse>")
+ when(client.update(anyObject(),anyObject())).thenThrow(Exception.class)
+ thrown.expect(BpmnError.class)
+ doCreateVfModuleVolumeV2.callRESTUpdateCreatedVolGrpName(mockExecution,null)
+ verify(mockExecution).setVariable("DCVFMODVOLV2_heatStackId","volumeGroupStackId")
+ }
+
+ @Test
+ void testcallRESTQueryAAIGenericVnf(){
+ String vnfId = "vnfId"
+ when(mockExecution.getVariable(vnfId)).thenReturn(vnfId)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ GenericVnf genericVnf = new GenericVnf()
+ genericVnf.setVnfId(vnfId)
+ when(client.get(GenericVnf.class,uri)).thenReturn(Optional.of(genericVnf))
+ doCreateVfModuleVolumeV2.callRESTQueryAAIGenericVnf(mockExecution,null)
+ verify(mockExecution).setVariable("DCVFMODVOLV2_AAIQueryGenericVfnResponse",genericVnf)
+ }
+
+ @Test
+ void testcallRESTQueryAAIGenericVnf_NotFound(){
+ String vnfId = "vnfId"
+ when(mockExecution.getVariable(vnfId)).thenReturn(vnfId)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ when(client.get(GenericVnf.class,uri)).thenReturn(Optional.empty())
+ thrown.expect(BpmnError.class)
+ doCreateVfModuleVolumeV2.callRESTQueryAAIGenericVnf(mockExecution,null)
+ }
+
+ @Test
+ void testcallRESTCreateAAIVolGrpName(){
+ String vnfId = "vnfId"
+ String volumeGroupId = "volumeGroupId"
+ String volumeGroupName = "volumeGroupName"
+ String modelCustomizationId = "modelCustomizationId"
+ String vnfType= "vnfType"
+ String tenantId = "tenantId"
+ String lcpCloudRegionId= "lcpCloudRegionId"
+ String cloudOwner = "cloudOwner"
+
+ when(mockExecution.getVariable(vnfId)).thenReturn(vnfId)
+ when(mockExecution.getVariable(volumeGroupId)).thenReturn(volumeGroupId)
+ when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName)
+ when(mockExecution.getVariable(modelCustomizationId)).thenReturn(modelCustomizationId)
+ when(mockExecution.getVariable(vnfType)).thenReturn(vnfType)
+ when(mockExecution.getVariable(tenantId)).thenReturn(tenantId)
+ when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId)
+ when(mockExecution.getVariable(cloudOwner)).thenReturn(cloudOwner)
+ when(mockExecution.getVariable("rollbackData")).thenReturn(new RollbackData())
+ doCreateVfModuleVolumeV2.callRESTCreateAAIVolGrpName(mockExecution,null)
+ }
+
+ @Test
+ void testcallRESTCreateAAIVolGrpNameException(){
+ String vnfId = "vnfId"
+ String volumeGroupId = "volumeGroupId"
+ String volumeGroupName = "volumeGroupName"
+ String modelCustomizationId = "modelCustomizationId"
+ String vnfType= "vnfType"
+ String tenantId = "tenantId"
+ String lcpCloudRegionId= "lcpCloudRegionId"
+ String cloudOwner = "cloudOwner"
+
+ when(mockExecution.getVariable(vnfId)).thenReturn(vnfId)
+ when(mockExecution.getVariable(volumeGroupId)).thenReturn(volumeGroupId)
+ when(mockExecution.getVariable(volumeGroupName)).thenReturn(volumeGroupName)
+ when(mockExecution.getVariable(modelCustomizationId)).thenReturn(modelCustomizationId)
+ when(mockExecution.getVariable(vnfType)).thenReturn(vnfType)
+ when(mockExecution.getVariable(tenantId)).thenReturn(tenantId)
+ when(mockExecution.getVariable(lcpCloudRegionId)).thenReturn(lcpCloudRegionId)
+ when(mockExecution.getVariable(cloudOwner)).thenReturn(cloudOwner)
+ thrown.expect(BpmnError.class)
+ doCreateVfModuleVolumeV2.callRESTCreateAAIVolGrpName(mockExecution,null)
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy
new file mode 100644
index 0000000000..6b3674d908
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2Test.groovy
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.junit.Before
+import org.junit.Test
+import org.mockito.Mockito
+import org.mockito.Spy
+import org.onap.aai.domain.yang.AllottedResource
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import javax.ws.rs.core.UriBuilder
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+class DoCustomDeleteE2EServiceInstanceV2Test extends MsoGroovyTest {
+
+ @Spy
+ DoCustomDeleteE2EServiceInstanceV2 doCustomDeleteE2EServiceInstanceV2
+
+ @Before
+ void init(){
+ super.init("DoCustomDeleteE2EServiceInstanceV2")
+ Mockito.when(doCustomDeleteE2EServiceInstanceV2.getAAIClient()).thenReturn(client)
+ }
+
+ @Test
+ void testPrepareServiceDeleteResource(){
+ when(mockExecution.getVariable("serviceInstance")).thenReturn(FileUtil.readResourceFile("__files/AAI/ServiceInstanceWithAR.json"))
+ def relink = "/aai/v11/business/customers/customer/testCustIdInfra/service-subscriptions/service-subscription/HNPORTAL/service-instances/service-instance/testServiceInstanceIdPortalPri/allotted-resources/allotted-resource/testAllottedResourceIdPortalPri"
+ AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(relink).build())
+ AllottedResource ar = new AllottedResource();
+ ar.setId("ar1")
+ ar.setType("ar")
+ ar.setRole("ar")
+ ar.setResourceVersion("1234")
+ when(client.get(AllottedResource.class,uri)).thenReturn(Optional.of(ar))
+ doCustomDeleteE2EServiceInstanceV2.prepareServiceDeleteResource(mockExecution)
+ Mockito.verify(client, times(1)).get(AllottedResource.class,uri)
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy
index 7f55eb3dcb..f6efe1d7d1 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy
@@ -20,35 +20,39 @@
package org.onap.so.bpmn.infrastructure.scripts
-
import static org.mockito.Mockito.*
-
-import static org.onap.so.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapter;
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion;
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404;
+import static org.onap.so.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapter;
+
+import org.apache.commons.lang3.*
import org.camunda.bpm.engine.ProcessEngineServices
import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.delegate.DelegateExecution
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.delegate.DelegateExecution
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
-import org.junit.runner.RunWith
import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.L3Network
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipList
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.client.graphinventory.entities.uri.Depth
+import org.onap.so.constants.Defaults
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.junit.WireMockRule
-import org.apache.commons.lang3.*
-@RunWith(MockitoJUnitRunner.class)
-class DoDeleteNetworkInstanceTest {
+class DoDeleteNetworkInstanceTest extends MsoGroovyTest{
@Rule
public WireMockRule wireMockRule = new WireMockRule(8090);
@@ -1117,11 +1121,11 @@ String sdncAdapterWorkflowFormattedResponse_404 =
@Before
public void init()
{
+ super.init("DoDeleteNetworkInstance")
MockitoAnnotations.initMocks(this)
}
@Test
- //@Ignore
public void preProcessRequest_Json() {
println "************ preProcessRequest_Payload ************* "
@@ -1258,7 +1262,6 @@ String sdncAdapterWorkflowFormattedResponse_404 =
verify(mockExecution).setVariable(Prefix + "networkInputs", "")
verify(mockExecution).setVariable(Prefix + "tenantId", "")
- verify(mockExecution).setVariable(Prefix + "queryAAIRequest","")
verify(mockExecution).setVariable(Prefix + "queryAAIResponse", "")
verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "")
verify(mockExecution).setVariable(Prefix + "isAAIGood", false)
@@ -1583,13 +1586,10 @@ String sdncAdapterWorkflowFormattedResponse_404 =
@Test
- //@Ignore
- public void callRESTQueryAAI_200() {
- println "************ callRESTQueryAAI ************* "
+ public void callRESTQueryAAI_VfRelationshipExist() {
- WireMock.reset();
- MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "all");
+ println "************ callRESTQueryAAI ************* "
ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest)
@@ -1602,89 +1602,113 @@ String sdncAdapterWorkflowFormattedResponse_404 =
when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC")
-
- DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance()
- DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution)
+ String networkId = "bdc5efe8-404a-409b-85f6-0dcc9eebae30"
+ DoDeleteNetworkInstance doDeleteNetworkInstance = spy(DoDeleteNetworkInstance.class)
+ when(doDeleteNetworkInstance.getAAIClient()).thenReturn(client)
+ L3Network l3Network = getL3Network()
+ Relationship relationship = new Relationship();
+ relationship.setRelatedTo("vf-module")
+ l3Network.getRelationshipList().getRelationship().add(relationship)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL)
+ when(client.get(L3Network.class,uri)).thenReturn(Optional.of(l3Network))
+
+ doDeleteNetworkInstance.callRESTQueryAAI(mockExecution)
verify(mockExecution).setVariable("prefix", Prefix)
- verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+"?depth=all")
- verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200")
+ verify(mockExecution).setVariable(Prefix + "aaiReturnCode", 200)
//verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponse)
verify(mockExecution).setVariable(Prefix + "isAAIGood", true)
- verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", false)
+ verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", true)
}
@Test
//@Ignore
- public void callRESTQueryAAI_withRelationship_200() {
+ public void callRESTQueryAAI_200() {
println "************ callRESTQueryAAI ************* "
-
- WireMock.reset();
- MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_withRelationship_Success.xml", "all");
-
ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest)
when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6")
when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090")
when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("")
- // old: when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network")
- when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network")
+ when(mockExecution.getVariable("mso.workflow.doDeleteNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network")
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC")
-
- DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance()
- DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution)
+ when(mockExecution.getVariable(Prefix + "lcpCloudRegion")).thenReturn(null)
+ String networkId = "bdc5efe8-404a-409b-85f6-0dcc9eebae30"
+ DoDeleteNetworkInstance doDeleteNetworkInstance = spy(DoDeleteNetworkInstance.class)
+ when(doDeleteNetworkInstance.getAAIClient()).thenReturn(client)
+ L3Network l3Network = getL3Network()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL)
+ when(client.get(L3Network.class,uri)).thenReturn(Optional.of(l3Network))
+ doDeleteNetworkInstance.callRESTQueryAAI(mockExecution)
verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix)
- verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+"?depth=all")
- verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200")
- //verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponseWithRelationship)
+ verify(mockExecution).setVariable(Prefix + "aaiReturnCode", 200)
verify(mockExecution).setVariable(Prefix + "isAAIGood", true)
- verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", true)
-
+ verify(mockExecution).setVariable(Prefix + "queryAAIResponse", l3Network)
}
- @Test
- //@Ignore
- public void callRESTQueryAAI_200_DefaultUri() {
-
- println "************ callRESTQueryAAI ************* "
-
- WireMock.reset();
- MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "all");
-
- ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest)
- when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090")
- // old: when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8")
- when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network")
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
- when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC")
-
- DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance()
- DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution)
- verify(mockExecution).setVariable("prefix", Prefix)
- verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+ "?depth=all")
-
- verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200")
- //verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponse)
- verify(mockExecution).setVariable(Prefix + "isAAIGood", true)
+ @Test
+ //@Ignore
+ public void callRESTQueryAAI_CloudRegionRelation() {
+
+ println "************ callRESTQueryAAI ************* "
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest)
+ when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090")
+ when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("")
+ when(mockExecution.getVariable("mso.workflow.doDeleteNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network")
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+ when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC")
+ when(mockExecution.getVariable(Prefix + "lcpCloudRegion")).thenReturn(null)
+ String networkId = "bdc5efe8-404a-409b-85f6-0dcc9eebae30"
+ DoDeleteNetworkInstance doDeleteNetworkInstance = spy(DoDeleteNetworkInstance.class)
+ when(doDeleteNetworkInstance.getAAIClient()).thenReturn(client)
+ L3Network l3Network = new L3Network();
+ RelationshipList relationshipList = new RelationshipList()
+ Relationship relationship = new Relationship();
+ relationship.setRelatedTo("cloud-region")
+ relationship.setRelatedLink("http://localhost:18080/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER.toString() + "/lcpCloudRegion/")
+ relationshipList.getRelationship().add(relationship)
+ l3Network.setRelationshipList(relationshipList)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ALL)
+ when(client.get(L3Network.class,uri)).thenReturn(Optional.of(l3Network))
+ doDeleteNetworkInstance.callRESTQueryAAI(mockExecution)
+
+ verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix)
+
+ verify(mockExecution).setVariable(Prefix + "aaiReturnCode", 200)
+ verify(mockExecution).setVariable(Prefix + "isAAIGood", true)
+ verify(mockExecution).setVariable(Prefix + "queryAAIResponse", l3Network)
+ }
+
+ private L3Network getL3Network() {
+ L3Network l3Network = new L3Network();
+ RelationshipList relationshipList = new RelationshipList()
+ Relationship relationship = new Relationship();
+ relationship.setRelatedTo("cloud-region")
+ relationship.setRelatedLink("http://localhost:18080/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER.toString() + "/lcpCloudRegion/")
+ relationshipList.getRelationship().add(relationship)
+ relationship.setRelatedTo("tenant")
+ relationship.setRelatedLink("http://localhost:18080/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER.toString() + "/lcpCloudRegion/tenants/tenant/tenantId/")
+ relationshipList.getRelationship().add(relationship)
+
+ l3Network.setRelationshipList(relationshipList)
+ l3Network
+ }
- }
@Test
- //@Ignore
public void callRESTQueryAAICloudRegion30_200() {
println "************ callRESTQueryAAICloudRegion30_200 ************* "
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy
new file mode 100644
index 0000000000..764ceb256a
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstanceTest.groovy
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.ExpectedException
+import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.aai.domain.yang.VolumeGroups
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.AAIObjectType
+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 static org.mockito.Matchers.isA
+import static org.mockito.Mockito.doThrow
+import static org.mockito.Mockito.spy
+import static org.mockito.Mockito.when
+
+public class DoDeleteVFCNetworkServiceInstanceTest extends MsoGroovyTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private DoDeleteVFCNetworkServiceInstance doDeleteVFCNetworkServiceInstance;
+ @Before
+ public void init(){
+ super.init("DoDeleteVFCNetworkServiceInstance");
+ doDeleteVFCNetworkServiceInstance = spy(DoDeleteVFCNetworkServiceInstance.class);
+ when(doDeleteVFCNetworkServiceInstance.getAAIClient()).thenReturn(client)
+ }
+
+ @Test
+ void callRESTDeleteAAIVolumeGroupTest(){
+ String resourceInstanceId = "resourceInstanceId"
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("resourceInstanceId")).thenReturn(resourceInstanceId)
+ doDeleteVFCNetworkServiceInstance.deleteNSRelationship(mockExecution)
+ }
+
+ @Test
+ void callRESTDeleteAAIVolumeGroupTestException(){
+ String resourceInstanceId = "resourceInstanceId"
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("resourceInstanceId")).thenReturn(resourceInstanceId)
+ doThrow(Exception.class).when(client).disconnect(isA(AAIResourceUri.class),isA(AAIResourceUri.class))
+ thrown.expect(BpmnError.class)
+ doDeleteVFCNetworkServiceInstance.deleteNSRelationship(mockExecution)
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
index 447463a079..cfdeee2c32 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy
@@ -35,14 +35,24 @@ import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.NetworkPolicies
+import org.onap.aai.domain.yang.NetworkPolicy
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.client.graphinventory.entities.uri.Depth
import static com.github.tomakehurst.wiremock.client.WireMock.*
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
-class DoDeleteVfModuleFromVnfTest {
+class DoDeleteVfModuleFromVnfTest extends MsoGroovyTest {
@Rule
public WireMockRule wireMockRule = new WireMockRule(28090);
@@ -50,9 +60,14 @@ class DoDeleteVfModuleFromVnfTest {
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+ @Spy
+ DoDeleteVfModuleFromVnf deleteVfModuleFromVnf
+
@Before
public void init() throws IOException {
- MockitoAnnotations.initMocks(this);
+ super.init("DoDeleteVfModuleFromVnf")
+ MockitoAnnotations.initMocks(this)
+ when(deleteVfModuleFromVnf.getAAIClient()).thenReturn(client)
}
@Test
@@ -89,40 +104,64 @@ class DoDeleteVfModuleFromVnfTest {
@Test
void testDeleteNetworkPoliciesFromAAI() {
- ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleFromVnf.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy")
- when(mockExecution.getVariable("mso.workflow.custom.DoDeleteVfModuleFromVnf.aai.version")).thenReturn("8")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+
List fqdnList = new ArrayList()
fqdnList.add("test")
when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList)
- mockData()
- DoDeleteVfModuleFromVnf obj = new DoDeleteVfModuleFromVnf()
- obj.deleteNetworkPoliciesFromAAI(mockExecution)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ uri.queryParam("network-policy-fqdn", "test")
+ NetworkPolicies networkPolicies = new NetworkPolicies();
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("NP1")
+ networkPolicies.getNetworkPolicy().add(networkPolicy)
+ when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies))
+
+ AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicy.getNetworkPolicyId())
+ doNothing().when(client).delete(delUri)
+ deleteVfModuleFromVnf.deleteNetworkPoliciesFromAAI(mockExecution)
Mockito.verify(mockExecution).setVariable("prefix", 'DDVFMV_')
Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200)
}
+ @Test
+ void testDeleteNetworkPoliciesFromAAINotFound() {
+
+ List fqdnList = new ArrayList()
+ fqdnList.add("test")
+ when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ uri.queryParam("network-policy-fqdn", "test")
+ when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.empty())
+ deleteVfModuleFromVnf.deleteNetworkPoliciesFromAAI(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable("prefix", 'DDVFMV_')
+ Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 404)
+ }
+
@Test
void testQueryAAIForVfModule() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable("vnfId")).thenReturn("12345")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("mso.workflow.global.default.aai.namespace")
- when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8")
- when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
- when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC")
-
- mockData()
- DoDeleteVfModuleFromVnf obj = new DoDeleteVfModuleFromVnf()
- obj.queryAAIForVfModule(mockExecution)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "12345").depth(Depth.ONE)
+ GenericVnf genericVnf = new GenericVnf()
+ genericVnf.setVnfId("test1")
+ when(client.get(GenericVnf.class, uri)).thenReturn(Optional.of(genericVnf))
+ deleteVfModuleFromVnf.queryAAIForVfModule(mockExecution)
Mockito.verify(mockExecution, atLeastOnce()).setVariable("DDVMFV_getVnfResponseCode", 200)
+ Mockito.verify(mockExecution, atLeastOnce()).setVariable("DDVMFV_getVnfResponse", genericVnf)
+ }
+
+ @Test
+ void testQueryAAIForVfModuleNotFound() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("vnfId")).thenReturn("12345")
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "12345").depth(Depth.ONE)
+ when(client.get(GenericVnf.class, uri)).thenReturn(Optional.empty())
+ deleteVfModuleFromVnf.queryAAIForVfModule(mockExecution)
+ Mockito.verify(mockExecution, atLeastOnce()).setVariable("DDVMFV_getVnfResponseCode", 404)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
index 3390b1a6f0..7776ab3fe6 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy
@@ -27,6 +27,7 @@ import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Assert
import org.junit.Before
+import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -34,16 +35,31 @@ import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.NetworkPolicies
+import org.onap.aai.domain.yang.NetworkPolicy
+import org.onap.aai.domain.yang.VfModule
+import org.onap.aai.domain.yang.VfModules
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.common.scripts.utils.XmlComparator
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.NotFoundException
import static com.github.tomakehurst.wiremock.client.WireMock.*
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
-class DoDeleteVfModuleTest {
+class DoDeleteVfModuleTest extends MsoGroovyTest{
+
+ @Spy
+ DoDeleteVfModule doDeleteVfModule
@Rule
public WireMockRule wireMockRule = new WireMockRule(28090);
@@ -53,7 +69,9 @@ class DoDeleteVfModuleTest {
@Before
public void init() throws IOException {
+ super.init("DoDeleteVfModule")
MockitoAnnotations.initMocks(this);
+ when(doDeleteVfModule.getAAIClient()).thenReturn(client)
}
@Test
@@ -82,38 +100,49 @@ class DoDeleteVfModuleTest {
@Test
void testDeleteNetworkPoliciesFromAAI() {
- ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable("mso.workflow.DoDeleteVfModule.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy")
- when(mockExecution.getVariable("mso.workflow.custom.DoDeleteVfModule.aai.version")).thenReturn("8")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
List fqdnList = new ArrayList()
fqdnList.add("test")
when(mockExecution.getVariable("DoDVfMod_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList)
- mockData()
- DoDeleteVfModule obj = new DoDeleteVfModule()
- obj.deleteNetworkPoliciesFromAAI(mockExecution)
-
+ NetworkPolicies networkPolicies = new NetworkPolicies()
+ NetworkPolicy networkPolicy = new NetworkPolicy()
+ networkPolicy.setNetworkPolicyId("NP1")
+ networkPolicies.getNetworkPolicy().add(networkPolicy)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ uri.queryParam("network-policy-fqdn", "test")
+ when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies))
+ doDeleteVfModule.deleteNetworkPoliciesFromAAI(mockExecution)
Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200)
}
+ @Test
+ void testDeleteNetworkPoliciesFromAAIError() {
+ List fqdnList = new ArrayList()
+ fqdnList.add("test")
+ when(mockExecution.getVariable("DoDVfMod_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList)
+ NetworkPolicies networkPolicies = new NetworkPolicies()
+ NetworkPolicy networkPolicy = new NetworkPolicy()
+ networkPolicy.setNetworkPolicyId("NP1")
+ networkPolicies.getNetworkPolicy().add(networkPolicy)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY)
+ uri.queryParam("network-policy-fqdn", "test")
+ when(client.get(NetworkPolicies.class, uri)).thenReturn(Optional.of(networkPolicies))
+ AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "NP1")
+ doThrow(new NotFoundException(("Not Found !"))).when(client).delete(delUri)
+ doDeleteVfModule.deleteNetworkPoliciesFromAAI(mockExecution)
+ Mockito.verify(client).delete(delUri)
+ }
@Test
void testQueryAAIVfModuleForStatus() {
- ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
- when(mockExecution.getVariable("DCVFM_vnfId")).thenReturn("12345")
- when(mockExecution.getVariable("DCVFM_vfModuleName")).thenReturn("module-0")
- when(mockExecution.getVariable("mso.workflow.DoDeleteVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
-
- mockData()
- DoCreateVfModule obj = new DoCreateVfModule()
- obj.queryAAIVfModuleForStatus(mockExecution)
-
- Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleForStatusResponseCode", 200)
+ when(mockExecution.getVariable("vnfId")).thenReturn("12345")
+ when(mockExecution.getVariable("vfModuleId")).thenReturn("module-0")
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE,"12345","module-0")
+ VfModule vfModule = new VfModule()
+ vfModule.setOrchestrationStatus("Created")
+ when(client.get(VfModule.class, uri)).thenReturn(Optional.of(vfModule))
+ doDeleteVfModule.queryAAIVfModuleForStatus(mockExecution)
+ Mockito.verify(mockExecution).setVariable("DoDVfMod_queryAAIVfModuleForStatusResponseCode", 200)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy
index 730be14df0..94aec7a73f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy
@@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.github.tomakehurst.wiremock.junit.WireMockRule
import org.camunda.bpm.engine.ProcessEngineServices
import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Assert
@@ -35,25 +36,41 @@ import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.common.scripts.utils.XmlComparator
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException
+
+import javax.ws.rs.NotFoundException
import static com.github.tomakehurst.wiremock.client.WireMock.*
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
-class DoDeleteVfModuleVolumeV2Test {
+class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{
@Rule
public WireMockRule wireMockRule = new WireMockRule(28090);
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+ @Spy
+ DoDeleteVfModuleVolumeV2 deleteVfModuleVolumeV2;
+
@Before
public void init() throws IOException {
+ super.init("DoDeleteVfModuleVolumeV2")
MockitoAnnotations.initMocks(this);
+ when(deleteVfModuleVolumeV2.getAAIClient()).thenReturn(client)
+
}
@Test
@@ -118,6 +135,118 @@ class DoDeleteVfModuleVolumeV2Test {
XmlComparator.assertXMLEquals(str, captor.getValue(),"messageId","notificationUrl")
}
+ @Test
+ void testCallRESTQueryAAIForVolumeGroup(){
+ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant123")
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123")
+ when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123")
+ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroupWithTenant.json");
+ when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup)
+ deleteVfModuleVolumeV2.callRESTQueryAAIForVolumeGroup(mockExecution,"true")
+ Mockito.verify(mockExecution).setVariable("DDVMV_queryAAIVolGrpResponse", volumeGroup.get())
+ Mockito.verify(mockExecution).setVariable("DDVMV_volumeGroupHeatStackId", volumeGroup.get().getHeatStackId())
+ }
+
+ @Test
+ void testCallRESTQueryAAIForVolumeGroupNoTenant(){
+ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant123")
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123")
+ when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123")
+ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroup.json");
+ when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup)
+ try {
+ deleteVfModuleVolumeV2.callRESTQueryAAIForVolumeGroup(mockExecution, "true")
+ }catch(BpmnError error) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ }
+
+ @Test
+ void testCallRESTQueryAAIForVolumeGroupDifferentTenant(){
+ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant12345")
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123")
+ when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123")
+ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroupWithTenant.json");
+ when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup)
+ try {
+ deleteVfModuleVolumeV2.callRESTQueryAAIForVolumeGroup(mockExecution, "true")
+ }catch(BpmnError error) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ }
+
+ @Test
+ void testCallRESTQueryAAIForVolumeGroupNotFound(){
+ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant123")
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123")
+ when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123")
+ when(client.get(VolumeGroup.class,resourceUri)).thenReturn(Optional.empty())
+ try {
+ deleteVfModuleVolumeV2.callRESTQueryAAIForVolumeGroup(mockExecution, "true")
+ }catch(BpmnError error) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ }
+
+ @Test
+ void testCallRESTQueryAAIForVolumeGroupWithVfModule(){
+ when(mockExecution.getVariable("tenantId")).thenReturn("Tenant123")
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123")
+ when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123")
+ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroupWithVfModule.json");
+ when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup)
+ try {
+ deleteVfModuleVolumeV2.callRESTQueryAAIForVolumeGroup(mockExecution, "true")
+ }catch(BpmnError error) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ }
+
+ @Test
+ void testCallRESTDeleteAAIVolumeGroup(){
+ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroup.json");
+ when(mockExecution.getVariable("DDVMV_queryAAIVolGrpResponse")).thenReturn(volumeGroup.get())
+ when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123")
+ doNothing().when(client).delete(resourceUri)
+ deleteVfModuleVolumeV2.callRESTDeleteAAIVolumeGroup(mockExecution,"true")
+ }
+
+ @Test
+ void testCallRESTDeleteAAIVolumeGroupAaiError(){
+ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroupWithVfModule.json");
+ when(mockExecution.getVariable("DDVMV_queryAAIVolGrpResponse")).thenReturn(volumeGroup.get())
+ when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1",volumeGroup.get().getVolumeGroupId())
+ doThrow(new GraphInventoryUriComputationException("Error")).when(client).delete(resourceUri)
+ try {
+ deleteVfModuleVolumeV2.callRESTDeleteAAIVolumeGroup(mockExecution, "true")
+ } catch (BpmnError error) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ }
+
+ @Test
+ void testCallRESTDeleteAAIVolumeGroupNotFound(){
+ Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroup.json");
+ when(mockExecution.getVariable("DDVMV_queryAAIVolGrpResponse")).thenReturn(volumeGroup.get())
+ when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1")
+ AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123")
+ doThrow(new NotFoundException("VolumeGroup Not found")).when(client).delete(resourceUri)
+ try {
+ deleteVfModuleVolumeV2.callRESTDeleteAAIVolumeGroup(mockExecution, "true")
+ } catch (BpmnError error) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ }
+
+
+
private ExecutionEntity setupMock() {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy
index 0b95ffc053..f98d454eb0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy
@@ -27,7 +27,6 @@ import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Assert
import org.junit.Before
-import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -35,14 +34,21 @@ import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.core.WorkflowException
-
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.client.graphinventory.entities.uri.Depth
+import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException
import static com.github.tomakehurst.wiremock.client.WireMock.*
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
-public class DoDeleteVnfAndModulesTest {
+public class DoDeleteVnfAndModulesTest extends MsoGroovyTest{
@Rule
public WireMockRule wireMockRule = new WireMockRule(28090);
@@ -50,13 +56,18 @@ public class DoDeleteVnfAndModulesTest {
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+ @Spy
+ DoDeleteVnfAndModules doDeleteVnfAndModules
+
String cloudConfiguration = "{ " +
"\"lcpCloudRegionId\": \"mdt1\"," +
"\"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + "}";
@Before
public void init() throws IOException {
+ super.init("DoDeleteVnfAndModules")
MockitoAnnotations.initMocks(this);
+ when(doDeleteVnfAndModules.getAAIClient()).thenReturn(client)
}
@Test
@@ -90,40 +101,26 @@ public class DoDeleteVnfAndModulesTest {
@Test
public void testQueryAAIVfModuleNullEndPoint() {
- ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable("vnfId")).thenReturn("12345")
- when(mockExecution.getVariable("mso.workflow.DoDeleteVnfAndModules.aai.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
-
- mockData()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "12345").depth(Depth.ONE)
+ doThrow(new GraphInventoryUriComputationException("Error in AAI")).when(client).get(GenericVnf.class,uri)
try {
- DoDeleteVnfAndModules obj = new DoDeleteVnfAndModules()
- obj.queryAAIVfModule(mockExecution)
+ doDeleteVnfAndModules.queryAAIVfModule(mockExecution)
} catch (Exception ex) {
println " Test End - Handle catch-throw BpmnError()! "
}
-
Mockito.verify(mockExecution,atLeastOnce()).setVariable(captor.capture(),captor.capture())
WorkflowException workflowException = captor.getValue()
- Assert.assertEquals("AAI GET Failed:null", workflowException.getErrorMessage())
+ Assert.assertEquals("AAI GET Failed:Error in AAI", workflowException.getErrorMessage())
Assert.assertEquals(1002, workflowException.getErrorCode())
}
@Test
public void testQueryAAIVfModule() {
ExecutionEntity mockExecution = setupMock()
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable("vnfId")).thenReturn("12345")
- when(mockExecution.getVariable("mso.workflow.DoDeleteVnfAndModules.aai.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
-
- mockData()
- DoDeleteVnfAndModules obj = new DoDeleteVnfAndModules()
- obj.queryAAIVfModule(mockExecution)
-
+ mockAAIGenericVnf("12345","__files/AAI/GenericVnfVfModule.json")
+ doDeleteVnfAndModules.queryAAIVfModule(mockExecution)
Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleResponseCode", 200)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceTest.groovy
new file mode 100644
index 0000000000..30df8eacc5
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceTest.groovy
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+/**
+ * @author sushilma
+ * @since January 10, 2018
+ */
+class DoUpdateE2EServiceInstanceTest extends MsoGroovyTest{
+
+
+ @Before
+ public void init() {
+ super.init("DoUpdateE2EServiceInstance")
+ }
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+ @Test
+ public void testPreProcessRequest(){
+ mockData()
+ ServiceInstance expectedServiceInstanceData = getExpectedServiceInstance()
+ DoUpdateE2EServiceInstance serviceInstance = new DoUpdateE2EServiceInstance()
+ serviceInstance.preProcessAAIPUT(mockExecution)
+ Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ assertThat(captor.getValue(), sameBeanAs(expectedServiceInstanceData))
+ }
+
+ private ServiceInstance getExpectedServiceInstance() {
+ ServiceInstance expectedServiceInstanceData = new ServiceInstance()
+ expectedServiceInstanceData.setServiceInstanceId("1234")
+ expectedServiceInstanceData.setServiceInstanceName("volte-service")
+ expectedServiceInstanceData.setServiceType("E2E Service")
+ expectedServiceInstanceData.setServiceRole("E2E Service")
+ return expectedServiceInstanceData
+ }
+
+ private void mockData() {
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345")
+ when(mockExecution.getVariable("serviceType")).thenReturn("TRANSPORT")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("1234")
+ when(mockExecution.getVariable("serviceInstanceName")).thenReturn("volte-service")
+ when(mockExecution.getVariable("uuiRequest")).thenReturn("""{"service":{"serviceDefId":"c1d4305f-cdbd-4bbe-9069-a2f4978fd89e" , "templateId" : "d4df5c27-98a1-4812-a8aa-c17f055b7a3f"}}""")
+ when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer')
+ when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn('/testUrl')
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy
index 6ed9dbd2bd..d635b2311a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy
@@ -35,7 +35,9 @@ import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
+import org.mockito.Spy
import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.common.scripts.VfModule
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
@@ -45,7 +47,7 @@ import static org.mockito.Mockito.*
import org.onap.so.bpmn.common.scripts.utils.XmlComparator
@RunWith(MockitoJUnitRunner.class)
-class DoUpdateVfModuleTest {
+class DoUpdateVfModuleTest extends MsoGroovyTest{
def prefix = "DOUPVfMod_"
String doUpdateVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/DoUpdateVfModuleRequest.xml");
@@ -56,11 +58,16 @@ class DoUpdateVfModuleTest {
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
@Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Spy
+ DoUpdateVfModule doUpdateVfModule
@Before
public void init() {
+ super.init("DoUpdateVfModule")
MockitoAnnotations.initMocks(this)
+ when(doUpdateVfModule.getAAIClient()).thenReturn(client)
}
@Test
@@ -258,18 +265,15 @@ class DoUpdateVfModuleTest {
@Test
void testQueryAAIVfModule() {
- ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("prefix")).thenReturn(prefix)
- when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("12345")
- when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8")
- when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
- when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
- mockData()
- DoUpdateVfModule obj = new DoUpdateVfModule()
- obj.queryAAIVfModule(mockExecution)
+ mockAAIGenericVnf("12345","__files/AAI/GenericVnfVfModule.json")
+ doUpdateVfModule.queryAAIVfModule(mockExecution)
Mockito.verify(mockExecution).setVariable(prefix + "queryAAIVfModuleResponseCode", 200)
+ Mockito.verify(mockExecution).setVariable("DOUPVfMod_baseVfModuleId", "lukewarm")
+ Mockito.verify(mockExecution).setVariable("DOUPVfMod_baseVfModuleHeatStackId", "fastburn")
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy
index 620b0b787d..06ae576307 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy
@@ -20,42 +20,48 @@
package org.onap.so.bpmn.infrastructure.scripts
-import com.github.tomakehurst.wiremock.junit.WireMockRule
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
+
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Assert
import org.junit.Before
-import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
+import org.junit.rules.ExpectedException
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
-import org.mockito.Mockito
import org.mockito.MockitoAnnotations
import org.mockito.runners.MockitoJUnitRunner
-import org.onap.so.bpmn.common.scripts.utils.XmlComparator
-import org.onap.so.bpmn.core.WorkflowException
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.VfModule
+import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+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 javax.ws.rs.core.UriBuilder
-import static com.github.tomakehurst.wiremock.client.WireMock.*
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
-class UpdateVfModuleVolumeInfraV1Test {
+class UpdateVfModuleVolumeInfraV1Test extends MsoGroovyTest{
def prefix = "UPDVfModVol_"
@Captor
static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none()
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(28090);
-
+
@Before
- public void init()
- {
+ public void init(){
+ super.init("UpdateVfModuleVolumeInfraV1")
MockitoAnnotations.initMocks(this)
}
@@ -69,66 +75,95 @@ class UpdateVfModuleVolumeInfraV1Test {
when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC")
- mockData()
- UpdateVfModuleVolumeInfraV1 obj = new UpdateVfModuleVolumeInfraV1()
+ UpdateVfModuleVolumeInfraV1 obj = spy(UpdateVfModuleVolumeInfraV1.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VF_MODULE, UriBuilder.fromPath("/aai/v8/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module/12345").build())
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("12345")
+ vfModule.setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff")
+ when(client.get(VfModule.class,uri)).thenReturn(Optional.of(vfModule))
obj.queryAAIForVfModule(mockExecution, "true")
- Mockito.verify(mockExecution, atLeastOnce()).setVariable("UPDVfModVol_personaModelId", "ff5256d2-5a33-55df-13ab-12abad84e7ff")
+ verify(mockExecution, atLeastOnce()).setVariable("UPDVfModVol_personaModelId", "ff5256d2-5a33-55df-13ab-12abad84e7ff")
+ }
+
+ @Test
+ void testQueryAAIForVolumeGroup() {
+ String aicCloudRegion = "aicCloudRegionId"
+ String volumeGroupId = "volumeGroupId"
+ when(mockExecution.getVariable("UPDVfModVol_volumeGroupId")).thenReturn(volumeGroupId)
+ when(mockExecution.getVariable("UPDVfModVol_aicCloudRegion")).thenReturn(aicCloudRegion)
+
+ UpdateVfModuleVolumeInfraV1 obj = spy(UpdateVfModuleVolumeInfraV1.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId)
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId(volumeGroupId)
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(FileUtil.readResourceFile("__files/aai/VolumeGroupWithTenant.json"))
+ when(client.get(uri)).thenReturn(wrapper)
+ thrown.expect(BpmnError.class)
+ obj.queryAAIForVolumeGroup(mockExecution, "true")
}
- @Test
+ @Test
+ void testQueryAAIForGenericVnf() {
+ String vnfId = "vnfId"
+ when(mockExecution.getVariable("vnfId")).thenReturn(vnfId)
+
+ UpdateVfModuleVolumeInfraV1 obj = spy(UpdateVfModuleVolumeInfraV1.class)
+ when(obj.getAAIClient()).thenReturn(client)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ GenericVnf genericVnf = new GenericVnf()
+ genericVnf.setVnfId(vnfId)
+ genericVnf.setVnfName("testvnfName")
+ when(client.get(GenericVnf.class,uri)).thenReturn(Optional.of(genericVnf))
+ obj.queryAAIForGenericVnf(mockExecution, "true")
+ verify(mockExecution).setVariable("UPDVfModVol_AAIQueryGenericVfnResponse", genericVnf)
+ }
+
+ @Test
+ void testQueryAAIForGenericVnfNodata() {
+ String vnfId = "vnfId"
+ when(mockExecution.getVariable("vnfId")).thenReturn(vnfId)
+
+ UpdateVfModuleVolumeInfraV1 obj = spy(UpdateVfModuleVolumeInfraV1.class)
+ when(obj.getAAIClient()).thenReturn(client)
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ when(client.get(GenericVnf.class,uri)).thenReturn(Optional.empty())
+ thrown.expect(BpmnError.class)
+ obj.queryAAIForGenericVnf(mockExecution, "true")
+ verify(mockExecution).setVariable("UPDVfModVol_AAIQueryGenericVfnResponse", genericVnf)
+ }
+
+ @Test
void testPrepVnfAdapterRest() {
- ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("prefix")).thenReturn(prefix)
when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("RDM2WAGPLCP")
when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("")
- when(mockExecution.getVariable(prefix + "aaiVolumeGroupResponse")).thenReturn(FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"))
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setHeatStackId("heatStackId")
+ when(mockExecution.getVariable(prefix + "aaiVolumeGroupResponse")).thenReturn(volumeGroup)
when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vnf1")
when(mockExecution.getVariable(prefix + "vnfVersion")).thenReturn("1")
- when(mockExecution.getVariable(prefix + "AAIQueryGenericVfnResponse")).thenReturn(FileUtil.readResourceFile("__files/GenericFlows/getGenericVnfByNameResponse.xml"))
+ GenericVnf genericVnf = new GenericVnf()
+ genericVnf.setVnfId("vnfId")
+ genericVnf.setVnfName("testvnfName")
+ when(mockExecution.getVariable(prefix + "AAIQueryGenericVfnResponse")).thenReturn(genericVnf)
when(mockExecution.getVariable(prefix + "requestId")).thenReturn("12345")
when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345")
when(mockExecution.getVariable("mso-request-id")).thenReturn("12345")
when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage')
when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true")
- mockData()
UpdateVfModuleVolumeInfraV1 obj = new UpdateVfModuleVolumeInfraV1()
obj.prepVnfAdapterRest(mockExecution, "true")
- Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
- def updateVolumeGroupRequest = captor.getValue()
- String expectedValue = FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVolumeGroupRequest.xml")
- XmlComparator.assertXMLEquals(expectedValue, updateVolumeGroupRequest, "messageId", "notificationUrl")
- }
-
-
- private static ExecutionEntity setupMock() {
- ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
- when(mockProcessDefinition.getKey()).thenReturn("UpdateVfModuleVolumeInfraV1")
- RepositoryService mockRepositoryService = mock(RepositoryService.class)
- when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
- when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateVfModuleVolumeInfraV1")
- when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
- ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
- when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- // Initialize prerequisite variables
- when(mockExecution.getId()).thenReturn("100")
- when(mockExecution.getProcessDefinitionId()).thenReturn("UpdateVfModuleVolumeInfraV1")
- when(mockExecution.getProcessInstanceId()).thenReturn("UpdateVfModuleVolumeInfraV1")
- when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
- when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
-
- return mockExecution
+ verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ String updateVolumeGroupRequest = captor.getValue()
+ Assert.assertTrue(updateVolumeGroupRequest.contains("testvnfName"))
}
-
- private static void mockData() {
- stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module/.*"))
- .willReturn(aResponse()
- .withStatus(200).withHeader("Content-Type", "text/xml")
- .withBodyFile("UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml")))
- }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy
new file mode 100644
index 0000000000..6771476955
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeTest.groovy
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.ExpectedException
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.aai.domain.yang.GenericVnf
+import org.onap.aai.domain.yang.VfModule
+import org.onap.aai.domain.yang.VolumeGroup
+import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.entities.AAIResultWrapper
+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 javax.ws.rs.core.UriBuilder
+
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+class UpdateVfModuleVolumeTest extends MsoGroovyTest{
+
+ def prefix = "UPDVfModVol_"
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none()
+
+
+ @Before
+ public void init(){
+ super.init("UpdateVfModuleVolume")
+ MockitoAnnotations.initMocks(this)
+ }
+
+
+ @Test
+ void testQueryAAIForVolumeGroup() {
+ String aicCloudRegion = "aicCloudRegionId"
+ String volumeGroupId = "volumeGroupId"
+ when(mockExecution.getVariable("UPDVfModVol_volumeGroupId")).thenReturn(volumeGroupId)
+ when(mockExecution.getVariable("UPDVfModVol_aicCloudRegion")).thenReturn(aicCloudRegion)
+
+ UpdateVfModuleVolume obj = spy(UpdateVfModuleVolume.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId)
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId(volumeGroupId)
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(FileUtil.readResourceFile("__files/aai/VolumeGroupWithTenant.json"))
+ when(client.get(uri)).thenReturn(wrapper)
+ obj.queryAAIForVolumeGroup(mockExecution)
+ verify(mockExecution).setVariable("UPDVfModVol_volumeGroupHeatStackId","heatStackId")
+ }
+
+ @Test
+ void testQueryAAIForVolumeGroupNoTenant() {
+ String aicCloudRegion = "aicCloudRegionId"
+ String volumeGroupId = "volumeGroupId"
+ when(mockExecution.getVariable("UPDVfModVol_volumeGroupId")).thenReturn(volumeGroupId)
+ when(mockExecution.getVariable("UPDVfModVol_aicCloudRegion")).thenReturn(aicCloudRegion)
+
+ UpdateVfModuleVolume obj = spy(UpdateVfModuleVolume.class)
+ when(obj.getAAIClient()).thenReturn(client)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId)
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId(volumeGroupId)
+
+ AAIResultWrapper wrapper = new AAIResultWrapper(FileUtil.readResourceFile("__files/aai/VolumeGroupWithTenant.json"))
+ when(client.get(uri)).thenThrow(Exception.class)
+ thrown.expect(BpmnError.class)
+ obj.queryAAIForVolumeGroup(mockExecution)
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
index 1e8842e68f..7982e4dd4b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy
@@ -617,7 +617,7 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
}
@@ -634,7 +634,7 @@ class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase {
private initDeleteAaiAR(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS)
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
index 543bb1db05..f5e48a02e4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy
@@ -21,11 +21,7 @@
package org.onap.so.bpmn.vcpe.scripts
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.delegate.DelegateExecution
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
@@ -36,10 +32,14 @@ import org.camunda.bpm.engine.delegate.BpmnError
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.core.UriBuilder
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
import static com.github.tomakehurst.wiremock.client.WireMock.put
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
import static org.junit.Assert.*;
import static org.mockito.Mockito.*
@@ -49,7 +49,6 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500
import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.vcpe.scripts.MapSetter
import com.github.tomakehurst.wiremock.junit.WireMockRule
@@ -62,7 +61,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
@BeforeClass
public static void setUpBeforeClass() {
- super.setUpBeforeClass()
+ aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
}
@Before
@@ -171,27 +170,18 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
// ***** createAaiAR *****
@Test
- @Ignore
public void createAaiAR() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initCreateAaiAr(mex)
-
- MockPutAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
- DoCreateAllottedResourceBRG.createAaiAR(mex)
-
- def data = map.get("rollbackData")
- assertNotNull(data)
- assertTrue(data instanceof RollbackData)
-
- assertEquals("45", data.get(Prefix, "disableRollback"))
- assertEquals("true", data.get(Prefix, "rollbackAAI"))
- assertEquals(ARID, data.get(Prefix, "allottedResourceId"))
- assertEquals("sii", data.get(Prefix, "serviceInstanceId"))
- assertEquals("psii", data.get(Prefix, "parentServiceInstanceId"))
- assertEquals(mex.getVariable("PSI_resourceLink")+"/allotted-resources/allotted-resource/"+ARID, data.get(Prefix, "aaiARPath"))
+ ExecutionEntity mockExecution = setupMock()
+ AAIResourcesClient client = mock(AAIResourcesClient.class)
+ when(mockExecution.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE,UriBuilder.fromPath( "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST).build()))
+ when(mockExecution.getVariable("CSI_resourceLink")).thenReturn("/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST)
+ when(mockExecution.getVariable("allottedResourceModelInfo")).thenReturn("{\n" +
+ " \"modelInvariantUuid\":\"modelInvariantUuid\",\n" +
+ " \"modelUuid\" : \"modelUuid\"\n" +
+ "}")
+ DoCreateAllottedResourceBRG doCreateAllottedResourceBRG = spy(DoCreateAllottedResourceBRG.class)
+ when(doCreateAllottedResourceBRG.getAAIClient()).thenReturn(client)
+ doCreateAllottedResourceBRG.createAaiAR(mockExecution)
}
@Test
@@ -225,7 +215,6 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
}
@Test
-// @Ignore
public void createAaiAR_MissingPsiLink() {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
@@ -240,7 +229,6 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
}
@Test
-// @Ignore
public void createAaiAR_HttpFailed() {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
@@ -253,7 +241,6 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
}
@Test
-// @Ignore
public void createAaiAR_BpmnError() {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
@@ -268,7 +255,6 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
}
@Test
-// @Ignore
public void createAaiAR_Ex() {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
@@ -921,7 +907,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
- when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST)
+ when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath( "/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST).build()))
when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi")
@@ -993,7 +979,7 @@ class DoCreateAllottedResourceBRGTest extends GroovyTestBase {
private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
index 66cfdb635d..50ce46e4a3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy
@@ -617,7 +617,7 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
}
@@ -634,7 +634,7 @@ class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase {
private initDeleteAaiAR(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS)
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
index fa40c17e63..b759ca1c20 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy
@@ -21,11 +21,7 @@
package org.onap.so.bpmn.vcpe.scripts
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.delegate.DelegateExecution
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
@@ -36,15 +32,12 @@ import org.camunda.bpm.engine.delegate.BpmnError
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
-import org.springframework.beans.factory.config.YamlPropertiesFactoryBean
-import org.springframework.core.io.ClassPathResource
-import org.springframework.core.io.FileSystemResource
-import org.springframework.core.io.Resource
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+
+import javax.ws.rs.core.UriBuilder
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
-import static com.github.tomakehurst.wiremock.client.WireMock.put
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
import static org.junit.Assert.*;
import static org.mockito.Mockito.*
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
@@ -52,10 +45,7 @@ import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500
-import java.util.Map
-
import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.vcpe.scripts.MapSetter
import com.github.tomakehurst.wiremock.junit.WireMockRule
@@ -85,7 +75,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** preProcessRequest *****
@Test
- // @Ignore
+
public void preProcessRequest() {
ExecutionEntity mex = setupMock()
initPreProcess(mex)
@@ -124,7 +114,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void getAaiAR_Duplicate() {
MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
@@ -140,7 +130,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void getAaiAR_NotActive() {
MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml")
@@ -175,61 +165,23 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** createAaiAR *****
@Test
- @Ignore
public void createAaiAR() {
ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
- initCreateAaiAr(mex)
-
- MockPutAllottedResource(CUST, SVC, INST, ARID)
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.createAaiAR(mex)
-
- def data = map.get("rollbackData")
- assertNotNull(data)
- assertTrue(data instanceof RollbackData)
-
- assertEquals("45", data.get(Prefix, "disableRollback"))
- assertEquals("true", data.get(Prefix, "rollbackAAI"))
- assertEquals(ARID, data.get(Prefix, "allottedResourceId"))
- assertEquals("sii", data.get(Prefix, "serviceInstanceId"))
- assertEquals("psii", data.get(Prefix, "parentServiceInstanceId"))
- assertEquals(mex.getVariable("PSI_resourceLink")+"/allotted-resources/allotted-resource/"+ARID, data.get(Prefix, "aaiARPath"))
- }
-
- @Test
- @Ignore
- public void createAaiAR_NoArid_NoModelUuids() {
- ExecutionEntity mex = setupMock()
- def map = setupMap(mex)
initCreateAaiAr(mex)
-
- // no allottedResourceId - will be generated
-
- when(mex.getVariable("allottedResourceId")).thenReturn(null)
-
- wireMockRule
- .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*"))
- .willReturn(aResponse()
- .withStatus(200)))
-
- DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC()
- DoCreateAllottedResourceTXC.createAaiAR(mex)
-
- def arid = map.get("allottedResourceId")
- assertNotNull(arid)
- assertFalse(arid.isEmpty())
-
- def data = map.get("rollbackData")
- assertNotNull(data)
- assertTrue(data instanceof RollbackData)
-
- assertEquals(arid, data.get(Prefix, "allottedResourceId"))
+ when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath( "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST).build()))
+ when(mex.getVariable("CSI_resourceLink")).thenReturn("/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST)
+ when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{\n" +
+ " \"modelInvariantUuid\":\"modelInvariantUuid\",\n" +
+ " \"modelUuid\" : \"modelUuid\"\n" +
+ "}")
+ AAIResourcesClient client = mock(AAIResourcesClient.class)
+ DoCreateAllottedResourceTXC doCreateAllottedResourceTXC = spy(DoCreateAllottedResourceTXC.class)
+ when(doCreateAllottedResourceTXC.getAAIClient()).thenReturn(client)
+ doCreateAllottedResourceTXC.createAaiAR(mex)
}
+
@Test
- // @Ignore
public void createAaiAR_MissingPsiLink() {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
@@ -244,7 +196,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void createAaiAR_HttpFailed() {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
@@ -257,7 +209,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void createAaiAR_BpmnError() {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
@@ -272,7 +224,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void createAaiAR_Ex() {
ExecutionEntity mex = setupMock()
initCreateAaiAr(mex)
@@ -290,7 +242,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** buildSDNCRequest *****
@Test
- // @Ignore
+
public void buildSDNCRequest() {
ExecutionEntity mex = setupMock()
initBuildSDNCRequest(mex)
@@ -317,7 +269,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void buildSDNCRequest_Ex() {
ExecutionEntity mex = setupMock()
initBuildSDNCRequest(mex)
@@ -333,7 +285,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** preProcessSDNCAssign *****
@Test
- // @Ignore
+
public void preProcessSDNCAssign() {
ExecutionEntity mex = setupMock()
def map = setupMap(mex)
@@ -359,7 +311,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessSDNCAssign_BpmnError() {
ExecutionEntity mex = setupMock()
initPreProcessSDNC(mex)
@@ -372,7 +324,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessSDNCAssign_Ex() {
ExecutionEntity mex = setupMock()
initPreProcessSDNC(mex)
@@ -388,7 +340,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** preProcessSDNCCreate *****
@Test
- // @Ignore
+
public void preProcessSDNCCreate() {
ExecutionEntity mex = setupMock()
def map = setupMap(mex)
@@ -415,7 +367,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessSDNCCreate_BpmnError() {
ExecutionEntity mex = setupMock()
initPreProcessSDNC(mex)
@@ -428,7 +380,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessSDNCCreate_Ex() {
ExecutionEntity mex = setupMock()
initPreProcessSDNC(mex)
@@ -444,7 +396,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** preProcessSDNCActivate *****
@Test
- // @Ignore
+
public void preProcessSDNCActivate() {
ExecutionEntity mex = setupMock()
def map = setupMap(mex)
@@ -471,7 +423,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessSDNCActivate_BpmnError() {
ExecutionEntity mex = setupMock()
initPreProcessSDNC(mex)
@@ -484,7 +436,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessSDNCActivate_Ex() {
ExecutionEntity mex = setupMock()
initPreProcessSDNC(mex)
@@ -500,7 +452,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** validateSDNCResp *****
@Test
- // @Ignore
+
public void validateSDNCResp() {
ExecutionEntity mex = setupMock()
def map = setupMap(mex)
@@ -524,7 +476,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void validateSDNCResp_Get() {
ExecutionEntity mex = setupMock()
def data = initValidateSDNCResp(mex)
@@ -543,7 +495,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void validateSDNCResp_Unsuccessful() {
ExecutionEntity mex = setupMock()
initValidateSDNCResp(mex)
@@ -558,7 +510,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void validateSDNCResp_BpmnError() {
ExecutionEntity mex = setupMock()
initValidateSDNCResp(mex)
@@ -572,7 +524,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void validateSDNCResp_Ex() {
ExecutionEntity mex = setupMock()
initValidateSDNCResp(mex)
@@ -589,7 +541,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** preProcessSDNCGet *****
@Test
- // @Ignore
+
public void preProcessSDNCGet_FoundAR() {
ExecutionEntity mex = setupMock()
def map = setupMap(mex)
@@ -608,7 +560,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessSDNCGet_NotFoundAR() {
ExecutionEntity mex = setupMock()
def map = setupMap(mex)
@@ -629,7 +581,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessSDNCGet_Ex() {
ExecutionEntity mex = setupMock()
initPreProcessSDNCGet(mex)
@@ -660,7 +612,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** generateOutputs *****
@Test
- // @Ignore
+
public void generateOutputs() {
ExecutionEntity mex = setupMock()
def txctop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml")
@@ -679,7 +631,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void generateOutputs_BadXml() {
ExecutionEntity mex = setupMock()
@@ -694,7 +646,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void generateOutputs_BpmnError() {
ExecutionEntity mex = setupMock()
@@ -709,7 +661,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void generateOutputs_Ex() {
ExecutionEntity mex = setupMock()
@@ -727,7 +679,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** preProcessRollback *****
@Test
- // @Ignore
+
public void preProcessRollback() {
ExecutionEntity mex = setupMock()
WorkflowException wfe = mock(WorkflowException.class)
@@ -743,7 +695,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessRollback_NotWFE() {
ExecutionEntity mex = setupMock()
@@ -758,7 +710,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessRollback_BpmnError() {
ExecutionEntity mex = setupMock()
@@ -772,7 +724,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void preProcessRollback_Ex() {
ExecutionEntity mex = setupMock()
@@ -789,7 +741,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
// ***** postProcessRollback *****
@Test
- // @Ignore
+
public void postProcessRollback() {
ExecutionEntity mex = setupMock()
WorkflowException wfe = mock(WorkflowException.class)
@@ -806,7 +758,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void postProcessRollback_NotWFE() {
ExecutionEntity mex = setupMock()
@@ -822,7 +774,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void postProcessRollback_BpmnError() {
ExecutionEntity mex = setupMock()
@@ -837,7 +789,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
}
@Test
- // @Ignore
+
public void postProcessRollback_Ex() {
ExecutionEntity mex = setupMock()
@@ -891,7 +843,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace"))
- when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST)
+ when(mex.getVariable("PSI_resourceLink")).thenReturn(AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath( "/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST).build()))
when(mex.getVariable("allottedResourceType")).thenReturn("TXCt")
when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr")
when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi")
@@ -951,7 +903,7 @@ class DoCreateAllottedResourceTXCTest extends GroovyTestBase {
private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
index e8004d3d2b..0528529819 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy
@@ -20,12 +20,7 @@
package org.onap.so.bpmn.vcpe.scripts
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.delegate.DelegateExecution
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
@@ -33,33 +28,19 @@ import org.junit.Test
import org.junit.Ignore
import org.mockito.MockitoAnnotations
import org.camunda.bpm.engine.delegate.BpmnError
+import org.mockito.Spy
import org.onap.so.bpmn.core.UrnPropertiesReader
-import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
-import static com.github.tomakehurst.wiremock.client.WireMock.delete
-import static com.github.tomakehurst.wiremock.client.WireMock.get
-import static com.github.tomakehurst.wiremock.client.WireMock.patch
-import static com.github.tomakehurst.wiremock.client.WireMock.put
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
import static org.junit.Assert.*;
import static org.mockito.Mockito.*
import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById
-
-import java.util.Map
-
-import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.vcpe.scripts.MapSetter
-
import com.github.tomakehurst.wiremock.junit.WireMockRule
class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
-
+
@Rule
public WireMockRule wireMockRule = new WireMockRule(PORT)
@@ -69,11 +50,16 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
public static void setUpBeforeClass() {
super.setUpBeforeClass()
}
+
+ @Spy
+ DoDeleteAllottedResourceBRG doDeleteAllottedResourceBRG
@Before
public void init()
{
MockitoAnnotations.initMocks(this)
+ super.init()
+ when(doDeleteAllottedResourceBRG.getAllottedResourceUtils()).thenReturn(allottedResourceUtils_MOCK)
}
public DoDeleteAllottedResourceBRGTest() {
@@ -131,40 +117,21 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
// ***** getAaiAR *****
@Test
- @Ignore
+ @Ignore
public void getAaiAR() {
- MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml")
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
-
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
- DoDeleteAllottedResourceBRG.getAaiAR(mex)
-
+ when(client_MOCK.exists(any(AAIResourceUri.class))).thenReturn(true)
+ doDeleteAllottedResourceBRG.getAaiAR(mex)
verify(mex).setVariable("parentServiceInstanceId", INST)
}
@Test
-// @Ignore
public void getAaiAR_EmptyResponse() {
-
- // note: empty result-link
- wireMockRule
- .stubFor(get(urlMatching("/aai/.*/search/.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody("<result-data></result-data>")))
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
-
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
-
- DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.getAaiAR(mex) }))
+ when(client_MOCK.exists(any(AAIResourceUri.class))).thenReturn(false)
+ assertTrue(doBpmnError( { _ -> doDeleteAllottedResourceBRG.getAaiAR(mex) }))
}
@@ -562,13 +529,13 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version"))
when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri"))
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
}
private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
}
private initBuildSDNCRequest(ExecutionEntity mex) {
@@ -598,7 +565,7 @@ class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
private initDeleteAaiAR(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers")
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
index 6719be17a1..ad9b3d4f88 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy
@@ -20,12 +20,7 @@
package org.onap.so.bpmn.vcpe.scripts
-
-import org.camunda.bpm.engine.ProcessEngineServices
-import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.delegate.DelegateExecution
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
@@ -33,30 +28,15 @@ import org.junit.Test
import org.junit.Ignore
import org.mockito.MockitoAnnotations
import org.camunda.bpm.engine.delegate.BpmnError
+import org.mockito.Spy
import org.onap.so.bpmn.core.UrnPropertiesReader
-import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.mock.FileUtil
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
-import static com.github.tomakehurst.wiremock.client.WireMock.delete
-import static com.github.tomakehurst.wiremock.client.WireMock.get
-import static com.github.tomakehurst.wiremock.client.WireMock.patch
-import static com.github.tomakehurst.wiremock.client.WireMock.put
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
import static org.junit.Assert.*;
import static org.mockito.Mockito.*
import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById
-
-
-import java.util.Map
-
-import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.vcpe.scripts.MapSetter
-
import com.github.tomakehurst.wiremock.junit.WireMockRule
class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
@@ -66,6 +46,9 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
String Prefix = "DDARTXC_"
+ @Spy
+ DoDeleteAllottedResourceTXC doDeleteAllottedResourceTXC
+
@BeforeClass
public static void setUpBeforeClass() {
super.setUpBeforeClass()
@@ -74,7 +57,9 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
@Before
public void init()
{
- MockitoAnnotations.initMocks(this)
+ MockitoAnnotations.initMocks(this)
+ super.init()
+ when(doDeleteAllottedResourceTXC.getAllottedResourceUtils()).thenReturn(allottedResourceUtils_MOCK)
}
public DoDeleteAllottedResourceTXCTest() {
@@ -130,42 +115,23 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
// ***** getAaiAR *****
-
@Test
- @Ignore
+ @Ignore
public void getAaiAR() {
- MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml")
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
-
+
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
- DoDeleteAllottedResourceTXC.getAaiAR(mex)
-
+ when(client_MOCK.exists(any(AAIResourceUri.class))).thenReturn(true)
+ doDeleteAllottedResourceTXC.getAaiAR(mex)
verify(mex).setVariable("parentServiceInstanceId", INST)
}
-
+
@Test
-// @Ignore
public void getAaiAR_EmptyResponse() {
-
- // note: empty result-link
- wireMockRule
- .stubFor(get(urlMatching("/aai/.*/search/.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody("<result-data></result-data>")))
-
- MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml")
-
ExecutionEntity mex = setupMock()
initGetAaiAR(mex)
-
- DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC()
-
- assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.getAaiAR(mex) }))
+ when(client_MOCK.exists(any(AAIResourceUri.class))).thenReturn(false)
+ assertTrue(doBpmnError( { _ -> doDeleteAllottedResourceTXC.getAaiAR(mex) }))
}
@@ -563,13 +529,13 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version"))
when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri"))
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
}
private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
}
private initBuildSDNCRequest(ExecutionEntity mex) {
@@ -599,7 +565,7 @@ class DoDeleteAllottedResourceTXCTest extends GroovyTestBase {
private initDeleteAaiAR(ExecutionEntity mex) {
when(mex.getVariable(DBGFLAG)).thenReturn("true")
- when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
+ when(mex.getVariable("aaiARPath")).thenReturn("/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers")
when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy
index 764e6244d4..8ce3bdb6c3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy
@@ -25,35 +25,17 @@ import org.camunda.bpm.engine.ProcessEngineServices
import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
import org.camunda.bpm.engine.repository.ProcessDefinition
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.junit.Before
-import org.junit.BeforeClass
-import org.junit.Rule
-import org.junit.Test
-import org.junit.Ignore
-import org.mockito.MockitoAnnotations
+import org.junit.runner.RunWith
+import org.mockito.Mock
import org.camunda.bpm.engine.delegate.BpmnError
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.AllottedResourceUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
-import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.bpmn.mock.FileUtil
-import org.springframework.beans.factory.config.YamlPropertiesFactoryBean
-import org.springframework.core.io.ClassPathResource
-import org.springframework.core.io.Resource
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
-import static com.github.tomakehurst.wiremock.client.WireMock.get
-import static com.github.tomakehurst.wiremock.client.WireMock.patch
-import static com.github.tomakehurst.wiremock.client.WireMock.put
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
-import static org.junit.Assert.*;
+import org.onap.so.client.aai.AAIResourcesClient
import static org.mockito.Mockito.*
-import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
-import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.vcpe.scripts.MapSetter
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule
+@RunWith(MockitoJUnitRunner.class)
class GroovyTestBase {
static final int PORT = 28090
@@ -71,6 +53,11 @@ class GroovyTestBase {
String processName
+ AllottedResourceUtils allottedResourceUtils_MOCK
+
+ @Mock
+ AAIResourcesClient client_MOCK
+
public static void setUpBeforeClass() {
aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint")
}
@@ -120,5 +107,10 @@ class GroovyTestBase {
doAnswer(mapset).when(mex).setVariable(any(), any())
return mapset.getMap();
}
-
+
+ void init(){
+ allottedResourceUtils_MOCK = spy(new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class)))
+ when(allottedResourceUtils_MOCK.getAAIClient()).thenReturn(client_MOCK)
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
index 7d3d298c68..2e588b7078 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java
@@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.aai;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -38,7 +38,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
@@ -86,7 +86,7 @@ public class AAICreateResourcesTest {
public void createAAIProjectTest() {
doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), isA(Optional.class));
doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
- doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class));
+
aaiCreateResources.createAAIProject(projectName, serviceInstanceId);
@@ -185,7 +185,7 @@ public class AAICreateResourcesTest {
@Test
public void getVnfInstanceExceptionTest() {
- doThrow(Exception.class).when(aaiResourcesClient).get(isA(AAIResourceUri.class));
+ doThrow(RuntimeException.class).when(aaiResourcesClient).get(isA(AAIResourceUri.class));
Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId);
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java
index 5808a330a3..a540a6d2cc 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java
@@ -20,7 +20,7 @@
package org.onap.so.bpmn.infrastructure.aai;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -77,7 +77,7 @@ public class AAIDeleteServiceInstanceTest {
doReturn("testProcessKey").when(execution).getVariable("testProcessKey");
doReturn("serviceInstanceId").when(execution).getVariable("serviceInstanceId");
- doThrow(Exception.class).when(aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ doThrow(RuntimeException.class).when(aaiResourcesClient).delete(isA(AAIResourceUri.class));
aaiDeleteServiceInstance.execute(execution);
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
index 3eb3bd8796..eeda355f80 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
@@ -20,9 +20,8 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -34,8 +33,10 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.onap.so.bpmn.core.WorkflowException;
@@ -45,6 +46,9 @@ public class CheckAaiForCorrelationIdDelegateTest {
public static class ConnectionOkTests {
private CheckAaiForCorrelationIdDelegate delegate;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
@Before
public void setUp() {
@@ -53,13 +57,14 @@ public class CheckAaiForCorrelationIdDelegateTest {
}
@Test
- public void shouldThrowExceptionWhenCorrelationIdIsNotSet() {
+ public void shouldThrowExceptionWhenCorrelationIdIsNotSet() throws Exception {
// given
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable(CORRELATION_ID)).thenReturn(null);
when(execution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
// when, then
- assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ delegate.execute(execution);
verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
}
@@ -89,6 +94,9 @@ public class CheckAaiForCorrelationIdDelegateTest {
public static class NoConnectionTests {
private CheckAaiForCorrelationIdDelegate delegate;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
@Before
public void setUp() {
@@ -97,13 +105,14 @@ public class CheckAaiForCorrelationIdDelegateTest {
}
@Test
- public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() {
+ public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() throws Exception {
// given
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY);
when(execution.getVariable("testProcessKey")).thenReturn("testProcessKey");
// when, then
- assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ delegate.execute(execution);
verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
index ddf33a1d77..7a31ae1a67 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
@@ -29,7 +29,7 @@ import org.junit.Test;
import org.mockito.InOrder;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
index 1f3ecce341..f5be34bf92 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
@@ -20,8 +20,7 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -30,12 +29,17 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
public class PnfCheckInputsTest {
private static final String DEFAULT_TIMEOUT = "P1D";
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
private DelegateExecution mockDelegateExecution() {
new PnfCheckInputs(DEFAULT_TIMEOUT);
DelegateExecution delegateExecution = mock(DelegateExecution.class);
@@ -49,7 +53,8 @@ public class PnfCheckInputsTest {
PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
DelegateExecution delegateExecution = mockDelegateExecution();
// when, then
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ testedObject.execute(delegateExecution);
}
@Test
@@ -59,7 +64,8 @@ public class PnfCheckInputsTest {
DelegateExecution delegateExecution = mockDelegateExecution();
when(delegateExecution.getVariable(CORRELATION_ID)).thenReturn("");
// when, then
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ testedObject.execute(delegateExecution);
}
private DelegateExecution mockDelegateExecutionWithCorrelationId() {
@@ -75,7 +81,8 @@ public class PnfCheckInputsTest {
PnfCheckInputs testedObject = new PnfCheckInputs(null);
DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
// when, then
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ testedObject.execute(delegateExecution);
}
@Test
@@ -85,7 +92,8 @@ public class PnfCheckInputsTest {
DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
when(delegateExecution.getVariable(TIMEOUT_FOR_NOTIFICATION)).thenReturn("");
// when, then
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ expectedException.expect(BpmnError.class);
+ testedObject.execute(delegateExecution);
}
@Test
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
index aab01c0a3e..470061f6c2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
@@ -20,8 +20,9 @@
package org.onap.so.bpmn.infrastructure.pnf.dmaap;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
+
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -47,7 +48,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread;
import org.springframework.core.env.Environment;
@RunWith(MockitoJUnitRunner.class)
@@ -123,10 +124,13 @@ public class PnfEventReadyDmaapClientTest {
thenReturn(createResponse(String.format(JSON_EXAMPLE_WITH_CORRELATION_ID, CORRELATION_ID)));
testedObjectInnerClassThread.run();
ArgumentCaptor<HttpGet> captor1 = ArgumentCaptor.forClass(HttpGet.class);
- verify(httpClientMock).execute(captor1.capture());
- assertThat(captor1.getValue().getURI()).hasHost(HOST).hasPort(PORT).hasScheme(PROTOCOL)
- .hasPath(
- "/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
+ verify(httpClientMock).execute(captor1.capture());
+
+ assertEquals(captor1.getValue().getURI().getHost(),HOST);
+ assertEquals(captor1.getValue().getURI().getPort(),PORT);
+ assertEquals(captor1.getValue().getURI().getScheme(),PROTOCOL);
+ assertEquals(captor1.getValue().getURI().getPath(),"/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
+
verify(threadMockToNotifyCamundaFlow).run();
verify(executorMock).shutdown();
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/GenericVnfVfModule.json b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/GenericVnfVfModule.json
new file mode 100644
index 0000000000..488865c326
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/GenericVnfVfModule.json
@@ -0,0 +1,62 @@
+{
+ "closedLoopDisabled":false,
+ "vnf-id":"vnfId1",
+ "vnf-name":"vnfName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "model-invariant-id":"model1",
+ "vf-modules": {
+ "vf-module": [{
+ "vf-module-id": "lukewarm",
+ "vf-module-name": "testVfModuleNameGWPrim",
+ "heat-stack-id": "fastburn",
+ "is-base-vf-module": true,
+ "orchestration-status": "Created",
+ "module-index":0,
+ "model-invariant-id":"model1"
+ },
+ {
+ "vf-module-id": "testVfModuleIdGWSec",
+ "vf-module-name": "testVfModuleNameGWSec",
+ "heat-stack-id": "testHeatStackIdGWSec",
+ "orchestration-status": "Created",
+ "module-index":2,
+ "model-invariant-id":"model1"
+ }]
+ },
+ "volume-groups":[],
+ "line-of-business":null,
+ "platform":null,
+ "cascaded":false,
+ "cloud-params":{},
+ "cloud-context":null,
+ "solution":null,
+ "vnf-name-2":null,
+ "service-id":null,
+ "regional-resource-zone":null,
+ "prov-status":null,
+ "operational-status":null,
+ "equipment-role":null,
+ "management-option":null,
+ "ipv4-oam-address":null,
+ "ipv4-loopback0-address":null,
+ "nm-lan-v6-address":null,
+ "management-v6-address":null,
+ "vcpu":null,
+ "vcpu-units":null,
+ "vmemory":null,
+ "vmemory-units":null,
+ "vdisk":null,
+ "vdisk-units":null,
+ "in-maint":false,
+ "is-closed-loop-disabled":false,
+ "summary-status":null,
+ "encrypted-access-flag":null,
+ "as-number":null,
+ "regional-resource-subzone":null,
+ "self-link":null,
+ "ipv4-oam-gateway-address":null,
+ "ipv4-oam-gateway-address-prefix-length":null,
+ "vlan-id-outer":null,"nm-profile-name":null,
+ "model-info-generic-vnf":null
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/ServiceInstanceWithAR.json b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/ServiceInstanceWithAR.json
new file mode 100644
index 0000000000..1a2f5b8aa4
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/ServiceInstanceWithAR.json
@@ -0,0 +1,36 @@
+{"service-instance":{
+ "service-instance-id": "serviceInstanceId",
+ "service-instance-name": "serviceInstanceName",
+ "orchestration-status": "CREATED",
+ "owning-entity": null,
+ "project": null,
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "allotted-resource",
+ "related-link": "/aai/v11/business/customers/customer/testCustIdInfra/service-subscriptions/service-subscription/HNPORTAL/service-instances/service-instance/testServiceInstanceIdPortalPri/allotted-resources/allotted-resource/testAllottedResourceIdPortalPri",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "mdt1"
+ },
+ {
+ "relationship-key": "allotted-resource.id",
+ "relationship-value": "4a9184ac-5fad-44a1-b224-289bb490eaa9"
+ }
+ ]
+ }
+ ]
+ },
+ "service-type": "serviceType",
+ "service-instance-location-id": "serviceInstanceLocId",
+ "selflink": "selfLink",
+ "metadata": null,
+ "configurations": [],
+ "model-info-service-instance": null
+}
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroup.json b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroup.json
new file mode 100644
index 0000000000..4022ffe98a
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroup.json
@@ -0,0 +1,10 @@
+{
+ "volume-group-id":"volumeGroupId",
+ "volume-group-name":"volumeGroupName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "cloud-params":{},
+ "cascaded":false,
+ "heat-stack-id":"heatStackId",
+ "resource-version":"12345"
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroupWithTenant.json b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroupWithTenant.json
new file mode 100644
index 0000000000..e0fadfb78a
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroupWithTenant.json
@@ -0,0 +1,29 @@
+{
+ "volume-group-id":"volumeGroupId",
+ "volume-group-name":"volumeGroupName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "cloud-params":{},
+ "cascaded":false,
+ "heat-stack-id":"heatStackId",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "tenant",
+ "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/mdt1/tenants/tenant/Tenant123",
+ "relationship-data": [
+ {
+ "relationship-key": "cloud-region.cloud-owner",
+ "relationship-value": "CloudOwner"
+ },
+ {
+ "relationship-key": "cloud-region.cloud-region-id",
+ "relationship-value": "mdt1"
+ },
+ {
+ "relationship-key": "tenant.tenant-id",
+ "relationship-value": "Tenant123"
+ }]
+ }]
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroupWithVfModule.json b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroupWithVfModule.json
new file mode 100644
index 0000000000..9a47c44751
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/AAI/VolumeGroupWithVfModule.json
@@ -0,0 +1,26 @@
+{
+ "volume-group-id":"volumeGroupId",
+ "volume-group-name":"volumeGroupName",
+ "vnf-type":"vnfType",
+ "orchestration-status":"PRECREATED",
+ "cloud-params":{},
+ "cascaded":false,
+ "heat-stack-id":"heatStackId",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "vf-module",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/GENERIC-VNFSAT-vig30001vm001vig001/vf-modules/vf-module/a62d14f0-421e-4e64-980a-a368722819db",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "GENERIC-VNFSAT-vig30001vm001vig001"
+ },
+ {
+ "relationship-key": "vf-module.vf-module-id",
+ "relationship-value": "a62d14f0-421e-4e64-980a-a368722819db"
+ }
+ ]
+ }]
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml b/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml
index 78ecd6ce88..5b36b65b43 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml
@@ -1,287 +1,287 @@
-aai:
- auth: 757A94191D685FD2092AC1490730A4FC
- dme2:
- timeout: '30000'
- endpoint: http://localhost:${wiremock.server.port}
-camunda:
- bpm:
- admin-user:
- id: admin
- password: admin
- database:
- type: h2
- history-level: FULL
- metrics:
- enabled: false
- db-reporter-activate: false
-canopi:
- auth: 757A94191D685FD2092AC1490730A4FC
-csi:
- aots:
- addincidentmanagement:
- endpoint: http://localhost:${wiremock.server.port}/AddIncidentManagementTicketRequest
- networkstatus:
- endpoint: http://localhost:${wiremock.server.port}/SendManagedNetworkStatusNotification
-entitymanager:
- packagesToScan: com
-mso:
- correlation:
- timeout: PT60S
- logPath: logs
- async:
- core-pool-size: 50
- max-pool-size: 50
- queue-capacity: 500
- adapters:
- completemsoprocess:
- endpoint: http://localhost:30253/CompleteMsoProcess
- db:
- auth: 757A94191D685FD2092AC1490730A4FC
- password: wLg4sjrAFUS8rfVfdvTXeQ==
- endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter
- spring:
- endpoint: http://localhost:${wiremock.server.port}
- network:
- endpoint: http://localhost:30253/services/NetworkAdapter
- rest:
- endpoint: http://localhost:30253/services/rest/v1/networks
- openecomp:
- db:
- endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter
- po:
- auth: 757A94191D685FD2092AC1490730A4FC
- password: 3141634BF7E070AA289CF2892C986C0B
- sdnc:
- endpoint: http://localhost:${wiremock.server.port}/adapters/SDNCAdapter
- rest:
- endpoint: http://localhost:${wiremock.server.port}/adapters/rest/v1/sdnc
- timeout: PT150S
- tenant:
- endpoint: http://localhost:30253/services/TenantAdapter
- vnf:
- endpoint: http://localhost:${wiremock.server.port}/services/VnfAdapter
- rest:
- endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs
- volume-groups:
- rest:
- endpoint: http://localhost:30253/services/rest/v1/volume-groups
- vnf-async:
- endpoint: http://localhost:30253/services/VnfAdapterAsync
- adiod:
- vce:
- service:
- model:
- invariant:
- uuid: 1cc4e2e4-eb6e-404d-a66f-c8733cedcce8
- version: '5.0'
- bpmn:
- process:
- historyTimeToLive: '30'
- callbackRetryAttempts: '5'
- catalog:
- db:
- endpoint: http://localhost:${wiremock.server.port}/ecomp/mso/catalog
- spring:
- endpoint: http://localhost:30258
- csi:
- pwd: 4EA237303511EFBBC37F17A351562131
- sendmanagednetworkstatusnotification:
- applicationname: NetworkManagementEthernetOverFiber
- version: '212'
- usrname: mso
- db:
- auth: Basic YnBlbDptc28tZGItMTUwNyE=
- default:
- adapter:
- namespace: http://com.att.mso
- gateway:
- service:
- model:
- name: HNGWaaS for DHV Test
- healthcheck:
- log:
- debug: 'false'
- infra:
- customer:
- id: testCustIdInfra
- msoKey: 07a7159d3bf51a0e53be7a8f89699be7
- oam:
- network:
- role:
- gateway: HngwOamNetVto.OAM
- portal: HnportalOamNetVto.OAM
- po:
- timeout: PT60S
- portal:
- service:
- model:
- name: HNPortalaaS for DHV Test
- request:
- db:
- endpoint: http://localhost:${wiremock.server.port}/
- rollback: 'true'
- sdnc:
- firewall:
- yang:
- model:
- version: '2015-05-15'
- password: 3141634BF7E070AA289CF2892C986C0B
- timeout:
- firewall:
- minutes: '20'
- ucpe:
- async:
- hours: '120'
- minutes: '5'
- site-name: CamundaEngine
- sriov:
- network:
- role:
- gateway1: HngwSriovProviderNet.SR_IOV_Provider2_1
- gateway2: HngwSriovProviderNet.SR_IOV_Provider2_2
- portal1: HnportalSriovProviderNet3.SR_IOV_Provider2_1
- portal2: HnportalSriovProviderNet3.SR_IOV_Provider2_2
- workflow:
- sdnc:
- replication:
- delay: PT5S
- aai:
- distribution:
- delay: PT5S
- CreateGenericVNFV1:
- aai:
- volume-group:
- uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group
- DHVCreateService:
- aai:
- customer:
- uri: /aai/v9/business/customers/customer
- createvce:
- delay:
- seconds: '1'
- default:
- aai:
- version: '8'
- cloud-region:
- version: '9'
- generic-vnf:
- version: '9'
- retry:
- attempts: '1'
- deleteCinderVolumeV1:
- aai:
- volume-group:
- uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group
- global:
- default:
- aai:
- namespace: http://org.openecomp.aai.inventory/
- l3ToHigherLayerAddBonding:
- model:
- invariantid: 50359538-066f-4a8d-807f-f2bc8eaa79dc
- name: WAN Bonding v0.1
- version: '0.1'
- versionid: 52dbec20-47aa-42e4-936c-331d8e350d44
- message:
- endpoint: http://localhost:30252/mso/WorkflowMessage
- notification:
- name: GenericNotificationServiceATT
- sdncadapter:
- callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService
- vnfadapter:
- create:
- callback: http://localhost:30253/mso/vnfAdapterNotify
- delete:
- callback: http://localhost:30253/mso/vnfAdapterNotify
- query:
- callback: http://localhost:30253/mso/vnfAdapterNotify
- rollback:
- callback: http://localhost:30253/mso/vnfAdapterNotify
-policy:
- auth: Basic dGVzdHBkcDphbHBoYTEyMw==
- client:
- auth: Basic bTAzNzQzOnBvbGljeVIwY2sk
- endpoint: https://localhost:8081/pdp/api/
- environment: TEST
-sdnc:
- auth: Basic YWRtaW46YWRtaW4=
- host: https://localhost:8443
- path: /restconf/operations/GENERIC-RESOURCE-API
-sdno:
- health-check:
- dmaap:
- password: eHQ1cUJrOUc
- publisher:
- topic: com.att.sdno.test-health-diagnostic-v02
- subscriber:
- topic: com.att.sdno.test-health-diagnostic-v02
- username: testuser
-pnf:
- dmaap:
- host:
- port:
-sniro:
- conductor:
- host: http://localhost:30253
- uri: /release
- manager:
- timeout: PT30M
- host: http://localhost:${wiremock.server.port}
- uri.v1: /sniro/api/v2/placement
- uri.v2: /sniro/api/placement/v2
- headers.auth: Basic dGVzdDp0ZXN0cHdk
- headers.patchVersion: 1
- headers.minorVersion: 1
- headers.latestVersion: 2
-server:
- port: 8080
- tomcat:
- max-threads: 50
- # ssl:
- # key-store: /app/msoClientKeyStore.jks
- # key-store-password: mso4you
- # key-store-type: JKS
- # trust-store: /app/msoTrustStore.jks
- # trust-store-password: mso_Domain2.0_4you
-spring:
- h2:
- console:
- enabled: true
- path: /h2
- datasource:
- url: jdbc:h2:mem:AZ;;DB_CLOSE_ON_EXIT=FALSE
- username: sa
- password: sa
- driverClassName: org.h2.Driver
- security:
- usercredentials:
- -
- username: test
- password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
- role: BPMN-Client
-# Hibernate
-hibernate:
- dialect: org.hibernate.dialect.MySQL5Dialect
- show_sql: false
-
-management:
- security:
- enabled: false
-
-security:
- basic:
- enabled: false
-
-appc:
- client:
- topic:
- read:
- name: APPC-TEST-AMDOCS2
- timeout: 360000
- write: APPC-TEST-AMDOCS1-IST
- response:
- timeout: 360000
- key: LSl8QKolmKcC0yJR
- secret: lgjXraD1HutKxv8jEN6tVouu
- service: ueb
- poolMembers: localhost:3904,localhost:3904,localhost:3904 \ No newline at end of file
+aai:
+ auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
+ dme2:
+ timeout: '30000'
+ endpoint: http://localhost:${wiremock.server.port}
+camunda:
+ bpm:
+ admin-user:
+ id: admin
+ password: admin
+ database:
+ type: h2
+ history-level: FULL
+ metrics:
+ enabled: false
+ db-reporter-activate: false
+canopi:
+ auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
+csi:
+ aots:
+ addincidentmanagement:
+ endpoint: http://localhost:${wiremock.server.port}/AddIncidentManagementTicketRequest
+ networkstatus:
+ endpoint: http://localhost:${wiremock.server.port}/SendManagedNetworkStatusNotification
+entitymanager:
+ packagesToScan: com
+mso:
+ correlation:
+ timeout: PT60S
+ logPath: logs
+ async:
+ core-pool-size: 50
+ max-pool-size: 50
+ queue-capacity: 500
+ adapters:
+ completemsoprocess:
+ endpoint: http://localhost:30253/CompleteMsoProcess
+ db:
+ auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
+ password: wLg4sjrAFUS8rfVfdvTXeQ==
+ endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter
+ spring:
+ endpoint: http://localhost:${wiremock.server.port}
+ network:
+ endpoint: http://localhost:30253/services/NetworkAdapter
+ rest:
+ endpoint: http://localhost:30253/services/rest/v1/networks
+ openecomp:
+ db:
+ endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter
+ po:
+ auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C
+ password: 3141634BF7E070AA289CF2892C986C0B
+ sdnc:
+ endpoint: http://localhost:${wiremock.server.port}/adapters/SDNCAdapter
+ rest:
+ endpoint: http://localhost:${wiremock.server.port}/adapters/rest/v1/sdnc
+ timeout: PT150S
+ tenant:
+ endpoint: http://localhost:30253/services/TenantAdapter
+ vnf:
+ endpoint: http://localhost:${wiremock.server.port}/services/VnfAdapter
+ rest:
+ endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs
+ volume-groups:
+ rest:
+ endpoint: http://localhost:30253/services/rest/v1/volume-groups
+ vnf-async:
+ endpoint: http://localhost:30253/services/VnfAdapterAsync
+ adiod:
+ vce:
+ service:
+ model:
+ invariant:
+ uuid: 1cc4e2e4-eb6e-404d-a66f-c8733cedcce8
+ version: '5.0'
+ bpmn:
+ process:
+ historyTimeToLive: '30'
+ callbackRetryAttempts: '5'
+ catalog:
+ db:
+ endpoint: http://localhost:${wiremock.server.port}/ecomp/mso/catalog
+ spring:
+ endpoint: http://localhost:30258
+ csi:
+ pwd: E684FA9977AF5DFB50F5ADC5B7425FDFA0CEBFF2E138E0477549879AEC8A9CE2DB7563
+ sendmanagednetworkstatusnotification:
+ applicationname: NetworkManagementEthernetOverFiber
+ version: '212'
+ usrname: mso
+ db:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ default:
+ adapter:
+ namespace: http://com.att.mso
+ gateway:
+ service:
+ model:
+ name: HNGWaaS for DHV Test
+ healthcheck:
+ log:
+ debug: 'false'
+ infra:
+ customer:
+ id: testCustIdInfra
+ msoKey: 07a7159d3bf51a0e53be7a8f89699be7
+ oam:
+ network:
+ role:
+ gateway: HngwOamNetVto.OAM
+ portal: HnportalOamNetVto.OAM
+ po:
+ timeout: PT60S
+ portal:
+ service:
+ model:
+ name: HNPortalaaS for DHV Test
+ request:
+ db:
+ endpoint: http://localhost:${wiremock.server.port}/
+ rollback: 'true'
+ sdnc:
+ firewall:
+ yang:
+ model:
+ version: '2015-05-15'
+ password: 3141634BF7E070AA289CF2892C986C0B
+ timeout:
+ firewall:
+ minutes: '20'
+ ucpe:
+ async:
+ hours: '120'
+ minutes: '5'
+ site-name: CamundaEngine
+ sriov:
+ network:
+ role:
+ gateway1: HngwSriovProviderNet.SR_IOV_Provider2_1
+ gateway2: HngwSriovProviderNet.SR_IOV_Provider2_2
+ portal1: HnportalSriovProviderNet3.SR_IOV_Provider2_1
+ portal2: HnportalSriovProviderNet3.SR_IOV_Provider2_2
+ workflow:
+ sdnc:
+ replication:
+ delay: PT5S
+ aai:
+ distribution:
+ delay: PT5S
+ CreateGenericVNFV1:
+ aai:
+ volume-group:
+ uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group
+ DHVCreateService:
+ aai:
+ customer:
+ uri: /aai/v9/business/customers/customer
+ createvce:
+ delay:
+ seconds: '1'
+ default:
+ aai:
+ version: '8'
+ cloud-region:
+ version: '9'
+ generic-vnf:
+ version: '9'
+ retry:
+ attempts: '1'
+ deleteCinderVolumeV1:
+ aai:
+ volume-group:
+ uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group
+ global:
+ default:
+ aai:
+ namespace: http://org.openecomp.aai.inventory/
+ l3ToHigherLayerAddBonding:
+ model:
+ invariantid: 50359538-066f-4a8d-807f-f2bc8eaa79dc
+ name: WAN Bonding v0.1
+ version: '0.1'
+ versionid: 52dbec20-47aa-42e4-936c-331d8e350d44
+ message:
+ endpoint: http://localhost:30252/mso/WorkflowMessage
+ notification:
+ name: GenericNotificationServiceATT
+ sdncadapter:
+ callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService
+ vnfadapter:
+ create:
+ callback: http://localhost:30253/mso/vnfAdapterNotify
+ delete:
+ callback: http://localhost:30253/mso/vnfAdapterNotify
+ query:
+ callback: http://localhost:30253/mso/vnfAdapterNotify
+ rollback:
+ callback: http://localhost:30253/mso/vnfAdapterNotify
+policy:
+ auth: Basic dGVzdHBkcDphbHBoYTEyMw==
+ client:
+ auth: Basic bTAzNzQzOnBvbGljeVIwY2sk
+ endpoint: https://localhost:8081/pdp/api/
+ environment: TEST
+sdnc:
+ auth: Basic YWRtaW46YWRtaW4=
+ host: https://localhost:8443
+ path: /restconf/operations/GENERIC-RESOURCE-API
+sdno:
+ health-check:
+ dmaap:
+ password: eHQ1cUJrOUc
+ publisher:
+ topic: com.att.sdno.test-health-diagnostic-v02
+ subscriber:
+ topic: com.att.sdno.test-health-diagnostic-v02
+ username: testuser
+pnf:
+ dmaap:
+ host:
+ port:
+sniro:
+ conductor:
+ host: http://localhost:30253
+ uri: /release
+ manager:
+ timeout: PT30M
+ host: http://localhost:${wiremock.server.port}
+ uri.v1: /sniro/api/v2/placement
+ uri.v2: /sniro/api/placement/v2
+ headers.auth: Basic dGVzdDp0ZXN0cHdk
+ headers.patchVersion: 1
+ headers.minorVersion: 1
+ headers.latestVersion: 2
+server:
+ port: 8080
+ tomcat:
+ max-threads: 50
+ # ssl:
+ # key-store: /app/msoClientKeyStore.jks
+ # key-store-password: mso4you
+ # key-store-type: JKS
+ # trust-store: /app/msoTrustStore.jks
+ # trust-store-password: mso_Domain2.0_4you
+spring:
+ h2:
+ console:
+ enabled: true
+ path: /h2
+ datasource:
+ url: jdbc:h2:mem:AZ;;DB_CLOSE_ON_EXIT=FALSE
+ username: sa
+ password: sa
+ driverClassName: org.h2.Driver
+ security:
+ usercredentials:
+ -
+ username: test
+ password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
+ role: BPMN-Client
+# Hibernate
+hibernate:
+ dialect: org.hibernate.dialect.MySQL5Dialect
+ show_sql: false
+
+management:
+ security:
+ enabled: false
+
+security:
+ basic:
+ enabled: false
+
+appc:
+ client:
+ topic:
+ read:
+ name: APPC-TEST-AMDOCS2
+ timeout: 360000
+ write: APPC-TEST-AMDOCS1-IST
+ response:
+ timeout: 360000
+ key: LSl8QKolmKcC0yJR
+ secret: lgjXraD1HutKxv8jEN6tVouu
+ service: ueb
+ poolMembers: localhost:3904,localhost:3904,localhost:3904