diff options
Diffstat (limited to 'bpmn')
35 files changed, 592 insertions, 212 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 005e7a3374..dfb6af793c 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -14,9 +14,7 @@ <properties> <camunda.version>7.8.0</camunda.version> - <httpclient.version>4.5.5</httpclient.version> - <jax.ws.rs>2.0.1</jax.ws.rs> <jackson.version>1.1.1</jackson.version> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index ab6ae35ace..b5203c676a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -247,14 +247,18 @@ public class BBInputSetup implements JavaDelegate { org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = requestDetails.getLineOfBusiness(); if (modelType.equals(ModelType.network)) { + lookupKeyMap.put(ResourceKey.NETWORK_ID, resourceId); this.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); } else if (modelType.equals(ModelType.vnf)) { + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, resourceId); this.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null); } else if (modelType.equals(ModelType.volumeGroup)) { + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, resourceId); this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); } else if (modelType.equals(ModelType.vfModule)) { + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration()); } else { @@ -321,8 +325,6 @@ public class BBInputSetup implements JavaDelegate { protected void populateVfModule(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, RelatedInstanceList[] relatedInstanceList, String instanceName, List<Map<String, String>> instanceParams, CloudConfiguration cloudConfiguration) throws Exception { - boolean foundByName = false; - boolean foundById = false; String vnfModelCustomizationUUID = null; if (relatedInstanceList != null) { for (RelatedInstanceList relatedInstList : relatedInstanceList) { @@ -350,29 +352,31 @@ public class BBInputSetup implements JavaDelegate { cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); + break; } } break; } } if (vnf != null) { - for (VfModule vfModule : vnf.getVfModules()) { + VfModule vfModule = null; + for (VfModule vfModuleTemp : vnf.getVfModules()) { if (lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null - && vfModule.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) { - foundById = true; - this.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); - } else if (instanceName != null && vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) { - foundByName = true; - lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId()); - this.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + && vfModuleTemp.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) { + vfModule = vfModuleTemp; + String vfModuleCustId = bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()).getModelCustomizationId(); + modelInfo.setModelCustomizationId(vfModuleCustId); + break; } } - if (!foundByName && !foundById && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) { - VfModule vfModule = this.createVfModule(lookupKeyMap, + if (vfModule == null && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) { + vfModule = createVfModule(lookupKeyMap, resourceId, instanceName, instanceParams); - this.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); vnf.getVfModules().add(vfModule); } + if(vfModule != null) { + mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + } } else { msoLogger.debug("Related VNF instance Id not found: " + lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); throw new Exception("Could not find relevant information for related VNF"); @@ -423,48 +427,47 @@ public class BBInputSetup implements JavaDelegate { protected void populateVolumeGroup(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, RelatedInstanceList[] relatedInstanceList, String instanceName, String vnfType, List<Map<String, String>> instanceParams) throws Exception { - boolean foundByName = false; - boolean foundById = false; + VolumeGroup volumeGroup = null; + GenericVnf vnf = null; String vnfModelCustomizationUUID = null; + String generatedVnfType = vnfType; + if (generatedVnfType == null || generatedVnfType.isEmpty()) { + generatedVnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); + } if (relatedInstanceList != null) { for (RelatedInstanceList relatedInstList : relatedInstanceList) { RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationUuid(); + break; } } } - GenericVnf vnf = null; for (GenericVnf tempVnf : serviceInstance.getVnfs()) { if (tempVnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { vnf = tempVnf; - vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()) + vnfModelCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()) .getModelCustomizationId(); ModelInfo vnfModelInfo = new ModelInfo(); vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); - this.mapCatalogVnf(tempVnf, vnfModelInfo, service); + mapCatalogVnf(tempVnf, vnfModelInfo, service); break; } } if (vnf != null && vnfModelCustomizationUUID != null) { - for (VolumeGroup volumeGroup : vnf.getVolumeGroups()) { - if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) != null && volumeGroup.getVolumeGroupId() + for (VolumeGroup volumeGroupTemp : vnf.getVolumeGroups()) { + if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) != null && volumeGroupTemp.getVolumeGroupId() .equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID))) { - foundById = true; - this.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); - } else if (instanceName != null && volumeGroup.getVolumeGroupName().equalsIgnoreCase(instanceName)) { - foundByName = true; - lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); - this.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); + volumeGroup = volumeGroupTemp; + break; } } - if (!foundByName && !foundById && bbName.equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString())) { - if (vnfType == null || vnfType.isEmpty()) { - vnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); - } - VolumeGroup volumeGroup = this.createVolumeGroup(lookupKeyMap, resourceId, instanceName, vnfType, instanceParams); + if (volumeGroup == null && bbName.equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString())) { + volumeGroup = createVolumeGroup(lookupKeyMap, resourceId, instanceName, generatedVnfType, instanceParams); vnf.getVolumeGroups().add(volumeGroup); - this.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); + } + if(volumeGroup != null) { + mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); } } else { msoLogger.debug("Related VNF instance Id not found: " + lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); @@ -522,10 +525,13 @@ public class BBInputSetup implements JavaDelegate { org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType, List<Map<String, String>> instanceParams) { - boolean foundByName = false; - boolean foundById = false; + GenericVnf vnf = null; ModelInfo instanceGroupModelInfo = null; String instanceGroupId = null; + String generatedVnfType = vnfType; + if (generatedVnfType == null || generatedVnfType.isEmpty()) { + generatedVnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); + } if (relatedInstanceList != null) { for (RelatedInstanceList relatedInstList : relatedInstanceList) { RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); @@ -535,36 +541,26 @@ public class BBInputSetup implements JavaDelegate { } } } - for (GenericVnf genericVnf : serviceInstance.getVnfs()) { + for (GenericVnf vnfTemp : serviceInstance.getVnfs()) { if (lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID) != null - && genericVnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { - foundById = true; - org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(genericVnf.getVnfId()); - if(vnf!=null){ - modelInfo.setModelCustomizationUuid(vnf.getModelCustomizationId()); - } - this.mapCatalogVnf(genericVnf, modelInfo, service); - } else if (instanceName != null && genericVnf.getVnfName().equalsIgnoreCase(instanceName)) { - foundByName = true; - lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId()); - org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(genericVnf.getVnfId()); - if(vnf!=null){ - modelInfo.setModelCustomizationUuid(vnf.getModelCustomizationId()); - } - this.mapCatalogVnf(genericVnf, modelInfo, service); + && vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + String vnfModelCustId = bbInputSetupUtils.getAAIGenericVnf(vnfTemp.getVnfId()).getModelCustomizationId(); + modelInfo.setModelCustomizationUuid(vnfModelCustId); + vnf = vnfTemp; + break; } } - if (!foundByName && !foundById && bbName.equalsIgnoreCase(AssignFlows.VNF.toString())) { - if(vnfType == null || vnfType.isEmpty()) { - vnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); + if (vnf == null && bbName.equalsIgnoreCase(AssignFlows.VNF.toString())) { + vnf = createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, + resourceId, generatedVnfType, instanceParams); + serviceInstance.getVnfs().add(vnf); + } + if(vnf != null) { + mapCatalogVnf(vnf, modelInfo, service); + mapVnfcCollectionInstanceGroup(vnf, modelInfo, service); + if (instanceGroupId != null && instanceGroupModelInfo != null) { + mapNetworkCollectionInstanceGroup(vnf, instanceGroupId); } - GenericVnf genericVnf = this.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, - resourceId, vnfType, instanceParams); - serviceInstance.getVnfs().add(genericVnf); - this.mapCatalogVnf(genericVnf, modelInfo, service); - this.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service); - if (instanceGroupId != null && instanceGroupModelInfo != null) - this.mapNetworkCollectionInstanceGroup(genericVnf, instanceGroupId); } } @@ -585,7 +581,7 @@ public class BBInputSetup implements JavaDelegate { } protected void mapNetworkCollectionInstanceGroup(GenericVnf genericVnf, String instanceGroupId) { - org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = this.bbInputSetupUtils + org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = bbInputSetupUtils .getAAIInstanceGroup(instanceGroupId); InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup); instanceGroup.setModelInfoInstanceGroup(this.mapperLayer.mapCatalogInstanceGroupToInstanceGroup( @@ -636,25 +632,22 @@ public class BBInputSetup implements JavaDelegate { protected void populateL3Network(String instanceName, ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, List<Map<String, String>> instanceParams) { - boolean foundByName = false; - boolean foundById = false; - for (L3Network network : serviceInstance.getNetworks()) { + L3Network network = null; + for (L3Network networkTemp : serviceInstance.getNetworks()) { if (lookupKeyMap.get(ResourceKey.NETWORK_ID) != null - && network.getNetworkId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.NETWORK_ID))) { - foundById = true; - this.mapCatalogNetwork(network, modelInfo, service); - } else if (instanceName != null && network.getNetworkName().equalsIgnoreCase(instanceName)) { - foundByName = true; - lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId()); - this.mapCatalogNetwork(network, modelInfo, service); + && networkTemp.getNetworkId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.NETWORK_ID))) { + network = networkTemp; + break; } } - if (!foundByName && !foundById + if (network == null && (bbName.equalsIgnoreCase(AssignFlows.NETWORK_A_LA_CARTE.toString()) || bbName.equalsIgnoreCase(AssignFlows.NETWORK_MACRO.toString()))) { - L3Network l3Network = this.createNetwork(lookupKeyMap, instanceName, resourceId, instanceParams); - serviceInstance.getNetworks().add(l3Network); - this.mapCatalogNetwork(l3Network, modelInfo, service); + network = createNetwork(lookupKeyMap, instanceName, resourceId, instanceParams); + serviceInstance.getNetworks().add(network); + } + if(network != null) { + mapCatalogNetwork(network, modelInfo, service); } } @@ -1496,7 +1489,7 @@ public class BBInputSetup implements JavaDelegate { Relationships relationships = relationshipsOp.get(); this.mapNetworkPolicies(relationships.getByType(AAIObjectType.NETWORK_POLICY), network.getNetworkPolicies()); - this.mapRouteTableReferences(relationships.getByType(AAIObjectType.ROUTE_TABLE_REFERENCE), + mapRouteTableReferences(relationships.getByType(AAIObjectType.ROUTE_TABLE_REFERENCE), network.getContrailNetworkRouteTableReferences()); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index abd7ed5a8e..c2161a4fee 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -142,6 +142,10 @@ public class BBInputSetupMapperLayer { protected VfModule mapAAIVfModule(org.onap.aai.domain.yang.VfModule aaiVfModule) { VfModule vfModule = modelMapper.map(aaiVfModule, VfModule.class); vfModule.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVfModule.getOrchestrationStatus())); + + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setIsBaseBoolean(aaiVfModule.isIsBaseVfModule()); + vfModule.setModelInfoVfModule(modelInfoVfModule); return vfModule; } @@ -175,7 +179,7 @@ public class BBInputSetupMapperLayer { protected ModelInfoInstanceGroup mapCatalogInstanceGroupToInstanceGroup(CollectionResourceCustomization collectionCust, InstanceGroup instanceGroup) { ModelInfoInstanceGroup modelInfoInstanceGroup = modelMapper.map(instanceGroup, ModelInfoInstanceGroup.class); - if(instanceGroup.getType().equals(InstanceGroupType.L3_NETWORK)) + if(instanceGroup.getType() != null && instanceGroup.getType().equals(InstanceGroupType.L3_NETWORK)) modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_L3_NETWORK); else modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_VNFC); @@ -462,4 +466,4 @@ public class BBInputSetupMapperLayer { CollectionNetworkResourceCustomization collectionNetworkResourceCust) { return modelMapper.map(collectionNetworkResourceCust, NetworkResourceCustomization.class); } -} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 3a88377a51..4b85538428 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -412,4 +412,4 @@ public class BBInputSetupUtils { return Optional.of(volumeGroup); } } -} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index daa63044e4..a821d69754 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -658,8 +658,8 @@ public class BBInputSetupTest { public void testPopulateObjectsOnAssignAndCreateFlows() throws Exception { String bbName = AssignFlows.SERVICE_INSTANCE.toString(); String instanceName = "instanceName"; - String resourceId = "123"; String vnfType = "vnfType"; + String resourceId = "networkId"; Service service = Mockito.mock(Service.class); ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); RequestDetails requestDetails = Mockito.mock(RequestDetails.class); @@ -675,12 +675,6 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); - doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, - service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null); - doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); - doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, relatedInstanceList, instanceName, null, cloudConfiguration); doReturn(modelInfo).when(requestDetails).getModelInfo(); doReturn(requestInfo).when(requestDetails).getRequestInfo(); doReturn(instanceName).when(requestInfo).getInstanceName(); @@ -690,36 +684,41 @@ public class BBInputSetupTest { doReturn(cloudConfiguration).when(requestDetails).getCloudConfiguration(); doReturn(ModelType.network).when(modelInfo).getModelType(); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); + assertEquals("NetworkId populated", true, lookupKeyMap.get(ResourceKey.NETWORK_ID).equalsIgnoreCase(resourceId)); doReturn(ModelType.vnf).when(modelInfo).getModelType(); - + resourceId = "vnfId"; + doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, + service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null); + assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId)); doReturn(ModelType.volumeGroup).when(modelInfo).getModelType(); - + resourceId = "volumeGroupId"; + doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance, + lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); + assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId)); doReturn(ModelType.vfModule).when(modelInfo).getModelType(); - + resourceId = "vfModuleId"; + doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, relatedInstanceList, instanceName, null, cloudConfiguration); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration); + assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId)); } @Test @@ -946,7 +945,6 @@ public class BBInputSetupTest { vg.setVolumeGroupName("volumeGroupName"); vg.setVolumeGroupId("volumeGroupId"); vnf.getVolumeGroups().add(vg); - vnf.getVolumeGroups().add(vg); serviceInstance.getVnfs().add(vnf); Service service = mapper.readValue( @@ -962,9 +960,10 @@ public class BBInputSetupTest { aaiGenericVnf.setModelCustomizationId("vnfModelCustomizationUUID"); doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId"); SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); - verify(SPY_bbInputSetup, times(2)).mapCatalogVolumeGroup(vg, modelInfo, service, "vnfModelCustomizationUUID"); + verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vg, modelInfo, service, "vnfModelCustomizationUUID"); vnf.getVolumeGroups().clear(); SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); @@ -1023,14 +1022,14 @@ public class BBInputSetupTest { SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); - verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network, modelInfo, service); + verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network, modelInfo, service); instanceName = "networkName2"; L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null); doReturn(network2).when(SPY_bbInputSetup).createNetwork(lookupKeyMap, instanceName, resourceId, null); SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); - verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network2, modelInfo, service); + verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service); } @Test @@ -1148,8 +1147,15 @@ public class BBInputSetupTest { String resourceId = "123"; doReturn(expectedPlatform).when(bbInputSetupMapperLayer).mapRequestPlatform(platform); doReturn(expectedLineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(lineOfBusiness); + org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf(); + vnfAAI.setModelCustomizationId("modelCustId"); + doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service); - doReturn(null).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class)); + org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup(); + doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any()); + org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup(); + doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any()); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); @@ -1157,7 +1163,7 @@ public class BBInputSetupTest { SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); - verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf, modelInfo, service); + verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, @@ -1166,11 +1172,14 @@ public class BBInputSetupTest { resourceId, vnfType, null); doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); doNothing().when(SPY_bbInputSetup).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); + + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId2"); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); - verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf2, modelInfo, service); - verify(SPY_bbInputSetup, times(1)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); - verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); + verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); + verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); + verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); } @Test @@ -1202,7 +1211,14 @@ public class BBInputSetupTest { String resourceId = "123"; doReturn(expectedPlatform).when(bbInputSetupMapperLayer).mapRequestPlatform(platform); doReturn(expectedLineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(lineOfBusiness); + org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf(); + vnfAAI.setModelCustomizationId("modelCustId"); + doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service); + org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup(); + doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any()); + org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup(); + doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any()); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); @@ -1211,20 +1227,24 @@ public class BBInputSetupTest { SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); - verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf, modelInfo, service); + verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, resourceId, vnfType, null); doReturn(vnf2).when(SPY_bbInputSetup).createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, resourceId, vnfType, null); + org.onap.aai.domain.yang.GenericVnf vnf2AAI = new org.onap.aai.domain.yang.GenericVnf(); + vnfAAI.setModelCustomizationId("modelCustId2"); + doReturn(vnf2AAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf2.getVnfId()); + doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service); doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); doNothing().when(SPY_bbInputSetup).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); - verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf2, modelInfo, service); - verify(SPY_bbInputSetup, times(1)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); - verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); + verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); + verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); + verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); } @Test diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index db0f408010..aa883b67a2 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -773,4 +773,4 @@ public class BBInputSetupUtilsTest { assertEquals(actualVolumeGroup, Optional.empty()); } -} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GenericVnfExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GenericVnfExpected.json index 0d00e4d007..e4c8a8f59b 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GenericVnfExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GenericVnfExpected.json @@ -12,7 +12,9 @@ "heat-stack-id":"heatStackId", "contrail-service-instance-fqdn":"contrailServiceInstanceFqdn", "module-index":1,"selflink":"selflink", - "model-info-vf-module":null + "model-info-vf-module": { + "is-base-boolean":false + } }], "volume-groups":[], "line-of-business":null, diff --git a/bpmn/so-bpmn-building-blocks/pom.xml b/bpmn/so-bpmn-building-blocks/pom.xml index cc6e19d446..a8a6441740 100644 --- a/bpmn/so-bpmn-building-blocks/pom.xml +++ b/bpmn/so-bpmn-building-blocks/pom.xml @@ -9,7 +9,6 @@ <artifactId>so-bpmn-building-blocks</artifactId> <packaging>jar</packaging> <properties> - <jax.ws.rs>2.0.1</jax.ws.rs> <httpclient.version>3.1</httpclient.version> <camunda.bpm.assert.version>1.2</camunda.bpm.assert.version> <h2.version>1.4.196</h2.version> @@ -142,11 +141,6 @@ <version>3.4</version> </dependency> <dependency> - <groupId>javax.ws.rs</groupId> - <artifactId>javax.ws.rs-api</artifactId> - <version>2.0</version> - </dependency> - <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index 3d18810e48..abc017c957 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -23,21 +23,27 @@ <bpmn:outgoing>SequenceFlow_1s4rpyp</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_16g4dz0" sourceRef="CreateVfModule" targetRef="VnfAdapter" /> - <bpmn:sequenceFlow id="SequenceFlow_0ecr393" sourceRef="VnfAdapter" targetRef="UpdateVfModuleStatus" /> + <bpmn:sequenceFlow id="SequenceFlow_0ecr393" sourceRef="VnfAdapter" targetRef="UpdateVfModuleHeatStackId" /> <bpmn:callActivity id="VnfAdapter" name="Vnf Adapter" calledElement="VnfAdapter"> <bpmn:extensionElements> <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> + <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_16g4dz0</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ecr393</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="SequenceFlow_1stomxq" sourceRef="UpdateVfModuleStatus" targetRef="CreateVfModuleBB_End" /> <bpmn:serviceTask id="UpdateVfModuleStatus" name="Update VfModule Ostatus to Created (AAI)" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusCreatedVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0ecr393</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0qqsilv</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1stomxq</bpmn:outgoing> </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0qqsilv" sourceRef="UpdateVfModuleHeatStackId" targetRef="UpdateVfModuleStatus" /> + <bpmn:serviceTask id="UpdateVfModuleHeatStackId" name="Update VfModule HeatStackId (AAI)" camunda:expression="${AAIUpdateTasks.updateHeatStackIdVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0ecr393</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0qqsilv</bpmn:outgoing> + </bpmn:serviceTask> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateVfModuleBB"> @@ -58,9 +64,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0qdq7wj_di" bpmnElement="CreateVfModuleBB_End"> - <dc:Bounds x="1259" y="-3" width="36" height="36" /> + <dc:Bounds x="1391" y="-3" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1267" y="37" width="19" height="12" /> + <dc:Bounds x="1399" y="37" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1dgenhy_di" bpmnElement="CreateVfModule"> @@ -92,23 +98,33 @@ </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0ecr393_di" bpmnElement="SequenceFlow_0ecr393"> <di:waypoint xsi:type="dc:Point" x="990" y="15" /> - <di:waypoint xsi:type="dc:Point" x="1065" y="15" /> + <di:waypoint xsi:type="dc:Point" x="1063" y="15" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1028" y="0" width="0" height="0" /> + <dc:Bounds x="1027" y="0" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1i1pfzb_di" bpmnElement="VnfAdapter"> <dc:Bounds x="890" y="-25" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1stomxq_di" bpmnElement="SequenceFlow_1stomxq"> - <di:waypoint xsi:type="dc:Point" x="1165" y="15" /> - <di:waypoint xsi:type="dc:Point" x="1259" y="15" /> + <di:waypoint xsi:type="dc:Point" x="1327" y="15" /> + <di:waypoint xsi:type="dc:Point" x="1391" y="15" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1212" y="0" width="0" height="0" /> + <dc:Bounds x="1359" y="0" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0fpfn71_di" bpmnElement="UpdateVfModuleStatus"> - <dc:Bounds x="1065" y="-25" width="100" height="80" /> + <dc:Bounds x="1227" y="-25" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0qqsilv_di" bpmnElement="SequenceFlow_0qqsilv"> + <di:waypoint xsi:type="dc:Point" x="1163" y="15" /> + <di:waypoint xsi:type="dc:Point" x="1227" y="15" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1195" y="0" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_04k1b85_di" bpmnElement="UpdateVfModuleHeatStackId"> + <dc:Bounds x="1063" y="-25" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn index 58a429dcc5..a95dc9ce73 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVolumeGroupBB.bpmn @@ -1,5 +1,5 @@ <?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> <bpmn:process id="CreateVolumeGroupBB" name="CreateVolumeGroupBB" isExecutable="true"> <bpmn:startEvent id="CreateVolumeGroupBB_Start" name="Start"> <bpmn:outgoing>SequenceFlow_1wz1rfg</bpmn:outgoing> @@ -14,7 +14,7 @@ </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0kfkpbh" sourceRef="CreateVolumeGroupVnfAdapter" targetRef="Vnf_Adapter" /> <bpmn:serviceTask id="UpdateVolumeGroupAAI" name="UpdateVolumeGroupAAI" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_06flg6h</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1d5nux2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0mh0v9h</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0mh0v9h" sourceRef="UpdateVolumeGroupAAI" targetRef="CreateVolumeGroupBB_End" /> @@ -28,11 +28,17 @@ <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> + <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0kfkpbh</bpmn:incoming> <bpmn:outgoing>SequenceFlow_06flg6h</bpmn:outgoing> </bpmn:callActivity> - <bpmn:sequenceFlow id="SequenceFlow_06flg6h" sourceRef="Vnf_Adapter" targetRef="UpdateVolumeGroupAAI" /> + <bpmn:sequenceFlow id="SequenceFlow_06flg6h" sourceRef="Vnf_Adapter" targetRef="UpdateVolumeGroupHeatStackId" /> + <bpmn:sequenceFlow id="SequenceFlow_1d5nux2" sourceRef="UpdateVolumeGroupHeatStackId" targetRef="UpdateVolumeGroupAAI" /> + <bpmn:serviceTask id="UpdateVolumeGroupHeatStackId" name="Update VolumeGroup HeatStackId (AAI)" camunda:expression="${AAIUpdateTasks.updateHeatStackIdVolumeGroup(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_06flg6h</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1d5nux2</bpmn:outgoing> + </bpmn:serviceTask> </bpmn:process> <bpmn:error id="Error_0pz4sdi" name="gDelegateError" errorCode="7000" /> <bpmn:escalation id="Escalation_1hjulni" name="Escalation_2cgup2p" /> @@ -52,9 +58,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1k6463v_di" bpmnElement="CreateVolumeGroupBB_End"> - <dc:Bounds x="928" y="102" width="36" height="36" /> + <dc:Bounds x="1063" y="102" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="901" y="142" width="90" height="12" /> + <dc:Bounds x="1081" y="142" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_01zmebl_di" bpmnElement="CreateVolumeGroupVnfAdapter"> @@ -68,13 +74,13 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0rytcj0_di" bpmnElement="UpdateVolumeGroupAAI"> - <dc:Bounds x="776" y="80" width="100" height="80" /> + <dc:Bounds x="929" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0mh0v9h_di" bpmnElement="SequenceFlow_0mh0v9h"> - <di:waypoint xsi:type="dc:Point" x="876" y="120" /> - <di:waypoint xsi:type="dc:Point" x="928" y="120" /> + <di:waypoint xsi:type="dc:Point" x="1029" y="120" /> + <di:waypoint xsi:type="dc:Point" x="1063" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="857" y="98.5" width="90" height="13" /> + <dc:Bounds x="1046" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1wythmn_di" bpmnElement="QueryVfModuleSDNC"> @@ -92,11 +98,21 @@ </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_06flg6h_di" bpmnElement="SequenceFlow_06flg6h"> <di:waypoint xsi:type="dc:Point" x="729" y="120" /> - <di:waypoint xsi:type="dc:Point" x="776" y="120" /> + <di:waypoint xsi:type="dc:Point" x="774" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="752.5" y="99" width="0" height="12" /> + <dc:Bounds x="752" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1d5nux2_di" bpmnElement="SequenceFlow_1d5nux2"> + <di:waypoint xsi:type="dc:Point" x="874" y="120" /> + <di:waypoint xsi:type="dc:Point" x="929" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="902" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0m035ns_di" bpmnElement="UpdateVolumeGroupHeatStackId"> + <dc:Bounds x="774" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 755bfe8126..07d0b18938 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -24,6 +24,7 @@ <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="deleteVfModuleRequest" target="deleteVfModuleRequest" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> + <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_08tvhtf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_02lpx87</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetwork1802BB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetwork1802BB.bpmn index bd6b124175..212e735dd1 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetwork1802BB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetwork1802BB.bpmn @@ -11,18 +11,13 @@ <bpmn:endEvent id="End_UnassignNetworkBB" name="end"> <bpmn:incoming>SequenceFlow_1ks8kmt</bpmn:incoming> </bpmn:endEvent> - <bpmn:sequenceFlow id="SequenceFlow_0zaz9o2" sourceRef="Start_UnassignNetworkBB" targetRef="Task_GetL3NetworkById" /> + <bpmn:sequenceFlow id="SequenceFlow_0zaz9o2" sourceRef="Start_UnassignNetworkBB" targetRef="Task_VfModuleRelatioship" /> <bpmn:sequenceFlow id="SequenceFlow_1ks8kmt" sourceRef="Task_SNDCUnAssign" targetRef="End_UnassignNetworkBB" /> <bpmn:serviceTask id="Task_VfModuleRelatioship" name="Veriyf 'vf-module' relationship exists" camunda:expression="${UnassignNetworkBB.checkRelationshipRelatedTo(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), "vf-module")}"> - <bpmn:incoming>SequenceFlow_1gd5h4c</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0zaz9o2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0mxe1a7</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0mxe1a7" sourceRef="Task_VfModuleRelatioship" targetRef="Task_GetCloudRegionVersion" /> - <bpmn:sequenceFlow id="SequenceFlow_1gd5h4c" sourceRef="Task_GetL3NetworkById" targetRef="Task_VfModuleRelatioship" /> - <bpmn:serviceTask id="Task_GetL3NetworkById" name="Get L3Network by networkId (AAI)" camunda:expression="${AAIQueryTasks.getNetworkWrapperById(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0zaz9o2</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1gd5h4c</bpmn:outgoing> - </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0le4vrj" sourceRef="Task_GetCloudRegionVersion" targetRef="Task_SNDCUnAssign" /> <bpmn:serviceTask id="Task_GetCloudRegionVersion" name="Get Sdnc Cloud Region Version" camunda:expression="${UnassignNetworkBB.getCloudSdncRegion(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_0mxe1a7</bpmn:incoming> @@ -32,9 +27,9 @@ <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="UnassignNetwork1802BB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_UnassignNetworkBB"> - <dc:Bounds x="145" y="119" width="36" height="36" /> + <dc:Bounds x="288" y="119" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="152" y="155" width="22" height="12" /> + <dc:Bounds x="295" y="155" width="22" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0m0ikey_di" bpmnElement="Task_SNDCUnAssign"> @@ -47,10 +42,10 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0zaz9o2_di" bpmnElement="SequenceFlow_0zaz9o2"> - <di:waypoint xsi:type="dc:Point" x="181" y="137" /> - <di:waypoint xsi:type="dc:Point" x="232" y="137" /> + <di:waypoint xsi:type="dc:Point" x="324" y="137" /> + <di:waypoint xsi:type="dc:Point" x="375" y="137" /> <bpmndi:BPMNLabel> - <dc:Bounds x="207" y="122" width="0" height="0" /> + <dc:Bounds x="304.5" y="122" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1ks8kmt_di" bpmnElement="SequenceFlow_1ks8kmt"> @@ -70,16 +65,6 @@ <dc:Bounds x="500" y="122" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1gd5h4c_di" bpmnElement="SequenceFlow_1gd5h4c"> - <di:waypoint xsi:type="dc:Point" x="332" y="137" /> - <di:waypoint xsi:type="dc:Point" x="375" y="137" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="354" y="122" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1scptd7_di" bpmnElement="Task_GetL3NetworkById"> - <dc:Bounds x="232" y="97" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0le4vrj_di" bpmnElement="SequenceFlow_0le4vrj"> <di:waypoint xsi:type="dc:Point" x="624" y="137" /> <di:waypoint xsi:type="dc:Point" x="665" y="137" /> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java index a3c6a820bd..a94a4bb89a 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java @@ -42,6 +42,7 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ "QueryVfModule", "CreateVfModule", "VnfAdapter", + "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); @@ -54,7 +55,7 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf") - .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -65,7 +66,7 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule") - .hasNotPassed("CreateVfModule", "VnfAdapter", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -76,18 +77,32 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule") - .hasNotPassed("VnfAdapter", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @Test + public void rainyDayCreateVfModuleUpdateVfModuleHeatStackIdError_Test() throws Exception { + mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub"); + + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateHeatStackIdVfModule(any(BuildingBlockExecution.class)); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables); + assertThat(pi).isNotNull(); + assertThat(pi).isStarted() + .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId") + .hasNotPassed("UpdateVfModuleStatus", "CreateVfModuleBB_End"); + assertThat(pi).isEnded(); + + } + + @Test public void rainyDayCreateVfModuleUpdateVfModuleStatusError_Test() throws Exception { mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub"); doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateOrchestrationStatusCreatedVfModule(any(BuildingBlockExecution.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleStatus") + .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus") .hasNotPassed("CreateVfModuleBB_End"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java index 980e609e97..eb372fb6a7 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVolumeGroupBBTest.java @@ -36,7 +36,7 @@ public class CreateVolumeGroupBBTest extends BaseBPMNTest{ mockSubprocess("VnfAdapter", "Mocked VnfAdapter", "GenericStub"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVolumeGroupBB", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted(); + assertThat(pi).isStarted().hasPassedInOrder("CreateVolumeGroupBB_Start", "QueryVfModuleSDNC", "CreateVolumeGroupVnfAdapter", "Vnf_Adapter", "UpdateVolumeGroupHeatStackId", "UpdateVolumeGroupAAI", "CreateVolumeGroupBB_End"); assertThat(pi).isEnded(); assertThat(pi).hasPassedInOrder("CreateVolumeGroupBB_Start", "QueryVfModuleSDNC", "CreateVolumeGroupVnfAdapter", "Vnf_Adapter","UpdateVolumeGroupAAI", "CreateVolumeGroupBB_End"); } @@ -46,7 +46,20 @@ public class CreateVolumeGroupBBTest extends BaseBPMNTest{ doThrow(new BpmnError("7000", "TESTING ERRORS")).when(vnfAdapterCreateTasks).createVolumeGroupRequest(any(BuildingBlockExecution.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVolumeGroupBB", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted(); + assertThat(pi).isStarted() + .hasPassedInOrder("CreateVolumeGroupBB_Start", "QueryVfModuleSDNC", "CreateVolumeGroupVnfAdapter") + .hasNotPassed("UpdateVolumeGroupHeatStackId", "UpdateVolumeGroupAAI", "CreateVolumeGroupBB_End"); + assertThat(pi).isEnded(); + } + + @Test + public void rainyDayCreateVolumeGroupUpdateHeatStackIdError_Test() throws Exception { + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(aaiUpdateTasks).updateHeatStackIdVolumeGroup(any(BuildingBlockExecution.class)); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVolumeGroupBB", variables); + assertThat(pi).isNotNull(); + assertThat(pi).isStarted() + .hasPassedInOrder("CreateVolumeGroupBB_Start", "QueryVfModuleSDNC", "CreateVolumeGroupVnfAdapter", "Vnf_Adapter") + .hasNotPassed("UpdateVolumeGroupAAI", "CreateVolumeGroupBB_End"); assertThat(pi).isEnded(); assertThat(pi).hasPassedInOrder("CreateVolumeGroupBB_Start", "QueryVfModuleSDNC", "CreateVolumeGroupVnfAdapter") .hasNotPassed("Vnf_Adapter", "UpdateVolumeGroupAAI", "CreateVolumeGroupBB_End"); diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetwork1802BBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetwork1802BBTest.java index ad374e3304..2c5381de09 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetwork1802BBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/UnassignNetwork1802BBTest.java @@ -36,7 +36,7 @@ public class UnassignNetwork1802BBTest extends BaseBPMNTest { public void sunnyDayAssignNetwork_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnassignNetwork1802BB",variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("Start_UnassignNetworkBB","Task_GetL3NetworkById","Task_VfModuleRelatioship","Task_GetCloudRegionVersion","Task_SNDCUnAssign","End_UnassignNetworkBB"); + assertThat(pi).isStarted().hasPassedInOrder("Start_UnassignNetworkBB","Task_VfModuleRelatioship","Task_GetCloudRegionVersion","Task_SNDCUnAssign","End_UnassignNetworkBB"); assertThat(pi).isEnded(); } @@ -46,8 +46,8 @@ public class UnassignNetwork1802BBTest extends BaseBPMNTest { ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnassignNetwork1802BB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("Start_UnassignNetworkBB", "Task_GetL3NetworkById", "Task_VfModuleRelatioship") + .hasPassedInOrder("Start_UnassignNetworkBB", "Task_VfModuleRelatioship") .hasNotPassed("End_UnassignNetworkBB"); assertThat(pi).isEnded(); } -} +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index 70b9d0633b..ab0ac25a99 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -234,7 +234,7 @@ <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> - <version>2.0</version> + <version>${jax.ws.rs}</version> </dependency> <dependency> <groupId>org.onap.so</groupId> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy index 34a73bd35c..6b42406883 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -304,19 +304,22 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition") List<ModuleResource> moduleResources = vnfResource.getVfModules() - for (j in 0..moduleResources.size()-1) { - ModelInfo modelInfo = moduleResources[j].getModelInfo() - String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() - msoLogger.debug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition) - - if (modelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { - String vfModuleModelInfo = modelInfo.toJsonString() - String vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfo, "modelInfo") - execution.setVariable("DUVAM_vfModuleModelInfo", vfModuleModelInfoValue) - msoLogger.debug("vfModuleModelInfo: " + vfModuleModelInfoValue) - break + if (moduleResources != null && !moduleResources.isEmpty()) { + + for (j in 0..moduleResources.size()-1) { + ModelInfo modelInfo = moduleResources[j].getModelInfo() + String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() + msoLogger.debug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition) + + if (modelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { + String vfModuleModelInfo = modelInfo.toJsonString() + String vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfo, "modelInfo") + execution.setVariable("DUVAM_vfModuleModelInfo", vfModuleModelInfoValue) + msoLogger.debug("vfModuleModelInfo: " + vfModuleModelInfoValue) + break + } + } - } }catch(Exception e){ diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml index 8557cf178e..1a3a64bcc8 100644 --- a/bpmn/so-bpmn-infrastructure-flows/pom.xml +++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml @@ -211,7 +211,7 @@ <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> - <version>2.0</version> + <version>${jax.ws.rs}</version> </dependency> <dependency> <groupId>org.onap.so</groupId> diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index 68f7e5a3bb..3483aed8a7 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -30,6 +30,12 @@ <groupId>org.onap.sdnc.northbound</groupId> <artifactId>generic-resource-api-client</artifactId> <version>1.4.0-SNAPSHOT</version> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>ch.vorburger.mariaDB4j</groupId> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 074652e221..9c1fba62e9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -141,6 +141,19 @@ public class AAIUpdateTasks { } } + public void updateHeatStackIdVolumeGroup(BuildingBlockExecution execution) { + try { + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + + VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); + CloudRegion cloudRegion = gBBInput.getCloudRegion(); + + aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + public void updateOrchestrationStatusAssignedVfModule(BuildingBlockExecution execution) { try { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); @@ -281,6 +294,16 @@ public class AAIUpdateTasks { } } + public void updateHeatStackIdVfModule(BuildingBlockExecution execution) { + try { + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + /** * BPMN access method to update L3Network after it was created in AIC * @param execution diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java index f94b967643..c45a47bc12 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java @@ -23,8 +23,12 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAINetworkResources; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -42,6 +46,12 @@ public class UnassignNetworkBB { @Autowired private NetworkBBUtils networkBBUtils; + + @Autowired + private ExtractPojosForBB extractPojosForBB; + + @Autowired + private AAINetworkResources aaiNetworkResources; /** * BPMN access method to prepare overall error messages. @@ -54,9 +64,11 @@ public class UnassignNetworkBB { public void checkRelationshipRelatedTo(BuildingBlockExecution execution, String relatedToValue) throws Exception { try { - AAIResultWrapper aaiResultWrapper = execution.getVariable("l3NetworkAAIResultWrapper"); - Optional<org.onap.aai.domain.yang.L3Network> l3network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class); - if (networkBBUtils.isRelationshipRelatedToExists(l3network, relatedToValue)) { + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); + Optional<org.onap.aai.domain.yang.L3Network> network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class); + if (networkBBUtils.isRelationshipRelatedToExists(network, relatedToValue)) { String msg = MESSAGE_CANNOT_PERFORM_UNASSIGN + relatedToValue; execution.setVariable("ErrorUnassignNetworkBB", msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 5f922e0c99..1d87b70754 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -187,7 +187,9 @@ public class VnfAdapterVfModuleObjectMapper { paramsMap.put("vf_module_id", vfModule.getVfModuleId()); paramsMap.put("vf_module_name", vfModule.getVfModuleName()); paramsMap.put("environment_context",serviceInstance.getModelInfoServiceInstance().getEnvironmentContext()); + paramsMap.putIfAbsent("environment_context", ""); paramsMap.put("workload_context", serviceInstance.getModelInfoServiceInstance().getWorkloadContext()); + paramsMap.putIfAbsent("workload_context", ""); Integer vfModuleIndex = vfModule.getModuleIndex(); if (vfModuleIndex != null) { paramsMap.put("vf_module_index", vfModuleIndex.toString()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java index 7fef56d965..a641d43ba3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java @@ -67,6 +67,15 @@ public class AAIVfModuleResources { injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule); } + public void updateHeatStackIdVfModule(VfModule vfModule, GenericVnf vnf) { + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + VfModule copiedVfModule = vfModule.shallowCopyId(); + + copiedVfModule.setHeatStackId(vfModule.getHeatStackId()); + org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule); + injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule); + } + public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) { AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java index 70c6724921..af97e55c14 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java @@ -74,4 +74,12 @@ public class AAIVolumeGroupResources { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); injectionHelper.getAaiClient().delete(uri); } + + public void updateHeatStackIdVolumeGroup(VolumeGroup volumeGroup, CloudRegion cloudRegion) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + VolumeGroup copiedVolumeGroup = volumeGroup.shallowCopyId(); + + copiedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId()); + injectionHelper.getAaiClient().update(uri, aaiObjectMapper.mapVolumeGroup(copiedVolumeGroup)); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/BaseClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/BaseClient.java index 5a63d2097b..50137cf985 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/BaseClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/BaseClient.java @@ -52,20 +52,19 @@ public class BaseClient<I,O> { this.targetUrl = targetUrl; } - public O get(I data, Object... uriVariables) throws RestClientException { - return run(data, HttpMethod.GET, uriVariables); + public O get(I data, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { + return run(data, HttpMethod.GET, typeRef, uriVariables); } - public O post(I data, Object... uriVariables) throws RestClientException { - return run(data, HttpMethod.POST, uriVariables); + public O post(I data, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { + return run(data, HttpMethod.POST, typeRef, uriVariables); } - public O run(I data, HttpMethod method, Object... uriVariables) throws RestClientException { + public O run(I data, HttpMethod method, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { HttpEntity<I> requestEntity = new HttpEntity<I>(data, getHttpHeader()); RestTemplate restTemplate = new RestTemplate(); restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())); - ParameterizedTypeReference<O> output = new ParameterizedTypeReference<O>() {}; - ResponseEntity<O> responseEntity = restTemplate.exchange(getTargetUrl(), method, requestEntity, output, + ResponseEntity<O> responseEntity = restTemplate.exchange(getTargetUrl(), method, requestEntity, typeRef, uriVariables); return responseEntity.getBody(); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index 1f0d654a85..9e60196426 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -21,6 +21,7 @@ package org.onap.so.client.sdnc; import java.util.LinkedHashMap; + import javax.ws.rs.core.UriBuilder; import org.onap.so.client.exception.BadResponseException; @@ -29,6 +30,7 @@ import org.onap.so.client.sdnc.beans.SDNCProperties; import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Component; @@ -58,7 +60,7 @@ public class SDNCClient { HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); STOClient.setHttpHeader(httpHeader); msoLogger.info("Running SDNC CLIENT for TargetUrl: " + targetUrl); - LinkedHashMap<?, ?> output = STOClient.post(jsonRequest); + LinkedHashMap<?, ?> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); msoLogger.info("Validating output..."); return sdnCommonTasks.validateSDNResponse(output); } @@ -84,7 +86,7 @@ public class SDNCClient { HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); STOClient.setHttpHeader(httpHeader); msoLogger.info("Running SDNC CLIENT..."); - LinkedHashMap<?, ?> output = STOClient.get(jsonRequest); + LinkedHashMap<?, ?> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); msoLogger.info("Validating output..."); return sdnCommonTasks.validateSDNGetResponse(output); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java index 20c95dd55e..5b23707cb9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/ServiceTopologyOperationMapper.java @@ -54,7 +54,7 @@ public class ServiceTopologyOperationMapper{ GenericResourceApiServiceinformationServiceInformation servInfo = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true); GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = new GenericResourceApiServicerequestinputServiceRequestInput(); - servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceId()); + servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName()); servOpInput.setSdncRequestHeader(sdncRequestHeader); servOpInput.setRequestInformation(reqInfo); @@ -64,7 +64,7 @@ public class ServiceTopologyOperationMapper{ if(requestContext.getUserParams()!=null){ for (Map.Entry<String, String> entry : requestContext.getUserParams().entrySet()) { GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput(); - serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceId()); + serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName()); GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam(); GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam(); paramItem.setName(entry.getKey()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java index 979b9e5e80..cee94e28bd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java @@ -31,6 +31,7 @@ import org.onap.so.client.sniro.beans.SniroConductorRequest; import org.onap.so.client.sniro.beans.SniroManagerRequest; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; @@ -76,7 +77,7 @@ public class SniroClient { baseClient.setTargetUrl(url); baseClient.setHttpHeader(header); - LinkedHashMap<?, ?> response = baseClient.post(homingRequest.toJsonString()); + LinkedHashMap<?, ?> response = baseClient.post(homingRequest.toJsonString(), new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); validator.validateDemandsResponse(response); log.trace("Completed Sniro Client Post Demands"); } @@ -106,7 +107,7 @@ public class SniroClient { baseClient.setTargetUrl(url); baseClient.setHttpHeader(header); - LinkedHashMap<?, ?> response = baseClient.post(releaseRequest.toJsonString()); + LinkedHashMap<?, ?> response = baseClient.post(releaseRequest.toJsonString(), new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); SniroValidator v = new SniroValidator(); v.validateReleaseResponse(response); log.trace("Completed Sniro Client Post Release"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index 6ad263a935..c9433a6212 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -203,6 +203,24 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ } @Test + public void updateHeatStackIdVfModuleTest() throws Exception { + doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); + + aaiUpdateTasks.updateHeatStackIdVfModule(execution); + + verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf); + } + + @Test + public void updateHeatStackIdVfModuleExceptionTest() throws Exception { + doThrow(Exception.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); + + expectedException.expect(BpmnError.class); + + aaiUpdateTasks.updateHeatStackIdVfModule(execution); + } + + @Test public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception { doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE); @@ -249,7 +267,23 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ expectedException.expect(BpmnError.class); doThrow(Exception.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED); aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution); - } + } + @Test + public void updateHeatStackIdVolumeGroupTest() throws Exception { + doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + + aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); + + verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + } + + @Test + public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + doThrow(Exception.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); + } + @Test public void updateOstatusAssignedNetworkTest() throws Exception { doNothing().when(aaiNetworkResources).updateNetwork(network); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java index 6a117902ea..32c285b0fe 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBBTest.java @@ -20,48 +20,58 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; +import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.doReturn; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Test; +import org.mockito.Mock; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.springframework.beans.factory.annotation.Autowired; public class UnassignNetworkBBTest extends BaseTaskTest { + + @Mock + private NetworkBBUtils networkBBUtils; + @Mock + private ExtractPojosForBB extractPojosForBB; @Autowired private UnassignNetworkBB unassignNetworkBB; private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/Network/"; + private L3Network network; @Test public void checkRelationshipRelatedToTrueTest() throws Exception { expectedException.expect(BpmnError.class); + network = setL3Network(); + network.setNetworkId("testNetworkId1"); final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse); - execution.setVariable("l3NetworkAAIResultWrapper", aaiResultWrapper); - + Optional<org.onap.aai.domain.yang.L3Network> l3network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class); + doReturn(network).when(extractPojosForBB).extractByKey(execution, ResourceKey.NETWORK_ID, "testNetworkId1"); + doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network); + doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(l3network, "vf-module"); unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module"); - } - - @Test - public void checkRelationshipRelatedToFalseTest() throws Exception { - final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json"))); - AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse); - execution.setVariable("l3NetworkAAIResultWrapper", aaiResultWrapper); - - unassignNetworkBB.checkRelationshipRelatedTo(execution, "kfc-module"); - //expected result is no exception + assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue()); } @Test public void getCloudSdncRegion25Test() throws Exception { CloudRegion cloudRegion = setCloudRegion(); cloudRegion.setCloudRegionVersion("2.5"); + doReturn("AAIAIC25").when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC); unassignNetworkBB.getCloudSdncRegion(execution); assertEquals("AAIAIC25", execution.getVariable("cloudRegionSdnc")); } @@ -71,6 +81,7 @@ public class UnassignNetworkBBTest extends BaseTaskTest { CloudRegion cloudRegion = setCloudRegion(); cloudRegion.setCloudRegionVersion("3.0"); gBBInput.setCloudRegion(cloudRegion); + doReturn(cloudRegion.getLcpCloudRegionId()).when(networkBBUtils).getCloudRegion(execution, SourceSystem.SDNC); unassignNetworkBB.getCloudSdncRegion(execution); assertEquals(cloudRegion.getLcpCloudRegionId(), execution.getVariable("cloudRegionSdnc")); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index 9c51ee8006..1bb59e7b8d 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -129,6 +129,76 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { } @Test + public void createVfModuleRequestWithNoEnvironmentAndWorkloadContextMapperTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + modelInfoServiceInstance.setEnvironmentContext(null); + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + + RequestContext requestContext = new RequestContext(); + HashMap<String, String> userParams = new HashMap<String, String>(); + userParams.put("key1", "value2"); + requestContext.setMsoRequestId("requestId"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("vnfId"); + vnf.setVnfType("vnfType"); + vnf.setVnfName("vnfName"); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); + modelInfoGenericVnf.setModelName("vnfModelName"); + modelInfoGenericVnf.setModelVersion("vnfModelVersion"); + modelInfoGenericVnf.setModelUuid("vnfModelUuid"); + modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); + vnf.setModelInfoGenericVnf(modelInfoGenericVnf); + + Integer vfModuleIndex = 1; + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setVfModuleName("vfModuleName"); + vfModule.setModuleIndex(vfModuleIndex); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); + modelInfoVfModule.setModelName("vfModuleModelName"); + modelInfoVfModule.setModelVersion("vfModuleModelVersion"); + modelInfoVfModule.setModelUUID("vfModuleModelUuid"); + modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); + vfModule.setModelInfoVfModule(modelInfoVfModule); + + CloudRegion cloudRegion = new CloudRegion(); + cloudRegion.setLcpCloudRegionId("cloudRegionId"); + cloudRegion.setTenantId("tenantId"); + + OrchestrationContext orchestrationContext = new OrchestrationContext(); + orchestrationContext.setIsRollbackEnabled(false); + + String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json"))); + String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json"))); + + CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper( + requestContext, cloudRegion, orchestrationContext, serviceInstance, + vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse); + + + String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json"))); + + CreateVfModuleRequest reqMapper1 = omapper.readValue( + jsonToCompare, + CreateVfModuleRequest.class); + + assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); + } + + @Test public void createVfModuleAddonRequestMapperTest() throws Exception { // prepare and set service instance diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java index 0c4c8fc443..477be816aa 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java @@ -124,4 +124,17 @@ public class AAIVfModuleResourcesTest extends TestDataSetup{ aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, cloudRegion); verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class)); } + + @Test + public void updateHeatStackIdVfModuleTest() throws Exception { + vfModule.setHeatStackId("testHeatStackId"); + + doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class)); + + aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf); + + verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.VfModule.class)); + + assertEquals("testHeatStackId", vfModule.getHeatStackId()); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java index de15e0a550..f60f29fa34 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java @@ -129,4 +129,17 @@ public class AAIVolumeGroupResourcesTest extends TestDataSetup{ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class)); } + + @Test + public void updateHeatStackIdVolumeGroupTest() throws Exception { + volumeGroup.setHeatStackId("testVolumeHeatStackId"); + + doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VolumeGroup.class)); + + aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + + verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.VolumeGroup.class)); + + assertEquals("testVolumeHeatStackId", volumeGroup.getHeatStackId()); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java new file mode 100644 index 0000000000..a564d8a21d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java @@ -0,0 +1,50 @@ +package org.onap.so.client.sdnc; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.util.Map; + +import javax.ws.rs.core.UriBuilder; + +import org.junit.Rule; +import org.junit.Test; +import org.springframework.core.ParameterizedTypeReference; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; + +import wiremock.org.apache.http.entity.ContentType; +public class BaseClientTest { + + + @Rule + public WireMockRule wm = new WireMockRule(options().dynamicPort()); + + @Test + public void verifyString() { + BaseClient<String, String> client = new BaseClient<>(); + String response = "{\"hello\" : \"world\"}"; + client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(wm.port()).build().toString()); + wm.stubFor(get(urlEqualTo("/test")) + .willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString()))); + + String result = client.get("", new ParameterizedTypeReference<String>() {}); + assertThat(result, equalTo(response)); + } + + @Test + public void verifyMap() { + BaseClient<String, Map<String, Object>> client = new BaseClient<>(); + String response = "{\"hello\" : \"world\"}"; + client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(wm.port()).build().toString()); + wm.stubFor(get(urlEqualTo("/test")) + .willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString()))); + + Map<String, Object> result = client.get("", new ParameterizedTypeReference<Map<String, Object>>() {}); + assertThat("world", equalTo(result.get("hello"))); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json new file mode 100644 index 0000000000..fd3b0a3d58 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithNoEnvironmentAndWorkloadContextRequest.json @@ -0,0 +1,67 @@ +{ + "cloudSiteId": "cloudRegionId", + "tenantId": "tenantId", + "vnfId": "vnfId", + "vnfType": "vnfType", + "vfModuleId": "vfModuleId", + "vfModuleName": "vfModuleName", + "vfModuleType": "vfModuleModelName", + "vnfVersion": "serviceModelVersion", + "modelCustomizationUuid": "vfModuleModelCustomizationUuid", + "skipAAI": true, + "backout": false, + "failIfExists": true, + "msoRequest": + { + "requestId": "requestId", + "serviceInstanceId": "serviceInstanceId" + }, + + "vfModuleParams": + { + "vnf_id": "vnfId", + "vnf_name": "vnfName", + "vf_module_id": "vfModuleId", + "vf_module_index": "1", + "vf_module_name": "vfModuleName", + "environment_context": "", + "fw_0_subint_ctrl_port_0_ip": "ip0,ip1", + "fw_0_subint_ctrl_port_0_ip_0": "ip0", + "fw_0_subint_ctrl_port_0_ip_1": "ip1", + "fw_0_subint_ctrl_port_0_net_ids": "networkId0", + "fw_0_subint_ctrl_port_0_net_names": "1", + "fw_subint_ctrl_port_0_subintcount": "1", + "fw_0_subint_ctrl_port_0_v6_ip": "ip0,ip1", + "fw_0_subint_ctrl_port_0_v6_ip_0": "ip0", + "fw_0_subint_ctrl_port_0_v6_ip_1": "ip1", + "fw_0_subint_ctrl_port_0_vlan_ids": "1", + "fw_subint_ctrl_port_0_floating_ip": "floatingIpV40", + "fw_subint_ctrl_port_0_floating_v6_ip": "floatingIpV60", + "workload_context": "", + "key1": "value2", + "availability_zone_0": "zone0", + "availability_zone_1": "zone1", + "availability_zone_2": "zone2", + "vnfNetworkRole0_net_fqdn": "netFqdnValue0", + "vnfNetworkRole0_net_id": "neutronId0", + "vnfNetworkRole0_net_name": "netName0", + "vnfNetworkRole0_subnet_id": "subnetId0", + "vnfNetworkRole0_v6_subnet_id": "subnetId1", + "vmType0_name_0": "vmName0", + "vmType0_name_1": "vmName1", + "vmType0_names": "vmName0,vmName1", + "vmType0_vmNetworkRole0_floating_ip": "floatingIpV40", + "vmType0_vmNetworkRole0_floating_v6_ip": "floatingIpV60", + "vmType0_vmNetworkRole0_route_prefixes": "[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]", + "vmNetworkRole0_ATT_VF_VLAN_FILTER": "heatVlanFilter0,heatVlanFilter1", + "vmType0_vmNetworkRole0_ip_0": "ip0", + "vmType0_vmNetworkRole0_ip_1": "ip1", + "vmType0_vmNetworkRole0_ips": "ip0,ip1", + "vmType0_vmNetworkRole0_v6_ip_0": "ip2", + "vmType0_vmNetworkRole0_v6_ip_1": "ip3", + "vmType0_vmNetworkRole0_v6_ips": "ip2,ip3", + "paramOne": "paramOneValue", + "paramTwo": "paramTwoValue", + "paramThree": "paramThreeValue" + } +}
\ No newline at end of file |