Merge "query clients now have more useable result methods"
authorSteve Smokowski <ss835w@att.com>
Wed, 6 Mar 2019 17:26:24 +0000 (17:26 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 6 Mar 2019 17:26:24 +0000 (17:26 +0000)
44 files changed:
adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
adapters/mso-catalog-db-adapter/src/main/resources/application.yaml
adapters/mso-openstack-adapters/pom.xml
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java [moved from adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java with 94% similarity]
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java [new file with mode: 0644]
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/HeatStackAudit.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java
adapters/mso-openstack-adapters/src/main/resources/application.yaml
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditCreateStackServiceTest.java [moved from adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceDataTest.java with 88% similarity]
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditVServerTest.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/HeatStackAuditTest.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json
bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json
bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/ActivateVfModuleBBTest.java
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java
bpmn/so-bpmn-building-blocks/src/test/resources/logback-test.xml
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java
mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImplTest.java
mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java
so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java
so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/Constants.java [new file with mode: 0644]
so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java
so-monitoring/so-monitoring-service/src/test/resources/application-test.yaml
so-monitoring/so-monitoring-service/src/test/resources/databaseResponses/searchResult.json [new file with mode: 0644]

index 00602af..8fbccaa 100644 (file)
@@ -128,6 +128,6 @@ public class KeystoneV3Authentication {
                                }
                        }
                }
-               throw new ServiceEndpointNotFoundException("endpoint url not found");
+               throw new ServiceEndpointNotFoundException("endpoint url not found: type:" + type +" region: " + region + " facing: " + facing);
        }
 }
