diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
6 files changed, 520 insertions, 343 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java new file mode 100644 index 0000000000..51bc4d7064 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java @@ -0,0 +1,32 @@ +package org.onap.so.bpmn.servicedecomposition.entities; + +import org.onap.so.db.catalog.beans.Service; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("serviceModel") +public class ServiceModel { + + @JsonProperty("currentService") + private Service currentService; + @JsonProperty("newService") + private Service newService; + + + public Service getCurrentService() { + return currentService; + } + + public void setCurrentService(Service currentService) { + this.currentService = currentService; + } + + public Service getNewService() { + return newService; + } + + public void setNewService(Service newService) { + this.newService = newService; + } + +} 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 6b96bc384a..ac66fb1a41 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 @@ -46,6 +46,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.entities.ServiceModel; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -72,7 +73,6 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; @@ -121,9 +121,6 @@ public class BBInputSetup implements JavaDelegate { @Autowired private ExceptionBuilder exceptionUtil; - @Autowired - private RequestsDbClient requestsDbClient; - private ObjectMapper mapper = new ObjectMapper(); public BBInputSetupUtils getBbInputSetupUtils() { @@ -246,31 +243,41 @@ public class BBInputSetup implements JavaDelegate { String bbName = executeBB.getBuildingBlock().getBpmnFlowName(); String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID); org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null; + ServiceModel serviceModel = new ServiceModel(); Service service = null; + Service newService = null; boolean isReplace = false; if (serviceInstanceId != null) { aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); if (aaiServiceInstance != null) { - if (requestAction.equalsIgnoreCase("replaceInstance")) { + if (requestAction.equalsIgnoreCase("replaceInstance") + || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) { RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList(); if (relatedInstanceList != null) { for (RelatedInstanceList relatedInstList : relatedInstanceList) { RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) { - service = bbInputSetupUtils.getCatalogServiceByModelUUID( + newService = bbInputSetupUtils.getCatalogServiceByModelUUID( relatedInstance.getModelInfo().getModelVersionId()); isReplace = true; } } } - } else { - service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); } + + service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + + serviceModel.setNewService(newService); + serviceModel.setCurrentService(service); + if (service == null) { String message = String.format( "Related service instance model not found in MSO CatalogDB: model-version-id=%s", aaiServiceInstance.getModelVersionId()); throw new ServiceModelNotFoundException(message); + } else if (newService == null && isReplace) { + String message = "Related service instance model in Request not found in MSO CatalogDB"; + throw new ServiceModelNotFoundException(message); } } else { String message = String.format("Related service instance from AAI not found: service-instance-id=%s", @@ -280,10 +287,16 @@ public class BBInputSetup implements JavaDelegate { } ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance); - serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service)); - this.populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, executeBB.getBuildingBlock().getKey(), - executeBB.getConfigurationResourceKeys(), isReplace); + if (isReplace) { + serviceInstance.setModelInfoServiceInstance( + this.mapperLayer.mapCatalogServiceIntoServiceInstance(serviceModel.getNewService())); + } else { + serviceInstance.setModelInfoServiceInstance( + this.mapperLayer.mapCatalogServiceIntoServiceInstance(serviceModel.getCurrentService())); + } + this.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, + resourceId, vnfType, executeBB.getBuildingBlock().getKey(), executeBB.getConfigurationResourceKeys(), + isReplace, serviceModel); return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); } @@ -301,18 +314,14 @@ public class BBInputSetup implements JavaDelegate { org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf); genericVnfs.add(genericVnf); - if (genericVnf != null) { - updateInstanceName(executeBB.getRequestId(), ModelType.vnf, genericVnf.getVnfName()); - } } String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID); - if (instanceGroupId != null) { + if (instanceGroupId != null && !instanceGroupId.isEmpty()) { org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId); InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup); instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); - updateInstanceName(executeBB.getRequestId(), ModelType.instanceGroup, instanceGroup.getInstanceGroupName()); if (serviceInstanceId == null) { Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = @@ -347,10 +356,10 @@ public class BBInputSetup implements JavaDelegate { customer); } - protected void populateObjectsOnAssignAndCreateFlows(String requestId, RequestDetails requestDetails, - Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, - String resourceId, String vnfType, String configurationKey, - ConfigurationResourceKeys configurationResourceKeys, boolean isReplace) throws Exception { + protected void populateObjectsOnAssignAndCreateFlows(RequestDetails requestDetails, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType, + String configurationKey, ConfigurationResourceKeys configurationResourceKeys, boolean isReplace, + ServiceModel serviceModel) throws Exception { ModelInfo modelInfo = requestDetails.getModelInfo(); String instanceName = requestDetails.getRequestInfo().getInstanceName(); String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId(); @@ -366,29 +375,30 @@ public class BBInputSetup implements JavaDelegate { if (modelType.equals(ModelType.network)) { lookupKeyMap.put(ResourceKey.NETWORK_ID, resourceId); - this.populateL3Network(requestId, instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, null); + 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(requestId, modelInfo, instanceName, platform, lineOfBusiness, service, bbName, - serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, - applicationId); + this.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, + lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, applicationId, + isReplace); } else if (modelType.equals(ModelType.volumeGroup) || (modelType.equals(ModelType.vfModule) && (bbName.equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString()) || bbName.startsWith(CREATEVOLUME)))) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, resourceId); - this.populateVolumeGroup(requestId, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); } else if (modelType.equals(ModelType.vfModule)) { if (bbName.contains("Configuration")) { String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID); ModelInfo configurationModelInfo = new ModelInfo(); configurationModelInfo.setModelCustomizationUuid(configurationKey); - populateConfiguration(requestId, configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, + populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, configurationId, instanceName, configurationResourceKeys, requestDetails); } else { lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); - this.populateVfModule(requestId, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration(), isReplace); + this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration(), isReplace, + serviceModel); } } else if (modelType.equals(ModelType.instanceGroup)) { lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, resourceId); @@ -412,7 +422,7 @@ public class BBInputSetup implements JavaDelegate { // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter to support VNF Groups } - protected void populateConfiguration(String requestId, ModelInfo modelInfo, Service service, String bbName, + protected void populateConfiguration(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String instanceName, ConfigurationResourceKeys configurationResourceKeys, RequestDetails requestDetails) { Configuration configuration = null; @@ -436,13 +446,11 @@ public class BBInputSetup implements JavaDelegate { Vnfc vnfc = getVnfcToConfiguration(configurationResourceKeys.getVnfcName()); configuration.setVnfc(vnfc); this.mapCatalogConfiguration(configuration, modelInfo, service, configurationResourceKeys); - updateInstanceName(requestId, ModelType.configuration, configuration.getConfigurationName()); } else if (configuration != null && bbName.contains("Vrf")) { configuration.setModelInfoConfiguration(mapperLayer.mapCatalogConfigurationToConfiguration( findConfigurationResourceCustomization(modelInfo, service), null)); configuration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType()); configuration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole()); - updateInstanceName(requestId, ModelType.configuration, configuration.getConfigurationName()); } } @@ -517,10 +525,10 @@ public class BBInputSetup implements JavaDelegate { vfModuleCustomizationUUID, cvnfcCustomizationUUID); } - protected void populateVfModule(String requestId, ModelInfo modelInfo, Service service, String bbName, + 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, boolean isReplace) throws Exception { + CloudConfiguration cloudConfiguration, boolean isReplace, ServiceModel serviceModel) throws Exception { String replaceVnfModelCustomizationUUID = null; String vnfModelCustomizationUUID = null; if (relatedInstanceList != null) { @@ -545,8 +553,13 @@ public class BBInputSetup implements JavaDelegate { vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId(); ModelInfo vnfModelInfo = new ModelInfo(); - vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); - this.mapCatalogVnf(tempVnf, vnfModelInfo, service); + if (isReplace) { + vnfModelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID); + this.mapCatalogVnf(tempVnf, vnfModelInfo, serviceModel.getNewService()); + } else { + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + this.mapCatalogVnf(tempVnf, vnfModelInfo, serviceModel.getCurrentService()); + } Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(tempVnf, modelInfo, cloudConfiguration.getCloudOwner(), cloudConfiguration.getLcpCloudRegionId(), lookupKeyMap); if (volumeGroupIdOp.isPresent()) { @@ -566,24 +579,26 @@ public class BBInputSetup implements JavaDelegate { .getModelCustomizationId(); ModelInfo modelInfoVfModule = new ModelInfo(); modelInfoVfModule.setModelCustomizationId(vfModuleCustId); - if (isReplace) { - mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, replaceVnfModelCustomizationUUID); + if (isReplace && lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null + && vfModuleTemp.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) { + mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, serviceModel.getNewService(), + replaceVnfModelCustomizationUUID); } else { - mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID); + mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, serviceModel.getCurrentService(), + vnfModelCustomizationUUID); } } if (vfModule == null && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) { vfModule = createVfModule(lookupKeyMap, resourceId, instanceName, instanceParams); vnf.getVfModules().add(vfModule); if (isReplace) { - mapCatalogVfModule(vfModule, modelInfo, service, replaceVnfModelCustomizationUUID); + mapCatalogVfModule(vfModule, modelInfo, serviceModel.getNewService(), + replaceVnfModelCustomizationUUID); } else { - mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + mapCatalogVfModule(vfModule, modelInfo, serviceModel.getCurrentService(), + vnfModelCustomizationUUID); } } - if (vfModule != null) { - updateInstanceName(requestId, ModelType.vfModule, vfModule.getVfModuleName()); - } } else { logger.debug("Related VNF instance Id not found: {}", lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); throw new Exception("Could not find relevant information for related VNF"); @@ -648,7 +663,7 @@ public class BBInputSetup implements JavaDelegate { return vfModule; } - protected void populateVolumeGroup(String requestId, ModelInfo modelInfo, Service service, String bbName, + 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 { @@ -694,7 +709,6 @@ public class BBInputSetup implements JavaDelegate { } if (volumeGroup != null) { mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); - updateInstanceName(requestId, ModelType.volumeGroup, volumeGroup.getVolumeGroupName()); } } else { logger.debug("Related VNF instance Id not found: {}", lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); @@ -748,16 +762,17 @@ public class BBInputSetup implements JavaDelegate { return null; } - protected void populateGenericVnf(String requestId, ModelInfo modelInfo, String instanceName, + protected void populateGenericVnf(ModelInfo modelInfo, String instanceName, org.onap.so.serviceinstancebeans.Platform platform, 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, String productFamilyId, String applicationId) { + List<Map<String, String>> instanceParams, String productFamilyId, String applicationId, boolean isReplace) { GenericVnf vnf = null; ModelInfo instanceGroupModelInfo = null; String instanceGroupId = null; String generatedVnfType = vnfType; + String replaceVnfModelCustomizationUUID = null; if (generatedVnfType == null || generatedVnfType.isEmpty()) { generatedVnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); } @@ -768,6 +783,9 @@ public class BBInputSetup implements JavaDelegate { instanceGroupModelInfo = relatedInstance.getModelInfo(); instanceGroupId = relatedInstance.getInstanceId(); } + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf) && isReplace) { + replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } } } for (GenericVnf vnfTemp : serviceInstance.getVnfs()) { @@ -775,6 +793,12 @@ public class BBInputSetup implements JavaDelegate { && vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { String vnfModelCustId = bbInputSetupUtils.getAAIGenericVnf(vnfTemp.getVnfId()).getModelCustomizationId(); + if (isReplace && replaceVnfModelCustomizationUUID != null + && vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + modelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID); + } else { + modelInfo.setModelCustomizationUuid(vnfModelCustId); + } modelInfo.setModelCustomizationUuid(vnfModelCustId); vnf = vnfTemp; break; @@ -793,7 +817,6 @@ public class BBInputSetup implements JavaDelegate { && !instanceGroupInList(vnf, instanceGroupId)) { mapNetworkCollectionInstanceGroup(vnf, instanceGroupId); } - updateInstanceName(requestId, ModelType.vnf, vnf.getVnfName()); } } @@ -885,8 +908,8 @@ public class BBInputSetup implements JavaDelegate { return vnfResourceCustomization; } - protected void populateL3Network(String requestId, String instanceName, ModelInfo modelInfo, Service service, - String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, + protected void populateL3Network(String instanceName, ModelInfo modelInfo, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, List<Map<String, String>> instanceParams) { L3Network network = null; for (L3Network networkTemp : serviceInstance.getNetworks()) { @@ -903,7 +926,6 @@ public class BBInputSetup implements JavaDelegate { } if (network != null) { mapCatalogNetwork(network, modelInfo, service); - updateInstanceName(requestId, ModelType.network, network.getNetworkName()); } } @@ -963,7 +985,6 @@ public class BBInputSetup implements JavaDelegate { ServiceInstance serviceInstance = this.getALaCarteServiceInstance(service, requestDetails, customer, project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()), executeBB.getBuildingBlock().getBpmnFlowName()); - updateInstanceName(executeBB.getRequestId(), ModelType.service, serviceInstance.getServiceInstanceName()); return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, customer); } else { @@ -1172,8 +1193,8 @@ public class BBInputSetup implements JavaDelegate { NetworkResourceCustomization networkCust = getNetworkCustomizationByKey(key, service); if (networkCust != null) { networkModelInfo.setModelCustomizationUuid(networkCust.getModelCustomizationUUID()); - this.populateL3Network(executeBB.getRequestId(), null, networkModelInfo, service, bbName, - serviceInstance, lookupKeyMap, networkId, null); + this.populateL3Network(null, networkModelInfo, service, bbName, serviceInstance, lookupKeyMap, + networkId, null); } else { logger.debug("Could not find a network customization with key: {}", key); } @@ -1193,9 +1214,8 @@ public class BBInputSetup implements JavaDelegate { String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID); ModelInfo configurationModelInfo = new ModelInfo(); configurationModelInfo.setModelCustomizationUuid(key); - this.populateConfiguration(executeBB.getRequestId(), configurationModelInfo, service, bbName, - serviceInstance, lookupKeyMap, configurationId, null, executeBB.getConfigurationResourceKeys(), - executeBB.getRequestDetails()); + this.populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, + configurationId, null, executeBB.getConfigurationResourceKeys(), executeBB.getRequestDetails()); } if (executeBB.getWorkflowResourceIds() != null) { this.populateNetworkCollectionAndInstanceGroupAssign(service, bbName, serviceInstance, @@ -1312,7 +1332,6 @@ public class BBInputSetup implements JavaDelegate { ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance); serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service)); - updateInstanceName(executeBB.getRequestId(), ModelType.service, serviceInstance.getServiceInstanceName()); gBB = populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); serviceInstance = gBB.getServiceInstance(); @@ -1451,9 +1470,13 @@ public class BBInputSetup implements JavaDelegate { } String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId(); String applicationId = ""; - this.populateGenericVnf(executeBB.getRequestId(), vnfs.getModelInfo(), vnfs.getInstanceName(), - vnfs.getPlatform(), vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, - vnfId, vnfType, vnfs.getInstanceParams(), productFamilyId, applicationId); + if (vnfs.getApplicationId() != null) { + applicationId = vnfs.getApplicationId(); + } + this.populateGenericVnf(vnfs.getModelInfo(), vnfs.getInstanceName(), vnfs.getPlatform(), + vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType, + vnfs.getInstanceParams(), productFamilyId, applicationId, false); + } else if (bbName.contains(PNF)) { String pnfId = lookupKeyMap.get(ResourceKey.PNF); resources.getPnfs().stream() @@ -1472,24 +1495,24 @@ public class BBInputSetup implements JavaDelegate { ModelInfo modelInfo = vfModules.getModelInfo(); if (bbName.contains(VOLUME_GROUP)) { String volumeGroupId = lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID); - this.populateVolumeGroup(executeBB.getRequestId(), modelInfo, service, bbName, serviceInstance, - lookupKeyMap, volumeGroupId, null, vfModules.getVolumeGroupInstanceName(), vnfType, - vfModules.getInstanceParams()); + this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, volumeGroupId, null, + vfModules.getVolumeGroupInstanceName(), vnfType, vfModules.getInstanceParams()); } else { String vfModuleId = lookupKeyMap.get(ResourceKey.VF_MODULE_ID); CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId(cloudRegion.getLcpCloudRegionId()); cloudConfig.setCloudOwner(cloudRegion.getCloudOwner()); - this.populateVfModule(executeBB.getRequestId(), modelInfo, service, bbName, serviceInstance, - lookupKeyMap, vfModuleId, null, vfModules.getInstanceName(), vfModules.getInstanceParams(), - cloudConfig, false); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, vfModuleId, null, + vfModules.getInstanceName(), vfModules.getInstanceParams(), cloudConfig, false, serviceModel); } } else if (bbName.contains(NETWORK)) { networks = findNetworksByKey(key, resources); String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID); if (networks != null) { - this.populateL3Network(executeBB.getRequestId(), networks.getInstanceName(), networks.getModelInfo(), - service, bbName, serviceInstance, lookupKeyMap, networkId, networks.getInstanceParams()); + this.populateL3Network(networks.getInstanceName(), networks.getModelInfo(), service, bbName, + serviceInstance, lookupKeyMap, networkId, networks.getInstanceParams()); } } else if (bbName.contains("Configuration")) { String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID); @@ -1498,9 +1521,8 @@ public class BBInputSetup implements JavaDelegate { ConfigurationResourceCustomization configurationCust = findConfigurationResourceCustomization(configurationModelInfo, service); if (configurationCust != null) { - this.populateConfiguration(executeBB.getRequestId(), configurationModelInfo, service, bbName, - serviceInstance, lookupKeyMap, configurationId, null, executeBB.getConfigurationResourceKeys(), - executeBB.getRequestDetails()); + this.populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, + configurationId, null, executeBB.getConfigurationResourceKeys(), executeBB.getRequestDetails()); } else { logger.debug("Could not find a configuration customization with key: {}", key); } @@ -2011,25 +2033,4 @@ public class BBInputSetup implements JavaDelegate { } return customer; } - - protected void updateInstanceName(String requestId, ModelType resourceType, String instanceName) { - try { - if (instanceName != null) { - InfraActiveRequests request = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); - if (resourceType.getName(request) == null) { - logger.info("Updating instanceName to: {} in requestDb for requestId: {}", instanceName, requestId); - resourceType.setName(request, instanceName); - requestsDbClient.updateInfraActiveRequests(request); - } - } else { - logger.info("Failed to update instanceName in RequestDb because it was null for requestId: {}", - requestId); - } - } catch (Exception ex) { - logger.error("Unable to update Request db with instanceName for requestId: {} due to error: {}", requestId, - ex.getMessage()); - } - } - - } 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 994abda083..ec7b613727 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 @@ -276,7 +276,7 @@ public class BBInputSetupUtils { } } - protected InstanceGroup getAAIInstanceGroup(String instanceGroupId) { + public InstanceGroup getAAIInstanceGroup(String instanceGroupId) { return injectionHelper.getAaiClient().get(InstanceGroup.class, AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId)).orElse(null); } @@ -549,6 +549,20 @@ public class BBInputSetupUtils { } } + public Optional<VolumeGroup> getRelatedVolumeGroupByIdFromVnf(String vnfId, String volumeGroupId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-id", volumeGroupId); + Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); + VolumeGroup volumeGroup = null; + if (!volumeGroups.isPresent()) { + logger.debug("No VolumeGroups matched by id"); + return Optional.empty(); + } else { + volumeGroup = volumeGroups.get().getVolumeGroup().get(0); + return Optional.of(volumeGroup); + } + } + public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVfModule(String vnfId, String vfModuleId, String volumeGroupName) throws MultipleObjectsFoundException { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index 5498b5be31..9741d4b6c2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -24,7 +24,6 @@ package org.onap.so.client.cds; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -51,28 +50,29 @@ import io.grpc.Status; * */ @Component -public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { +public class AbstractCDSProcessingBBUtils { private static final Logger logger = LoggerFactory.getLogger(AbstractCDSProcessingBBUtils.class); private static final String SUCCESS = "Success"; private static final String FAILED = "Failed"; private static final String PROCESSING = "Processing"; + private static final String RESPONSE_PAYLOAD = "CDSResponsePayload"; + private static final String CDS_STATUS = "CDSStatus"; + private static final String EXEC_INPUT = "executionServiceInput"; + /** * indicate exception thrown. */ private static final String EXCEPTION = "Exception"; - - private final AtomicReference<String> cdsResponse = new AtomicReference<>(); - @Autowired private ExceptionBuilder exceptionUtil; /** * Extracting data from execution object and building the ExecutionServiceInput Object - * + * * @param execution DelegateExecution object */ public void constructExecutionServiceInputObject(DelegateExecution execution) { @@ -105,7 +105,7 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { ExecutionServiceInput.newBuilder().setCommonHeader(commonHeader) .setActionIdentifiers(actionIdentifiers).setPayload(struct.build()).build(); - execution.setVariable("executionServiceInput", executionServiceInput); + execution.setVariable(EXEC_INPUT, executionServiceInput); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -114,7 +114,7 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { /** * get the executionServiceInput object from execution and send a request to CDS Client and wait for TIMEOUT period - * + * * @param execution DelegateExecution object */ public void sendRequestToCDSClient(DelegateExecution execution) { @@ -127,10 +127,11 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { "No RestProperty.CDSProperties implementation found on classpath, can't create client."); } - ExecutionServiceInput executionServiceInput = - (ExecutionServiceInput) execution.getVariable("executionServiceInput"); + ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution.getVariable(EXEC_INPUT); + + CDSResponse cdsResponse = new CDSResponse(); - try (CDSProcessingClient cdsClient = new CDSProcessingClient(this)) { + try (CDSProcessingClient cdsClient = new CDSProcessingClient(new ResponseHandler(cdsResponse))) { CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput); countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS); } catch (InterruptedException ex) { @@ -138,61 +139,82 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { Thread.currentThread().interrupt(); } - if (cdsResponse != null) { - String cdsResponseStatus = cdsResponse.get(); - execution.setVariable("CDSStatus", cdsResponseStatus); + String cdsResponseStatus = cdsResponse.status; + + /** + * throw CDS failed exception. + */ + if (!cdsResponseStatus.equals(SUCCESS)) { + throw new BadResponseException("CDS call failed with status: " + cdsResponse.status + + " and errorMessage: " + cdsResponse.errorMessage); + } + + execution.setVariable(CDS_STATUS, cdsResponseStatus); - /** - * throw CDS failed exception. - */ - if (cdsResponseStatus != SUCCESS) { - throw new BadResponseException("CDS call failed with status: " + cdsResponseStatus); - } + if (cdsResponse.payload != null) { + String payload = JsonFormat.printer().print(cdsResponse.payload); + execution.setVariable(RESPONSE_PAYLOAD, payload); } + + } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } - /** - * Get Response from CDS Client - * - */ - @Override - public void onMessage(ExecutionServiceOutput message) { - logger.info("Received notification from CDS: {}", message); - EventType eventType = message.getStatus().getEventType(); - - switch (eventType) { - - case EVENT_COMPONENT_FAILURE: - // failed processing with failure - cdsResponse.set(FAILED); - break; - case EVENT_COMPONENT_PROCESSING: - // still processing - cdsResponse.set(PROCESSING); - break; - case EVENT_COMPONENT_EXECUTED: - // done with async processing - cdsResponse.set(SUCCESS); - break; - default: - cdsResponse.set(FAILED); - break; + private class ResponseHandler implements CDSProcessingListener { + + private CDSResponse cdsResponse; + + ResponseHandler(CDSResponse cdsResponse) { + this.cdsResponse = cdsResponse; } - } + /** + * Get Response from CDS Client + */ + @Override + public void onMessage(ExecutionServiceOutput message) { + logger.info("Received notification from CDS: {}", message); + EventType eventType = message.getStatus().getEventType(); + + switch (eventType) { + case EVENT_COMPONENT_PROCESSING: + cdsResponse.status = PROCESSING; + break; + case EVENT_COMPONENT_EXECUTED: + cdsResponse.status = SUCCESS; + break; + default: + cdsResponse.status = FAILED; + cdsResponse.errorMessage = message.getStatus().getErrorMessage(); + break; + } + cdsResponse.payload = message.getPayload(); + } - /** - * On error at CDS, log the error - */ - @Override - public void onError(Throwable t) { - Status status = Status.fromThrowable(t); - logger.error("Failed processing blueprint {}", status, t); - cdsResponse.set(EXCEPTION); + /** + * On error at CDS, log the error + */ + @Override + public void onError(Throwable t) { + Status status = Status.fromThrowable(t); + logger.error("Failed processing blueprint {}", status, t); + cdsResponse.status = EXCEPTION; + } } + private class CDSResponse { + + String status; + String errorMessage; + Struct payload; + + @Override + public String toString() { + return "CDSResponse{" + "status='" + status + '\'' + ", errorMessage='" + errorMessage + '\'' + ", payload=" + + payload + '}'; + } + } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java index 7bd2beeb92..dbd5000387 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java @@ -115,6 +115,12 @@ public class ExtractPojosForBBTest extends BaseTest { instanceGroupsPend.add(instanceGroupPend); lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupPend.getId()); + List<Pnf> pnfsPend = serviceInstancePend.getPnfs(); + Pnf pnfPend = new Pnf(); + pnfPend.setPnfId("abc"); + pnfsPend.add(pnfPend); + lookupKeyMap.put(ResourceKey.PNF, pnfPend.getPnfId()); + customer.getServiceSubscription().getServiceInstances().add(serviceInstancePend); gBBInput.setCustomer(customer); @@ -143,89 +149,49 @@ public class ExtractPojosForBBTest extends BaseTest { InstanceGroup extractInstanceGroupPend = extractPojos.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); assertEquals(instanceGroupPend.getId(), extractInstanceGroupPend.getId()); + + Pnf extractPnfPend = extractPojos.extractByKey(execution, ResourceKey.PNF); + assertEquals(extractPnfPend.getPnfId(), pnfPend.getPnfId()); } @Test public void siError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - - extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.SERVICE_INSTANCE_ID); } @Test public void vnfError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.GENERIC_VNF_ID); } @Test public void vfModuleError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VF_MODULE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VF_MODULE_ID); } @Test public void configurationError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.CONFIGURATION_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.CONFIGURATION_ID); } @Test public void allotedError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.ALLOTTED_RESOURCE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.ALLOTTED_RESOURCE_ID); } @Test public void vpnBindingError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VPN_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VPN_ID); } @Test public void vpnBondingLinkError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VPN_BONDING_LINK_ID); + } + + @Test + public void pnfError() throws BBObjectNotFoundException { + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.PNF); } @Test @@ -239,4 +205,19 @@ public class ExtractPojosForBBTest extends BaseTest { ServiceInstance extractServPend = extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); assertEquals(extractServPend.getServiceInstanceId(), serviceInstancePend.getServiceInstanceId()); } + + private void assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey key) + throws BBObjectNotFoundException { + expectedException.expect(BBObjectNotFoundException.class); + setCustomerWithEmptyServiceInstance(); + extractPojos.extractByKey(execution, key); + } + + private void setCustomerWithEmptyServiceInstance() { + Customer customer = new Customer(); + customer.setServiceSubscription(new ServiceSubscription()); + ServiceInstance serviceInstance = new ServiceInstance(); + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + gBBInput.setCustomer(customer); + } } 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 8ee3979386..e0ee918ead 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 @@ -79,6 +79,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.entities.ServiceModel; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -445,6 +446,8 @@ public class BBInputSetupTest { Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); String requestAction = "createInstance"; Service service = Mockito.mock(Service.class); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); String resourceId = "123"; String vnfType = "vnfType"; @@ -456,9 +459,9 @@ public class BBInputSetupTest { .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); - doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), - requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, - false); + doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service), + eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null), + eq(false), isA(ServiceModel.class)); doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); @@ -470,6 +473,51 @@ public class BBInputSetupTest { } @Test + public void testGetGBBALaCarteNonServiceIsReplace() throws Exception { + GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), + GeneralBuildingBlock.class); + ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), + ExecuteBuildingBlock.class); + RequestDetails requestDetails = mapper.readValue( + new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + String requestAction = "replaceInstance"; + Service service = Mockito.mock(Service.class); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); + String resourceId = "123"; + String vnfType = "vnfType"; + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); + aaiServiceInstance.setModelVersionId("modelVersionId"); + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class); + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId"); + doReturn(service).when(SPY_bbInputSetupUtils) + .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID("modelUUID"); + doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); + + doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service), + eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null), + eq(true), isA(ServiceModel.class)); + doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); + doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, + executeBB, requestAction, null); + + GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, + requestAction, resourceId, vnfType); + + verify(SPY_bbInputSetup, times(1)).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service), + eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null), + eq(true), isA(ServiceModel.class)); + + verify(SPY_bbInputSetupUtils, times(1)).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + verify(SPY_bbInputSetupUtils, times(1)).getCatalogServiceByModelUUID("modelUUID"); + + assertThat(actual, sameBeanAs(expected)); + } + + @Test public void testGetGBBALaCarteNonServiceWithoutServiceModelInfo() throws Exception { ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class); @@ -528,6 +576,8 @@ public class BBInputSetupTest { Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); String requestAction = "createInstance"; Service service = Mockito.mock(Service.class); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); String resourceId = "123"; ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); @@ -539,9 +589,9 @@ public class BBInputSetupTest { .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); - doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), - requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, - false); + doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service), + eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null), + eq(false), isA(ServiceModel.class)); doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, @@ -820,6 +870,8 @@ public class BBInputSetupTest { String productFamilyId = "productFamilyId"; String applicationId = "applicationId"; Service service = Mockito.mock(Service.class); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); RequestDetails requestDetails = Mockito.mock(RequestDetails.class); ModelInfo modelInfo = Mockito.mock(ModelInfo.class); @@ -832,8 +884,8 @@ public class BBInputSetupTest { Mockito.mock(org.onap.so.serviceinstancebeans.LineOfBusiness.class); Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); - doNothing().when(SPY_bbInputSetup).populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, - serviceInstance, lookupKeyMap, resourceId, null); + doNothing().when(SPY_bbInputSetup).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, + lookupKeyMap, resourceId, null); doReturn(modelInfo).when(requestDetails).getModelInfo(); doReturn(productFamilyId).when(requestInfo).getProductFamilyId(); doReturn(requestInfo).when(requestDetails).getRequestInfo(); @@ -845,59 +897,59 @@ public class BBInputSetupTest { doReturn(applicationId).when(requestInfo).getApplicationId(); doReturn(ModelType.network).when(modelInfo).getModelType(); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, - serviceInstance, lookupKeyMap, resourceId, null); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, + lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + 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(REQUEST_ID, modelInfo, instanceName, platform, - lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, - vnfType, null, productFamilyId, applicationId); + doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, + service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, + productFamilyId, applicationId, false); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, - lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, - vnfType, null, productFamilyId, applicationId); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, + lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, + service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, + productFamilyId, applicationId, false); 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(REQUEST_ID, modelInfo, service, bbName, serviceInstance, + doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, + lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + 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(REQUEST_ID, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false); + doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false, serviceModel); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, + lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + verify(SPY_bbInputSetup, times(1)).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false, serviceModel); assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId)); String bbNameAssignVolume = AssignFlows.VOLUME_GROUP.toString(); doReturn(ModelType.vfModule).when(modelInfo).getModelType(); resourceId = "vfModuleId"; - doNothing().when(SPY_bbInputSetup).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbNameAssignVolume, - serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbNameAssignVolume, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbNameAssignVolume, - serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); + doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbNameAssignVolume, serviceInstance, + lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbNameAssignVolume, + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbNameAssignVolume, serviceInstance, + lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId)); } @@ -1178,12 +1230,12 @@ public class BBInputSetupTest { doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId"); - SPY_bbInputSetup.populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); + SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vg, modelInfo, service, "vnfModelCustomizationUUID"); vnf.getVolumeGroups().clear(); - SPY_bbInputSetup.populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); + SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service, "vnfModelCustomizationUUID"); } @@ -1232,19 +1284,19 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(network, modelInfo, service); - SPY_bbInputSetup.populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, null); + SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, null); lookupKeyMap.put(ResourceKey.NETWORK_ID, null); - SPY_bbInputSetup.populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, null); + SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, null); verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network, modelInfo, service); instanceName = "networkName2"; L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null); - SPY_bbInputSetup.populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, null); + SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, null); verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service); } @@ -1302,15 +1354,15 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); - SPY_bbInputSetup.populateConfiguration(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, instanceName, configResourceKeys, requestDetails); + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null); - SPY_bbInputSetup.populateConfiguration(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, instanceName, configResourceKeys, requestDetails); + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); @@ -1321,8 +1373,8 @@ public class BBInputSetupTest { doReturn(configuration2).when(SPY_bbInputSetup).createConfiguration(lookupKeyMap, instanceName, resourceId); doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys); - SPY_bbInputSetup.populateConfiguration(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, instanceName, configResourceKeys, requestDetails); + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys); } @@ -1387,8 +1439,8 @@ public class BBInputSetupTest { doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service); doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); - SPY_bbInputSetup.populateConfiguration(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, instanceName, configResourceKeys, requestDetails); + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); } @@ -1433,15 +1485,15 @@ public class BBInputSetupTest { new org.onap.so.db.catalog.beans.InstanceGroup(); doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any()); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; @@ -1454,9 +1506,9 @@ public class BBInputSetupTest { lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId2"); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); 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); @@ -1531,15 +1583,15 @@ public class BBInputSetupTest { new org.onap.so.db.catalog.beans.InstanceGroup(); doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any()); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; @@ -1551,9 +1603,9 @@ public class BBInputSetupTest { doReturn(vnf2AAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf2.getVnfId()); doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service); doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); @@ -2007,33 +2059,33 @@ public class BBInputSetupTest { executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), any(String.class), isA(ModelInfo.class), + verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString()); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(any(String.class), isA(ModelInfo.class), - any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), + verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), + isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), - any(String.class), any(String.class)); + any(String.class), any(String.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), - any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); + verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class), + isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), + isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any(String.class), any()); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + ArgumentMatchers.isNull(), any(String.class), any()); Configuration configuration = new Configuration(); configuration.setConfigurationId("configurationId"); @@ -2043,16 +2095,16 @@ public class BBInputSetupTest { configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); doReturn(configurationCustList).when(service).getConfigurationCustomizations(); configurationCustList.add(configurationCust); - doNothing().when(SPY_bbInputSetup).populateConfiguration(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); executeBB.getBuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB"); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateConfiguration(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); } @@ -2118,16 +2170,16 @@ public class BBInputSetupTest { ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization(); configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); configurationCustList.add(configurationCust); - doNothing().when(SPY_bbInputSetup).populateConfiguration(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); executeBB.getBuildingBlock().setBpmnFlowName("AssignVrfConfigurationBB"); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); gBB = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateConfiguration(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); assertEquals(gBB.getCustomer().getVpnBindings().get(0).getVpnId(), "vpnBindingId"); assertEquals(gBB.getServiceInstance().getNetworks().get(0).getNetworkId(), "localNetworkId"); assertEquals(gBB.getServiceInstance().getNetworks().get(0).getVpnBindings().get(0).getVpnId(), @@ -2290,33 +2342,33 @@ public class BBInputSetupTest { executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), any(String.class), isA(ModelInfo.class), + verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(any(String.class), isA(ModelInfo.class), - any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), + verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), + isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), ArgumentMatchers.isNull(), any(String.class), - ArgumentMatchers.isNull(), any(), any(String.class), any()); + ArgumentMatchers.isNull(), any(), any(String.class), any(), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), - any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); + verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class), + isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), + isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any()); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any()); } @Test @@ -2355,33 +2407,33 @@ public class BBInputSetupTest { executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), any(String.class), isA(ModelInfo.class), + verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(any(String.class), isA(ModelInfo.class), - any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), + verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), + isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), - any(String.class), any(String.class)); + any(String.class), any(String.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), - any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); + verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class), + isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), + isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any(String.class), any()); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + ArgumentMatchers.isNull(), any(String.class), any()); } @Test @@ -2459,8 +2511,8 @@ public class BBInputSetupTest { doReturn("ab153b6e-c364-44c0-bef6-1f2982117f04").when(networkCust).getModelCustomizationUUID(); networkCustList.add(networkCust); doReturn(networkCustList).when(service).getNetworkCustomizations(); - doNothing().when(SPY_bbInputSetup).populateL3Network(any(String.class), any(), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); + doNothing().when(SPY_bbInputSetup).populateL3Network(any(), isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); @@ -2947,6 +2999,8 @@ public class BBInputSetupTest { ModelInfo modelInfo = new ModelInfo(); modelInfo.setModelCustomizationId(vfModuleCustomizationId); Service service = new Service(); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); String bbName = AssignFlows.VF_MODULE.toString(); ServiceInstance serviceInstance = new ServiceInstance(); GenericVnf vnf = new GenericVnf(); @@ -2985,8 +3039,8 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); - SPY_bbInputSetup.populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration, false); + SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, instanceParams, cloudConfiguration, false, serviceModel); verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); @@ -2997,6 +3051,84 @@ public class BBInputSetupTest { } @Test + public void testPopulateVfModuleIsReplaceCorrectPopulationOfVfs() throws Exception { + String vnfId = "vnfId"; + String vfModuleId = "vfModuleId"; + String volumeGroupId = "volumeGroupId"; + String vfModuleCustomizationId = "vfModuleCustomizationId"; + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationId(vfModuleCustomizationId); + Service currentService = new Service(); + currentService.setModelUUID("currentUUID"); + Service newService = new Service(); + newService.setModelUUID("newUUID"); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(currentService); + serviceModel.setNewService(newService); + String bbName = "ActivateVfModuleBB"; + ServiceInstance serviceInstance = new ServiceInstance(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId(vnfId); + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId(volumeGroupId); + vnf.getVolumeGroups().add(volumeGroup); + serviceInstance.getVnfs().add(vnf); + VfModule vfModule1 = new VfModule(); + vfModule1.setVfModuleId("vfModuleId1"); + VfModule vfModule2 = new VfModule(); + vfModule2.setVfModuleId("vfModuleId2"); + vnf.getVfModules().add(vfModule1); + vnf.getVfModules().add(vfModule2); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId); + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId1"); + String resourceId = vfModuleId; + RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1]; + RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList(); + RelatedInstance relatedInstance = new RelatedInstance(); + relatedInstance.setInstanceId(vnfId); + + ModelInfo vnfModelInfo = new ModelInfo(); + vnfModelInfo.setModelCustomizationId("vnfCustomizationId"); + vnfModelInfo.setModelType(ModelType.vnf); + relatedInstance.setModelInfo(vnfModelInfo); + relatedInstanceListObj.setRelatedInstance(relatedInstance); + relatedInstanceList[0] = relatedInstanceListObj; + + String instanceName = "vfModuleName"; + List<Map<String, String>> instanceParams = null; + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + + org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf(); + vnfAAI.setModelCustomizationId("vnfModelCustId"); + org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup(); + volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId); + org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule(); + vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId); + + doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); + doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER, + cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class)); + doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class), + isA(Service.class)); + doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + isA(Service.class), isA(String.class)); + + SPY_bbInputSetup.populateVfModule(modelInfo, newService, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true, serviceModel); + + verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + eq(currentService), eq("vnfModelCustId")); + verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(newService), + eq("vnfCustomizationId")); + assertEquals("Lookup Key Map populated with VfModule Id", "vfModuleId1", + lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); + assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, + lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID)); + } + + @Test public void testPopulateVfModuleIsReplace() throws Exception { String vnfId = "vnfId"; String vfModuleId = "vfModuleId"; @@ -3004,7 +3136,13 @@ public class BBInputSetupTest { String vfModuleCustomizationId = "vfModuleCustomizationId"; ModelInfo modelInfo = new ModelInfo(); modelInfo.setModelCustomizationId(vfModuleCustomizationId); - Service service = new Service(); + Service currentService = new Service(); + Service newService = new Service(); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(currentService); + currentService.setModelUUID("currentUUID"); + serviceModel.setNewService(newService); + currentService.setModelUUID("newUUID"); String bbName = AssignFlows.VF_MODULE.toString(); ServiceInstance serviceInstance = new ServiceInstance(); GenericVnf vnf = new GenericVnf(); @@ -3021,6 +3159,7 @@ public class BBInputSetupTest { vnf.getVfModules().add(vfModule2); Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId); + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId); String resourceId = vfModuleId; RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1]; RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList(); @@ -3054,11 +3193,13 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); - SPY_bbInputSetup.populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true); + SPY_bbInputSetup.populateVfModule(modelInfo, newService, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true, serviceModel); - verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), - isA(Service.class), isA(String.class)); + verify(SPY_bbInputSetup, times(2)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + eq(serviceModel.getCurrentService()), isA(String.class)); + verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + eq(serviceModel.getNewService()), isA(String.class)); assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, @@ -3082,18 +3223,4 @@ public class BBInputSetupTest { vnfc = SPY_bbInputSetup.getVnfcToConfiguration(vnfcName); Assert.assertNotNull(vnfc); } - - @Test - public void updateInstanceNameTest() { - InfraActiveRequests request = new InfraActiveRequests(); - request.setRequestId(REQUEST_ID); - - when(requestsDbClient.getInfraActiveRequestbyRequestId(REQUEST_ID)).thenReturn(request); - SPY_bbInputSetup.updateInstanceName(REQUEST_ID, ModelType.service, "instanceName"); - - verify(requestsDbClient).updateInfraActiveRequests(request); - assertEquals("instanceName", request.getServiceInstanceName()); - } - - } |