diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks')
21 files changed, 529 insertions, 242 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 e534142471..887c51e179 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 @@ -24,6 +24,7 @@ import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; @@ -40,6 +41,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAINetworkResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; @@ -74,6 +76,8 @@ public class AAICreateTasks { private AAINetworkResources aaiNetworkResources; @Autowired private AAIVpnBindingResources aaiVpnBindingResources; + @Autowired + private AAIConfigurationResources aaiConfigurationResources; public void createServiceInstance(BuildingBlockExecution execution) { try { @@ -376,4 +380,13 @@ public class AAICreateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void createConfiguration(BuildingBlockExecution execution){ + try{ + Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID)); + aaiConfigurationResources.createConfiguration(configuration); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java index cb265b6e41..a00806a19c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java @@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -31,6 +32,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAINetworkResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; @@ -56,6 +58,8 @@ public class AAIDeleteTasks { private AAINetworkResources aaiNetworkResources; @Autowired private AAIVolumeGroupResources aaiVolumeGroupResources; + @Autowired + private AAIConfigurationResources aaiConfigurationResources; public void deleteVfModule(BuildingBlockExecution execution) throws Exception { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); @@ -133,4 +137,12 @@ public class AAIDeleteTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + public void deleteConfiguration(BuildingBlockExecution execution) { + try { + Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID)); + aaiConfigurationResources.deleteConfiguration(configuration); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index b059a77641..58c51f6223 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -24,6 +24,7 @@ import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -35,6 +36,7 @@ import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAICollectionResources; +import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAINetworkResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; @@ -64,6 +66,8 @@ public class AAIUpdateTasks { private AAINetworkResources aaiNetworkResources; @Autowired private AAICollectionResources aaiCollectionResources; + @Autowired + private AAIConfigurationResources aaiConfigurationResources; public void updateOrchestrationStatusAssignedService(BuildingBlockExecution execution) { try { @@ -394,4 +398,21 @@ public class AAIUpdateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + public void updateOrchestrationStatusActivateFabricConfiguration(BuildingBlockExecution execution) { + try { + Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID)); + aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void updateOrchestrationStatusDeactivateFabricConfiguration(BuildingBlockExecution execution) { + try { + Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID)); + aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java index 6fcad95144..03559afb33 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java @@ -27,6 +27,9 @@ public class Resource { private boolean generated; private boolean baseVfModule; private String virtualLinkKey; + private String vnfCustomizationId; + private String vfModuleCustomizationId; + private String cvnfModuleCustomizationId; public Resource(WorkflowType resourceType, String resourceId, boolean generated){ this.resourceId = resourceId; @@ -64,4 +67,22 @@ public class Resource { public void setVirtualLinkKey(String virtualLinkKey) { this.virtualLinkKey = virtualLinkKey; } + public String getVnfCustomizationId() { + return vnfCustomizationId; + } + public void setVnfCustomizationId(String vnfCustomizationId) { + this.vnfCustomizationId = vnfCustomizationId; + } + public String getVfModuleCustomizationId() { + return vfModuleCustomizationId; + } + public void setVfModuleCustomizationId(String vfModuleCustomizationId) { + this.vfModuleCustomizationId = vfModuleCustomizationId; + } + public String getCvnfModuleCustomizationId() { + return cvnfModuleCustomizationId; + } + public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) { + this.cvnfModuleCustomizationId = cvnfModuleCustomizationId; + } } 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 b2b071e1ee..5809d16492 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 @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -36,21 +37,27 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; 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.infrastructure.workflow.tasks.Resource; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; -import org.onap.so.db.catalog.beans.InstanceGroup; +import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -103,6 +110,8 @@ public class WorkflowAction { private ExceptionBuilder exceptionBuilder; @Autowired private CatalogDbClient catalogDbClient; + @Autowired + private AAIConfigurationResources aaiConfigurationResources; public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) { this.bbInputSetupUtils = bbInputSetupUtils; @@ -125,7 +134,6 @@ public class WorkflowAction { WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); List<Resource> resourceCounter = new ArrayList<>(); - execution.setVariable("sentSyncResponse", false); execution.setVariable("homing", false); execution.setVariable("calledHoming", false); @@ -160,9 +168,10 @@ public class WorkflowAction { } else { key = modelInfo.getModelCustomizationId(); } + Resource resourceKey = new Resource(resourceType, key, aLaCarte); for (OrchestrationFlow orchFlow : orchFlows) { - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, key, apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null); + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false); flowsToExecute.add(ebb); } } else { @@ -212,7 +221,8 @@ public class WorkflowAction { } else if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("unassignInstance") - || requestAction.equalsIgnoreCase("deleteInstance"))) { + || requestAction.equalsIgnoreCase("deleteInstance") + || requestAction.equalsIgnoreCase("activateFabricConfiguration"))) { // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and // SERVICE-MACRO-DELETE // Will never get user params with service, macro will have @@ -230,7 +240,7 @@ public class WorkflowAction { foundObjects = foundObjects + type + " - " + resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()).size() + " "; } msoLogger.info("Found " + foundObjects); - + if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); } @@ -267,7 +277,6 @@ public class WorkflowAction { execution.setVariable("flowsToExecute", flowsToExecute); } catch (Exception ex) { - msoLogger.error(ex); buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex); } } @@ -278,7 +287,7 @@ public class WorkflowAction { if(resource.isBaseVfModule()){ Collections.swap(vfModuleResources, 0, count); break; - } + } count++; } return vfModuleResources; @@ -294,7 +303,7 @@ public class WorkflowAction { List<Resource> resources = resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()); for(int i = 0; i < resources.size(); i++){ updateWorkflowResourceIds(flowsToExecute, type, resources.get(i).getResourceId(), retrieveAAIResourceId(aaiResourceIds,type), null); - } + } }); } @@ -317,7 +326,7 @@ public class WorkflowAction { .collect(Collectors.toList()).get(i); updateWorkflowResourceIds(flowsToExecute, type, resource.getResourceId(), null, resource.getVirtualLinkKey()); } }); - } + } protected void updateWorkflowResourceIds(List<ExecuteBuildingBlock> flowsToExecute, WorkflowType resource, String key, String id, String virtualLinkKey){ String resourceId = id; @@ -337,6 +346,8 @@ public class WorkflowAction { workflowResourceIds.setNetworkId(resourceId); }else if(resource == WorkflowType.NETWORKCOLLECTION){ workflowResourceIds.setNetworkCollectionId(resourceId); + }else if(resource == WorkflowType.CONFIGURATION){ + workflowResourceIds.setConfigurationId(resourceId); } ebb.setWorkflowResourceIds(workflowResourceIds); } @@ -389,7 +400,7 @@ public class WorkflowAction { String toscaNodeType = collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType(); if (toscaNodeType != null && toscaNodeType.contains("NetworkCollection")) { int minNetworks = 0; - InstanceGroup instanceGroup = collectionResourceCustomization.getCollectionResource().getInstanceGroup(); + org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = collectionResourceCustomization.getCollectionResource().getInstanceGroup(); CollectionResourceInstanceGroupCustomization collectionInstCust = null; if(!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { for(CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup.getCollectionInstanceGroupCustomizations()) { @@ -418,14 +429,14 @@ public class WorkflowAction { } } } else { - msoLogger.debug("Instance Group tosca node type does not contain NetworkCollection: " + toscaNodeType); + msoLogger.debug("Instance Group tosca node type does not contain NetworkCollection: " + toscaNodeType); + } + }else{ + msoLogger.debug("No Instance Group found for network collection."); } }else{ - msoLogger.debug("No Instance Group found for network collection."); + msoLogger.debug("No Network Collection found. collectionResource is null"); } - }else{ - msoLogger.debug("No Network Collection found. collectionResource is null"); - } } else { msoLogger.debug("No Network Collection Customization found"); } @@ -484,6 +495,20 @@ public class WorkflowAction { aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId())); resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,serviceInstanceMSO.getCollection().getId(),false)); } + if (serviceInstanceMSO.getConfigurations() !=null) { + for(Configuration config : serviceInstanceMSO.getConfigurations()){ + Optional<org.onap.aai.domain.yang.Configuration> aaiConfig = aaiConfigurationResources.getConfiguration(config.getConfigurationId()); + if(aaiConfig.isPresent() && aaiConfig.get().getRelationshipList()!=null){ + for(Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()){ + if(relationship.getRelatedTo().contains("vnfc")){ + aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, config.getConfigurationId())); + resourceCounter.add(new Resource(WorkflowType.CONFIGURATION,config.getConfigurationId(),false)); + break; + } + } + } + } + } } catch (Exception ex) { buildAndThrowException(execution, "Could not find existing Service Instance or related Instances to execute the request on."); @@ -495,6 +520,8 @@ public class WorkflowAction { throws IOException { boolean foundRelated = false; boolean foundVfModuleOrVG = false; + String vnfCustomizationUUID = ""; + String vfModuleCustomizationUUID = ""; if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams(); for (Map<String, Object> params : userParams) { @@ -507,18 +534,23 @@ public class WorkflowAction { for (Vnfs vnf : validate.getResources().getVnfs()) { resourceCounter.add(new Resource(WorkflowType.VNF,vnf.getModelInfo().getModelCustomizationId(),false)); foundRelated = true; + if(vnf.getModelInfo()!=null && vnf.getModelInfo().getModelCustomizationUuid()!=null){ + vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid(); + } if (vnf.getVfModules() != null) { for (VfModules vfModule : vnf.getVfModules()) { VfModuleCustomization vfModuleCustomization = catalogDbClient .getVfModuleCustomizationByModelCuztomizationUUID( vfModule.getModelInfo().getModelCustomizationUuid()); if (vfModuleCustomization != null) { - if(vfModuleCustomization.getVfModule()!=null && vfModuleCustomization.getVfModule().getVolumeHeatTemplate()!=null &&vfModuleCustomization.getVolumeHeatEnv() != null) { + + if(vfModuleCustomization.getVfModule() != null && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null && vfModuleCustomization.getVolumeHeatEnv() != null) { resourceCounter.add(new Resource(WorkflowType.VOLUMEGROUP,vfModuleCustomization.getModelCustomizationUUID(),false)); foundRelated = true; foundVfModuleOrVG = true; } - if(vfModuleCustomization.getVfModule()!=null && vfModuleCustomization.getVfModule().getModuleHeatTemplate()!=null && vfModuleCustomization.getHeatEnvironment()!=null){ + + if(vfModuleCustomization.getVfModule() != null && vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null && vfModuleCustomization.getHeatEnvironment() != null){ foundRelated = true; foundVfModuleOrVG = true; Resource resource = new Resource(WorkflowType.VFMODULE,vfModuleCustomization.getModelCustomizationUUID(),false); @@ -528,6 +560,18 @@ public class WorkflowAction { resource.setBaseVfModule(false); } resourceCounter.add(resource); + if(vfModule.getModelInfo()!=null && vfModule.getModelInfo().getModelCustomizationUuid()!=null){ + vfModuleCustomizationUUID = vfModule.getModelInfo().getModelCustomizationUuid(); + } + if(!vnfCustomizationUUID.equals("")&&!vfModuleCustomizationUUID.equals("")){ + List<String> configs = traverseCatalogDbForConfiguration(vnfCustomizationUUID,vfModuleCustomizationUUID); + for(String config : configs){ + Resource configResource = new Resource(WorkflowType.CONFIGURATION,config,false); + resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId()); + resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId()); + resourceCounter.add(configResource); + } + } } if(!foundVfModuleOrVG){ buildAndThrowException(execution, "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null"); @@ -556,6 +600,25 @@ public class WorkflowAction { } return foundRelated; } + + + private List<String> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { + List<String> configurations = new ArrayList<>(); + try{ + List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(vnfCustomizationUUID, vfModuleCustomizationUUID); + for(CvnfcCustomization cvnfc : cvnfcCustomizations){ + for(VnfVfmoduleCvnfcConfigurationCustomization customization : cvnfc.getVnfVfmoduleCvnfcConfigurationCustomization()){ + if(customization.getConfigurationResource().getToscaNodeType().contains("FabricConfiguration")){ + configurations.add(customization.getConfigurationResource().getModelUUID()); + } + } + } + msoLogger.debug("found " + configurations.size() + " configurations"); + return configurations; + } catch (Exception ex){ + return configurations; + } + } protected String queryCatalogDBforNetworkCollection(DelegateExecution execution, ServiceInstancesRequest sIRequest) { org.onap.so.db.catalog.beans.Service service = catalogDbClient @@ -664,7 +727,6 @@ public class WorkflowAction { } return generatedResourceId; } catch (Exception ex) { - msoLogger.error(ex); throw new IllegalStateException( "WorkflowAction was unable to verify if the instance name already exist in AAI."); } @@ -763,69 +825,73 @@ public class WorkflowAction { for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.SERVICE == x.getResourceType()).collect(Collectors.toList()).size(); i++) { workflowResourceIds.setServiceInstanceId(resourceId); flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.SERVICE == x.getResourceType()) - .collect(Collectors.toList()).get(i).getResourceId(), apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + .collect(Collectors.toList()).get(i), apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, 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).getResourceId(), apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + .collect(Collectors.toList()).get(i), apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, 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).getResourceId(), apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + .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.getResourceId(), apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, true, resource.getVirtualLinkKey())); + flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, true, resource.getVirtualLinkKey(), false)); } } else if (orchFlow.getFlowName().contains(VFMODULE)) { List<Resource> vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceCounter.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).getResourceId(), apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i), apiVersion, resourceId, + requestAction, aLaCarte, 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).getResourceId(), apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + .collect(Collectors.toList()).get(i), apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, 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).getResourceId(), apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + .collect(Collectors.toList()).get(i), apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, 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).getResourceId(), apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + .collect(Collectors.toList()).get(i), apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true)); } - } else { - flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, "", apiVersion, resourceId, - requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + }else { + flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, false)); } } return flowsToExecute; } - protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, String key, + protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, - WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean isVirtualLink, String virtualLinkKey) { + WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean isVirtualLink, String virtualLinkKey, boolean isConfiguration) { ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); BuildingBlock buildingBlock = new BuildingBlock(); buildingBlock.setBpmnFlowName(orchFlow.getFlowName()); buildingBlock.setMsoId(UUID.randomUUID().toString()); - buildingBlock.setKey(key); + if(resource == null){ + buildingBlock.setKey(""); + }else{ + buildingBlock.setKey(resource.getResourceId()); + } buildingBlock.setIsVirtualLink(isVirtualLink); buildingBlock.setVirtualLinkKey(virtualLinkKey); executeBuildingBlock.setApiVersion(apiVersion); @@ -837,6 +903,13 @@ public class WorkflowAction { executeBuildingBlock.setRequestId(requestId); executeBuildingBlock.setBuildingBlock(buildingBlock); executeBuildingBlock.setRequestDetails(requestDetails); + if(isConfiguration){ + ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); + configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId()); + configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId()); + configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId()); + executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys); + } return executeBuildingBlock; } @@ -852,24 +925,24 @@ public class WorkflowAction { buildAndThrowException(execution,"The request: Macro " + resourceName + " " + requestAction + " is not supported by GR_API."); } } else { - if(northBoundRequest.getIsToplevelflow()!=null){ - execution.setVariable(G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow()); - } - List<OrchestrationFlow> flows = northBoundRequest.getOrchestrationFlowList(); - if (flows == null) - flows = new ArrayList<>(); - for (OrchestrationFlow flow : flows) { - if (!flow.getFlowName().contains("BB")) { - List<OrchestrationFlow> macroQueryFlows = catalogDbClient - .getOrchestrationFlowByAction(flow.getFlowName()); - for (OrchestrationFlow macroFlow : macroQueryFlows) { - listToExecute.add(macroFlow); - } - } else { - listToExecute.add(flow); + if(northBoundRequest.getIsToplevelflow()!=null){ + execution.setVariable(G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow()); + } + List<OrchestrationFlow> flows = northBoundRequest.getOrchestrationFlowList(); + if (flows == null) + flows = new ArrayList<>(); + for (OrchestrationFlow flow : flows) { + if (!flow.getFlowName().contains("BB")) { + List<OrchestrationFlow> macroQueryFlows = catalogDbClient + .getOrchestrationFlowByAction(flow.getFlowName()); + for (OrchestrationFlow macroFlow : macroQueryFlows) { + listToExecute.add(macroFlow); } + } else { + listToExecute.add(flow); } } + } return listToExecute; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 101a355c2f..ab29e21dea 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -30,9 +30,10 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; -import org.onap.so.client.db.request.RequestsDbClient; + import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.RequestReferences; import org.onap.so.serviceinstancebeans.ServiceInstancesResponse; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index be19f25cca..4a1c3f512c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -7,15 +7,14 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * Modifications Copyright (C) 2018 IBM * ============LICENSE_END========================================================= */ diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java index b84f8b6459..e13a765cf2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java @@ -148,6 +148,18 @@ public class AAIConfigurationResources { AAIResourceUri vpnBindingURI = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnId); injectionHelper.getAaiClient().connect(configurationURI, vpnBindingURI); } + + public void connectConfigurationToVfModule(String configurationId, String vfModuleId, String vnfId){ + AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); + injectionHelper.getAaiClient().connect(configurationURI, vfModuleURI); + } + + public void connectConfigurationToVnfc(String configurationId, String vnfcName){ + AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); + AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfcName); + injectionHelper.getAaiClient().connect(configurationURI, vnfcURI); + } /** * method to delete Configuration details in A&AI * @@ -157,6 +169,15 @@ public class AAIConfigurationResources { AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); injectionHelper.getAaiClient().delete(aaiResourceUri); } + /** + * method to delete Configuration details in A&AI + * + * @param configuration + */ + public void deleteConfiguration(Configuration configuration) { + AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId()); + injectionHelper.getAaiClient().delete(aaiResourceUri); + } /** * Get Configuration from AAI using related Link @@ -167,4 +188,11 @@ public class AAIConfigurationResources { return injectionHelper.getAaiClient() .get(org.onap.aai.domain.yang.Configuration.class, AAIUriFactory.createResourceFromExistingURI(AAIObjectType.CONFIGURATION, UriBuilder.fromPath(relatedLink).build())); } + + public void updateOrchestrationStatusConfiguration(Configuration configuration, OrchestrationStatus orchestrationStatus) { + AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId()); + configuration.setOrchestrationStatus(orchestrationStatus); + org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration); + injectionHelper.getAaiClient().update(aaiResourceUri, aaiConfiguration); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/BaseClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/BaseClient.java deleted file mode 100644 index 50137cf985..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/BaseClient.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.sdnc; - -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; -import org.springframework.web.client.RestClientException; -import org.springframework.web.client.RestTemplate; - -//TODO move to common location -public class BaseClient<I,O> { - - private HttpHeaders httpHeader; - private String targetUrl; - - public HttpHeaders getHttpHeader() { - return httpHeader; - } - - public void setHttpHeader(HttpHeaders httpHeader) { - this.httpHeader = httpHeader; - } - - public String getTargetUrl() { - return targetUrl; - } - - public void setTargetUrl(String targetUrl) { - this.targetUrl = targetUrl; - } - - public O get(I data, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { - return run(data, HttpMethod.GET, typeRef, uriVariables); - } - - public O post(I data, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { - return run(data, HttpMethod.POST, typeRef, uriVariables); - } - - public O run(I data, HttpMethod method, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { - HttpEntity<I> requestEntity = new HttpEntity<I>(data, getHttpHeader()); - RestTemplate restTemplate = new RestTemplate(); - restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())); - ResponseEntity<O> responseEntity = restTemplate.exchange(getTargetUrl(), method, requestEntity, typeRef, - uriVariables); - return responseEntity.getBody(); - } - -}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index 9e60196426..0061f50ba8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -24,6 +24,7 @@ import java.util.LinkedHashMap; import javax.ws.rs.core.UriBuilder; +import org.onap.so.bpmn.common.baseclient.BaseClient; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCProperties; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java index cee94e28bd..eb12278528 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java @@ -23,9 +23,9 @@ package org.onap.so.client.sniro; import java.util.LinkedHashMap; import org.camunda.bpm.engine.delegate.BpmnError; +import org.onap.so.bpmn.common.baseclient.BaseClient; import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.client.exception.BadResponseException; -import org.onap.so.client.sdnc.BaseClient; import org.onap.so.client.sniro.beans.ManagerProperties; import org.onap.so.client.sniro.beans.SniroConductorRequest; import org.onap.so.client.sniro.beans.SniroManagerRequest; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java index 6401d5516d..9244f7ee1f 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/TestApplication.java @@ -21,14 +21,8 @@ package org.onap.so; -import java.io.IOException; - -import javax.annotation.PreDestroy; - import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepositoryImpl; -import org.onap.so.requestsdb.RequestsDBHelper; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; @@ -40,9 +34,7 @@ import org.springframework.context.annotation.Profile; @Profile("test") @EnableProcessApplication("MSO CommonBPMN Test Application") @ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = { - @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class), - @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RequestsDBHelper.class), - @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = InfraActiveRequestsRepositoryImpl.class) }) + @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) public class TestApplication { public static void main(String... args) { SpringApplication.run(TestApplication.class, args); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java index 3fce15a6c4..2b25dfd9f1 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java @@ -28,8 +28,8 @@ import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.appc.ApplicationControllerAction; -import org.onap.so.client.db.request.RequestsDbClient; import org.onap.so.client.orchestration.AAICollectionResources; +import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.onap.so.client.orchestration.AAINetworkResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; @@ -46,6 +46,8 @@ import org.onap.so.client.orchestration.VnfAdapterVfModuleResources; import org.onap.so.client.orchestration.VnfAdapterVolumeGroupResources; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.client.RequestsDbClient; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.SpyBean; @@ -111,6 +113,7 @@ public abstract class BaseTaskTest extends TestDataSetup { protected CatalogDbClient catalogDbClient; @MockBean + @Qualifier("RequestsDbClient") protected RequestsDbClient requestsDbClient; @Mock @@ -118,10 +121,13 @@ public abstract class BaseTaskTest extends TestDataSetup { @Mock protected BBInputSetup bbInputSetup; - + @SpyBean protected SDNCClient SPY_sdncClient; @MockBean protected ApplicationControllerAction appCClient; + + @MockBean + protected AAIConfigurationResources aaiConfigurationResources; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index 675e8a1d95..fb9533091b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -663,4 +663,20 @@ public class TestDataSetup{ return ar; } + + public Configuration setConfiguration () { + Configuration config = new Configuration(); + config.setConfigurationId("testConfigurationId"); + List<Configuration> configurations = new ArrayList<>(); + configurations.add(config); + ServiceInstance serviceInstance = new ServiceInstance(); + try { + serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + } catch(BBObjectNotFoundException e) { + serviceInstance = setServiceInstance(); + } + lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId"); + serviceInstance.setConfigurations(configurations); + return config; + } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java index 51a7f1ab04..0b802a3385 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java @@ -26,6 +26,9 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.util.ArrayList; +import java.util.List; + import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Rule; @@ -33,6 +36,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -54,6 +58,7 @@ public class AAICreateTasksTest extends BaseTaskTest{ private CloudRegion cloudRegion; private VfModule vfModule; private Customer customer; + private Configuration configuration; @Rule public final ExpectedException exception = ExpectedException.none(); @@ -67,6 +72,7 @@ public class AAICreateTasksTest extends BaseTaskTest{ volumeGroup = setVolumeGroup(); cloudRegion = setCloudRegion(); vfModule = setVfModule(); + configuration = setConfiguration(); } @@ -384,4 +390,12 @@ public class AAICreateTasksTest extends BaseTaskTest{ aaiCreateTasks.connectNetworkToTenant(execution); verify(aaiNetworkResources, times(1)).connectNetworkToTenant(network, gBBInput.getCloudRegion()); } + + @Test + public void createConfigurationTest() throws Exception { + gBBInput = execution.getGeneralBuildingBlock(); + doNothing().when(aaiConfigurationResources).createConfiguration(configuration); + aaiCreateTasks.createConfiguration(execution); + verify(aaiConfigurationResources, times(1)).createConfiguration(configuration); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java new file mode 100644 index 0000000000..efe5b5d971 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.aai.tasks; + +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.ArrayList; +import java.util.List; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.springframework.beans.factory.annotation.Autowired; + +public class AAIDeleteTasksTest extends BaseTaskTest { + @Autowired + private AAIDeleteTasks aaiDeleteTasks; + + private L3Network network; + private ServiceInstance serviceInstance; + private GenericVnf genericVnf; + private VfModule vfModule; + private VolumeGroup volumeGroup; + private CloudRegion cloudRegion; + private Configuration configuration; + + @Before + public void before() { + serviceInstance = setServiceInstance(); + genericVnf = setGenericVnf(); + vfModule = setVfModule(); + network = setL3Network(); + volumeGroup = setVolumeGroup(); + cloudRegion = setCloudRegion(); + configuration = setConfiguration(); + } + + @Test + public void deleteVfModuleTest() throws Exception { + doNothing().when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf); + aaiDeleteTasks.deleteVfModule(execution); + verify(aaiVfModuleResources, times(1)).deleteVfModule(vfModule, genericVnf); + } + + @Test + public void deleteVfModuleExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + doThrow(Exception.class).when(aaiVfModuleResources).deleteVfModule(vfModule, genericVnf); + aaiDeleteTasks.deleteVfModule(execution); + } + + @Test + public void deleteServiceInstanceTest() throws Exception { + doNothing().when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance); + + aaiDeleteTasks.deleteServiceInstance(execution); + + verify(aaiServiceInstanceResources, times(1)).deleteServiceInstance(serviceInstance); + } + + @Test + public void deleteServiceInstanceExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + + doThrow(Exception.class).when(aaiServiceInstanceResources).deleteServiceInstance(serviceInstance); + + aaiDeleteTasks.deleteServiceInstance(execution); + } + + @Test + public void deleteVnfTest() throws Exception { + doNothing().when(aaiVnfResources).deleteVnf(genericVnf); + aaiDeleteTasks.deleteVnf(execution); + verify(aaiVnfResources, times(1)).deleteVnf(genericVnf); + } + + @Test + public void deleteVnfTestException() throws Exception { + expectedException.expect(BpmnError.class); + doThrow(Exception.class).when(aaiVnfResources).deleteVnf(genericVnf); + + aaiDeleteTasks.deleteVnf(execution); + verify(aaiVnfResources, times(1)).deleteVnf(genericVnf); + } + + @Test + public void deleteNetworkTest() throws Exception { + doNothing().when(aaiNetworkResources).deleteNetwork(network); + aaiDeleteTasks.deleteNetwork(execution); + verify(aaiNetworkResources, times(1)).deleteNetwork(network); + } + + @Test + public void deleteCollectionTest() throws Exception { + doNothing().when(aaiNetworkResources).deleteCollection(serviceInstance.getCollection()); + aaiDeleteTasks.deleteCollection(execution); + verify(aaiNetworkResources, times(1)).deleteCollection(serviceInstance.getCollection()); + } + + @Test + public void deleteInstanceGroupTest() throws Exception { + doNothing().when(aaiNetworkResources).deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup()); + aaiDeleteTasks.deleteInstanceGroup(execution); + verify(aaiNetworkResources, times(1)).deleteNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup()); + } + + @Test + public void deleteVolumeGroupTest() { + doNothing().when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion); + + aaiDeleteTasks.deleteVolumeGroup(execution); + + verify(aaiVolumeGroupResources, times(1)).deleteVolumeGroup(volumeGroup, cloudRegion); + } + + @Test + public void deleteVolumeGroupExceptionTest() { + expectedException.expect(BpmnError.class); + + doThrow(Exception.class).when(aaiVolumeGroupResources).deleteVolumeGroup(volumeGroup, cloudRegion); + + aaiDeleteTasks.deleteVolumeGroup(execution); + } + + @Test + public void deleteConfigurationTest() throws Exception { + gBBInput = execution.getGeneralBuildingBlock(); + doNothing().when(aaiConfigurationResources).deleteConfiguration(configuration); + aaiDeleteTasks.deleteConfiguration(execution); + verify(aaiConfigurationResources, times(1)).deleteConfiguration(configuration); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index b45752957e..d800ae9618 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -32,6 +32,7 @@ import org.junit.Test; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -50,6 +51,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ private GenericVnf genericVnf; private VolumeGroup volumeGroup; private CloudRegion cloudRegion; + private Configuration configuration; @Before public void before() { @@ -59,6 +61,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ volumeGroup = setVolumeGroup(); cloudRegion = setCloudRegion(); network = setL3Network(); + configuration = setConfiguration(); } @Test @@ -462,4 +465,23 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ doThrow(Exception.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf); aaiUpdateTasks.updateModelVfModule(execution); } + + @Test + public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception { + gBBInput = execution.getGeneralBuildingBlock(); + doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED); + + aaiUpdateTasks.updateOrchestrationStatusDeactivateFabricConfiguration(execution); + + verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED); + } + @Test + public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception { + gBBInput = execution.getGeneralBuildingBlock(); + doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE); + + aaiUpdateTasks.updateOrchestrationStatusActivateFabricConfiguration(execution); + + verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE); + } } 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 3869988c40..65d16adb40 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 @@ -36,7 +36,6 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Optional; @@ -74,7 +73,6 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; -import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.RequestParameters; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @@ -304,7 +302,7 @@ public class WorkflowActionTest extends BaseTaskTest { orchFlows.add(orch7); OrchestrationFlow orch8 = new OrchestrationFlow(); orch8.setFlowName("ActivateServiceInstanceBB"); - orchFlows.add(orch8); + orchFlows.add(orch8); ServiceInstance serviceInstanceAAI = new ServiceInstance(); serviceInstanceAAI.setServiceInstanceId("si0"); @@ -718,6 +716,9 @@ public class WorkflowActionTest extends BaseTaskTest { orch15.setFlowName("ActivateServiceInstanceBB"); orchFlows.add(orch15); + Service service = new Service(); + service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a"); + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); HeatEnvironment volumeHeatEnv = new HeatEnvironment(); @@ -743,6 +744,7 @@ public class WorkflowActionTest extends BaseTaskTest { when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f")).thenReturn(vfModuleCustomization); when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8")).thenReturn(vfModuleCustomization2); when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969")).thenReturn(vfModuleCustomization3); + when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service); workflowAction.selectExecutionList(execution); List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); @@ -796,48 +798,48 @@ public class WorkflowActionTest extends BaseTaskTest { NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = new LinkedList<>(); northBoundRequest.setOrchestrationFlowList(orchFlows); - OrchestrationFlow orch1 = new OrchestrationFlow(); - orch1.setFlowName("DeactivateVfModuleBB"); - orchFlows.add(orch1); - OrchestrationFlow orch2 = new OrchestrationFlow(); - orch2.setFlowName("DeleteVfModuleBB"); - orchFlows.add(orch2); OrchestrationFlow orch3 = new OrchestrationFlow(); - orch3.setFlowName("DeactivateVolumeGroupBB"); + orch3.setFlowName("DeactivateVfModuleBB"); orchFlows.add(orch3); OrchestrationFlow orch4 = new OrchestrationFlow(); - orch4.setFlowName("DeleteVolumeGroupBB"); + orch4.setFlowName("DeleteVfModuleBB"); orchFlows.add(orch4); OrchestrationFlow orch5 = new OrchestrationFlow(); - orch5.setFlowName("DeactivateVnfBB"); + orch5.setFlowName("DeactivateVolumeGroupBB"); orchFlows.add(orch5); OrchestrationFlow orch6 = new OrchestrationFlow(); - orch6.setFlowName("DeactivateNetworkBB"); + orch6.setFlowName("DeleteVolumeGroupBB"); orchFlows.add(orch6); OrchestrationFlow orch7 = new OrchestrationFlow(); - orch7.setFlowName("DeleteNetworkBB"); + orch7.setFlowName("DeactivateVnfBB"); orchFlows.add(orch7); OrchestrationFlow orch8 = new OrchestrationFlow(); - orch8.setFlowName("DeleteNetworkCollectionBB"); + orch8.setFlowName("DeactivateNetworkBB"); orchFlows.add(orch8); OrchestrationFlow orch9 = new OrchestrationFlow(); - orch9.setFlowName("DeactivateServiceInstanceBB"); + orch9.setFlowName("DeleteNetworkBB"); orchFlows.add(orch9); OrchestrationFlow orch10 = new OrchestrationFlow(); - orch10.setFlowName("UnassignVfModuleBB"); + orch10.setFlowName("DeleteNetworkCollectionBB"); orchFlows.add(orch10); OrchestrationFlow orch11 = new OrchestrationFlow(); - orch11.setFlowName("UnassignVolumeGroupBB"); + orch11.setFlowName("DeactivateServiceInstanceBB"); orchFlows.add(orch11); OrchestrationFlow orch12 = new OrchestrationFlow(); - orch12.setFlowName("UnassignVnfBB"); + orch12.setFlowName("UnassignVfModuleBB"); orchFlows.add(orch12); OrchestrationFlow orch13 = new OrchestrationFlow(); - orch13.setFlowName("UnassignNetworkBB"); + orch13.setFlowName("UnassignVolumeGroupBB"); orchFlows.add(orch13); OrchestrationFlow orch14 = new OrchestrationFlow(); - orch14.setFlowName("UnassignServiceInstanceBB"); + orch14.setFlowName("UnassignVnfBB"); orchFlows.add(orch14); + OrchestrationFlow orch15 = new OrchestrationFlow(); + orch15.setFlowName("UnassignNetworkBB"); + orchFlows.add(orch15); + OrchestrationFlow orch16 = new OrchestrationFlow(); + orch16.setFlowName("UnassignServiceInstanceBB"); + orchFlows.add(orch16); ServiceInstance serviceInstanceAAI = new ServiceInstance(); serviceInstanceAAI.setServiceInstanceId("aaisi123"); @@ -954,49 +956,49 @@ public class WorkflowActionTest extends BaseTaskTest { NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List<OrchestrationFlow> orchFlows = new LinkedList<>(); - northBoundRequest.setOrchestrationFlowList(orchFlows); - OrchestrationFlow orch1 = new OrchestrationFlow(); - orch1.setFlowName("DeactivateVfModuleBB"); - orchFlows.add(orch1); - OrchestrationFlow orch2 = new OrchestrationFlow(); - orch2.setFlowName("DeleteVfModuleBB"); - orchFlows.add(orch2); + northBoundRequest.setOrchestrationFlowList(orchFlows); OrchestrationFlow orch3 = new OrchestrationFlow(); - orch3.setFlowName("DeactivateVolumeGroupBB"); + orch3.setFlowName("DeactivateVfModuleBB"); orchFlows.add(orch3); OrchestrationFlow orch4 = new OrchestrationFlow(); - orch4.setFlowName("DeleteVolumeGroupBB"); + orch4.setFlowName("DeleteVfModuleBB"); orchFlows.add(orch4); OrchestrationFlow orch5 = new OrchestrationFlow(); - orch5.setFlowName("DeactivateVnfBB"); + orch5.setFlowName("DeactivateVolumeGroupBB"); orchFlows.add(orch5); OrchestrationFlow orch6 = new OrchestrationFlow(); - orch6.setFlowName("DeactivateNetworkBB"); + orch6.setFlowName("DeleteVolumeGroupBB"); orchFlows.add(orch6); OrchestrationFlow orch7 = new OrchestrationFlow(); - orch7.setFlowName("DeleteNetworkBB"); + orch7.setFlowName("DeactivateVnfBB"); orchFlows.add(orch7); OrchestrationFlow orch8 = new OrchestrationFlow(); - orch8.setFlowName("DeleteNetworkCollectionBB"); - orchFlows.add(orch8); + orch8.setFlowName("DeactivateNetworkBB"); + orchFlows.add(orch8); OrchestrationFlow orch9 = new OrchestrationFlow(); - orch9.setFlowName("DeactivateServiceInstanceBB"); - orchFlows.add(orch9); + orch9.setFlowName("DeleteNetworkBB"); + orchFlows.add(orch9); OrchestrationFlow orch10 = new OrchestrationFlow(); - orch10.setFlowName("UnassignVfModuleBB"); - orchFlows.add(orch10); + orch10.setFlowName("DeleteNetworkCollectionBB"); + orchFlows.add(orch10); OrchestrationFlow orch11 = new OrchestrationFlow(); - orch11.setFlowName("UnassignVolumeGroupBB"); - orchFlows.add(orch11); + orch11.setFlowName("DeactivateServiceInstanceBB"); + orchFlows.add(orch11); OrchestrationFlow orch12 = new OrchestrationFlow(); - orch12.setFlowName("UnassignVnfBB"); - orchFlows.add(orch12); + orch12.setFlowName("UnassignVfModuleBB"); + orchFlows.add(orch12); OrchestrationFlow orch13 = new OrchestrationFlow(); - orch13.setFlowName("UnassignNetworkBB"); - orchFlows.add(orch13); + orch13.setFlowName("UnassignVolumeGroupBB"); + orchFlows.add(orch13); OrchestrationFlow orch14 = new OrchestrationFlow(); - orch14.setFlowName("UnassignServiceInstanceBB"); - orchFlows.add(orch14); + orch14.setFlowName("UnassignVnfBB"); + orchFlows.add(orch14); + OrchestrationFlow orch15 = new OrchestrationFlow(); + orch15.setFlowName("UnassignNetworkBB"); + orchFlows.add(orch15); + OrchestrationFlow orch16 = new OrchestrationFlow(); + orch16.setFlowName("UnassignServiceInstanceBB"); + orchFlows.add(orch16); ServiceInstance serviceInstanceAAI = new ServiceInstance(); serviceInstanceAAI.setServiceInstanceId("aaisi123"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index 0355006d15..99f1b188c9 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -562,7 +562,7 @@ public class AAIObjectMapperTest { AAIObjectMapper aaiObjectMapper = new AAIObjectMapper(); org.onap.aai.domain.yang.CtagAssignments v12CtagAssingments = aaiObjectMapper.mapToAAICtagAssignmentList(ctagAssignments); - assertEquals(ctagAssignments.get(0).getVlanIdInner().longValue(), v12CtagAssingments.getCtagAssignment().get(0).getVlanIdInner()); + assertEquals(new Long(ctagAssignments.get(0).getVlanIdInner().longValue()), new Long(v12CtagAssingments.getCtagAssignment().get(0).getVlanIdInner())); String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiCtagAssingmentsMapped_to_aai.json"))); ObjectMapper omapper = new ObjectMapper(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java index cc48c46508..3dc9a4da63 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java @@ -43,6 +43,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; @@ -63,6 +64,7 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{ private ServiceInstance serviceInstance; private GenericVnf genericVnf; private VpnBinding vpnBinding; + private VfModule vfModule; @Mock protected AAIResourcesClient MOCK_aaiResourcesClient; @@ -82,6 +84,7 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{ serviceProxy = buildServiceProxy(); serviceInstance = buildServiceInstance(); genericVnf = buildGenericVnf(); + vfModule = buildVfModule(); vpnBinding = buildVpnBinding(); doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient(); } @@ -126,6 +129,20 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{ aaiConfigurationResources.connectConfigurationToGenericVnf(configuration.getConfigurationId(), genericVnf.getVnfId()); verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class)); } + + @Test + public void connectConfigurationToVfModuleTest() { + doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + aaiConfigurationResources.connectConfigurationToVfModule(configuration.getConfigurationId(), vfModule.getVfModuleId(),genericVnf.getVnfId()); + verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class)); + } + + @Test + public void connectConfigurationToVnfcTest() { + doNothing().when(MOCK_aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + aaiConfigurationResources.connectConfigurationToVnfc(configuration.getConfigurationId(), "vnfcName"); + verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class)); + } @Test public void connectConfigurationToVpnBindingTest() { @@ -177,4 +194,13 @@ public class AAIConfigurationResourcesTest extends TestDataSetup{ aaiConfigurationResources.deleteConfiguration("configurationId"); verify(MOCK_aaiResourcesClient, times(1)).delete(aaiResourceUri); } + + @Test + public void updateOrchestrationStatusConfigurationTest() throws Exception { + configuration.setOrchestrationStatus(OrchestrationStatus.ACTIVE); + doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Configuration.class)); + aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration,OrchestrationStatus.ACTIVE); + verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.Configuration.class)); + assertEquals(OrchestrationStatus.ACTIVE, configuration.getOrchestrationStatus()); + } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java deleted file mode 100644 index a564d8a21d..0000000000 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/BaseClientTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.onap.so.client.sdnc; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -import java.util.Map; - -import javax.ws.rs.core.UriBuilder; - -import org.junit.Rule; -import org.junit.Test; -import org.springframework.core.ParameterizedTypeReference; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import wiremock.org.apache.http.entity.ContentType; -public class BaseClientTest { - - - @Rule - public WireMockRule wm = new WireMockRule(options().dynamicPort()); - - @Test - public void verifyString() { - BaseClient<String, String> client = new BaseClient<>(); - String response = "{\"hello\" : \"world\"}"; - client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(wm.port()).build().toString()); - wm.stubFor(get(urlEqualTo("/test")) - .willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString()))); - - String result = client.get("", new ParameterizedTypeReference<String>() {}); - assertThat(result, equalTo(response)); - } - - @Test - public void verifyMap() { - BaseClient<String, Map<String, Object>> client = new BaseClient<>(); - String response = "{\"hello\" : \"world\"}"; - client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(wm.port()).build().toString()); - wm.stubFor(get(urlEqualTo("/test")) - .willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString()))); - - Map<String, Object> result = client.get("", new ParameterizedTypeReference<Map<String, Object>>() {}); - assertThat("world", equalTo(result.get("hello"))); - } -} |