index ee1c79c..a0fbd48 100644 (file)
@@ -999,6 +999,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
             OpenStackRequest <Stack> request = heatClient.getStacks ().byName (stackName);
             return executeAndRecordOpenstackRequest (request);
         } catch (OpenStackResponseException e) {
+               logger.error("Error in Query Stack", e);
             if (e.getStatus () == 404) {
                 logger.debug ("queryHeatStack - stack not found: {}", stackName);
                 return null;
index aa9317c..07b0008 100644 (file)
@@ -28,6 +28,7 @@ spring:
     password: ${DB_ADMIN_PASSWORD}
     outOfOrder: true
     validateOnMigrate: false
+    repeatableSqlMigrationPrefix: RATT
   jpa:
       show-sql: true
       hibernate:
index f2f411d..cb35e90 100644 (file)
@@ -13,8 +13,8 @@
 
        <build>
                <finalName>${project.artifactId}-${project.version}</finalName>
-
-               <plugins>
+               
+               <plugins>                       
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-dependency-plugin</artifactId>
                                </executions>
                        </plugin>
 
-                       <!-- run the following plugin only when there's a wsdl change and you 
-                               need to recompile the java classes <plugin> <groupId>org.codehaus.mojo</groupId> 
-                               <artifactId>jaxws-maven-plugin</artifactId> <version>2.4.1</version> <executions> 
-                               <execution> <id>generate-network-async-stubs</id> <phase>process-classes</phase> 
-                               <goals> <goal>wsimport</goal> </goals> <configuration> <vmArgs> <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> 
-                               </vmArgs> <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> <wsdlFiles> 
-                               <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile> </wsdlFiles> <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation> 
-                               <packageName>org.onap.so.adapters.network.async.client</packageName> <xnocompile>false</xnocompile> 
-                               <keep>true</keep> </configuration> </execution> <execution> <id>generate-vnf-async-stubs</id> 
-                               <phase>process-classes</phase> <goals> <goal>wsimport</goal> </goals> <configuration> 
-                               <vmArgs> <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> </vmArgs> <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory> 
-                               <wsdlFiles> <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile> </wsdlFiles> <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation> 
-                               <packageName>org.onap.so.adapters.vnf.async.client</packageName> <xnocompile>false</xnocompile> 
-                               <keep>true</keep> </configuration> </execution> </executions> </plugin> <plugin> 
-                               <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> 
-                               <version>3.0.0</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> 
-                               <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>${project.build.directory}/generated-sources/wsimport/</source> 
-                               </sources> </configuration> </execution> </executions> </plugin> -->
+<!--  run the following plugin only when there's a wsdl change and you need to recompile the java classes
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>jaxws-maven-plugin</artifactId>
+                               <version>2.4.1</version>
+                               <executions>
+                                       <execution>
+                                               <id>generate-network-async-stubs</id>
+                                               <phase>process-classes</phase>
+                                               <goals>
+                                                       <goal>wsimport</goal>
+                                               </goals>
+                                               <configuration>
+                            <vmArgs>
+                                <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
+                            </vmArgs>
+                                                       <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
+                                                       <wsdlFiles>
+                                                               <wsdlFile>NetworkAdapterNotify.wsdl</wsdlFile>
+                                                       </wsdlFiles>
+                                                       <wsdlLocation>/NetworkAdapterNotify.wsdl</wsdlLocation>
+                                                       <packageName>org.onap.so.adapters.network.async.client</packageName>
+                                                       <xnocompile>false</xnocompile>
+                                                       <keep>true</keep>
+                                               </configuration>
+                                       </execution>
+                                       
+                                       <execution>
+                                               <id>generate-vnf-async-stubs</id>
+                                               <phase>process-classes</phase>
+                                               <goals>
+                                                       <goal>wsimport</goal>
+                                               </goals>
+                                               <configuration>
+                                               <vmArgs>
+                                                   <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
+                                               </vmArgs>
+                                                       <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
+                                                       <wsdlFiles>
+                                                               <wsdlFile>VnfAdapterNotify.wsdl</wsdlFile>
+                                                       </wsdlFiles>
+                                                       <wsdlLocation>/VnfAdapterNotify.wsdl</wsdlLocation>
+                                                       <packageName>org.onap.so.adapters.vnf.async.client</packageName>
+                                                       <xnocompile>false</xnocompile>
+                                                       <keep>true</keep>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
                        <plugin>
+                           <groupId>org.codehaus.mojo</groupId>
+                           <artifactId>build-helper-maven-plugin</artifactId>
+                           <version>3.0.0</version>
+                           <executions>
+                               <execution>
+                                   <id>add-source</id>
+                                   <phase>generate-sources</phase>
+                                   <goals>
+                                       <goal>add-source</goal>
+                                   </goals>
+                                   <configuration>
+                                       <sources>
+                                           <source>${project.build.directory}/generated-sources/wsimport/</source>
+                                       </sources>
+                                   </configuration>
+                               </execution>
+                           </executions>
+                        </plugin>                      
+ -->           <plugin>
                                <groupId>org.jacoco</groupId>
                                <artifactId>jacoco-maven-plugin</artifactId>
                        </plugin>
                                        </execution>
                                </executions>
                        </plugin>
-               </plugins>
-
-
+               </plugins>              
+               
+               
                <pluginManagement>
                        <plugins>
-                               <!--This plugin's configuration is used to store Eclipse m2e settings 
+                               <!--This plugin's configuration is used to store Eclipse m2e settings
                                        only. It has no influence on the Maven build itself. -->
                                <plugin>
                                        <groupId>org.eclipse.m2e</groupId>
        </build>
 
        <dependencies>
-               <!-- added for spring boot support -->
+       <!-- added for spring boot support -->  
                <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-actuator</artifactId>
+               <groupId>org.springframework.boot</groupId>
+               <artifactId>spring-boot-starter-actuator</artifactId>
                </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
-                       <version>${cxf.version}</version>
+                       <version>${cxf.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <version>${cxf.version}</version>
                </dependency>
                <dependency>
-                       <groupId>org.apache.cxf</groupId>
-                       <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
-                       <version>${cxf.version}</version>
+               <groupId>org.apache.cxf</groupId>
+               <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
+               <version>${cxf.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.webjars</groupId>
                        <scope>test</scope>
                </dependency>
                <dependency>
-                       <groupId>janino</groupId>
-                       <artifactId>janino</artifactId>
-                       <version>2.5.15</version>
+               <groupId>janino</groupId>
+               <artifactId>janino</artifactId>
+               <version>2.5.15</version>
                </dependency>
-
-               <!-- end added for spring boot support -->
-
-
-
-               <!-- added for unit testing -->
+        
+       <!-- end added for spring boot support -->      
+       
+       
+       
+       <!-- added for unit testing -->         
                <dependency>
                        <groupId>org.onap.so.adapters</groupId>
                        <artifactId>mso-adapter-utils</artifactId>
                        <groupId>javax.servlet</groupId>
                        <artifactId>javax.servlet-api</artifactId>
                        <scope>test</scope>
-               </dependency>
+               </dependency>           
                <dependency>
                        <groupId>org.mariadb.jdbc</groupId>
                        <artifactId>mariadb-java-client</artifactId>
-               </dependency>
+               </dependency>           
                <dependency>
                        <groupId>org.onap.so</groupId>
                        <artifactId>common</artifactId>
                        <version>${openstack.version}</version>
                </dependency>
                <dependency>
-                       <groupId>org.camunda.bpm</groupId>
-                       <artifactId>camunda-external-task-client</artifactId>
-                       <version>1.0.0</version>
-               </dependency>
+                       <groupId>org.camunda.bpm</groupId>
+                       <artifactId>camunda-external-task-client</artifactId>
+                       <version>1.1.1</version>
+               </dependency>   
        </dependencies>
 </project>
@@ -22,7 +22,6 @@
 
 package org.onap.so.adapters.audit;
 
-
 import org.camunda.bpm.client.task.ExternalTask;
 import org.camunda.bpm.client.task.ExternalTaskService;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
@@ -35,14 +34,14 @@ import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
 
 @Component
-public class AuditStackServiceData {
+public class AuditCreateStackService {
        
        private static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "Unable to find all VServers and L-Interaces in A&AI";
        
        private static final int[] RETRY_SEQUENCE = new int[] { 1, 1, 2, 3, 5, 8, 13, 20};
 
        
-       private static final Logger logger = LoggerFactory.getLogger(AuditStackServiceData.class);
+       private static final Logger logger = LoggerFactory.getLogger(AuditCreateStackService.class);
        
        @Autowired
        public HeatStackAudit heatStackAudit; 
@@ -56,7 +55,7 @@ public class AuditStackServiceData {
                boolean success = false;
                try {
                        logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries());
-                       success=heatStackAudit.auditHeatStack(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(),
+                       success=heatStackAudit.auditHeatStackCreate(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(),
                                        auditInventory.getTenantId(), auditInventory.getHeatStackName());
                } catch (Exception e) {
                        logger.error("Error during audit of stack", e);
@@ -72,7 +71,7 @@ public class AuditStackServiceData {
                        }else if(externalTask.getRetries() != null &&
                                        externalTask.getRetries()-1 == 0){
                                logger.debug("The External Task Id: {}  Failed, All Retries Exhausted", externalTask.getId());
-                               externalTaskService.handleBpmnError(externalTask, "AuditAAIInventoryFailure");
+                               externalTaskService.handleBpmnError(externalTask, "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory");
                        }else{
                                logger.debug("The External Task Id: {}  Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(),externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries()));
                                externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries()));
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java
new file mode 100644 (file)
index 0000000..66d8fbd
--- /dev/null
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.audit;
+
+import org.camunda.bpm.client.task.ExternalTask;
+import org.camunda.bpm.client.task.ExternalTaskService;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.audit.beans.AuditInventory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AuditDeleteStackService {
+       
+       private static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "All VServers have not been deleted in A&AI";
+       
+       private static final int[] RETRY_SEQUENCE = new int[] { 1, 1, 2, 3, 5, 8, 13, 20};
+
+       
+       private static final Logger logger = LoggerFactory.getLogger(AuditDeleteStackService.class);
+       
+       @Autowired
+       public HeatStackAudit heatStackAudit; 
+       
+       @Autowired
+       public Environment env;
+
+       protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService){
+               AuditInventory auditInventory = externalTask.getVariable("auditInventory");
+               setupMDC(externalTask);
+               boolean success = false;
+               try {
+                       logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory,externalTask.getRetries());
+                       success=heatStackAudit.auditHeatStackDeleted(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(),
+                                       auditInventory.getTenantId(), auditInventory.getHeatStackName());
+               } catch (Exception e) {
+                       logger.error("Error during audit of stack", e);
+               }
+               
+               if (success) {
+                       externalTaskService.complete(externalTask);
+                       logger.debug("The External Task Id: {}  Successful", externalTask.getId());
+               } else {
+                       if(externalTask.getRetries() == null){
+                               logger.debug("The External Task Id: {}  Failed, Setting Retries to Default Start Value: {}", externalTask.getId(),RETRY_SEQUENCE.length);
+                               externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, RETRY_SEQUENCE.length, 10000);                      
+                       }else if(externalTask.getRetries() != null &&
+                                       externalTask.getRetries()-1 == 0){
+                               logger.debug("The External Task Id: {}  Failed, All Retries Exhausted", externalTask.getId());
+                               externalTaskService.complete(externalTask);
+                       }else{
+                               logger.debug("The External Task Id: {}  Failed, Decrementing Retries: {} , Retry Delay: ", externalTask.getId(),externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries()));
+                               externalTaskService.handleFailure(externalTask, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI, externalTask.getRetries()-1, calculateRetryDelay(externalTask.getRetries()));
+                       }
+                       logger.debug("The External Task Id: {} Failed", externalTask.getId());
+               }
+       }
+       private void setupMDC(ExternalTask externalTask) {
+               String msoRequestId = (String)externalTask.getVariable("mso-request-id");
+               if(msoRequestId != null && !msoRequestId.isEmpty())
+                       MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
+       }
+       protected long calculateRetryDelay(int currentRetries){
+               int retrySequence = RETRY_SEQUENCE.length - currentRetries;
+               long retryMultiplier = Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier","6000"));
+               return RETRY_SEQUENCE[retrySequence] * retryMultiplier;
+       }
+}
index 499c113..6ea14dc 100644 (file)
@@ -46,10 +46,30 @@ public class AuditStackService {
        public Environment env;
 
        @Autowired
-       private AuditStackServiceData auditStack;
+       private AuditCreateStackService auditCreateStack;
+       
+       @Autowired
+       private AuditDeleteStackService auditDeleteStack;
 
        @PostConstruct
-       public void auditAAIInventory() {
+       public void auditAddAAIInventory() {
+               String auth = "";
+               try {
+                       auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey"));
+               } catch (IllegalStateException | GeneralSecurityException e) {
+                       logger.error("Error Decrypting Password", e);
+               }
+               ClientRequestInterceptor interceptor = new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"),
+                               auth);
+               ExternalTaskClient client = ExternalTaskClient.create()
+                               .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
+                               .asyncResponseTimeout(120000).build();
+               client.subscribe("InventoryAddAudit").lockDuration(60000)
+                               .handler(auditCreateStack::executeExternalTask).open();
+       }
+       
+       @PostConstruct
+       public void auditDeleteAAIInventory() {
                String auth = "";
                try {
                        auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey"));
@@ -60,9 +80,9 @@ public class AuditStackService {
                                auth);
                ExternalTaskClient client = ExternalTaskClient.create()
                                .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
-                               .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(10000, 2, 120000)).build();
-               client.subscribe("InventoryAudit").lockDuration(60000)
-                               .handler(auditStack::executeExternalTask).open();
+                               .asyncResponseTimeout(120000).build();
+               client.subscribe("InventoryDeleteAudit").lockDuration(60000)
+                               .handler(auditDeleteStack::executeExternalTask).open();
        }
 
 }
index 6e6ecd5..c81dac7 100644 (file)
@@ -39,23 +39,32 @@ import org.springframework.stereotype.Component;
 public class AuditVServer extends AbstractAudit {
        private static final Logger logger = LoggerFactory.getLogger(AuditVServer.class);
 
-       public boolean auditVservers(Set<Vserver> vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) {
+       public boolean auditAllVserversDoExist(Set<Vserver> vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) {
                if (vServersToAudit == null || vServersToAudit.isEmpty()){
                        return false;
                }
                return vServersToAudit.stream()
-                               .filter(vServer -> !doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion)).findFirst()
+                               .filter(vServer -> !doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion,true)).findFirst()
+                               .map(v -> false).orElse(true);
+       }
+       
+       public boolean auditAllVserversDoNotExist(Set<Vserver> vServersToAudit, String tenantId, String cloudOwner, String cloudRegion) {
+               if (vServersToAudit == null || vServersToAudit.isEmpty()){
+                       return true;
+               }
+               return vServersToAudit.stream()
+                               .filter(vServer -> doesVServerExistInAAI(vServer, tenantId, cloudOwner, cloudRegion,false)).findFirst()
                                .map(v -> false).orElse(true);
        }
 
-       private boolean doesVServerExistInAAI(Vserver vServer, String tenantId, String cloudOwner, String cloudRegion) {
+       private boolean doesVServerExistInAAI(Vserver vServer, String tenantId, String cloudOwner, String cloudRegion, boolean checkLinterfaces) {
                AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion,
                                tenantId, vServer.getVserverId());
                boolean vServerExists = getAaiClient().exists(vserverURI);
                boolean doesExist = getAaiClient().exists(vserverURI);
                logger.info("v-server {} exists: {}", vServer.getVserverId(), doesExist);
                boolean allNeutronNetworksExist = true;
-               if (vServerExists && vServer.getLInterfaces() != null) {
+               if (vServerExists && vServer.getLInterfaces() != null && checkLinterfaces) {
                        allNeutronNetworksExist = vServer.getLInterfaces()
                                        .getLInterface().stream().filter(lInterface -> !doesLinterfaceExistinAAI(lInterface,
                                                        vServer.getVserverId(), tenantId, cloudOwner, cloudRegion))
index da833c7..19e3ab7 100644 (file)
@@ -57,26 +57,51 @@ public class HeatStackAudit {
        @Autowired
        protected AuditVServer auditVservers;
 
-       public boolean auditHeatStack(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) {
+       public boolean auditHeatStackCreate(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) {
                try {
-                       logger.debug("Fetching Top Level Stack Information");
-                       Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName);
-                       List<Resource> novaResources = resources.getList().stream()
-                                       .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
-                       List<Resource> resourceGroups = resources.getList().stream()
-                                       .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList());
-                       if(novaResources.isEmpty())
-                               return true;
-                       else{                           
-                               Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources);
-                               Set<Vserver> vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups,
-                                       vserversToAudit);
-                               return auditVservers.auditVservers(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion);
-                       }
+                       return auditStack(cloudRegion,cloudOwner,tenantId,heatStackName,true);
                } catch (Exception e) {
                        logger.error("Error during auditing stack resources", e);
                        return false;
                }
+       }
+       
+       public boolean auditHeatStackDeleted(String cloudRegion, String cloudOwner, String tenantId, String heatStackName) {
+               try {
+                       return auditStack(cloudRegion,cloudOwner,tenantId,heatStackName,false);
+               } catch (Exception e) {
+                       logger.error("Error during auditing stack resources", e);
+                       return false;
+               }
+       }
+       
+       private boolean auditStack(String cloudRegion, String cloudOwner, String tenantId, String heatStackName,boolean isCreateAudit) throws Exception{
+               logger.debug("Fetching Top Level Stack Information");
+               Resources resources = heat.queryStackResources(cloudRegion, tenantId, heatStackName);
+               List<Resource> novaResources = extractNovaResources(resources);
+               if(novaResources.isEmpty())
+                       return true;
+               else{
+                       List<Resource> resourceGroups = extractResourceGroups(resources);
+                       Set<Vserver> vserversToAudit = createVserverSet(resources, novaResources);
+                       Set<Vserver> vserversWithSubInterfaces = processSubInterfaces(cloudRegion, tenantId, resourceGroups,
+                               vserversToAudit);
+                       if(isCreateAudit){
+                               return auditVservers.auditAllVserversDoExist(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion);
+                       }else{
+                               return auditVservers.auditAllVserversDoNotExist(vserversWithSubInterfaces, tenantId, cloudOwner, cloudRegion);
+                       }
+               }
+       }
+
+       private List<Resource> extractResourceGroups(Resources resources) {
+               return resources.getList().stream()
+                               .filter(p -> "OS::Heat::ResourceGroup".equals(p.getType()) && p.getName().contains("subinterfaces")).collect(Collectors.toList());
+       }
+
+       private List<Resource> extractNovaResources(Resources resources) {
+               return resources.getList().stream()
+                               .filter(p -> "OS::Nova::Server".equals(p.getType())).collect(Collectors.toList());
        } 
 
        protected Set<Vserver> processSubInterfaces(String cloudRegion, String tenantId, List<Resource> resourceGroups,
@@ -208,5 +233,4 @@ public class HeatStackAudit {
                return Optional.empty();
        }
        
-       
 }
index 8f9152a..253f13d 100644 (file)
@@ -90,6 +90,7 @@ public class NetworkAdapterRest {
 
        @Autowired
        private MsoNetworkAdapterImpl adapter;
+       
        @Autowired
        private Provider<BpelRestClient> bpelRestClientProvider;
        
index 7265a59..8a5a083 100644 (file)
@@ -59,7 +59,7 @@ import org.springframework.stereotype.Component;
  * org.onap.so.adapters.vnf.retrylist list of response codes that will trigger a retry (the special code
  *                     900 means "connection was not established")
  */
-@Component()
+@Component
 @Scope("prototype")
 public class BpelRestClient {
        public  static final String MSO_PROP_VNF_ADAPTER     = "MSO_PROP_VNF_ADAPTER";
index 4e8d389..cdd04b8 100644 (file)
@@ -30,8 +30,19 @@ spring:
         ddl-auto: validate
         naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
         enable-lazy-load-no-trans: true
-  
-
+org:
+  onap:
+    so:
+      adapters:
+        default_keystone_url_version: /v2.0
+        default_keystone_reg_ex: "/[vV][0-9]"        
+        po:
+          retryCodes: 504
+          retryDelay: 5
+          retryCount: 3
+          pollTimeout: 7500
+          pollInterval: 15
+          
 #Actuator
 management:
   endpoints:
@@ -40,10 +40,10 @@ import org.springframework.core.env.Environment;
 import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonMappingException;
 
-public class AuditStackServiceDataTest extends AuditStackServiceData {
+public class AuditCreateStackServiceTest extends AuditCreateStackService {
 
        @InjectMocks
-       AuditStackServiceData auditStackService = new AuditStackServiceData();
+       AuditCreateStackService auditStackService = new AuditCreateStackService();
 
        @Mock
        HeatStackAudit heatStackAuditMock;
@@ -73,14 +73,14 @@ public class AuditStackServiceDataTest extends AuditStackServiceData {
 
        @Test
        public void execute_external_task_audit_success_Test() {
-               doReturn(true).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName");
+               doReturn(true).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName");
                auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
                Mockito.verify(mockExternalTaskService).complete(mockExternalTask);
        }
 
        @Test
        public void execute_external_task_audit_first_failure_Test() {
-               doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName");
+               doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName");
                doReturn(null).when(mockExternalTask).getRetries();
                auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);
                Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask,
@@ -90,7 +90,7 @@ public class AuditStackServiceDataTest extends AuditStackServiceData {
 
        @Test
        public void execute_external_task_audit_intermediate_failure_Test() {
-               doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName");
+               doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName");
                doReturn(6).when(mockExternalTask).getRetries();
                auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);               
                Mockito.verify(mockExternalTaskService).handleFailure(mockExternalTask,
@@ -101,11 +101,11 @@ public class AuditStackServiceDataTest extends AuditStackServiceData {
 
        @Test
        public void execute_external_task_audit_final_failure_Test() {
-               doReturn(false).when(heatStackAuditMock).auditHeatStack("cloudRegion", "cloudOwner", "tenantId", "stackName");
+               doReturn(false).when(heatStackAuditMock).auditHeatStackCreate("cloudRegion", "cloudOwner", "tenantId", "stackName");
                doReturn(1).when(mockExternalTask).getRetries();
                auditStackService.executeExternalTask(mockExternalTask, mockExternalTaskService);               
                Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask,
-                               "AuditAAIInventoryFailure");
+                               "AuditAAIInventoryFailure", "Number of Retries Exceeded auditing inventory");
        }
 
        @Test
index 02557d8..9176b58 100644 (file)
@@ -58,8 +58,6 @@ import com.woorea.openstack.heat.model.Resources;
 @RunWith(MockitoJUnitRunner.Silent.class)
 public class AuditVServerTest extends AuditVServer {
 
-       private ObjectMapper objectMapper = new ObjectMapper();
-
        @InjectMocks
        private AuditVServer auditNova = new AuditVServer();
 
@@ -225,9 +223,13 @@ public class AuditVServerTest extends AuditVServer {
        
        @Test
        public void audit_Vserver_Empty_HashSet() throws JsonParseException, JsonMappingException, IOException {
-               boolean exists = auditNova.auditVservers(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion);            
+               boolean exists = auditNova.auditAllVserversDoExist(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion);
                assertEquals(false, exists);
+               
+               boolean doNotExist = auditNova.auditAllVserversDoNotExist(new HashSet<Vserver>(), tenantId, cloudOwner, cloudRegion);
+               assertEquals(true, doNotExist);
        }
+       
 
        @Test
        public void audit_Vserver_Found_Test() throws JsonParseException, JsonMappingException, IOException {
@@ -246,8 +248,11 @@ public class AuditVServerTest extends AuditVServer {
                doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri);
                doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri);
 
-               boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);           
+               boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);         
                assertEquals(true, exists);
+               
+               boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);          
+               assertEquals(false, doNotExist);
        }
 
        @Test
@@ -268,8 +273,11 @@ public class AuditVServerTest extends AuditVServer {
                doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri);
                doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri);
 
-               boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);           
+               boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);         
                assertEquals(false, exists);
+               
+               boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);          
+               assertEquals(false, doNotExist);
        }
 
        @Test
@@ -288,16 +296,23 @@ public class AuditVServerTest extends AuditVServer {
                doReturn(true).when(aaiResourcesMock).exists(service2_sub_1_uri);
                doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri);
                doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri);
-               boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);
+               boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);
                assertEquals(false, exists);
+               
+               boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);          
+               assertEquals(false, doNotExist);
        }
 
        @Test
