diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks')
20 files changed, 1599 insertions, 232 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index bd60fbe38c..b9f73f3f0e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -372,6 +372,7 @@ public class AAICreateTasks { logger.info("VolumeGroup not found. Skipping Connect between VfModule and VolumeGroup"); } if (volumeGroup != null) { + logger.debug("Connecting VfModule to VolumGroup"); aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup, execution.getGeneralBuildingBlock().getCloudRegion()); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index b5b1f5db2f..68f33c18a8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Copyright (C) 2019 Nokia. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -54,6 +56,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -62,6 +65,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; +import org.onap.so.client.orchestration.AAIEntityNotFoundException; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; @@ -102,6 +106,7 @@ public class WorkflowAction { private static final String VNF_TYPE = "vnfType"; private static final String SERVICE = "Service"; private static final String VNF = "Vnf"; + private static final String PNF = "Pnf"; private static final String VFMODULE = "VfModule"; private static final String VOLUMEGROUP = "VolumeGroup"; private static final String NETWORK = "Network"; @@ -109,6 +114,8 @@ public class WorkflowAction { private static final String CONFIGURATION = "Configuration"; private static final String ASSIGNINSTANCE = "assignInstance"; private static final String CREATEINSTANCE = "createInstance"; + private static final String REPLACEINSTANCE = "replaceInstance"; + private static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments"; private static final String USERPARAMSERVICE = "service"; private static final String SUPPORTEDTYPES = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups"; @@ -128,6 +135,8 @@ public class WorkflowAction { private static final String NAME_EXISTS_WITH_DIFF_PARENT = "(%s) id (%s) and different parent relationship"; private static final String CREATENETWORKBB = "CreateNetworkBB"; private static final String ACTIVATENETWORKBB = "ActivateNetworkBB"; + private static final String VOLUMEGROUP_DELETE_PATTERN = "(Un|De)(.*)Volume(.*)"; + private static final String VOLUMEGROUP_CREATE_PATTERN = "(A|C)(.*)Volume(.*)"; @Autowired protected BBInputSetup bbInputSetup; @@ -184,7 +193,14 @@ public class WorkflowAction { execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); RequestDetails requestDetails = sIRequest.getRequestDetails(); - execution.setVariable("suppressRollback", isSuppressRollback(requestDetails.getRequestInfo())); + boolean suppressRollback = false; + try { + suppressRollback = requestDetails.getRequestInfo().getSuppressRollback(); + } catch (Exception ex) { + logger.error("Exception in getSuppressRollback", ex); + suppressRollback = false; + } + execution.setVariable("suppressRollback", suppressRollback); boolean isResume = false; if (isUriResume(uri)) { isResume = true; @@ -253,6 +269,18 @@ public class WorkflowAction { } orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)) .collect(Collectors.toList()); + + if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE) + || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) + && resourceType.equals(WorkflowType.VFMODULE)) { + logger.debug("Build a BB list for replacing BB modules"); + orchFlows = getVfModuleReplaceBuildingBlocks( + new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) + .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte) + .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) + .setRequestDetails(requestDetails).setExecution(execution)); + } for (OrchestrationFlow orchFlow : orchFlows) { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, @@ -263,7 +291,8 @@ public class WorkflowAction { boolean foundRelated = false; boolean containsService = false; if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) { - // SERVICE-MACRO-ASSIGN will always get user params with a + // SERVICE-MACRO-ASSIGN will always get user params with + // a // service. if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { List<Map<String, Object>> userParams = @@ -281,7 +310,8 @@ public class WorkflowAction { "Service-Macro-Assign request details must contain user params with a service"); } } else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATEINSTANCE)) { - // SERVICE-MACRO-CREATE will get user params with a service, + // SERVICE-MACRO-CREATE will get user params with a + // service, // a service with a network, a service with a // networkcollection, OR an empty service. // If user params is just a service or null and macro @@ -310,7 +340,8 @@ public class WorkflowAction { || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and // SERVICE-MACRO-DELETE - // Will never get user params with service, macro will have + // Will never get user params with service, macro will + // have // to query the SI in AAI to find related instances. traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds); } else if (resourceType == WorkflowType.SERVICE @@ -335,14 +366,20 @@ public class WorkflowAction { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType); } + boolean vnfReplace = false; + if (resourceType.equals(WorkflowType.VNF) && ("replaceInstance".equalsIgnoreCase(requestAction) + || "replaceInstanceRetainAssignments".equalsIgnoreCase(requestAction))) { + vnfReplace = true; + } flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceCounter, requestId, apiVersion, - resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails); + resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace); if (!resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) .collect(Collectors.toList()).isEmpty()) { logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } - // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE + // By default, enable homing at VNF level for CREATEINSTANCE + // and ASSIGNINSTANCE if (resourceType == WorkflowType.SERVICE && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())) @@ -359,7 +396,8 @@ public class WorkflowAction { } } } - // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, + // If the user set "Homing_Solution" to "none", disable homing, else + // if "Homing_Solution" is specified, // enable it. if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { @@ -397,7 +435,7 @@ public class WorkflowAction { execution.setVariable("isRollbackComplete", false); } catch (Exception ex) { - buildAndThrowException(execution, "Exception in create execution list. " + ex.getMessage(), ex); + buildAndThrowException(execution, "Exception in execution list. ", ex); } } @@ -473,7 +511,8 @@ public class WorkflowAction { return false; } - protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) { + protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) + throws Exception { List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>(); List<OrchestrationFlow> result = dataObj.getOrchFlows().stream() @@ -482,8 +521,17 @@ public class WorkflowAction { String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId(); String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(); - String vfModuleCustomizationUUID = - bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId(); + String vfModuleCustomizationUUID = ""; + org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId); + + if (aaiVfModule == null) { + logger.error("No matching VfModule is found in Generic-Vnf in AAI for vnfId: {} and vfModuleId : {}", vnfId, + vfModuleId); + throw new AAIEntityNotFoundException("No matching VfModule is found in Generic-Vnf in AAI for vnfId: " + + vnfId + " and vfModuleId : " + vfModuleId); + } else { + vfModuleCustomizationUUID = aaiVfModule.getModelCustomizationId(); + } List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC); @@ -520,6 +568,68 @@ public class WorkflowAction { return flowsToExecuteConfigs; } + protected List<OrchestrationFlow> getVfModuleReplaceBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) + throws Exception { + + List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>(); + + String vnfId = dataObj.getWorkflowResourceIds().getVnfId(); + String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId(); + + logger.debug("BUILDING REPLACE LIST"); + + boolean volumeGroupExisted = false; + boolean volumeGroupWillExist = false; + boolean keepVolumeGroup = false; + + boolean rebuildVolumeGroups = false; + if (dataObj.getRequestDetails().getRequestParameters() != null + && dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups() != null) { + rebuildVolumeGroups = + dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups().booleanValue(); + } + + Optional<VolumeGroup> volumeGroupFromVfModule = + bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, vfModuleId); + if (volumeGroupFromVfModule.isPresent()) { + String volumeGroupId = volumeGroupFromVfModule.get().getVolumeGroupId(); + logger.debug("Volume group id of the existing volume group is: " + volumeGroupId); + volumeGroupExisted = true; + dataObj.getWorkflowResourceIds().setVolumeGroupId(volumeGroupId); + } + + List<OrchestrationFlow> orchFlows = dataObj.getOrchFlows(); + VfModuleCustomization vfModuleCustomization = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID( + dataObj.getRequestDetails().getModelInfo().getModelCustomizationUuid()); + if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null + && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null + && vfModuleCustomization.getVolumeHeatEnv() != null) { + volumeGroupWillExist = true; + if (!volumeGroupExisted) { + String newVolumeGroupId = UUID.randomUUID().toString(); + dataObj.getWorkflowResourceIds().setVolumeGroupId(newVolumeGroupId); + logger.debug("newVolumeGroupId: " + newVolumeGroupId); + } + } + + if (volumeGroupExisted && volumeGroupWillExist && !rebuildVolumeGroups) { + keepVolumeGroup = true; + } + + if (!volumeGroupExisted || keepVolumeGroup) { + logger.debug("Filtering out deletion of volume groups"); + orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().matches(VOLUMEGROUP_DELETE_PATTERN)) + .collect(Collectors.toList()); + } + if (!volumeGroupWillExist || keepVolumeGroup) { + logger.debug("Filtering out creation of volume groups"); + orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().matches(VOLUMEGROUP_CREATE_PATTERN)) + .collect(Collectors.toList()); + } + + return orchFlows; + } + protected String getVnfcNameForConfiguration(org.onap.aai.domain.yang.Configuration configuration) { AAIResultWrapper wrapper = new AAIResultWrapper(configuration); Optional<Relationships> relationshipsOp = wrapper.getRelationships(); @@ -1169,142 +1279,21 @@ public class WorkflowAction { RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception { try { if ("SERVICE".equalsIgnoreCase(type.toString())) { - // Service name verification based upon name + model-version-id - // + service-type + global-customer-id per requirements - String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId(); - String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType(); - if (instanceName != null) { - Optional<ServiceInstance> serviceInstanceAAI = - bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName); - if (serviceInstanceAAI.isPresent()) { - if (serviceInstanceAAI.get().getModelVersionId() - .equalsIgnoreCase(reqDetails.getModelInfo().getModelVersionId())) { - return serviceInstanceAAI.get().getServiceInstanceId(); - } else { - throw new DuplicateNameException(SERVICE_INSTANCE, - String.format(NAME_EXISTS_WITH_DIFF_VERSION_ID, instanceName, - reqDetails.getModelInfo().getModelVersionId())); - } - } else { - ServiceInstances aaiServiceInstances = - bbInputSetupUtils.getAAIServiceInstancesGloballyByName(instanceName); - if (aaiServiceInstances != null) { - if (aaiServiceInstances.getServiceInstance() != null - && !aaiServiceInstances.getServiceInstance().isEmpty()) { - if (aaiServiceInstances.getServiceInstance().size() > 1) { - throw new DuplicateNameException(SERVICE_INSTANCE, - String.format(NAME_EXISTS_MULTIPLE, instanceName)); - } else { - ServiceInstance si = - aaiServiceInstances.getServiceInstance().stream().findFirst().get(); - Map<String, String> keys = - bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId()); - - throw new DuplicateNameException(SERVICE_INSTANCE, - String.format(NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName, - keys.get("global-customer-id"), keys.get("service-type"), - si.getModelVersionId())); - } - } - } - } - } + return validateServiceResourceIdInAAI(generatedResourceId, instanceName, reqDetails); } else if ("NETWORK".equalsIgnoreCase(type.toString())) { - Optional<L3Network> network = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance( - workflowResourceIds.getServiceInstanceId(), instanceName); - if (network.isPresent()) { - if (network.get().getModelCustomizationId() - .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { - return network.get().getNetworkId(); - } else { - throw new DuplicateNameException("l3Network", - String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, - network.get().getModelCustomizationId())); - } - } - - if (bbInputSetupUtils.existsAAINetworksGloballyByName(instanceName)) { - throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_PARENT, - instanceName, workflowResourceIds.getServiceInstanceId())); - } - + return validateNetworkResourceIdInAAI(generatedResourceId, instanceName, reqDetails, + workflowResourceIds); } else if ("VNF".equalsIgnoreCase(type.toString())) { - Optional<GenericVnf> vnf = bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance( - workflowResourceIds.getServiceInstanceId(), instanceName); - if (vnf.isPresent()) { - if (vnf.get().getModelCustomizationId() - .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { - return vnf.get().getVnfId(); - } else { - throw new DuplicateNameException("generic-vnf", - String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, - vnf.get().getModelCustomizationId())); - } - } - GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName); - if (vnfs != null) { - throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_PARENT, - instanceName, vnfs.getGenericVnf().get(0).getVnfId())); - } + return validateVnfResourceIdInAAI(generatedResourceId, instanceName, reqDetails, workflowResourceIds); } else if ("VFMODULE".equalsIgnoreCase(type.toString())) { - GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId()); - if (vnf != null && vnf.getVfModules() != null) { - for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) { - if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) { - if (vfModule.getModelCustomizationId() - .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { - return vfModule.getVfModuleId(); - } else { - throw new DuplicateNameException("vfModule", - String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, - reqDetails.getModelInfo().getModelCustomizationId())); - } - } - } - } + return validateVfModuleResourceIdInAAI(generatedResourceId, instanceName, reqDetails, + workflowResourceIds); } else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) { - GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId()); - Optional<VolumeGroup> volumeGroup = bbInputSetupUtils - .getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName); - if (volumeGroup.isPresent()) { - if (vnf.getModelCustomizationId() - .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { - return volumeGroup.get().getVolumeGroupId(); - } else { - throw new DuplicateNameException("volumeGroup", volumeGroup.get().getVolumeGroupName()); - } - } - if (vnf != null && vnf.getVfModules() != null) { - for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) { - Optional<VolumeGroup> volumeGroupFromVfModule = - bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnf.getVnfId(), - vfModule.getVfModuleId(), instanceName); - if (volumeGroupFromVfModule.isPresent()) { - if (vnf.getModelCustomizationId() - .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { - return volumeGroupFromVfModule.get().getVolumeGroupId(); - } else { - throw new DuplicateNameException("volumeGroup", - String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, - volumeGroupFromVfModule.get().getModelCustomizationId())); - } - } - } - } + return validateVolumeGroupResourceIdInAAI(generatedResourceId, instanceName, reqDetails, + workflowResourceIds); } else if ("CONFIGURATION".equalsIgnoreCase(type.toString())) { - Optional<org.onap.aai.domain.yang.Configuration> configuration = - bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance( - workflowResourceIds.getServiceInstanceId(), instanceName); - if (configuration.isPresent()) { - if (configuration.get().getModelCustomizationId() - .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { - return configuration.get().getConfigurationId(); - } else { - throw new DuplicateNameException("configuration", - String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, - configuration.get().getConfigurationId())); - } - } + return validateConfigurationResourceIdInAAI(generatedResourceId, instanceName, reqDetails, + workflowResourceIds); } return generatedResourceId; } catch (DuplicateNameException dne) { @@ -1399,99 +1388,83 @@ public class WorkflowAction { return sortedOrchFlows; } + private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList, + WorkflowType workflowType, OrchestrationFlow orchFlow, String requestId, String apiVersion, + String resourceId, String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds, + RequestDetails requestDetails, boolean isVirtualLink, boolean isConfiguration) { + + List<Resource> serviceResources = resourceList.stream() + .filter(resource -> resource.getResourceType().equals(workflowType)).collect(Collectors.toList()); + serviceResources.forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, + apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, + isVirtualLink, resource.getVirtualLinkKey(), isConfiguration))); + } + protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows, - List<Resource> resourceCounter, String requestId, String apiVersion, String resourceId, - String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, - RequestDetails requestDetails) { + List<Resource> resourceList, String requestId, String apiVersion, String resourceId, String requestAction, + String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, + boolean replaceVnf) { List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); for (OrchestrationFlow orchFlow : orchFlows) { if (orchFlow.getFlowName().contains(SERVICE)) { - for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.SERVICE == x.getResourceType()) - .collect(Collectors.toList()).size(); i++) { + if (!replaceVnf) { workflowResourceIds.setServiceInstanceId(resourceId); - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, - resourceCounter.stream().filter(x -> WorkflowType.SERVICE == x.getResourceType()) - .collect(Collectors.toList()).get(i), - apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, false)); } + addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.SERVICE, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, + false); } else if (orchFlow.getFlowName().contains(VNF)) { - for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.VNF == x.getResourceType()) - .collect(Collectors.toList()).size(); i++) { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, - resourceCounter.stream().filter(x -> WorkflowType.VNF == x.getResourceType()) - .collect(Collectors.toList()).get(i), - apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, false)); - } + addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VNF, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, + false); + } else if (orchFlow.getFlowName().contains(PNF)) { + addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.PNF, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, + false); } else if (orchFlow.getFlowName().contains(NETWORK) && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) { - for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.NETWORK == x.getResourceType()) - .collect(Collectors.toList()).size(); i++) { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, - resourceCounter.stream().filter(x -> WorkflowType.NETWORK == x.getResourceType()) - .collect(Collectors.toList()).get(i), - apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, false)); - } - for (int i = 0; i < resourceCounter.stream() - .filter(x -> WorkflowType.VIRTUAL_LINK == x.getResourceType()).collect(Collectors.toList()) - .size(); i++) { - Resource resource = - resourceCounter.stream().filter(x -> WorkflowType.VIRTUAL_LINK == x.getResourceType()) - .collect(Collectors.toList()).get(i); - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, true, - resource.getVirtualLinkKey(), false)); - } + addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORK, orchFlow, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, + false); + addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow, + requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, + true, false); + } else if (orchFlow.getFlowName().contains(VFMODULE)) { List<Resource> vfModuleResourcesSorted = null; if (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE) || requestAction.equals("activateInstance")) { - vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceCounter.stream() + vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream() .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList())); } else { - vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceCounter.stream() + vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream() .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList())); } for (int i = 0; i < vfModuleResourcesSorted.size(); i++) { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i), - apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, false)); + apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, + false, null, false)); } } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) { - for (int i = 0; i < resourceCounter.stream() - .filter(x -> WorkflowType.VOLUMEGROUP == x.getResourceType()).collect(Collectors.toList()) - .size(); i++) { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, - resourceCounter.stream().filter(x -> WorkflowType.VOLUMEGROUP == x.getResourceType()) - .collect(Collectors.toList()).get(i), - apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, false)); + if (requestAction.equalsIgnoreCase(REPLACEINSTANCE) + || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) { + logger.debug("Replacing workflow resource id by volume group id"); + resourceId = workflowResourceIds.getVolumeGroupId(); } + addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VOLUMEGROUP, orchFlow, + requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, + false, false); } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) { - for (int i = 0; i < resourceCounter.stream() - .filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()) - .size(); i++) { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, - resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) - .collect(Collectors.toList()).get(i), - apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, false)); - } + addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORKCOLLECTION, orchFlow, + requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, + false, false); } else if (orchFlow.getFlowName().contains(CONFIGURATION)) { - for (int i = 0; i < resourceCounter.stream() - .filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()).collect(Collectors.toList()) - .size(); i++) { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, - resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()) - .collect(Collectors.toList()).get(i), - apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, true)); - } + addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.CONFIGURATION, orchFlow, + requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, + false, true); } else { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false)); + requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, false)); } } return flowsToExecute; @@ -1503,6 +1476,11 @@ public class WorkflowAction { boolean isVirtualLink, String virtualLinkKey, boolean isConfiguration) { ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); BuildingBlock buildingBlock = new BuildingBlock(); + + Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(action -> buildingBlock.setBpmnAction(action)); + Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(scope -> buildingBlock.setBpmnScope(scope)); + + buildingBlock.setBpmnFlowName(orchFlow.getFlowName()); buildingBlock.setMsoId(UUID.randomUUID().toString()); if (resource == null) { @@ -1515,6 +1493,13 @@ public class WorkflowAction { executeBuildingBlock.setApiVersion(apiVersion); executeBuildingBlock.setaLaCarte(aLaCarte); executeBuildingBlock.setRequestAction(requestAction); + + if (resource != null + && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE) + || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) { + logger.debug("Setting resourceId to volume group id for volume group flow on replace"); + resourceId = workflowResourceIds.getVolumeGroupId(); + } executeBuildingBlock.setResourceId(resourceId); executeBuildingBlock.setVnfType(vnfType); executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds); @@ -1627,5 +1612,151 @@ public class WorkflowAction { && (serviceInstanceId != null && serviceInstanceId.trim().length() > 1) && (bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId) != null)); } -} + protected String validateServiceResourceIdInAAI(String generatedResourceId, String instanceName, + RequestDetails reqDetails) throws DuplicateNameException, MultipleObjectsFoundException { + String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId(); + String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType(); + if (instanceName != null) { + Optional<ServiceInstance> serviceInstanceAAI = + bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName); + if (serviceInstanceAAI.isPresent()) { + if (serviceInstanceAAI.get().getModelVersionId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelVersionId())) { + return serviceInstanceAAI.get().getServiceInstanceId(); + } else { + throw new DuplicateNameException(SERVICE_INSTANCE, String.format(NAME_EXISTS_WITH_DIFF_VERSION_ID, + instanceName, reqDetails.getModelInfo().getModelVersionId())); + } + } else { + ServiceInstances aaiServiceInstances = + bbInputSetupUtils.getAAIServiceInstancesGloballyByName(instanceName); + if (aaiServiceInstances != null) { + if (aaiServiceInstances.getServiceInstance() != null + && !aaiServiceInstances.getServiceInstance().isEmpty()) { + if (aaiServiceInstances.getServiceInstance().size() > 1) { + throw new DuplicateNameException(SERVICE_INSTANCE, + String.format(NAME_EXISTS_MULTIPLE, instanceName)); + } else { + ServiceInstance si = aaiServiceInstances.getServiceInstance().stream().findFirst().get(); + Map<String, String> keys = + bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId()); + + throw new DuplicateNameException(SERVICE_INSTANCE, + String.format(NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName, + keys.get("global-customer-id"), keys.get("service-type"), + si.getModelVersionId())); + } + } + } + } + } + return generatedResourceId; + } + + protected String validateNetworkResourceIdInAAI(String generatedResourceId, String instanceName, + RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) + throws DuplicateNameException, MultipleObjectsFoundException { + Optional<L3Network> network = bbInputSetupUtils + .getRelatedNetworkByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName); + if (network.isPresent()) { + if (network.get().getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return network.get().getNetworkId(); + } else { + throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, + instanceName, network.get().getModelCustomizationId())); + } + } + if (bbInputSetupUtils.existsAAINetworksGloballyByName(instanceName)) { + throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName, + workflowResourceIds.getServiceInstanceId())); + } + return generatedResourceId; + } + + protected String validateVnfResourceIdInAAI(String generatedResourceId, String instanceName, + RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) + throws DuplicateNameException, MultipleObjectsFoundException { + Optional<GenericVnf> vnf = bbInputSetupUtils + .getRelatedVnfByNameFromServiceInstance(workflowResourceIds.getServiceInstanceId(), instanceName); + if (vnf.isPresent()) { + if (vnf.get().getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return vnf.get().getVnfId(); + } else { + throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, + instanceName, vnf.get().getModelCustomizationId())); + } + } + GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName); + if (vnfs != null) { + throw new DuplicateNameException("generic-vnf", + String.format(NAME_EXISTS_WITH_DIFF_PARENT, instanceName, vnfs.getGenericVnf().get(0).getVnfId())); + } + return generatedResourceId; + } + + protected String validateVfModuleResourceIdInAAI(String generatedResourceId, String instanceName, + RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws DuplicateNameException { + GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId()); + if (vnf != null && vnf.getVfModules() != null) { + for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) { + if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) { + if (vfModule.getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return vfModule.getVfModuleId(); + } else { + throw new DuplicateNameException("vfModule", + String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName, + reqDetails.getModelInfo().getModelCustomizationId())); + } + } + } + } + if (bbInputSetupUtils.existsAAIVfModuleGloballyByName(instanceName)) { + throw new DuplicateNameException("vfModule", instanceName); + } + return generatedResourceId; + } + + protected String validateVolumeGroupResourceIdInAAI(String generatedResourceId, String instanceName, + RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) + throws DuplicateNameException, MultipleObjectsFoundException { + Optional<VolumeGroup> volumeGroup = + bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName); + if (volumeGroup.isPresent()) { + if (volumeGroup.get().getVfModuleModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return volumeGroup.get().getVolumeGroupId(); + } else { + throw new DuplicateNameException("volumeGroup", volumeGroup.get().getVolumeGroupName()); + } + } + if (bbInputSetupUtils.existsAAIVolumeGroupGloballyByName(instanceName)) { + throw new DuplicateNameException("volumeGroup", instanceName); + } + return generatedResourceId; + } + + protected String validateConfigurationResourceIdInAAI(String generatedResourceId, String instanceName, + RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) + throws DuplicateNameException, MultipleObjectsFoundException { + Optional<org.onap.aai.domain.yang.Configuration> configuration = + bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance( + workflowResourceIds.getServiceInstanceId(), instanceName); + if (configuration.isPresent()) { + if (configuration.get().getModelCustomizationId() + .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) { + return configuration.get().getConfigurationId(); + } else { + throw new DuplicateNameException("configuration", String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, + instanceName, configuration.get().getConfigurationId())); + } + } + if (bbInputSetupUtils.existsAAIConfigurationGloballyByName(instanceName)) { + throw new DuplicateNameException("configuration", instanceName); + } + return generatedResourceId; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java index 05a51797dd..1eb5cf7437 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java @@ -24,6 +24,7 @@ public enum WorkflowType { SERVICE("Service"), VNF("Vnf"), + PNF("Pnf"), VFMODULE("VfModule"), VOLUMEGROUP("VolumeGroup"), NETWORK("Network"), diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java index ebebae3cce..293bcf9f0e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java @@ -52,6 +52,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Component public class VnfAdapterObjectMapper { private ObjectMapper mapper = new ObjectMapper(); + private static final String ENABLE_BRIDGE = "mso.bridgeEnabled"; @PostConstruct public void init() { @@ -86,6 +87,10 @@ public class VnfAdapterObjectMapper { createVolumeGroupRequest.setMessageId(messageId); createVolumeGroupRequest.setNotificationUrl(createCallbackUrl("VNFAResponse", messageId)); + String enableBridge = getProperty(ENABLE_BRIDGE); + if (enableBridge == null || Boolean.valueOf(enableBridge)) { + createVolumeGroupRequest.setEnableBridge(true); + } return createVolumeGroupRequest; } 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 685531e9a7..9857adbd09 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 @@ -68,6 +68,7 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfresourceassign import org.onap.sdnc.northbound.client.model.GenericResourceApiVnftopologyVnfTopology; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; +import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -95,6 +96,7 @@ import com.google.common.base.Joiner; public class VnfAdapterVfModuleObjectMapper { @Autowired protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils; + private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVfModuleObjectMapper.class); private static List<String> sdncResponseParamsToSkip = asList("vnf_id", "vf_module_id", "vnf_name", "vf_module_name"); @@ -114,6 +116,7 @@ public class VnfAdapterVfModuleObjectMapper { private static final String FLOATING_IP = "_floating_ip"; private static final String FLOATING_V6_IP = "_floating_v6_ip"; private static final String UNDERSCORE = "_"; + private static final String ENABLE_BRIDGE = "mso.bridgeEnabled"; @PostConstruct public void init() { @@ -160,6 +163,11 @@ public class VnfAdapterVfModuleObjectMapper { createVfModuleRequest .setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId)); + String enableBridge = getProperty(ENABLE_BRIDGE); + if (enableBridge == null || Boolean.valueOf(enableBridge)) { + createVfModuleRequest.setEnableBridge(true); + } + return createVfModuleRequest; } @@ -916,4 +924,8 @@ public class VnfAdapterVfModuleObjectMapper { } return baseVfModule; } + + protected String getProperty(String key) { + return UrnPropertiesReader.getVariable(key); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java index 3994208d23..5bd4df74bb 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; -import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.xml.bind.JAXBException; @@ -31,23 +32,24 @@ import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.DeleteNetworkResponse; import org.onap.so.adapters.nwrest.UpdateNetworkError; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; -import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.client.exception.MapperException; import org.onap.so.utils.Components; import org.onap.logging.filter.base.ONAPComponents; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -60,13 +62,22 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { @Mock ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); + private static final String CREATE_NETWORK_RESPONSE = "createNetworkResponse"; + private static final String DELETE_NETWORK_RESPONSE = "deleteNetworkResponse"; + private static final String CREATE_NETWORK_ERROR = "createNetworkError"; + private static final String DELETE_NETWORK_ERROR = "deleteNetworkError"; + private static final String NET_ID_FOR_CREATE_NETWORK_RESPONSE = "netIdForCreateNetworkResponse"; + private static final String NET_ID_FOR_DELETE_NETWORK_RESPONSE = "netIdForDeleteNetworkResponse"; + private static final String CREATE_NETWORK_ERROR_MESSAGE = "createNetErrorMessage"; + private static final String DELETE_NETWORK_ERROR_MESSAGE = "deleteNetErrorMessage"; + @Before public void setup() { delegateExecution = new DelegateExecutionFake(); } @Test - public void testUnmarshalXml() throws IOException, JAXBException { + public void testUnmarshalXml() throws JAXBException { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><createNetworkResponse><messageId>ec37c121-e3ec-4697-8adf-2d7dca7044fc</messageId><networkCreated>true</networkCreated><networkFqdn>someNetworkFqdn</networkFqdn><networkId>991ec7bf-c9c4-4ac1-bb9c-4b61645bddb3</networkId><networkStackId>someStackId</networkStackId><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><rollback><cloudId>someCloudId</cloudId><modelCustomizationUuid>b7171cdd-8b05-459b-80ef-2093150e8983</modelCustomizationUuid><msoRequest><requestId>90b32315-176e-4dab-bcf1-80eb97a1c4f4</requestId><serviceInstanceId>71e7db22-7907-4d78-8fcc-8d89d28e90be</serviceInstanceId></msoRequest><networkCreated>true</networkCreated><networkStackId>someStackId</networkStackId><networkType>SomeNetworkType</networkType><neutronNetworkId>9c47521a-2916-4018-b2bc-71ab767497e3</neutronNetworkId><tenantId>b60da4f71c1d4b35b8113d4eca6deaa1</tenantId></rollback><subnetMap><entry><key>6b381fa9-48ce-4e16-9978-d75309565bb6</key><value>bc1d5537-860b-4894-8eba-6faff41e648c</value></entry></subnetMap></createNetworkResponse>"; CreateNetworkResponse response = @@ -76,11 +87,11 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { } @Test - public void testUnmarshalXmlUpdate() throws IOException, JAXBException { + public void testUnmarshalXmlUpdate() throws JAXBException { UpdateNetworkResponse expectedResponse = new UpdateNetworkResponse(); expectedResponse.setMessageId("ec100bcc-2659-4aa4-b4d8-3255715c2a51"); expectedResponse.setNetworkId("80de31e3-cc78-4111-a9d3-5b92bf0a39eb"); - Map<String, String> subnetMap = new HashMap<String, String>(); + Map<String, String> subnetMap = new HashMap<>(); subnetMap.put("95cd8437-25f1-4238-8720-cbfe7fa81476", "d8d16606-5d01-4822-b160-9a0d257303e0"); expectedResponse.setSubnetMap(subnetMap); String xml = @@ -91,7 +102,7 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { } @Test - public void processCallbackTest() throws MapperException, BadResponseException, IOException { + public void processCallbackTest() { UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); UpdateNetworkResponse updateNetworkResponse = new UpdateNetworkResponse(); updateNetworkResponse.setMessageId("messageId"); @@ -105,7 +116,7 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { } @Test - public void processCallbackErrorTest() throws MapperException, BadResponseException, IOException { + public void processCallbackErrorTest() { UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); UpdateNetworkError updateNetworkResponse = new UpdateNetworkError(); updateNetworkResponse.setMessageId("messageId"); @@ -125,4 +136,67 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), eq("test error message"), eq(Components.OPENSTACK)); } + + @Test + public void processCallback_createNetworkResponse() { + delegateExecution.setVariable("networkAdapterRequest", new CreateNetworkRequest()); + delegateExecution.setVariable("NetworkAResponse_MESSAGE", + createNetworkResponse(CREATE_NETWORK_RESPONSE, NET_ID_FOR_CREATE_NETWORK_RESPONSE)); + networkAdapterRestV1Tasks.processCallback(delegateExecution); + + Object result = delegateExecution.getVariable("createNetworkResponse"); + assertTrue(result instanceof CreateNetworkResponse); + CreateNetworkResponse createNetworkResponse = (CreateNetworkResponse) result; + assertEquals(createNetworkResponse.getNetworkId(), NET_ID_FOR_CREATE_NETWORK_RESPONSE); + } + + @Test + public void processCallback_deleteNetworkResponse() { + delegateExecution.setVariable("networkAdapterRequest", new DeleteNetworkRequest()); + delegateExecution.setVariable("NetworkAResponse_MESSAGE", + createNetworkResponse(DELETE_NETWORK_RESPONSE, NET_ID_FOR_DELETE_NETWORK_RESPONSE)); + networkAdapterRestV1Tasks.processCallback(delegateExecution); + + Object result = delegateExecution.getVariable("deleteNetworkResponse"); + assertTrue(result instanceof DeleteNetworkResponse); + DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) result; + assertEquals(deleteNetworkResponse.getNetworkId(), NET_ID_FOR_DELETE_NETWORK_RESPONSE); + } + + @Test + public void processCallback_createNetworkError() { + try { + delegateExecution.setVariable("networkAdapterRequest", new CreateNetworkRequest()); + delegateExecution.setVariable("NetworkAResponse_MESSAGE", + createNetworkError(CREATE_NETWORK_ERROR, CREATE_NETWORK_ERROR_MESSAGE)); + networkAdapterRestV1Tasks.processCallback(delegateExecution); + } catch (Exception e) { + assertEquals(e.getMessage(), CREATE_NETWORK_ERROR_MESSAGE); + } + } + + @Test + public void processCallback_deleteNetworkError() { + try { + delegateExecution.setVariable("networkAdapterRequest", new DeleteNetworkRequest()); + delegateExecution.setVariable("NetworkAResponse_MESSAGE", + createNetworkError(DELETE_NETWORK_ERROR, DELETE_NETWORK_ERROR_MESSAGE)); + networkAdapterRestV1Tasks.processCallback(delegateExecution); + } catch (Exception e) { + assertEquals(e.getMessage(), DELETE_NETWORK_ERROR_MESSAGE); + } + } + + private String createNetworkResponse(String networkResponseType, String networkId) { + + return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><" + networkResponseType + "><networkId>" + + networkId + "</networkId></" + networkResponseType + ">"; + } + + private String createNetworkError(String networkErrorType, String message) { + + return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><" + networkErrorType + "><message>" + + message + "</message></" + networkErrorType + ">"; + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index cb5ffd6fa7..ed3ee0a3a1 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -83,6 +83,7 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.Relationships; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.orchestration.AAIEntityNotFoundException; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; @@ -124,6 +125,16 @@ public class WorkflowActionTest extends BaseTaskTest { private String RESOURCE_PATH = "src/test/resources/__files/"; + private List<OrchestrationFlow> replaceVfModuleOrchFlows = + createFlowList("DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", + "DeleteVolumeGroupBB", "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", + "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVolumeGroupBB", + "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + private List<OrchestrationFlow> replaceRetainAssignmentsVfModuleOrchFlows = createFlowList("DeactivateVfModuleBB", + "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", + "AssignVolumeGroupBB", "ChangeModelVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", + "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + @Before public void before() throws Exception { execution = new DelegateExecutionFake(); @@ -927,6 +938,9 @@ public class WorkflowActionTest extends BaseTaskTest { "CreateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB"); + for (ExecuteBuildingBlock executeBuildingBlock : ebbs) { + assertEquals("123", executeBuildingBlock.getWorkflowResourceIds().getServiceInstanceId()); + } } @Ignore @@ -1089,6 +1103,362 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceTest() throws Exception { + String gAction = "replaceInstance"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "UnassignVFModuleBB", + "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", + "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceRetainAssignmentsTest() throws Exception { + String gAction = "replaceInstanceRetainAssignments"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "ChangeModelVfModuleBB", + "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleVolumeGroupToNoVolumeGroupReplaceTest() throws Exception { + String gAction = "replaceInstance"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + doReturn(Optional.of(volumeGroup)).when(bbSetupUtils) + .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234"); + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", + "DeleteVolumeGroupBB", "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVfModuleBB", + "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleVolumeGroupToNoVolumeGroupReplaceRetainAssignmentsTest() + throws Exception { + String gAction = "replaceInstanceRetainAssignments"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + doReturn(Optional.of(volumeGroup)).when(bbSetupUtils) + .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", + "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", + "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceTest() throws Exception { + String gAction = "replaceInstance"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + doReturn(Optional.of(volumeGroup)).when(bbSetupUtils) + .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule(); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModuleCustomization.setVfModule(vfModule); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")) + .thenReturn(vfModuleCustomization); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "UnassignVFModuleBB", + "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", + "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest() throws Exception { + String gAction = "replaceInstanceRetainAssignments"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + doReturn(Optional.of(volumeGroup)).when(bbSetupUtils) + .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule(); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModuleCustomization.setVfModule(vfModule); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")) + .thenReturn(vfModuleCustomization); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "ChangeModelVfModuleBB", + "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleNoVolumeGroupToVolumeGroupReplaceTest() throws Exception { + String gAction = "replaceInstance"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule(); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModuleCustomization.setVfModule(vfModule); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")) + .thenReturn(vfModuleCustomization); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "UnassignVFModuleBB", + "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", + "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleNoVolumeGroupToVolumeGroupReplaceRetainAssignmentsTest() + throws Exception { + String gAction = "replaceInstanceRetainAssignments"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule(); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModuleCustomization.setVfModule(vfModule); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")) + .thenReturn(vfModuleCustomization); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "AssignVolumeGroupBB", + "ChangeModelVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", + "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest() throws Exception { + String gAction = "replaceInstance"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = new String( + Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + doReturn(Optional.of(volumeGroup)).when(bbSetupUtils) + .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule(); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModuleCustomization.setVfModule(vfModule); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")) + .thenReturn(vfModuleCustomization); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", + "DeleteVolumeGroupBB", "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", + "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVolumeGroupBB", + "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + @Test + public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest() throws Exception { + String gAction = "replaceInstanceRetainAssignments"; + String resource = "VfModule"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = new String( + Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); + execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); + execution.setVariable("vfModuleId", "1234"); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("volumeGroupId"); + doReturn(Optional.of(volumeGroup)).when(bbSetupUtils) + .getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment()); + org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule(); + vfModule.setVolumeHeatTemplate(new HeatTemplate()); + vfModuleCustomization.setVfModule(vfModule); + when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")) + .thenReturn(vfModuleCustomization); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + true, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + + assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", + "DeleteVolumeGroupBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "ChangeModelVfModuleBB", + "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", + "ChangeModelVnfBB", "ChangeModelServiceInstanceBB"); + } + + + @Test public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "VfModule"; @@ -1146,6 +1516,56 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void getConfigBuildingBlocksNoVfModuleFabricDeleteTest() throws Exception { + String gAction = "deleteInstance"; + ObjectMapper mapper = new ObjectMapper(); + WorkflowType resourceType = WorkflowType.VFMODULE; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("vnfId", "1234"); + execution.setVariable("vfModuleId", "vfModuleId1234"); + execution.setVariable("requestUri", + "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); + ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); + RequestDetails requestDetails = sIRequest.getRequestDetails(); + String requestAction = "deleteInstance"; + String requestId = "9c944122-d161-4280-8594-48c06a9d96d5"; + boolean aLaCarte = true; + String apiVersion = "7"; + String vnfType = "vnfType"; + String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0"; + String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e"; + Resource resourceKey = new Resource(resourceType, key, aLaCarte); + WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution); + + thrown.expect(AAIEntityNotFoundException.class); + thrown.expectMessage(containsString( + "No matching VfModule is found in Generic-Vnf in AAI for vnfId: 1234 and vfModuleId : vfModuleId1234")); + + List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", + "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB"); + + ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest) + .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution); + + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setVnfId("vnf0"); + vnf.setModelCustomizationId("modelCustomizationId"); + when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf); + + org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); + vfModule.setModelCustomizationId("modelCustomizationId"); + when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(null); + + SPY_workflowAction.getConfigBuildingBlocks(dataObj); + } + + @Test public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "VfModule"; @@ -1541,7 +1961,7 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void validateVnfResourceIdInAAITest() throws Exception { + public void validateResourceIdInAAIVnfTest() throws Exception { RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); @@ -1574,7 +1994,7 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void validateVnfResourceNameInAAITest() throws Exception { + public void validateResourceIdInAAIVnfNotGloballyUniqueTest() throws Exception { RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); @@ -1596,7 +2016,7 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void validateNetworkResourceIdInAAITest() throws Exception { + public void validateResourceIdInAAINetworkTest() throws Exception { RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); @@ -1656,7 +2076,7 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void validateVfModuleResourceIdInAAITest() throws Exception { + public void validateResourceIdInAAIVfModuleTest() throws Exception { RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); @@ -1699,11 +2119,28 @@ public class WorkflowActionTest extends BaseTaskTest { "vfModule with name (vFModName222), same parent and different customization id (1234567) already exists. The name must be unique.")); workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName222", reqDetails, workflowResourceIds); + } + + @Test + public void validateResourceIdInAAIVfModuleNotGloballyUniqueTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setVnfId("id111"); + + GenericVnf vnf1 = new GenericVnf(); + workflowResourceIds.setVnfId("id111"); + when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf1); + when(bbSetupUtils.existsAAIVfModuleGloballyByName("vFModName333")).thenReturn(true); + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage( + containsString("vfModule with name vFModName333 already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName333", reqDetails, + workflowResourceIds); } @Test - public void validateVolumeGroupResourceIdInAAITest() throws Exception { + public void validateResourceIdInAAIVolumeGroupTest() throws Exception { RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); @@ -1722,6 +2159,7 @@ public class WorkflowActionTest extends BaseTaskTest { VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("id123"); volumeGroup.setVolumeGroupName("name123"); + volumeGroup.setVfModuleModelCustomizationId("1234567"); workflowResourceIds.setVnfId("id123"); Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup); @@ -1744,7 +2182,25 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void validateConfigurationResourceIdInAAITest() throws Exception { + public void validatesourceIdInAAIVolumeGroupNotGloballyUniqueTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setVnfId("id123"); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("id123"); + when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf); + when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "testVolumeGroup")).thenReturn(Optional.empty()); + + when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("testVolumeGroup")).thenReturn(true); + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage( + containsString("volumeGroup with name testVolumeGroup already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "testVolumeGroup", + reqDetails, workflowResourceIds); + } + + @Test + public void validateResourceIdInAAIConfigurationTest() throws Exception { RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); @@ -1786,7 +2242,23 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void validateServiceInstanceResourceIdInAAITest() throws Exception { + public void validateResourceIdInAAIConfigurationNotGloballyUniqueTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "testConfig")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.existsAAIConfigurationGloballyByName("testConfig")).thenReturn(true); + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage( + containsString("configuration with name testConfig already exists. The name must be unique.")); + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "testConfig", reqDetails, + workflowResourceIds); + } + + @Test + public void validateResourceIdInAAISITest() throws Exception { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); @@ -1828,7 +2300,7 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void validateServiceInstanceResourceIdInAAIMultipleTest() throws Exception { + public void validateResourceIdInAAIMultipleSITest() throws Exception { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); @@ -1859,7 +2331,7 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test - public void validateServiceInstanceResourceIdInAAIExistsTest() throws Exception { + public void validateResourceIdInAAISIExistsTest() throws Exception { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId("siId123"); RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); @@ -1890,6 +2362,490 @@ public class WorkflowActionTest extends BaseTaskTest { } @Test + public void validateServiceResourceIdInAAINoDupTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + reqDetails.getModelInfo().setModelVersionId("1234567"); + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(null); + String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails); + assertEquals("generatedId123", id); + } + + @Test + public void validateServiceResourceIdInAAISameModelVersionId() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + reqDetails.getModelInfo().setModelVersionId("1234567"); + + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("siId123"); + si.setModelVersionId("1234567"); + Optional<ServiceInstance> siOp = Optional.of(si); + + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp); + String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails); + assertEquals("siId123", id); + } + + @Test + public void validateServiceResourceIdInAAIDifferentModelVersionId() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + reqDetails.getModelInfo().setModelVersionId("1234567"); + + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("siId123"); + si.setModelVersionId("9999999"); + ServiceInstances serviceInstances = new ServiceInstances(); + serviceInstances.getServiceInstance().add(si); + Optional<ServiceInstance> siOp = Optional.of(si); + + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "serviceInstance with name (siName123) and different version id (1234567) already exists. The name must be unique.")); + + String id = workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName123", reqDetails); + assertEquals("siId123", id); + } + + @Test + public void validateServiceResourceIdInAAIDuplicateNameTest() throws Exception { + + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + reqDetails.getModelInfo().setModelVersionId("1234567"); + + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("siId123"); + si.setModelVersionId("1234567"); + + ServiceInstances serviceInstances = new ServiceInstances(); + serviceInstances.getServiceInstance().add(si); + + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "serviceInstance with name (siName) and global-customer-id (null), service-type (null), model-version-id (1234567) already exists. The name must be unique.")); + + workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails); + } + + @Test + public void validateServiceResourceIdInAAIDuplicateNameMultipleTest() throws Exception { + + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + reqDetails.getModelInfo().setModelVersionId("1234567"); + + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("siId123"); + si.setModelVersionId("1234567"); + + ServiceInstance si2 = new ServiceInstance(); + si2.setServiceInstanceId("siId222"); + si2.setModelVersionId("22222"); + si2.setServiceInstanceName("siName222"); + + ServiceInstances serviceInstances = new ServiceInstances(); + serviceInstances.getServiceInstance().add(si); + serviceInstances.getServiceInstance().add(si2); + + when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName")).thenReturn(serviceInstances); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "serviceInstance with name (siName) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique.")); + + workflowAction.validateServiceResourceIdInAAI("generatedId123", "siName", reqDetails); + } + + @Test + public void validateNetworkResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.existsAAINetworksGloballyByName("name123")).thenReturn(false); + + String id = workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + assertEquals("generatedId123", id); + } + + @Test + public void validateNetworkResourceIdInAAISameModelCustIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + L3Network network = new L3Network(); + network.setNetworkId("id123"); + network.setNetworkName("name123"); + network.setModelCustomizationId("1234567"); + Optional<L3Network> opNetwork = Optional.of(network); + + when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork); + + String id = workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + assertEquals("id123", id); + } + + @Test + public void validateNetworkResourceIdInAAIDuplicateNameTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + L3Network network = new L3Network(); + network.setNetworkId("id123"); + network.setNetworkName("name123"); + network.setModelCustomizationId("9999999"); + Optional<L3Network> opNetwork = Optional.of(network); + + when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "l3Network with name (name123), same parent and different customization id (9999999) already exists. The name must be unique.")); + + workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds); + } + + @Test + public void validateNetworkResourceIdInAAINotGloballyUniqueTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.existsAAINetworksGloballyByName("name123")).thenReturn(true); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "l3Network with name (name123) id (siId123) and different parent relationship already exists. The name must be unique.")); + + workflowAction.validateNetworkResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds); + } + + @Test + public void validateVnfResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(Optional.empty()); + String id = workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, + workflowResourceIds); + assertEquals("generatedId123", id); + } + + @Test + public void validateVnfResourceIdInAAISameModelCustomizationIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("id123"); + vnf.setVnfName("vnfName123"); + vnf.setModelCustomizationId("1234567"); + Optional<GenericVnf> opVnf = Optional.of(vnf); + + when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf); + String id = workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, + workflowResourceIds); + assertEquals("id123", id); + } + + @Test + public void validateVnfResourceIdInAAIDiffModelCustomizationIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("id123"); + vnf.setVnfName("vnfName123"); + vnf.setModelCustomizationId("9999999"); + Optional<GenericVnf> opVnf = Optional.of(vnf); + + when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "generic-vnf with name (vnfName123), same parent and different customization id (9999999) already exists. The name must be unique.")); + + workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds); + } + + @Test + public void validateVnfResourceIdInAAINotGloballyUniqueTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("id123"); + vnf.setVnfName("vnfName123"); + GenericVnfs genericVnfs = new GenericVnfs(); + genericVnfs.getGenericVnf().add(vnf); + + when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(Optional.empty()); + when(bbSetupUtils.getAAIVnfsGloballyByName("vnfName123")).thenReturn(genericVnfs); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "generic-vnf with name (vnfName123) id (id123) and different parent relationship already exists. The name must be unique.")); + + workflowAction.validateVnfResourceIdInAAI("generatedId123", "vnfName123", reqDetails, workflowResourceIds); + } + + @Test + public void validateVfModuleResourceIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setVnfId("vnfId123"); + + when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(null); + when(bbSetupUtils.existsAAIVfModuleGloballyByName("name123")).thenReturn(false); + + String id = workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + assertEquals("generatedId123", id); + } + + @Test + public void validateVfModuleResourceIdSameModelCustIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setVnfId("vnfId123"); + + VfModules vfModules = new VfModules(); + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("id123"); + vfModule.setVfModuleName("name123"); + vfModule.setModelCustomizationId("1234567"); + vfModules.getVfModule().add(vfModule); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("id123"); + vnf.setVnfName("vnfName123"); + vnf.setVfModules(vfModules); + + when(bbSetupUtils.getAAIGenericVnf("vnfId123")).thenReturn(vnf); + + String id = workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + assertEquals("id123", id); + } + + @Test + public void validateVfModuleResourceIdDifferentModelCustIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setVnfId("vnfId123"); + + VfModules vfModules = new VfModules(); + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("id123"); + vfModule.setVfModuleName("name123"); + vfModule.setModelCustomizationId("9999999"); + vfModules.getVfModule().add(vfModule); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("id123"); + vnf.setVnfName("vnfName123"); + vnf.setVfModules(vfModules); + + when(bbSetupUtils.getAAIGenericVnf("vnfId123")).thenReturn(vnf); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "vfModule with name (name123), same parent and different customization id (1234567) already exists. The name must be unique.")); + + workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds); + + } + + @Test + public void validateVfModuleResourceIdNotGloballyUniqueTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setVnfId("vnfId123"); + + when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(null); + when(bbSetupUtils.existsAAIVfModuleGloballyByName("name123")).thenReturn(true); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException + .expectMessage(containsString("vfModule with name name123 already exists. The name must be unique.")); + + workflowAction.validateVfModuleResourceIdInAAI("generatedId123", "name123", reqDetails, workflowResourceIds); + } + + @Test + public void validateVolumeGroupResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setVnfId("vnfId123"); + + when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(Optional.empty()); + when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("name123")).thenReturn(false); + + String id = workflowAction.validateVolumeGroupResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + assertEquals("generatedId123", id); + } + + @Test + public void validateVolumeGroupResourceIdInAAISameModelCustIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + workflowResourceIds.setVnfId("vnfId123"); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("id123"); + volumeGroup.setVolumeGroupName("name123"); + volumeGroup.setVfModuleModelCustomizationId("1234567"); + + Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup); + + when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(opVolumeGroup); + String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", + reqDetails, workflowResourceIds); + + assertEquals("id123", id); + } + + @Test + public void validateVolumeGroupResourceIdInAAIDifferentModelCustIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + workflowResourceIds.setVnfId("vnfId123"); + + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId("id123"); + volumeGroup.setVolumeGroupName("name123"); + volumeGroup.setVfModuleModelCustomizationId("9999999"); + + Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup); + + when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(opVolumeGroup); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage( + containsString("volumeGroup with name name123 already exists. The name must be unique.")); + + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails, + workflowResourceIds); + } + + @Test + public void validateVolumeGroupResourceIdInAAINotGloballyUniqueTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setVnfId("vnfId123"); + + when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("vnfId123", "name123")).thenReturn(Optional.empty()); + when(bbSetupUtils.existsAAIVolumeGroupGloballyByName("name123")).thenReturn(true); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage( + containsString("volumeGroup with name name123 already exists. The name must be unique.")); + + workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails, + workflowResourceIds); + } + + @Test + public void validateConfigurationResourceIdInAAITest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false); + + String id = workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + assertEquals("generatedId123", id); + } + + @Test + public void validateConfigurationResourceIdInAAISameModelCustIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); + configuration.setConfigurationId("id123"); + configuration.setConfigurationName("name123"); + configuration.setModelCustomizationId("1234567"); + Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration); + + when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123")) + .thenReturn(opConfiguration); + when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false); + + String id = workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + assertEquals("id123", id); + } + + @Test + public void validateConfigurationResourceIdInAAIDifferentModelCustIdTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration(); + configuration.setConfigurationId("id123"); + configuration.setConfigurationName("name123"); + configuration.setModelCustomizationId("9999999"); + Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration); + + when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123")) + .thenReturn(opConfiguration); + when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(false); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage(containsString( + "configuration with name (name123), same parent and different customization id (id123) already exists. The name must be unique.")); + + workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + } + + @Test + public void validateConfigurationResourceIdInAAINotGloballyUniqueTest() throws Exception { + RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567"); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("siId123"); + + when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123")) + .thenReturn(Optional.empty()); + when(bbSetupUtils.existsAAIConfigurationGloballyByName("name123")).thenReturn(true); + + this.expectedException.expect(DuplicateNameException.class); + this.expectedException.expectMessage( + containsString("configuration with name name123 already exists. The name must be unique.")); + + workflowAction.validateConfigurationResourceIdInAAI("generatedId123", "name123", reqDetails, + workflowResourceIds); + } + + @Test public void handleRuntimeExceptionTest() { execution.setVariable("BPMN_javaExpMsg", "test runtime error message"); execution.setVariable("testProcessKey", "testProcessKeyValue"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java index 2e77023757..a482da5158 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java @@ -150,7 +150,23 @@ public class VnfAdapterObjectMapperTest { CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse); + assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest)); + + doReturn("false").when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled"); + actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, + cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse); + assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest)); + + doReturn(null).when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled"); + expectedCreateVolumeGroupRequest.setEnableBridge(true); + actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, + cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse); + assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest)); + doReturn("true").when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled"); + expectedCreateVolumeGroupRequest.setEnableBridge(true); + actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, + cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse); assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest)); } 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 44a08139d6..836f8c1842 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 @@ -23,6 +23,7 @@ package org.onap.so.client.adapter.vnf.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -32,6 +33,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.Mockito; import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; @@ -46,6 +48,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.openstack.utils.MsoMulticloudUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -56,6 +59,9 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { private VnfAdapterVfModuleObjectMapper vfModuleObjectMapper = new VnfAdapterVfModuleObjectMapper(); private ObjectMapper omapper = new ObjectMapper(); + @Autowired + protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils; + @Rule public ExpectedException expectedException = ExpectedException.none(); @@ -128,16 +134,35 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { String sdncVfModuleQueryResponse = new String(Files .readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json"))); + VnfAdapterVfModuleObjectMapper spyMapper = Mockito.spy(vfModuleObjectMapper); + + doReturn("false").when(spyMapper).getProperty("mso.bridgeEnabled"); CreateVfModuleRequest vfModuleVNFAdapterRequest = - vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, + spyMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse); - - String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequest.json"))); - CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class); + assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); + + doReturn("true").when(spyMapper).getProperty("mso.bridgeEnabled"); + vfModuleVNFAdapterRequest = + spyMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, + serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse); + jsonToCompare = new String(Files + .readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestBridgeEnabled.json"))); + reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class); + assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); + + + doReturn(null).when(spyMapper).getProperty("mso.bridgeEnabled"); + vfModuleVNFAdapterRequest = + spyMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, + serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse); + jsonToCompare = new String(Files + .readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestBridgeEnabled.json"))); + reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class); assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json index 5975cb21fe..b57c8341f1 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleAddonRequest.json @@ -13,6 +13,7 @@ "skipAAI": true, "backout": false, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestBridgeEnabled.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestBridgeEnabled.json new file mode 100644 index 0000000000..a02b1c901d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestBridgeEnabled.json @@ -0,0 +1,71 @@ +{ + "cloudSiteId": "cloudRegionId", + "tenantId": "tenantId", + "vnfId": "vnfId", + "vnfType": "vnfType", + "vfModuleId": "vfModuleId", + "vfModuleName": "vfModuleName", + "vfModuleType": "vfModuleModelName", + "vnfVersion": "serviceModelVersion", + "modelCustomizationUuid": "vfModuleModelCustomizationUuid", + "skipAAI": true, + "backout": false, + "failIfExists": false, + "enableBridge": 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": "environmentContext", + "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": "workloadContext", + "key1": "value2", + "key3": "value3", + "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", + "sdnc_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_subintcount\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}, {\"attribute_name\": \"paramOne\", \"attribute_value\": \"paramOneValue\"}, {\"attribute_name\": \"vmType0_name_0\", \"attribute_value\": \"vmName0\"}, {\"attribute_name\": \"vnfNetworkRole0_v6_subnet_id\", \"attribute_value\": \"subnetId1\"}, {\"attribute_name\": \"vmType0_name_1\", \"attribute_value\": \"vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_name\", \"attribute_value\": \"netName0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_vlan_ids\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"vnfNetworkRole0_net_id\", \"attribute_value\": \"neutronId0\"}, {\"attribute_name\": \"availability_zone_0\", \"attribute_value\": \"zone0\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_1\", \"attribute_value\": \"ip3\"}, {\"attribute_name\": \"availability_zone_1\", \"attribute_value\": \"zone1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"availability_zone_2\", \"attribute_value\": \"zone2\"}, {\"attribute_name\": \"vmType0_names\", \"attribute_value\": \"vmName0,vmName1\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_route_prefixes\", \"attribute_value\": \"[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ip_0\", \"attribute_value\": \"ip2\"}, {\"attribute_name\": \"vnfNetworkRole0_subnet_id\", \"attribute_value\": \"subnetId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_1\", \"attribute_value\": \"ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vnfNetworkRole0_net_fqdn\", \"attribute_value\": \"netFqdnValue0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip_0\", \"attribute_value\": \"ip0\"}, {\"attribute_name\": \"vmNetworkRole0_ATT_VF_VLAN_FILTER\", \"attribute_value\": \"heatVlanFilter0,heatVlanFilter1\"}, {\"attribute_name\": \"paramTwo\", \"attribute_value\": \"paramTwoValue\"}, {\"attribute_name\": \"paramThree\", \"attribute_value\": \"paramThreeValue\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_v6_ips\", \"attribute_value\": \"ip2,ip3\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_floating_v6_ip\", \"attribute_value\": \"floatingIpV60\"}, {\"attribute_name\": \"vmType0_vmNetworkRole0_ips\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_names\", \"attribute_value\": \"1\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_net_ids\", \"attribute_value\": \"networkId0\"}, {\"attribute_name\": \"fw_0_subint_ctrl_port_0_v6_ip\", \"attribute_value\": \"ip0,ip1\"}, {\"attribute_name\": \"fw_subint_ctrl_port_0_floating_ip\", \"attribute_value\": \"floatingIpV40\"}] }", + "user_directives": "{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value2\"}] }" + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json index aa4ada059d..ea51d2c6b2 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestDhcpDisabled.json @@ -11,6 +11,7 @@ "skipAAI": true, "backout": false, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json index f7fb1e9f44..aa633bf5a8 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestMultipleDhcp.json @@ -11,6 +11,7 @@ "skipAAI": true, "backout": false, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json index e06f9cbf36..9bddf29433 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestNoUserParams.json @@ -11,6 +11,7 @@ "skipAAI": true, "backout": false, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json index b97bab4149..4ccfdbe890 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json @@ -11,6 +11,7 @@ "skipAAI": true, "backout": true, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json index 7b78510f56..da826b8a89 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithCloudResources.json @@ -11,6 +11,7 @@ "skipAAI": true, "backout": false, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json index 83ba299914..3170b8ba54 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json @@ -11,6 +11,7 @@ "skipAAI": true, "backout": false, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", 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 index aaee92b083..be860ace96 100644 --- 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 @@ -11,6 +11,7 @@ "skipAAI": true, "backout": false, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json index a419c2ee59..54f6e403ed 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleWithVolumeGroupRequest.json @@ -13,6 +13,7 @@ "skipAAI": true, "backout": false, "failIfExists": false, + "enableBridge": true, "msoRequest": { "requestId": "requestId", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json new file mode 100644 index 0000000000..aa2462f371 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json @@ -0,0 +1,66 @@ +{ + "requestDetails": { + "modelInfo": { + "modelCustomizationName": "model-cust-name", + "modelInvariantId": "db86e4a6-c027-452e-a559-3a23b3128367", + "modelType": "vfModule", + "modelName": "test-model-name", + "modelVersion": "1", + "modelCustomizationUuid": "9a6d01fd-19a7-490a-9800-460830a12e0b", + "modelVersionId": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60", + "modelCustomizationId": "9a6d01fd-19a7-490a-9800-460830a12e0b", + "modelUuid": "14c8f313-fb0f-4cf6-8caf-c7cce8137b60", + "modelInvariantUuid": "db86e4a6-c027-452e-a559-3a23b3128367", + "modelInstanceName": "test-model-instance-name" + }, + "requestInfo": { + "source": "VID", + "instanceName": "instanceName", + "suppressRollback": false, + "requestorId": "user" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f647e3ef-6d2e-4cd3-bff4-8df4634208de", + "modelInfo": { + "modelInvariantId": "86adb376-5303-441a-b50e-96c0cd643b0f", + "modelType": "service", + "modelName": "model-name", + "modelVersion": "1.0", + "modelVersionId": "599e21ed-803d-4d1f-83df-20005339b83f", + "modelUuid": "599e21ed-803d-4d1f-83df-20005339b83f", + "modelInvariantUuid": "86adb376-5303-441a-b50e-96c0cd643b0f" + } + } + }, + { + "relatedInstance": { + "instanceId": "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", + "modelInfo": { + "modelCustomizationName": "modle-cust-name", + "modelInvariantId": "5cca9285-4ed4-4e11-a609-921ed3344811", + "modelType": "vnf", + "modelName": "modle-name", + "modelVersion": "1.0", + "modelCustomizationUuid": "fc25201d-36d6-43a3-8d39-fdae88e526ae", + "modelVersionId": "7cae703a-b20d-481a-863a-b862236c00f7", + "modelCustomizationId": "fc25201d-36d6-43a3-8d39-fdae88e526ae", + "modelUuid": "7cae703a-b20d-481a-863a-b862236c00f7", + "modelInvariantUuid": "5cca9285-4ed4-4e11-a609-921ed3344811", + "modelInstanceName": "model-inst-name" + } + } + } + ], + "cloudConfiguration": { + "tenantId": "872f331350c54e59991a8de2cbffb40c", + "cloudOwner": "my-custom-cloud-owner", + "lcpCloudRegionId": "cloud-region" + }, + "requestParameters": { + "usePreload": true, + "rebuildVolumeGroups": true + } + } +}
\ No newline at end of file |