-       public void audit_Vserver_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException {
+       public void audit_Vservers_Not_Found_Test() throws JsonParseException, JsonMappingException, IOException {
                doReturn(false).when(aaiResourcesMock).exists(vserverURI);
                doReturn(false).when(aaiResourcesMock).exists(vserverURI2);
-               boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);           
+               
+               boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);         
                assertEquals(false, exists);
+               
+               boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);          
+               assertEquals(true, doNotExist);
        }
 
        @Test
@@ -306,8 +321,11 @@ public class AuditVServerTest extends AuditVServer {
                doReturn(true).when(aaiResourcesMock).exists(vserverURI2);
                doReturn(Optional.of(test_port_1_plural)).when(aaiResourcesMock).get(LInterface.class,test_port_1_uri);
                doReturn(Optional.of(test_port_2_plural)).when(aaiResourcesMock).get(LInterface.class,test_port_2_uri);
-               boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);           
+               boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);         
                assertEquals(false, exists);
+               
+               boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);          
+               assertEquals(false, doNotExist);
        }
 
        @Test
@@ -325,8 +343,12 @@ public class AuditVServerTest extends AuditVServer {
                doReturn(true).when(aaiResourcesMock).exists(service1_sub_0_uri);
                doReturn(true).when(aaiResourcesMock).exists(service1_sub_1_uri);
                doReturn(false).when(aaiResourcesMock).exists(vserverURI2);
-               boolean exists = auditNova.auditVservers(vserversToAudit, tenantId, cloudOwner, cloudRegion);
+               
+               boolean exists = auditNova.auditAllVserversDoExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);
                assertEquals(false, exists);
+               
+               boolean doNotExist = auditNova.auditAllVserversDoNotExist(vserversToAudit, tenantId, cloudOwner, cloudRegion);          
+               assertEquals(false, doNotExist);
        }
 
 }
index 6967841..5eea46d 100644 (file)
@@ -203,7 +203,7 @@ public class HeatStackAuditTest extends HeatStackAudit {
                Resources getResource = objectMapper.readValue(new File("src/test/resources/Service1ResourceGroupResponse.json"), Resources.class);
                doReturn(getResource).when(msoHeatUtilsMock).queryStackResources(cloudRegion,   tenantId, "heatStackName");
                
-               boolean actual = heatStackAudit.auditHeatStack(cloudRegion, "cloudOwner", tenantId, "heatStackName");
+               boolean actual = heatStackAudit.auditHeatStackCreate(cloudRegion, "cloudOwner", tenantId, "heatStackName");
                assertEquals(true, actual);
        }
        
index 75cea9e..376076a 100644 (file)
@@ -65,7 +65,7 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
 
     @Test
     public void createVfModule() throws Exception {
-        //expectedException.expect(VnfException.class);
+        
         Map<String, Object> stackInputs = new HashMap<>();
         stackInputs.put("oof_directives", "{}");
         stackInputs.put("sdnc_directives", "{}");
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java
new file mode 100644 (file)
index 0000000..a23f85b
--- /dev/null
@@ -0,0 +1,58 @@
+package org.onap.so.bpmn.servicedecomposition.bbobjects;
+
+import java.io.Serializable;
+
+import javax.persistence.Id;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Tenant implements Serializable {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = -8704478668505531590L;
+       @Id
+       @JsonProperty("tenant-id")
+       private String tenantId;
+       @JsonProperty("tenant-name")
+       private String tenantName;
+       @JsonProperty("tenant-context")
+       private String tenantContext;
+       
+       @Override
+       public boolean equals(final Object other) {
+               if (!(other instanceof Tenant)) {
+                       return false;
+               }
+               Tenant castOther = (Tenant) other;
+               return new EqualsBuilder().append(tenantId, castOther.tenantId).isEquals();
+       }
+       @Override
+       public int hashCode() {
+               return new HashCodeBuilder().append(tenantId).toHashCode();
+       }
+       public String getTenantId() {
+               return tenantId;
+       }
+       public void setTenantId(String tenantId) {
+               this.tenantId = tenantId;
+       }
+       public String getTenantName() {
+               return tenantName;
+       }
+       public void setTenantName(String tenantName) {
+               this.tenantName = tenantName;
+       }
+       public String getTenantContext() {
+               return tenantContext;
+       }
+       public void setTenantContext(String tenantContext) {
+               this.tenantContext = tenantContext;
+       }
+
+       
+}
\ No newline at end of file
index adea99c..6d3be0f 100644 (file)
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
 
@@ -39,10 +40,20 @@ public class GeneralBuildingBlock implements Serializable {
        private OrchestrationContext orchContext;
        private Map<String, String> userInput;
        private CloudRegion cloudRegion;
+       private Tenant tenant;
 
        private Customer customer;
        private ServiceInstance serviceInstance;
 
+       
+       public Tenant getTenant() {
+               return tenant;
+       }
+
+       public void setTenant(Tenant tenant) {
+               this.tenant = tenant;
+       }
+
        public CloudRegion getCloudRegion() {
                return cloudRegion;
        }
index fb30946..77372bc 100644 (file)
@@ -49,6 +49,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
 import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
@@ -831,7 +832,7 @@ public class BBInputSetup implements JavaDelegate {
        }
 
        protected GeneralBuildingBlock populateGBBWithSIAndAdditionalInfo(RequestDetails requestDetails,
-                       ServiceInstance serviceInstance, ExecuteBuildingBlock executeBB, String requestAction, Customer customer) {
+                       ServiceInstance serviceInstance, ExecuteBuildingBlock executeBB, String requestAction, Customer customer) throws Exception {
                GeneralBuildingBlock outputBB = new GeneralBuildingBlock();
                OrchestrationContext orchContext = mapperLayer.mapOrchestrationContext(requestDetails);
                RequestContext requestContext = mapperLayer.mapRequestContext(requestDetails);
@@ -840,9 +841,11 @@ public class BBInputSetup implements JavaDelegate {
                org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils
                                .getCloudRegion(requestDetails.getCloudConfiguration());
                CloudRegion cloudRegion = mapperLayer.mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion);
+               Tenant tenant = getTenant(requestDetails.getCloudConfiguration(), aaiCloudRegion);
                outputBB.setOrchContext(orchContext);
                outputBB.setRequestContext(requestContext);
                outputBB.setCloudRegion(cloudRegion);
+               outputBB.setTenant(tenant);
                if(customer == null){
                        Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId());
                        String globalCustomerId = uriKeys.get("global-customer-id");
@@ -857,6 +860,23 @@ public class BBInputSetup implements JavaDelegate {
                return outputBB;
        }
 
+       protected Tenant getTenant(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion) throws Exception {
+               Tenant tenant = new Tenant();
+               if(cloudConfiguration != null && cloudConfiguration.getTenantId() != null 
+                               && aaiCloudRegion != null && aaiCloudRegion.getTenants() != null) {
+                       for(org.onap.aai.domain.yang.Tenant aaiTenant : aaiCloudRegion.getTenants().getTenant()) {
+                               if(aaiTenant.getTenantId().equalsIgnoreCase(cloudConfiguration.getTenantId())) {
+                                       tenant = mapperLayer.mapTenant(aaiTenant);
+                               }
+                       }
+                       if(tenant.getTenantId() == null || tenant.getTenantName() == null) { 
+                               throw new Exception("Invalid tenant information retrieved: tenantId = " + tenant.getTenantId() 
+                               + " tenantName = " + tenant.getTenantName()); 
+                       }
+               }
+               return tenant;
+       }
+
        protected ServiceSubscription getServiceSubscription(RequestDetails requestDetails, Customer customer) {
                org.onap.aai.domain.yang.ServiceSubscription aaiServiceSubscription = bbInputSetupUtils
                                .getAAIServiceSubscription(customer.getGlobalCustomerId(),
index 108fd66..a838ffd 100644 (file)
@@ -53,6 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
@@ -383,6 +384,14 @@ public class BBInputSetupMapperLayer {
                        modelMapper.map(aaiCloudRegion, cloudRegion);
                return cloudRegion;
        }
+       
+       protected Tenant mapTenant(org.onap.aai.domain.yang.Tenant aaiTenant) {
+               Tenant tenant = new Tenant();
+               if(aaiTenant != null) {
+                       modelMapper.map(aaiTenant, tenant);
+               }
+               return tenant;
+       }
 
        protected Collection mapAAICollectionIntoCollection(org.onap.aai.domain.yang.Collection aaiCollection) {
                Collection collection = new Collection();
index b3b4559..486164e 100644 (file)
@@ -173,7 +173,7 @@ public class BBInputSetupUtils {
                        if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) {
                                return injectionHelper.getAaiClient().get(CloudRegion.class,
                                                AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner,
-                                                               cloudRegionId)).orElse(null);
+                                                               cloudRegionId).depth(Depth.TWO)).orElse(null);
                        
                        } else {
                                return null;
index 3cb7b24..7e4afb7 100644 (file)
@@ -50,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
@@ -604,6 +605,23 @@ public class BBInputSetupMapperLayerTest {
 
                assertThat(actual, sameBeanAs(expected));
        }
+       
+       @Test
+       public void testMapTenant() {
+               Tenant expected = new Tenant();
+               expected.setTenantId("tenantId");
+               expected.setTenantName("tenantName");
+               expected.setTenantContext("tenantContext");
+
+               org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
+               aaiTenant.setTenantId("tenantId");
+               aaiTenant.setTenantName("tenantName");
+               aaiTenant.setTenantContext("tenantContext");
+
+               Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
+
+               assertThat(actual, sameBeanAs(expected));
+       }
 
        @Test
        public void testMapCloudRegionWithNullCheck() {
index cea8fc3..d7c681b 100644 (file)
@@ -787,7 +787,9 @@ public class BBInputSetupTest {
                ServiceInstance serviceInstance = mapper.readValue(
                                new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
                                ServiceInstance.class);
-
+               CloudConfiguration cloudConfiguration = new CloudConfiguration();
+               cloudConfiguration.setTenantId("tenantId");
+               requestDetails.setCloudConfiguration(cloudConfiguration);
                OrchestrationContext orchestrationContext = new OrchestrationContext();
                orchestrationContext.setIsRollbackEnabled(false);
 
@@ -808,17 +810,30 @@ public class BBInputSetupTest {
                customer.setSubscriberName("subscriberName");
                customer.setSubscriberType("subscriberType");
                customer.setServiceSubscription(serviceSubscription);
+               
+               org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant tenant = new org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant();
+               tenant.setTenantContext("tenantContext");
+               tenant.setTenantId("tenantId");
+               tenant.setTenantName("tenantName");
 
                org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+               org.onap.aai.domain.yang.Tenants aaiTenants = Mockito.mock(org.onap.aai.domain.yang.Tenants.class);
+               org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
+               aaiTenant.setTenantId("tenantId");
+               List<org.onap.aai.domain.yang.Tenant> tenants = new ArrayList<>();
+               tenants.add(aaiTenant);
 
                String requestAction = "createInstance";
-
+               
                doReturn(uriKeys).when(SPY_bbInputSetupUtils).getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId());
                doReturn(customer).when(SPY_bbInputSetup).mapCustomer(uriKeys.get("global-customer-id"),uriKeys.get("service-type"));
                doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
                doReturn(orchestrationContext).when(bbInputSetupMapperLayer).mapOrchestrationContext(requestDetails);
                doReturn(requestContext).when(bbInputSetupMapperLayer).mapRequestContext(requestDetails);
                doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion);
+               doReturn(tenant).when(bbInputSetupMapperLayer).mapTenant(aaiTenant);
+               doReturn(aaiTenants).when(aaiCloudRegion).getTenants();
+               doReturn(tenants).when(aaiTenants).getTenant();
 
                GeneralBuildingBlock actual = SPY_bbInputSetup.populateGBBWithSIAndAdditionalInfo(requestDetails,
                                serviceInstance, executeBB, requestAction, null);
index ae1af8f..d1d66ae 100644 (file)
@@ -181,10 +181,10 @@ public class BBInputSetupUtilsTest {
                expected.get().setCloudRegionId("lcpCloudRegionId");
                doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.CloudRegion.class,
                                AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(),
-                                               cloudConfig.getLcpCloudRegionId()));
+                                               cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO));
 
                AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(),
-                               cloudConfig.getLcpCloudRegionId());
+                               cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO);
                bbInputSetupUtils.getCloudRegion(cloudConfig);
                
                verify(MOCK_aaiResourcesClient, times(1)).get(CloudRegion.class, expectedUri);
index 5eb9a26..b18cad0 100644 (file)
                "tenant-id": "tenantId",
                "complex": "complexName"
        },
+       "tenant": {
+               "tenant-name": "tenantName",
+               "tenant-context": "tenantContext",
+               "tenant-id": "tenantId"
+       },
        "userInput": null,
        "customer": {
                "global-customer-id": "globalCustomerId",
index 5ac07c6..f07f060 100644 (file)
                "complex": "complexName"
        },
        "userInput": null,
+         "tenant": {
+    "tenant-id": "tenantId",
+    "tenant-name": "tenantName",
+    "tenant-context": "tenantContext"
+  },
        "customer": {
                "global-customer-id": "globalCustomerId",
                "subscriber-name": "subscriberName",
index fd24be1..c841da3 100644 (file)
@@ -35,7 +35,7 @@
       <bpmn:incoming>SequenceFlow_0ghzwlo</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0xndboi</bpmn:outgoing>
     </bpmn:serviceTask>
-    <bpmn:serviceTask id="Audit_AAI_Inventory" name="Validate A&#38;AI Inventory" camunda:type="external" camunda:topic="InventoryAudit">
+    <bpmn:serviceTask id="Audit_AAI_Inventory" name="Validate A&#38;AI Inventory" camunda:type="external" camunda:topic="InventoryAddAudit">
       <bpmn:incoming>SequenceFlow_0xndboi</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0ee42yq</bpmn:outgoing>
     </bpmn:serviceTask>
@@ -54,7 +54,7 @@
     </bpmn:exclusiveGateway>
     <bpmn:sequenceFlow id="SequenceFlow_07ybdik" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="ActivateVfModule" />
     <bpmn:sequenceFlow id="SequenceFlow_0ghzwlo" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="Setup_AAI_Inventory_Audit">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditInventoryNeeded").equals("true")}]]></bpmn:conditionExpression>
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditInventoryNeeded") == true}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="SequenceFlow_0ee42yq" sourceRef="Audit_AAI_Inventory" targetRef="ActivateVfModule" />
     <bpmn:serviceTask id="CheckAuditVariable" name="Check Audit Variable" camunda:expression="${AuditTasks.isAuditNeeded(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
index 804ae70..e1b36cf 100644 (file)
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1">
   <bpmn:process id="DeleteVfModuleBB" name="DeleteVfModuleBB" isExecutable="true">
     <bpmn:startEvent id="DeleteVfModuleBB_Start">
       <bpmn:outgoing>SequenceFlow_1537yw5</bpmn:outgoing>
     </bpmn:startEvent>
     <bpmn:serviceTask id="DeleteVfModuleVnfAdapter" name="Delete Vf Module VnfAdapter" camunda:expression="${VnfAdapterDeleteTasks.deleteVfModule(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
-      <bpmn:incoming>SequenceFlow_1537yw5</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_1n8gab5</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_08tvhtf</bpmn:outgoing>
     </bpmn:serviceTask>
-    <bpmn:sequenceFlow id="SequenceFlow_1537yw5" sourceRef="DeleteVfModuleBB_Start" targetRef="DeleteVfModuleVnfAdapter" />
+    <bpmn:sequenceFlow id="SequenceFlow_1537yw5" sourceRef="DeleteVfModuleBB_Start" targetRef="ExclusiveGateway_0xrgzm7" />
     <bpmn:serviceTask id="UpdateVfModuleDeleteStatus" name="&#10;AAI &#10;Update&#10;(vf module)&#10;" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusDeleteVfModule(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
       <bpmn:incoming>SequenceFlow_01vfwtp</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_09l7pcg</bpmn:outgoing>
@@ -32,7 +32,7 @@
       <bpmn:incoming>SequenceFlow_08tvhtf</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_02lpx87</bpmn:outgoing>
     </bpmn:callActivity>
-    <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="DeleteNetworkPolicies" />
+    <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="ExclusiveGateway_1yvh16a" />
     <bpmn:subProcess id="SubProcess_11p7mrh" name="Error Handling&#10;&#10;" triggeredByEvent="true">
       <bpmn:startEvent id="StartEvent_1xp6ewt">
         <bpmn:outgoing>SequenceFlow_0h607z0</bpmn:outgoing>
@@ -52,7 +52,7 @@
     <bpmn:sequenceFlow id="SequenceFlow_09l7pcg" sourceRef="UpdateVfModuleDeleteStatus" targetRef="DeleteVfModuleBB_End" />
     <bpmn:sequenceFlow id="SequenceFlow_0xyu3pk" sourceRef="DeleteNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" />
     <bpmn:serviceTask id="DeleteNetworkPolicies" name="AAI Delete (network policies)" camunda:expression="${AAIDeleteTasks.deleteNetworkPolicies(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
-      <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_14bu4ys</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0xyu3pk</bpmn:outgoing>
     </bpmn:serviceTask>
     <bpmn:serviceTask id="UpdateVnfManagementV6Address" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
       <bpmn:incoming>SequenceFlow_0khqfnc</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0yuz21z</bpmn:outgoing>
     </bpmn:serviceTask>
+    <bpmn:sequenceFlow id="SequenceFlow_1n8gab5" sourceRef="ExclusiveGateway_0xrgzm7" targetRef="DeleteVfModuleVnfAdapter" />
+    <bpmn:parallelGateway id="ExclusiveGateway_0xrgzm7">
+      <bpmn:incoming>SequenceFlow_1537yw5</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1n8gab5</bpmn:outgoing>
+      <bpmn:outgoing>SequenceFlow_1v3jgqe</bpmn:outgoing>
+    </bpmn:parallelGateway>
+    <bpmn:sequenceFlow id="SequenceFlow_032jv5j" name="Yes&#10;" sourceRef="ExclusiveGateway_1h2ystu" targetRef="Setup_Audit_Variable">
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditInventoryNeeded") == true}]]></bpmn:conditionExpression>
+    </bpmn:sequenceFlow>
+    <bpmn:sequenceFlow id="SequenceFlow_0qfmmgt" sourceRef="Audit_Inventory" targetRef="ExclusiveGateway_1pydilb" />
+    <bpmn:sequenceFlow id="SequenceFlow_14bu4ys" sourceRef="ExclusiveGateway_1yvh16a" targetRef="DeleteNetworkPolicies" />
+    <bpmn:parallelGateway id="ExclusiveGateway_1yvh16a">
+      <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_1ut7n32</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_14bu4ys</bpmn:outgoing>
+    </bpmn:parallelGateway>
+    <bpmn:sequenceFlow id="SequenceFlow_1mgunf3" name="No" sourceRef="ExclusiveGateway_1h2ystu" targetRef="ExclusiveGateway_1pydilb" />
+    <bpmn:serviceTask id="Check_Audit" name="Check Audit Variable" camunda:expression="${AuditTasks.isAuditNeeded(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+      <bpmn:incoming>SequenceFlow_1v3jgqe</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1odt2wt</bpmn:outgoing>
+    </bpmn:serviceTask>
+    <bpmn:sequenceFlow id="SequenceFlow_1v3jgqe" sourceRef="ExclusiveGateway_0xrgzm7" targetRef="Check_Audit" />
+    <bpmn:sequenceFlow id="SequenceFlow_1odt2wt" sourceRef="Check_Audit" targetRef="ExclusiveGateway_1h2ystu" />
+    <bpmn:sequenceFlow id="SequenceFlow_1swistn" sourceRef="Setup_Audit_Variable" targetRef="Audit_Inventory" />
+    <bpmn:serviceTask id="Audit_Inventory" name="Audit Inventory For Delete in AAI" camunda:type="external" camunda:topic="InventoryDeleteAudit">
+      <bpmn:incoming>SequenceFlow_1swistn</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_0qfmmgt</bpmn:outgoing>
+    </bpmn:serviceTask>
+    <bpmn:serviceTask id="Setup_Audit_Variable" name="Setup Audit Variable" camunda:expression="${AuditTasks.setupAuditVariable(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+      <bpmn:incoming>SequenceFlow_032jv5j</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1swistn</bpmn:outgoing>
+    </bpmn:serviceTask>
+    <bpmn:sequenceFlow id="SequenceFlow_1ut7n32" sourceRef="ExclusiveGateway_1pydilb" targetRef="ExclusiveGateway_1yvh16a" />
+    <bpmn:exclusiveGateway id="ExclusiveGateway_1h2ystu" name="Audit&#10; Enabled?" default="SequenceFlow_1mgunf3">
+      <bpmn:incoming>SequenceFlow_1odt2wt</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_032jv5j</bpmn:outgoing>
+      <bpmn:outgoing>SequenceFlow_1mgunf3</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
+    <bpmn:exclusiveGateway id="ExclusiveGateway_1pydilb">
+      <bpmn:incoming>SequenceFlow_0qfmmgt</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_1mgunf3</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1ut7n32</bpmn:outgoing>
+    </bpmn:exclusiveGateway>
   </bpmn:process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteVfModuleBB">
       <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="DeleteVfModuleBB_Start">
-        <dc:Bounds x="173" y="102" width="36" height="36" />
+        <dc:Bounds x="159" y="241" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="179" y="138" width="24" height="12" />
+          <dc:Bounds x="132" y="277" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ServiceTask_16798zf_di" bpmnElement="DeleteVfModuleVnfAdapter">
-        <dc:Bounds x="261" y="80" width="100" height="80" />
+        <dc:Bounds x="382" y="278" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1537yw5_di" bpmnElement="SequenceFlow_1537yw5">
-        <di:waypoint xsi:type="dc:Point" x="209" y="120" />
-        <di:waypoint xsi:type="dc:Point" x="261" y="120" />
+        <di:waypoint xsi:type="dc:Point" x="195" y="259" />
+        <di:waypoint xsi:type="dc:Point" x="282" y="259" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="190" y="99" width="90" height="12" />
+          <dc:Bounds x="193.5" y="238" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ServiceTask_0pbhsub_di" bpmnElement="UpdateVfModuleDeleteStatus">
-        <dc:Bounds x="758" y="243" width="100" height="80" />
+        <dc:Bounds x="840" y="443" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_08tvhtf_di" bpmnElement="SequenceFlow_08tvhtf">
-        <di:waypoint xsi:type="dc:Point" x="361" y="120" />
-        <di:waypoint xsi:type="dc:Point" x="427" y="120" />
+        <di:waypoint xsi:type="dc:Point" x="482" y="318" />
+        <di:waypoint xsi:type="dc:Point" x="511" y="318" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="349" y="99" width="90" height="12" />
+          <dc:Bounds x="451.5" y="297" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="EndEvent_1rn6yvh_di" bpmnElement="DeleteVfModuleBB_End">
-        <dc:Bounds x="918" y="265" width="36" height="36" />
+        <dc:Bounds x="1087" y="465" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="936" y="305" width="0" height="0" />
+          <dc:Bounds x="1060" y="505" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="CallActivity_0whogn3_di" bpmnElement="VnfAdapter">
-        <dc:Bounds x="427" y="80" width="100" height="80" />
+        <dc:Bounds x="511" y="278" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_02lpx87_di" bpmnElement="SequenceFlow_02lpx87">
-        <di:waypoint xsi:type="dc:Point" x="527" y="120" />
-        <di:waypoint xsi:type="dc:Point" x="591" y="120" />
+        <di:waypoint xsi:type="dc:Point" x="611" y="318" />
+        <di:waypoint xsi:type="dc:Point" x="836" y="318" />
+        <di:waypoint xsi:type="dc:Point" x="836" y="284" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="559" y="105" width="0" height="0" />
+          <dc:Bounds x="678.5" y="303" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="SubProcess_11p7mrh_di" bpmnElement="SubProcess_11p7mrh" isExpanded="true">
-        <dc:Bounds x="295" y="412" width="231" height="135" />
+        <dc:Bounds x="294" y="618" width="231" height="135" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="StartEvent_1xp6ewt_di" bpmnElement="StartEvent_1xp6ewt">
-        <dc:Bounds x="338" y="474" width="36" height="36" />
+        <dc:Bounds x="337" y="680" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="311" y="510" width="0" height="0" />
+          <dc:Bounds x="265" y="716" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_0guhjau_di" bpmnElement="EndEvent_0guhjau">
-        <dc:Bounds x="467" y="474" width="36" height="36" />
+        <dc:Bounds x="466" y="680" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="440" y="510" width="0" height="0" />
+          <dc:Bounds x="394" y="716" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0h607z0_di" bpmnElement="SequenceFlow_0h607z0">
-        <di:waypoint xsi:type="dc:Point" x="374" y="492" />
-        <di:waypoint xsi:type="dc:Point" x="467" y="492" />
+        <di:waypoint xsi:type="dc:Point" x="373" y="698" />
+        <di:waypoint xsi:type="dc:Point" x="466" y="698" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="421" y="471" width="0" height="0" />
+          <dc:Bounds x="375" y="677" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ServiceTask_0vlgqod_di" bpmnElement="UpdateVfModuleHeatStackId">
-        <dc:Bounds x="591" y="243" width="100" height="80" />
+        <dc:Bounds x="706" y="443" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_01vfwtp_di" bpmnElement="SequenceFlow_01vfwtp">
-        <di:waypoint xsi:type="dc:Point" x="691" y="283" />
-        <di:waypoint xsi:type="dc:Point" x="758" y="283" />
+        <di:waypoint xsi:type="dc:Point" x="806" y="483" />
+        <di:waypoint xsi:type="dc:Point" x="840" y="483" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="725" y="268" width="0" height="0" />
+          <dc:Bounds x="778" y="468" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_09l7pcg_di" bpmnElement="SequenceFlow_09l7pcg">
-        <di:waypoint xsi:type="dc:Point" x="858" y="283" />
-        <di:waypoint xsi:type="dc:Point" x="918" y="283" />
+        <di:waypoint xsi:type="dc:Point" x="940" y="483" />
+        <di:waypoint xsi:type="dc:Point" x="1087" y="483" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="888" y="258" width="0" height="0" />
+          <dc:Bounds x="968.5" y="468" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0xyu3pk_di" bpmnElement="SequenceFlow_0xyu3pk">
-        <di:waypoint xsi:type="dc:Point" x="691" y="120" />
-        <di:waypoint xsi:type="dc:Point" x="751" y="120" />
+        <di:waypoint xsi:type="dc:Point" x="998" y="259" />
+        <di:waypoint xsi:type="dc:Point" x="1072" y="259" />
+        <di:waypoint xsi:type="dc:Point" x="1072" y="399" />
+        <di:waypoint xsi:type="dc:Point" x="233" y="399" />
+        <di:waypoint xsi:type="dc:Point" x="233" y="483" />
+        <di:waypoint xsi:type="dc:Point" x="280" y="483" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="721" y="105" width="0" height="0" />
+          <dc:Bounds x="607.5" y="384" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ServiceTask_0tty0ac_di" bpmnElement="DeleteNetworkPolicies">
-        <dc:Bounds x="591" y="80" width="100" height="80" />
+        <dc:Bounds x="898" y="219" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ServiceTask_0lrrd16_di" bpmnElement="UpdateVnfManagementV6Address">
-        <dc:Bounds x="261" y="243" width="100" height="80" />
+        <dc:Bounds x="421" y="443" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0jtem3b_di" bpmnElement="SequenceFlow_0jtem3b">
-        <di:waypoint xsi:type="dc:Point" x="851" y="120" />
-        <di:waypoint xsi:type="dc:Point" x="941" y="120" />
-        <di:waypoint xsi:type="dc:Point" x="941" y="205" />
-        <di:waypoint xsi:type="dc:Point" x="182" y="205" />
-        <di:waypoint xsi:type="dc:Point" x="182" y="283" />
-        <di:waypoint xsi:type="dc:Point" x="261" y="283" />
+        <di:waypoint xsi:type="dc:Point" x="380" y="483" />
+        <di:waypoint xsi:type="dc:Point" x="421" y="483" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="562" y="190" width="0" height="0" />
+          <dc:Bounds x="355.5" y="468" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ServiceTask_0w9805b_di" bpmnElement="UpdateVnfIpv4OamAddress">
-        <dc:Bounds x="751" y="80" width="100" height="80" />
+        <dc:Bounds x="280" y="443" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0khqfnc_di" bpmnElement="SequenceFlow_0khqfnc">
-        <di:waypoint xsi:type="dc:Point" x="361" y="283" />
-        <di:waypoint xsi:type="dc:Point" x="427" y="283" />
+        <di:waypoint xsi:type="dc:Point" x="521" y="483" />
+        <di:waypoint xsi:type="dc:Point" x="561" y="483" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="394" y="268" width="0" height="0" />
+          <dc:Bounds x="496" y="468" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0yuz21z_di" bpmnElement="SequenceFlow_0yuz21z">
-        <di:waypoint xsi:type="dc:Point" x="527" y="283" />
-        <di:waypoint xsi:type="dc:Point" x="591" y="283" />
+        <di:waypoint xsi:type="dc:Point" x="661" y="483" />
+        <di:waypoint xsi:type="dc:Point" x="706" y="483" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="559" y="268" width="0" height="0" />
+          <dc:Bounds x="638.5" y="468" width="90" height="0" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ServiceTask_0v8naz9_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn">
-        <dc:Bounds x="427" y="243" width="100" height="80" />
+        <dc:Bounds x="561" y="443" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1n8gab5_di" bpmnElement="SequenceFlow_1n8gab5">
+        <di:waypoint xsi:type="dc:Point" x="307" y="284" />
+        <di:waypoint xsi:type="dc:Point" x="307" y="318" />
+        <di:waypoint xsi:type="dc:Point" x="382" y="318" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="277" y="294.5" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ParallelGateway_18x6mx2_di" bpmnElement="ExclusiveGateway_0xrgzm7">
+        <dc:Bounds x="282" y="234" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="262" y="287" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_032jv5j_di" bpmnElement="SequenceFlow_032jv5j">
+        <di:waypoint xsi:type="dc:Point" x="492" y="149" />
+        <di:waypoint xsi:type="dc:Point" x="492" y="108" />
+        <di:waypoint xsi:type="dc:Point" x="531" y="108" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="499" y="114" width="18" height="25" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_0qfmmgt_di" bpmnElement="SequenceFlow_0qfmmgt">
+        <di:waypoint xsi:type="dc:Point" x="754" y="108" />
+        <di:waypoint xsi:type="dc:Point" x="784" y="108" />
+        <di:waypoint xsi:type="dc:Point" x="784" y="149" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="724" y="86.5" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_14bu4ys_di" bpmnElement="SequenceFlow_14bu4ys">
+        <di:waypoint xsi:type="dc:Point" x="861" y="259" />
+        <di:waypoint xsi:type="dc:Point" x="898" y="259" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="834.5" y="237.5" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ParallelGateway_02fjfb8_di" bpmnElement="ExclusiveGateway_1yvh16a">
+        <dc:Bounds x="811" y="234" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="790" y="287" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1mgunf3_di" bpmnElement="SequenceFlow_1mgunf3">
+        <di:waypoint xsi:type="dc:Point" x="492" y="199" />
+        <di:waypoint xsi:type="dc:Point" x="492" y="232" />
+        <di:waypoint xsi:type="dc:Point" x="784" y="232" />
+        <di:waypoint xsi:type="dc:Point" x="784" y="199" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="499" y="212" width="15" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ServiceTask_1vmz3zo_di" bpmnElement="Check_Audit">
+        <dc:Bounds x="339" y="134" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1v3jgqe_di" bpmnElement="SequenceFlow_1v3jgqe">
+        <di:waypoint xsi:type="dc:Point" x="307" y="234" />
+        <di:waypoint xsi:type="dc:Point" x="307" y="174" />
+        <di:waypoint xsi:type="dc:Point" x="339" y="174" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="277" y="197.5" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1odt2wt_di" bpmnElement="SequenceFlow_1odt2wt">
+        <di:waypoint xsi:type="dc:Point" x="439" y="174" />
+        <di:waypoint xsi:type="dc:Point" x="467" y="174" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="408" y="152.5" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1swistn_di" bpmnElement="SequenceFlow_1swistn">
+        <di:waypoint xsi:type="dc:Point" x="631" y="108" />
+        <di:waypoint xsi:type="dc:Point" x="654" y="108" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="597.5" y="86.5" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ServiceTask_1l8r2a6_di" bpmnElement="Audit_Inventory">
+        <dc:Bounds x="654" y="68" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ServiceTask_1gttdjr_di" bpmnElement="Setup_Audit_Variable">
+        <dc:Bounds x="531" y="68" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1ut7n32_di" bpmnElement="SequenceFlow_1ut7n32">
+        <di:waypoint xsi:type="dc:Point" x="809" y="174" />
+        <di:waypoint xsi:type="dc:Point" x="836" y="174" />
+        <di:waypoint xsi:type="dc:Point" x="836" y="234" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="777.5" y="152.5" width="90" height="13" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ExclusiveGateway_1olwkdn_di" bpmnElement="ExclusiveGateway_1h2ystu" isMarkerVisible="true">
+        <dc:Bounds x="467" y="149" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="518" y="162" width="47" height="25" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ExclusiveGateway_1d1pmqz_di" bpmnElement="ExclusiveGateway_1pydilb" isMarkerVisible="true">
+        <dc:Bounds x="759" y="149" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="694" y="202" width="0" height="13" />
+        </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
index 9ffcd9d..2dae117 100644 (file)
@@ -47,13 +47,13 @@ public class ActivateVfModuleBBTest extends BaseBPMNTest{
                mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub");
                ProcessInstance pi = runtimeService.startProcessInstanceByKey("ActivateVfModuleBB", variables);
                List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
-                .topic("InventoryAudit", 60L * 1000L).execute();
+                .topic("InventoryAddAudit", 60L * 1000L).execute();
         while (!tasks.isEmpty()) {
             for (LockedExternalTask task : tasks) {
                 externalTaskService.complete(task.getId(), "externalWorkerId");
             }
             tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
-                    .topic("InventoryAudit", 60L * 1000L).execute();
+                    .topic("InventoryAddAudit", 60L * 1000L).execute();
         }
                
                assertThat(pi).isNotNull();
@@ -68,13 +68,13 @@ public class ActivateVfModuleBBTest extends BaseBPMNTest{
                doThrow(BpmnError.class).when(aaiUpdateTasks).updateOrchestrationStatusActivateVfModule(any(BuildingBlockExecution.class));
                ProcessInstance pi = runtimeService.startProcessInstanceByKey("ActivateVfModuleBB", variables);
                List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
-                .topic("InventoryAudit", 60L * 1000L).execute();
+                .topic("InventoryAddAudit", 60L * 1000L).execute();
         while (!tasks.isEmpty()) {
             for (LockedExternalTask task : tasks) {
                 externalTaskService.complete(task.getId(), "externalWorkerId");
             }
             tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
-                    .topic("InventoryAudit", 60L * 1000L).execute();
+                    .topic("InventoryAddAudit", 60L * 1000L).execute();
         }
 
                assertThat(pi).isNotNull().isStarted()
index cedffb7..48ae22c 100644 (file)
@@ -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.
@@ -23,21 +23,40 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doThrow;
 
 import java.io.IOException;
+import java.util.List;
 
 import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.externaltask.LockedExternalTask;
 import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Before;
 import org.junit.Test;
 import org.onap.so.bpmn.BaseBPMNTest;
 import org.onap.so.bpmn.common.BuildingBlockExecution;
 
 public class DeleteVfModuleBBTest extends BaseBPMNTest{
+
+       @Before
+       public void before() {
+               variables.put("auditInventoryNeeded", true);
+       }
+
        @Test
        public void sunnyDay() throws InterruptedException, IOException {
                mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub");
                mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub");
                ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVfModuleBB", variables);
+               List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
+                .topic("InventoryDeleteAudit", 60L * 1000L).execute();
+        while (!tasks.isEmpty()) {
+            for (LockedExternalTask task : tasks) {
+                externalTaskService.complete(task.getId(), "externalWorkerId");
+            }
+            tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
+                    .topic("InventoryDeleteAudit", 60L * 1000L).execute();
+        }
                assertThat(pi).isNotNull();
-               assertThat(pi).isStarted().hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter", "VnfAdapter",
+               assertThat(pi).isStarted().hasPassed("DeleteVfModuleBB_Start","ExclusiveGateway_0xrgzm7","ExclusiveGateway_1yvh16a","Check_Audit",
+                               "Setup_Audit_Variable","Audit_Inventory","DeleteVfModuleVnfAdapter", "VnfAdapter",
                                "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address",
                                "UpdateVfModuleContrailServiceInstanceFqdn",
                                "UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End");
@@ -48,10 +67,19 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest{
        public void rainyDay() throws Exception {
                doThrow(BpmnError.class).when(vnfAdapterDeleteTasks).deleteVfModule(any(BuildingBlockExecution.class));
                ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVfModuleBB", variables);
+               List<LockedExternalTask> tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
+                .topic("InventoryDeleteAudit", 60L * 1000L).execute();
+        while (!tasks.isEmpty()) {
+            for (LockedExternalTask task : tasks) {
+                externalTaskService.complete(task.getId(), "externalWorkerId");
+            }
+            tasks = externalTaskService.fetchAndLock(100, "externalWorkerId")
+                    .topic("InventoryDeleteAudit", 60L * 1000L).execute();
+        }
                assertThat(pi).isNotNull();
                assertThat(pi).isStarted()
-                               .hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter")
-                               .hasNotPassed("VnfAdapter", "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", 
+                               .hasPassed("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter")
+                               .hasNotPassed("VnfAdapter", "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address",
                                                "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus",
                                                "DeleteVfModuleBB_End");
                assertThat(pi).isEnded();
index d8f6ba3..c080bc9 100644 (file)
@@ -21,7 +21,8 @@
        <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false">
                <appender-ref ref="STDOUT" />
        </logger>
-  <root level="WARN">
+       
+  <root level="INFO">
     <appender-ref ref="STDOUT" />
   </root>
 
index 932558d..1815fcd 100644 (file)
@@ -9,9 +9,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.
@@ -43,6 +43,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import static org.apache.commons.lang3.StringUtils.*;
 
 @Component
 public class VnfAdapterCreateTasks {
@@ -91,25 +92,27 @@ public class VnfAdapterCreateTasks {
        public void createVfModule(BuildingBlockExecution execution) {
                try {
                        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
-                       
+
                        ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
                        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
                        GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
                        VolumeGroup volumeGroup = null;
                        try {
                                volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID));
-                       } catch(BBObjectNotFoundException bbException) {                                
+                       } catch(BBObjectNotFoundException bbException) {
                        }
                        CloudRegion cloudRegion = gBBInput.getCloudRegion();
                        RequestContext requestContext = gBBInput.getRequestContext();
                        OrchestrationContext orchestrationContext = gBBInput.getOrchContext();
                        String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId());
                        String sdncVnfQueryResponse = execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId());
-                       
+
                        CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
                        execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString());
                } catch (Exception ex) {
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
                }
        }
+
+       
 }
index aaa9e51..8cb7cbb 100644 (file)
@@ -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.
@@ -38,22 +38,22 @@ import org.springframework.stereotype.Component;
 
 @Component
 public class AuditTasks {
-       
+
        private static final Logger logger = LoggerFactory.getLogger(AuditTasks.class);
 
        @Autowired
        private ExceptionBuilder exceptionUtil;
-       
+
        @Autowired
        private ExtractPojosForBB extractPojosForBB;
-       
+
        @Autowired
        private Environment env;
-       
+
        public void isAuditNeeded(BuildingBlockExecution execution) {
-               try {                   
+               try {
                        logger.debug("auditInventoryNeeded Value: {}", env.getProperty("mso.infra.auditInventory"));
-                       execution.setVariable("auditInventoryNeeded",env.getProperty("mso.infra.auditInventory"));
+                       execution.setVariable("auditInventoryNeeded", Boolean.parseBoolean(env.getProperty("mso.infra.auditInventory")));
                } catch (Exception ex) {
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
                }
@@ -66,14 +66,14 @@ public class AuditTasks {
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
                }
        }
-       
+
        private AuditInventory createAuditInventory(BuildingBlockExecution execution) throws BBObjectNotFoundException {
                        AuditInventory auditInventory = new AuditInventory();
-                       
+
                        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
                        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
                        CloudRegion cloudRegion = gBBInput.getCloudRegion();
-                       
+
                        auditInventory.setCloudOwner(cloudRegion.getCloudOwner());
                        auditInventory.setCloudRegion(cloudRegion.getLcpCloudRegionId());
                        auditInventory.setTenantId(cloudRegion.getTenantId());
index 1f9f5f5..0b2b1e7 100644 (file)
@@ -1249,6 +1249,7 @@ public class ServiceInstances {
                try {
                        msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte);
                } catch (Exception e) {
+                       logger.error("failed to parse request", e);
                        ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
                ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
                  .errorInfo(errorLoggerInfo).build();
index 39cccd8..761aaa1 100644 (file)
 
 package org.onap.so.db.request.data.repository;
 
-import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NonUniqueResultException;
-import javax.persistence.Query;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Order;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -52,6 +35,24 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
 
+import javax.persistence.EntityManager;
+import javax.persistence.NonUniqueResultException;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Order;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
 
 @Repository
 @Transactional(readOnly = true)
@@ -219,17 +220,17 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep
                 }
             }
         }
-        if(!predicates.isEmpty()){
-               predicates.add(tableRoot.get(REQUEST_STATUS)
-                .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK")));
-
-               final Order order = cb.desc(tableRoot.get(START_TIME));
-       
-               final List<InfraActiveRequests> dupList = executeInfraQuery(crit, predicates, order);
-       
-               if (dupList != null && !dupList.isEmpty()) {
-                   infraActiveRequests = dupList.get(0);
-               }
+        if (!predicates.isEmpty()) {
+            predicates.add(tableRoot.get(REQUEST_STATUS)
+                    .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK")));
+
+            final Order order = cb.desc(tableRoot.get(START_TIME));
+
+            final List<InfraActiveRequests> dupList = executeInfraQuery(crit, predicates, order);
+
+            if (dupList != null && !dupList.isEmpty()) {
+                infraActiveRequests = dupList.get(0);
+            }
         }
 
         return infraActiveRequests;
@@ -560,7 +561,14 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep
             predicates.add(criteriaBuilder.greaterThanOrEqualTo(tableRoot.get(START_TIME), minTime));
             predicates.add(criteriaBuilder.lessThanOrEqualTo(tableRoot.get(END_TIME), maxTime));
 
-            criteriaQuery.where(criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()])));
+            final Predicate basePredicate = criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
+            
+            final Predicate additionalPredicate = criteriaBuilder.and(tableRoot.get(END_TIME).isNull(),
+                    criteriaBuilder.greaterThanOrEqualTo(tableRoot.get(START_TIME), minTime),
+                    criteriaBuilder.lessThanOrEqualTo(tableRoot.get(START_TIME), maxTime));
+
+            criteriaQuery.where(criteriaBuilder.or(basePredicate, additionalPredicate));
+
             if (maxResult != null) {
                 return entityManager.createQuery(criteriaQuery).setMaxResults(maxResult).getResultList();
             }
index 4097aee..def999b 100644 (file)
@@ -49,9 +49,26 @@ import org.springframework.test.context.junit4.SpringRunner;
 @ActiveProfiles("test")
 public class InfraActiveRequestsRepositoryImplTest {
 
+    /**
+     * January 1, 2019 2:00:00 PM
+     */
+    private static final long END_TIME = 1546351200000l;
+
+    /**
+     * January 1, 2019 12:45:00 PM
+     */
+    private static final long START_TIME = 1546346700000l;
     private static final int MAX_LIMIT = 1;
-    private static final long END_TIME_IN_MILISEC = 1482580740000l;      // December 23, 2016 23:59 PM
-    private static final long START_TIME_IN_MILISEC = 1482282000000l;    // December 21, 2016 01:00 AM
+
+    /**
+     * December 23, 2016 23:59 PM
+     */
+    private static final long END_TIME_IN_MILISEC = 1482580740000l;
+
+    /**
+     * December 21, 2016 01:00 AM
+     */
+    private static final long START_TIME_IN_MILISEC = 1482282000000l;
     private static final String REQUEST_ID_VALUE = "00032ab7-3fb3-42e5-965d-8ea592502017";
     private static final String SERVICE_INSTANCE_ID_VALUE = "e3b5744d-2ad1-4cdd-8390-c999a38829bc";
 
@@ -96,7 +113,6 @@ public class InfraActiveRequestsRepositoryImplTest {
         assertEquals(SERVICE_INSTANCE_ID_VALUE, actualRequests.get(0).getServiceInstanceId());
     }
 
-
     @Test
     public void test_GetInfraActiveRequestsData_withLikeRequestID() {
         final Map<String, String[]> values = new HashMap<>();
@@ -182,12 +198,34 @@ public class InfraActiveRequestsRepositoryImplTest {
                 objUnderTest.getInfraActiveRequests(null, START_TIME_IN_MILISEC, END_TIME_IN_MILISEC, MAX_LIMIT);
         assertTrue(actualRequests.isEmpty());
     }
-    
+
     @Test
-    public void checkInstanceNameDuplicateNullInstanceNameTest(){
-       Map<String, String> instanceIdMap = new HashMap<>();
+    public void checkInstanceNameDuplicateNullInstanceNameTest() {
+        final Map<String, String> instanceIdMap = new HashMap<>();
         instanceIdMap.put("serviceInstanceId", "e05864f0-ab35-47d0-8be4-56fd9619ba3b");
-       InfraActiveRequests results = objUnderTest.checkInstanceNameDuplicate((HashMap<String, String>)instanceIdMap, null, "vnf");
-       assertNull(results);
+        final InfraActiveRequests results =
+                objUnderTest.checkInstanceNameDuplicate((HashMap<String, String>) instanceIdMap, null, "vnf");
+        assertNull(results);
     }
+
+    @Test
+    public void test_GetInfraActiveRequestsData_returnRecordWithNullEndTime() {
+        final Map<String, String[]> values = new HashMap<>();
+        values.put(SERVICE_INSTANCE_ID,
+                new String[] {QueryOperationType.EQ.name(), "f7712652-b516-4925-a243-64550d26fd84"});
+        final List<InfraActiveRequests> actualRequests =
+                objUnderTest.getInfraActiveRequests(values, START_TIME, END_TIME, null);
+        assertFalse(actualRequests.isEmpty());
+
+        assertEquals(3, actualRequests.size());
+        final Map<String, InfraActiveRequests> result = new HashMap<>();
+        for (final InfraActiveRequests actualActiveRequests : actualRequests) {
+            result.put(actualActiveRequests.getRequestId(), actualActiveRequests);
+
+        }
+        final InfraActiveRequests actualInfraActiveRequests = result.get("9383dc81-7a6c-4673-8082-650d50a82a1a");
+        assertNull(actualInfraActiveRequests.getEndTime());
+        assertEquals("IN_PROGRESS", actualInfraActiveRequests.getRequestStatus());
+    }
+
 }
index 541f356..3358d77 100644 (file)
@@ -105,7 +105,14 @@ INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION,
 INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION, REQUEST_STATUS, STATUS_MESSAGE, PROGRESS, START_TIME, END_TIME, SOURCE, VNF_ID, VNF_NAME, VNF_TYPE, SERVICE_TYPE, AIC_NODE_CLLI, TENANT_ID, PROV_STATUS, VNF_PARAMS, VNF_OUTPUTS, REQUEST_BODY, RESPONSE_BODY, LAST_MODIFIED_BY, MODIFY_TIME, REQUEST_TYPE, VOLUME_GROUP_ID, VOLUME_GROUP_NAME, VF_MODULE_ID, VF_MODULE_NAME, VF_MODULE_MODEL_NAME, AAI_SERVICE_ID, AIC_CLOUD_REGION, CALLBACK_URL, CORRELATOR, NETWORK_ID, NETWORK_NAME, NETWORK_TYPE, REQUEST_SCOPE, REQUEST_ACTION, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, REQUESTOR_ID, CONFIGURATION_ID, CONFIGURATION_NAME, OPERATIONAL_ENV_ID, OPERATIONAL_ENV_NAME, REQUEST_URL) VALUES
 ('00164b9e-784d-48a8-8973-bbad6ef818ed', null, 'createInstance', 'COMPLETE', 'Service Instance was created successfully.', '100', '2017-09-28 12:45:51', '2017-09-28 12:45:53', 'VID', null, null, null, null, null, '19123c2924c648eb8e42a3c1f14b7682', null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f","modelType":"service","modelNameVersionId":null,"modelName":"MSO Test Network","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":"DEV-MTN6-3100-0927-1","suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":null,"subscriberInfo":{"globalSubscriberId":"MSO_1610_dev","subscriberName":"MSO_1610_dev"},"cloudConfiguration":{"aicNodeClli":null,"tenantId":"19123c2924c648eb8e42a3c1f14b7682","lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":"MSO-dev-service-type","userParams":[{"name":"someUserParam","value":"someValue"}],"aLaCarte":true,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":true},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'CreateGenericALaCarteServiceInstance', '2017-09-28 12:45:52', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'service', 'createInstance', 'b2f59173-b7e5-4e0f-8440-232fd601b865', 'DEV-MTN6-3100-0927-1', 'md5621', null, null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'),
 ('00173cc9-5ce2-4673-a810-f87fefb2829e', null, 'createInstance', 'FAILED', 'Error parsing request.  No valid instanceName is specified', '100', '2017-04-14 21:08:46', '2017-04-14 21:08:46', 'VID', null, null, null, null, null, 'a259ae7b7c3f493cb3d91f95a7c18149', null, null, null, '{"modelInfo":{"modelInvariantId":"ff6163d4-7214-459e-9f76-507b4eb00f51","modelType":"service","modelName":"ConstraintsSrvcVID","modelVersion":"2.0","modelVersionId":"722d256c-a374-4fba-a14f-a59b76bb7656"},"requestInfo":{"productFamilyId":"LRSI-OSPF","source":"VID","requestorId":"xxxxxx"},"subscriberInfo":{"globalSubscriberId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"},"cloudConfiguration":{"tenantId":"a259ae7b7c3f493cb3d91f95a7c18149","lcpCloudRegionId":"mtn16"},"requestParameters":{"subscriptionServiceType":"Mobility","userParams":[{"name":"neutronport6_name","value":"8"},{"name":"neutronnet5_network_name","value":"8"},{"name":"contrailv2vlansubinterface3_name","value":"false"}]}}', null, 'APIH', null, null, null, null, null, null, null, null, 'mtn16', null, null, null, null, null, 'service', 'createInstance', null, null, null, null, null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances'),
-('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', null, 'activateInstance', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', null, 'VID', null, null, null, null, null, null, null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances');        
+('0017f68c-eb2d-45bb-b7c7-ec31b37dc349', null, 'activateInstance', 'UNLOCKED', null, '20', '2017-09-26 16:09:29', null, 'VID', null, null, null, null, null, null, null, null, null, '{"modelInfo":{"modelCustomizationName":null,"modelInvariantId":"1587cf0e-f12f-478d-8530-5c55ac578c39","modelType":"configuration","modelNameVersionId":null,"modelName":null,"modelVersion":null,"modelCustomizationUuid":null,"modelVersionId":"36a3a8ea-49a6-4ac8-b06c-89a545444455","modelCustomizationId":"68dc9a92-214c-11e7-93ae-92361f002671","modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"requestInfo":{"billingAccountNumber":null,"callbackUrl":null,"correlator":null,"orderNumber":null,"productFamilyId":null,"orderVersion":null,"source":"VID","instanceName":null,"suppressRollback":false,"requestorId":"xxxxxx"},"relatedInstanceList":[{"relatedInstance":{"instanceName":null,"instanceId":"9e15a443-af65-4f05-9000-47ae495e937d","modelInfo":{"modelCustomizationName":null,"modelInvariantId":"de19ae10-9a25-11e7-abc4-cec278b6b50a","modelType":"service","modelNameVersionId":null,"modelName":"MSOTADevInfra_Configuration_Service","modelVersion":"1.0","modelCustomizationUuid":null,"modelVersionId":"ee938612-9a25-11e7-abc4-cec278b6b50a","modelCustomizationId":null,"modelUuid":null,"modelInvariantUuid":null,"modelInstanceName":null},"instanceDirection":null}}],"subscriberInfo":null,"cloudConfiguration":{"aicNodeClli":null,"tenantId":null,"lcpCloudRegionId":"mtn6"},"requestParameters":{"subscriptionServiceType":null,"userParams":[],"aLaCarte":false,"autoBuildVfModules":false,"cascadeDelete":false,"usePreload":true,"alaCarte":false},"project":null,"owningEntity":null,"platform":null,"lineOfBusiness":null}', null, 'APIH', '2017-09-26 16:09:29', null, null, null, null, null, null, null, 'mtn6', null, null, null, null, null, 'configuration', 'activateInstance', '9e15a443-af65-4f05-9000-47ae495e937d', null, 'xxxxxx', '26ef7f15-57bb-48df-8170-e59edc26234c', null, null, null, 'http://localhost:8080/onap/so/infra/serviceInstantiation/v7/serviceInstances');
+INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION, REQUEST_STATUS, START_TIME, END_TIME, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME ) VALUES
+('a5294d37-21db-4e3a-ae04-57412adcb4ac', null, 'createInstance', 'COMPLETE', '2019-01-01 12:45:00', '2019-01-01 12:50:00', 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_1'),
+('9383dc81-7a6c-4673-8082-650d50a82a1a', null, 'createInstance', 'IN_PROGRESS', '2019-01-01 12:55:00', null, 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_2'),
+('a1abeab2-f8ef-43ab-b76c-9c3c2cb9980f', null, 'activateInstance', 'FAILED', '2019-01-01 13:00:00', '2019-01-01 14:00:00', 'f7712652-b516-4925-a243-64550d26fd84', 'ShouldReturnInSearchQuery_3'),
+('81b8e152-ee89-49f4-b82b-08b0dcae27cd', null, 'createInstance', 'COMPLETE', '2019-01-01 14:10:00', '2019-01-01 15:00:00', 'f7712652-b516-4925-a243-64550d26fd84', 'SHOULD_NOT_RETURN_1'),
+('0c28cad2-ff79-4dfa-a04a-9e44996fd7f7', null, 'createInstance', 'IN_PROGRESS', '2019-01-01 13:30:00', '2019-01-01 15:00:00', 'f7712652-b516-4925-a243-64550d26fd84', 'SHOULD_NOT_RETURN_2'),
+('d0d995a7-549b-4e7e-9101-2bab17ec24ea', null, 'createInstance', 'IN_PROGRESS', '2019-01-01 14:15:00', null, 'f7712652-b516-4925-a243-64550d26fd84', 'SHOULD_NOT_RETURN_3');
 
 CREATE CACHED TABLE PUBLIC.ARCHIVED_INFRA_REQUESTS(
     REQUEST_ID VARCHAR NOT NULL SELECTIVITY 100,
index 557e2a6..0bcf24d 100644 (file)
 
 package org.onap.so.monitoring.configuration.rest;
 
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.core.Ordered;
 import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
 import org.springframework.web.filter.CorsFilter;
 
-import java.util.concurrent.TimeUnit;
-
 /**
  * @author waqas.ikram@ericsson, eoin.hanan@ericsson.com
  */
@@ -38,8 +34,8 @@ public class CorsConfigurer  {
 
     @Bean
     public CorsFilter corsFilter() {
-        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
-        CorsConfiguration config = new CorsConfiguration();
+        final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        final CorsConfiguration config = new CorsConfiguration();
         config.setAllowCredentials(true);
         config.addAllowedOrigin("*");
         config.addAllowedHeader("*");
index 31ef747..5866667 100644 (file)
@@ -79,7 +79,6 @@ public class DatabaseServiceProviderTest {
         assertTrue(objUnderTest.getSoInfraRequest(Collections.emptyMap(), 0, 0, null).isEmpty());
     }
 
-
     @Test
     public void test_GetSoInfraRequest_WithFilters_InfraActiveRequestsList() {
         final String searchUrl = URL_PROVIDER.getSearchUrl(0, 0, null);
@@ -87,7 +86,7 @@ public class DatabaseServiceProviderTest {
         final Map<String, String[]> filters = new HashMap<>();
         filters.put("requestId", new String[] {"EQ", requestID});
 
-        SoActiveInfraRequests soActiveInfraRequests = new SoActiveInfraRequests();
+        final SoActiveInfraRequests soActiveInfraRequests = new SoActiveInfraRequests();
         soActiveInfraRequests.setRequestId(requestID);
 
         final Optional<SoActiveInfraRequests[]> response =
diff --git a/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/Constants.java b/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/Constants.java
new file mode 100644 (file)
index 0000000..aef8234
--- /dev/null
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2019 Ericsson. 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.
+ * 
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.rest.api;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.UUID;
+
+/**
+ * @author andrei.barcovschi@ericsson.com
+ *
+ */
+public class Constants {
+
+    public static final String PROCRESS_DEF_ID = "AFRFLOW:1:c6eea1b7-9722-11e8-8caf-022ac9304eeb";
+
+    public static final String EMPTY_ARRAY_RESPONSE = "[]";
+
+    public static final String PROCESS_INSTACE_ID = "5956a99d-9736-11e8-8caf-022ac9304eeb";
+
+    public static final String EMPTY_STRING = "";
+
+    public static final String SOURCE_TEST_FOLDER = "src/test/resources/camundaResponses/";
+
+    public static final Path PROCESS_DEF_RESPONSE_JSON_FILE = Paths.get(SOURCE_TEST_FOLDER + "processDefinition.json");
+
+    public static final Path ACTIVITY_INSTANCE_RESPONSE_JSON_FILE =
+            Paths.get(SOURCE_TEST_FOLDER + "activityInstance.json");
+
+    public static final Path PROCESS_INSTANCE_VARIABLES_RESPONSE_JSON_FILE =
+            Paths.get(SOURCE_TEST_FOLDER + "processInstanceVariables.json");
+
+    public static final Path PROCCESS_INSTANCE_RESPONSE_JSON_FILE =
+            Paths.get(SOURCE_TEST_FOLDER + "processInstance.json");
+
+    public static final Path SINGLE_PROCCESS_INSTANCE_RESPONSE_JSON_FILE =
+            Paths.get(SOURCE_TEST_FOLDER + "singleprocessInstance.json");
+
+    public static final Path SEARCH_RESULT_RESPONSE_JSON_FILE =
+            Paths.get("src/test/resources/databaseResponses/searchResult.json");
+
+    public static final String ID = UUID.randomUUID().toString();
+
+    public static final long END_TIME_IN_MS = 1546351200000l;
+
+    public static final long START_TIME_IN_MS = 1546346700000l;
+
+    private Constants() {}
+
+}
index ca2a88d..3ca184e 100644 (file)
@@ -23,6 +23,20 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.CAMUNDA_REST_TEMPLATE;
+import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.DATABASE_REST_TEMPLATE;
+import static org.onap.so.monitoring.rest.api.Constants.ACTIVITY_INSTANCE_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.EMPTY_ARRAY_RESPONSE;
+import static org.onap.so.monitoring.rest.api.Constants.EMPTY_STRING;
+import static org.onap.so.monitoring.rest.api.Constants.END_TIME_IN_MS;
+import static org.onap.so.monitoring.rest.api.Constants.ID;
+import static org.onap.so.monitoring.rest.api.Constants.PROCCESS_INSTANCE_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.PROCESS_DEF_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.PROCESS_INSTACE_ID;
+import static org.onap.so.monitoring.rest.api.Constants.PROCESS_INSTANCE_VARIABLES_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.PROCRESS_DEF_ID;
+import static org.onap.so.monitoring.rest.api.Constants.SEARCH_RESULT_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.SINGLE_PROCCESS_INSTANCE_RESPONSE_JSON_FILE;
+import static org.onap.so.monitoring.rest.api.Constants.START_TIME_IN_MS;
 import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
 import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest;
 import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@@ -31,9 +45,10 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
-import java.util.UUID;
+import java.util.Map;
 
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
@@ -42,11 +57,13 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider;
+import org.onap.so.monitoring.configuration.database.DatabaseUrlProvider;
 import org.onap.so.monitoring.model.ActivityInstanceDetail;
 import org.onap.so.monitoring.model.ProcessDefinitionDetail;
 import org.onap.so.monitoring.model.ProcessInstanceDetail;
 import org.onap.so.monitoring.model.ProcessInstanceIdDetail;
 import org.onap.so.monitoring.model.ProcessInstanceVariableDetail;
+import org.onap.so.monitoring.model.SoInfraRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -57,56 +74,39 @@ import org.springframework.test.web.client.MockRestServiceServer;
 import org.springframework.web.client.RestTemplate;
 
 
-
 /**
- * @author waqas.ikram@ericsson.com
+ * @author waqas.ikram@ericsson.com, andrei.barcovschi@ericsson.com
  */
 @RunWith(SpringJUnit4ClassRunner.class)
 @ActiveProfiles("test")
 @SpringBootTest
 public class SoMonitoringControllerTest {
 
-    private static final String PROCRESS_DEF_ID = "AFRFLOW:1:c6eea1b7-9722-11e8-8caf-022ac9304eeb";
-
-    private static final String EMPTY_ARRAY_RESPONSE = "[]";
-
-    private static final String PROCESS_INSTACE_ID = "5956a99d-9736-11e8-8caf-022ac9304eeb";
-
-    private static final String EMPTY_STRING = "";
-
-    private static final String SOURCE_TEST_FOLDER = "src/test/resources/camundaResponses/";
-
-    private static final Path PROCESS_DEF_RESPONSE_JSON_FILE = Paths.get(SOURCE_TEST_FOLDER + "processDefinition.json");
-
-    private static final Path ACTIVITY_INSTANCE_RESPONSE_JSON_FILE =
-            Paths.get(SOURCE_TEST_FOLDER + "activityInstance.json");
-
-    private static final Path PROCESS_INSTANCE_VARIABLES_RESPONSE_JSON_FILE =
-            Paths.get(SOURCE_TEST_FOLDER + "processInstanceVariables.json");
-
-    private static final Path PROCCESS_INSTANCE_RESPONSE_JSON_FILE =
-            Paths.get(SOURCE_TEST_FOLDER + "processInstance.json");
-
-    private static final Path SINGLE_PROCCESS_INSTANCE_RESPONSE_JSON_FILE =
-            Paths.get(SOURCE_TEST_FOLDER + "singleprocessInstance.json");
-
-    private static final String ID = UUID.randomUUID().toString();
-
     @Autowired
     @Qualifier(CAMUNDA_REST_TEMPLATE)
     private RestTemplate restTemplate;
 
+    @Autowired
+    @Qualifier(DATABASE_REST_TEMPLATE)
+    private RestTemplate dataBaseRestTemplate;
+
     @Autowired
     private CamundaRestUrlProvider urlProvider;
 
+    @Autowired
+    private DatabaseUrlProvider databaseUrlProvider;
+
     private MockRestServiceServer camundaMockServer;
 
+    private MockRestServiceServer databaseMockServer;
+
     @Autowired
     private SoMonitoringController objUnderTest;
 
     @Before
     public void setUp() throws Exception {
         camundaMockServer = MockRestServiceServer.bindTo(restTemplate).build();
+        databaseMockServer = MockRestServiceServer.bindTo(dataBaseRestTemplate).build();
     }
 
     @Test
@@ -339,7 +339,7 @@ public class SoMonitoringControllerTest {
         final List<ProcessInstanceVariableDetail> actual = (List<ProcessInstanceVariableDetail>) response.getEntity();
         assertEquals(230, actual.size());
 
-        ProcessInstanceVariableDetail variableDetail = actual.get(0);
+        final ProcessInstanceVariableDetail variableDetail = actual.get(0);
         assertEquals("serviceType", variableDetail.getName());
         assertEquals("String", variableDetail.getType());
         assertEquals("PNFSERVICE", variableDetail.getValue());
@@ -393,6 +393,30 @@ public class SoMonitoringControllerTest {
 
     }
 
+    @Test
+    public void test_GetInfraActiveRequests_SuccessResponseWithSoInfraRequestList() throws Exception {
+        final String jsonString = getJsonResponse(SEARCH_RESULT_RESPONSE_JSON_FILE);
+        this.databaseMockServer
+                .expect(requestTo(databaseUrlProvider.getSearchUrl(START_TIME_IN_MS, END_TIME_IN_MS, null)))
+                .andRespond(withSuccess(jsonString, MediaType.APPLICATION_JSON));
+
+        final Response response =
+                objUnderTest.getInfraActiveRequests(Collections.emptyMap(), START_TIME_IN_MS, END_TIME_IN_MS, null);
+
+        assertEquals(Status.OK.getStatusCode(), response.getStatus());
+        @SuppressWarnings("unchecked")
+        final List<SoInfraRequest> actual = (List<SoInfraRequest>) response.getEntity();
+        assertEquals(3, actual.size());
+
+        final Map<String, SoInfraRequest> actualRequests = new HashMap<>();
+        for (final SoInfraRequest soInfraRequest : actual) {
+            actualRequests.put(soInfraRequest.getRequestId(), soInfraRequest);
+        }
+        final SoInfraRequest infraRequest = actualRequests.get("9383dc81-7a6c-4673-8082-650d50a82a1a");
+        assertNull(infraRequest.getEndTime());
+        assertEquals("IN_PROGRESS", infraRequest.getRequestStatus());
+    }
+
     private String getJsonResponse(final Path path) throws IOException {
         return new String(Files.readAllBytes(path));
     }
index 857266d..8d930fe 100644 (file)
@@ -13,3 +13,12 @@ camunda:
       url: http://localhost:8080/engine-rest/engine/
       engine: default
       auth: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==
+
+mso:
+  database:
+    rest:
+      api:
+        url: http://localhost:8083/infraActiveRequests/
+        auth: Basic YnBlbDpwYXNzd29yZDEk
+
+      
\ No newline at end of file
diff --git a/so-monitoring/so-monitoring-service/src/test/resources/databaseResponses/searchResult.json b/so-monitoring/so-monitoring-service/src/test/resources/databaseResponses/searchResult.json
new file mode 100644 (file)
index 0000000..90c27ef
--- /dev/null
@@ -0,0 +1,161 @@
+[
+    {
+        "requestId": "a5294d37-21db-4e3a-ae04-57412adcb4ac",
+        "clientRequestId": null,
+        "action": "createInstance",
+        "requestStatus": "COMPLETE",
+        "statusMessage": null,
+        "rollbackStatusMessage": null,
+        "flowStatus": null,
+        "retryStatusMessage": null,
+        "progress": null,
+        "startTime": 1546346700000,
+        "endTime": 1546347000000,
+        "source": null,
+        "vnfId": null,
+        "vnfName": null,
+        "vnfType": null,
+        "serviceType": null,
+        "aicNodeClli": null,
+        "tenantId": null,
+        "provStatus": null,
+        "vnfParams": null,
+        "vnfOutputs": null,
+        "requestBody": null,
+        "responseBody": null,
+        "lastModifiedBy": null,
+        "modifyTime": null,
+        "requestType": null,
+        "volumeGroupId": null,
+        "volumeGroupName": null,
+        "vfModuleId": null,
+        "vfModuleName": null,
+        "vfModuleModelName": null,
+        "aaiServiceId": null,
+        "aicCloudRegion": null,
+        "callBackUrl": null,
+        "correlator": null,
+        "serviceInstanceId": "f7712652-b516-4925-a243-64550d26fd84",
+        "serviceInstanceName": "ShouldReturnInSearchQuery_1",
+        "requestScope": null,
+        "requestAction": null,
+        "networkId": null,
+        "networkName": null,
+        "networkType": null,
+        "requestorId": null,
+        "configurationId": null,
+        "configurationName": null,
+        "operationalEnvId": null,
+        "operationalEnvName": null,
+        "instanceGroupId": null,
+        "instanceGroupName": null,
+        "requestUrl": null,
+        "requestURI": "a5294d37-21db-4e3a-ae04-57412adcb4ac"
+    },
+    {
+        "requestId": "9383dc81-7a6c-4673-8082-650d50a82a1a",
+        "clientRequestId": null,
+        "action": "createInstance",
+        "requestStatus": "IN_PROGRESS",
+        "statusMessage": null,
+        "rollbackStatusMessage": null,
+        "flowStatus": null,
+        "retryStatusMessage": null,
+        "progress": null,
+        "startTime": 1546347300000,
+        "endTime": null,
+        "source": null,
+        "vnfId": null,
+        "vnfName": null,
+        "vnfType": null,
+        "serviceType": null,
+        "aicNodeClli": null,
+        "tenantId": null,
+        "provStatus": null,
+        "vnfParams": null,
+        "vnfOutputs": null,
+        "requestBody": null,
+        "responseBody": null,
+        "lastModifiedBy": null,
+        "modifyTime": null,
+        "requestType": null,
+        "volumeGroupId": null,
+        "volumeGroupName": null,
+        "vfModuleId": null,
+        "vfModuleName": null,
+        "vfModuleModelName": null,
+        "aaiServiceId": null,
+        "aicCloudRegion": null,
+        "callBackUrl": null,
+        "correlator": null,
+        "serviceInstanceId": "f7712652-b516-4925-a243-64550d26fd84",
+        "serviceInstanceName": "ShouldReturnInSearchQuery_2",
+        "requestScope": null,
+        "requestAction": null,
+        "networkId": null,
+        "networkName": null,
+        "networkType": null,
+        "requestorId": null,
+        "configurationId": null,
+        "configurationName": null,
+        "operationalEnvId": null,
+        "operationalEnvName": null,
+        "instanceGroupId": null,
+        "instanceGroupName": null,
+        "requestUrl": null,
+        "requestURI": "9383dc81-7a6c-4673-8082-650d50a82a1a"
+    },
+    {
+        "requestId": "a1abeab2-f8ef-43ab-b76c-9c3c2cb9980f",
+        "clientRequestId": null,
+        "action": "activateInstance",
+        "requestStatus": "FAILED",
+        "statusMessage": null,
+        "rollbackStatusMessage": null,
+        "flowStatus": null,
+        "retryStatusMessage": null,
+        "progress": null,
+        "startTime": 1546347600000,
+        "endTime": 1546351200000,
+        "source": null,
+        "vnfId": null,
+        "vnfName": null,
+        "vnfType": null,
+        "serviceType": null,
+        "aicNodeClli": null,
+        "tenantId": null,
+        "provStatus": null,
+        "vnfParams": null,
+        "vnfOutputs": null,
+        "requestBody": null,
+        "responseBody": null,
+        "lastModifiedBy": null,
+        "modifyTime": null,
+        "requestType": null,
+        "volumeGroupId": null,
+        "volumeGroupName": null,
+        "vfModuleId": null,
+        "vfModuleName": null,
+        "vfModuleModelName": null,
+        "aaiServiceId": null,
+        "aicCloudRegion": null,
+        "callBackUrl": null,
+        "correlator": null,
+        "serviceInstanceId": "f7712652-b516-4925-a243-64550d26fd84",
+        "serviceInstanceName": "ShouldReturnInSearchQuery_3",
+        "requestScope": null,
+        "requestAction": null,
+        "networkId": null,
+        "networkName": null,
+        "networkType": null,
+        "requestorId": null,
+        "configurationId": null,
+        "configurationName": null,
+        "operationalEnvId": null,
+        "operationalEnvName": null,
+        "instanceGroupId": null,
+        "instanceGroupName": null,
+        "requestUrl": null,
+        "requestURI": "a1abeab2-f8ef-43ab-b76c-9c3c2cb9980f"
+    }
+]
\ No newline at end of file