diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
23 files changed, 1093 insertions, 33 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java index deb8c8e393..7a58f6db6b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java @@ -30,6 +30,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.onap.so.bpmn.servicedecomposition.ShallowCopy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.db.catalog.beans.OrchestrationStatus; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; @@ -48,10 +49,14 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup> private String resourceVersion; @JsonProperty("instance-group-name") private String instanceGroupName; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus = OrchestrationStatus.PRECREATED; @JsonProperty("model-info-instance-group") private ModelInfoInstanceGroup modelInfoInstanceGroup; @JsonProperty("instance-group-function") private String instanceGroupFunction; + @JsonProperty("vnfs") + private List<GenericVnf> vnfs = new ArrayList<>(); public String getId() { return id; @@ -76,6 +81,12 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup> } public void setInstanceGroupName(String instanceGroupName) { this.instanceGroupName = instanceGroupName; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; } public ModelInfoInstanceGroup getModelInfoInstanceGroup() { return modelInfoInstanceGroup; @@ -89,6 +100,12 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup> public void setInstanceGroupFunction(String instanceGroupFunction) { this.instanceGroupFunction = instanceGroupFunction; } + public List<GenericVnf> getVnfs() { + return vnfs; + } + public void setVnfs(List<GenericVnf> vnfs) { + this.vnfs = vnfs; + } @Override public boolean equals(final Object other) { if (!(other instanceof InstanceGroup)) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java index 259a988262..e2a8688395 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java @@ -79,6 +79,8 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc private SolutionInfo solutionInfo; @JsonProperty("model-info-service-instance") private ModelInfoServiceInstance modelInfoServiceInstance; + @JsonProperty("instance-groups") + private List<InstanceGroup> instanceGroups = new ArrayList<>(); public List<GenericVnf> getVnfs() { return vnfs; @@ -191,6 +193,12 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc public void setSolutionInfo(SolutionInfo solutionInfo) { this.solutionInfo = solutionInfo; } + public List<InstanceGroup> getInstanceGroups() { + return instanceGroups; + } + public void setInstanceGroups(List<InstanceGroup> instanceGroups) { + this.instanceGroups = instanceGroups; + } @Override public boolean equals(final Object other) { if (!(other instanceof ServiceInstance)) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java new file mode 100644 index 0000000000..a23f85bae9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Tenant.java @@ -0,0 +1,58 @@ +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Tenant implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -8704478668505531590L; + @Id + @JsonProperty("tenant-id") + private String tenantId; + @JsonProperty("tenant-name") + private String tenantName; + @JsonProperty("tenant-context") + private String tenantContext; + + @Override + public boolean equals(final Object other) { + if (!(other instanceof Tenant)) { + return false; + } + Tenant castOther = (Tenant) other; + return new EqualsBuilder().append(tenantId, castOther.tenantId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(tenantId).toHashCode(); + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getTenantName() { + return tenantName; + } + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + public String getTenantContext() { + return tenantContext; + } + public void setTenantContext(String tenantContext) { + this.tenantContext = tenantContext; + } + + +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java index adea99c4f3..6d3be0f822 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java @@ -26,6 +26,7 @@ import java.util.Map; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -39,10 +40,20 @@ public class GeneralBuildingBlock implements Serializable { private OrchestrationContext orchContext; private Map<String, String> userInput; private CloudRegion cloudRegion; + private Tenant tenant; private Customer customer; private ServiceInstance serviceInstance; + + public Tenant getTenant() { + return tenant; + } + + public void setTenant(Tenant tenant) { + this.tenant = tenant; + } + public CloudRegion getCloudRegion() { return cloudRegion; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java index 433315b2ed..15dfe85c1a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java @@ -36,6 +36,7 @@ public class WorkflowResourceIds implements Serializable { private String vfModuleId; private String networkCollectionId; private String configurationId; + private String instanceGroupId; @Override public String toString() { @@ -100,4 +101,12 @@ public class WorkflowResourceIds implements Serializable { public void setConfigurationId(String configurationId) { this.configurationId = configurationId; } + + public String getInstanceGroupId() { + return instanceGroupId; + } + + public void setInstanceGroupId(String instanceGroupId) { + this.instanceGroupId = instanceGroupId; + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index fb3094665e..c80cd3d2a0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -49,6 +49,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; @@ -58,6 +59,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -224,6 +226,7 @@ public class BBInputSetup implements JavaDelegate { lookupKeyMap.put(ResourceKey.VF_MODULE_ID, workflowResourceIds.getVfModuleId()); lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, workflowResourceIds.getVolumeGroupId()); lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, workflowResourceIds.getConfigurationId()); + lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, workflowResourceIds.getInstanceGroupId()); } protected GeneralBuildingBlock getGBBALaCarteNonService(ExecuteBuildingBlock executeBB, @@ -243,7 +246,7 @@ public class BBInputSetup implements JavaDelegate { ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance); serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service)); this.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, - resourceId, vnfType); + resourceId, vnfType, executeBB.getBuildingBlock().getKey(), executeBB.getConfigurationResourceKeys()); return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); } else { logger.debug("Related Service Instance from AAI: {}", aaiServiceInstance); @@ -254,25 +257,59 @@ public class BBInputSetup implements JavaDelegate { protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, - String resourceId) throws Exception { + String resourceId) throws Exception { ServiceInstance serviceInstance = new ServiceInstance(); String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID); - serviceInstance.setServiceInstanceId(serviceInstanceId); - + serviceInstance.setServiceInstanceId(serviceInstanceId); + Customer customer = new Customer(); List<GenericVnf> genericVnfs = serviceInstance.getVnfs(); String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID); - org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); - - GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf); - genericVnfs.add(genericVnf); - - return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, new Customer()); + if(vnfId != null) { + org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); + GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf); + genericVnfs.add(genericVnf); + } + String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID); + if(instanceGroupId != null) { + org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId); + InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup); + instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); + + if(serviceInstanceId == null) { + Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId); + if(aaiServiceInstanceOpt.isPresent()) { + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiServiceInstanceOpt.get(); + serviceInstance = this.mapperLayer.mapAAIServiceInstanceIntoServiceInstance(aaiServiceInstance); + WorkflowResourceIds workflowResourceIds = executeBB.getWorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId()); + } else { + throw new NoServiceInstanceFoundException("Related ServiceInstance not found in A&AI."); + } + } + RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList(); + if (relatedInstanceList != null) { + for (RelatedInstanceList relatedInstList : relatedInstanceList) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { + org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(relatedInstance.getInstanceId()); + GenericVnf vnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiVnf); + instanceGroup.getVnfs().add(vnf); + } + } + } + + serviceInstance.getInstanceGroups().add(instanceGroup); + customer.setServiceSubscription(new ServiceSubscription()); + } + return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, customer); } protected void populateObjectsOnAssignAndCreateFlows(RequestDetails requestDetails, Service service, String bbName, - ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType) + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType, + String configurationKey, ConfigurationResourceKeys configurationResourceKeys) throws Exception { ModelInfo modelInfo = requestDetails.getModelInfo(); String instanceName = requestDetails.getRequestInfo().getInstanceName(); @@ -295,13 +332,36 @@ public class BBInputSetup implements JavaDelegate { this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); } else if (modelType.equals(ModelType.vfModule)) { - lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); - this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration()); + if(bbName.contains("Configuration")) { + ModelInfo configurationModelInfo = new ModelInfo(); + configurationModelInfo.setModelCustomizationUuid(configurationKey); + populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, + lookupKeyMap, resourceId, instanceName, configurationResourceKeys); + } else { + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); + this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration()); + } + } else if (modelType.equals(ModelType.instanceGroup)) { + lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, resourceId); + this.populateInstanceGroup(modelInfo, service, serviceInstance, resourceId, instanceName); } else { return; } } + + protected void populateInstanceGroup(ModelInfo modelInfo, Service service, ServiceInstance serviceInstance, String instanceGroupId, String instanceName) { + InstanceGroup instanceGroup = new InstanceGroup(); + instanceGroup.setId(instanceGroupId); + instanceGroup.setInstanceGroupName(instanceName); + mapCatalogInstanceGroup(instanceGroup, modelInfo, service); + serviceInstance.getInstanceGroups().add(instanceGroup); + } + + protected void mapCatalogInstanceGroup(InstanceGroup instanceGroup, ModelInfo modelInfo, Service service) { + // @TODO: this will populate the instanceGroup model info. + // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter to support VNF Groups + } protected void populateConfiguration(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String instanceName, ConfigurationResourceKeys configurationResourceKeys) { @@ -343,13 +403,19 @@ public class BBInputSetup implements JavaDelegate { if (configurationResourceCustomization != null && vnfVfmoduleCvnfcConfigurationCustomization != null) { configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization , vnfVfmoduleCvnfcConfigurationCustomization)); + } else { + logger.debug("for Fabric configuration mapping by VF MODULE CUST UUID: " + configurationResourceKeys.getVfModuleCustomizationUUID()); + vnfVfmoduleCvnfcConfigurationCustomization = findVnfVfmoduleCvnfcConfigurationCustomization(configurationResourceKeys.getVfModuleCustomizationUUID(), + configurationResourceKeys.getVnfResourceCustomizationUUID(), configurationResourceKeys.getCvnfcCustomizationUUID()); + if (vnfVfmoduleCvnfcConfigurationCustomization != null){ + configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(vnfVfmoduleCvnfcConfigurationCustomization)); + } } } protected VnfVfmoduleCvnfcConfigurationCustomization findVnfVfmoduleCvnfcConfigurationCustomization(String vfModuleCustomizationUUID, String vnfResourceCustomizationUUID, String cvnfcCustomizationUUID, ConfigurationResourceCustomization configurationResourceCustomization) { - - if(configurationResourceCustomization.getConfigurationResource() != null) + if(configurationResourceCustomization != null && configurationResourceCustomization.getConfigurationResource() != null) for(VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization : configurationResourceCustomization.getConfigurationResource().getVnfVfmoduleCvnfcConfigurationCustomization()) { if(vnfVfmoduleCvnfcConfigurationCustomization.getVfModuleCustomization().getModelCustomizationUUID().equalsIgnoreCase(vfModuleCustomizationUUID) @@ -369,6 +435,13 @@ public class BBInputSetup implements JavaDelegate { } return null; } + + protected VnfVfmoduleCvnfcConfigurationCustomization findVnfVfmoduleCvnfcConfigurationCustomization(String vnfResourceCustomizationUUID, + String vfModuleCustomizationUUID, String cvnfcCustomizationUUID) { + return bbInputSetupUtils.getVnfVfmoduleCvnfcConfigurationCustomizationByActionAndIsALaCarteAndRequestScopeAndCloudOwner(vnfResourceCustomizationUUID, + vfModuleCustomizationUUID, cvnfcCustomizationUUID); + + } protected void populateVfModule(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, @@ -831,7 +904,7 @@ public class BBInputSetup implements JavaDelegate { } protected GeneralBuildingBlock populateGBBWithSIAndAdditionalInfo(RequestDetails requestDetails, - ServiceInstance serviceInstance, ExecuteBuildingBlock executeBB, String requestAction, Customer customer) { + ServiceInstance serviceInstance, ExecuteBuildingBlock executeBB, String requestAction, Customer customer) throws Exception { GeneralBuildingBlock outputBB = new GeneralBuildingBlock(); OrchestrationContext orchContext = mapperLayer.mapOrchestrationContext(requestDetails); RequestContext requestContext = mapperLayer.mapRequestContext(requestDetails); @@ -840,9 +913,11 @@ public class BBInputSetup implements JavaDelegate { org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils .getCloudRegion(requestDetails.getCloudConfiguration()); CloudRegion cloudRegion = mapperLayer.mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion); + Tenant tenant = getTenant(requestDetails.getCloudConfiguration(), aaiCloudRegion); outputBB.setOrchContext(orchContext); outputBB.setRequestContext(requestContext); outputBB.setCloudRegion(cloudRegion); + outputBB.setTenant(tenant); if(customer == null){ Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId()); String globalCustomerId = uriKeys.get("global-customer-id"); @@ -857,6 +932,23 @@ public class BBInputSetup implements JavaDelegate { return outputBB; } + protected Tenant getTenant(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion) throws Exception { + Tenant tenant = new Tenant(); + if(cloudConfiguration != null && cloudConfiguration.getTenantId() != null + && aaiCloudRegion != null && aaiCloudRegion.getTenants() != null) { + for(org.onap.aai.domain.yang.Tenant aaiTenant : aaiCloudRegion.getTenants().getTenant()) { + if(aaiTenant.getTenantId().equalsIgnoreCase(cloudConfiguration.getTenantId())) { + tenant = mapperLayer.mapTenant(aaiTenant); + } + } + if(tenant.getTenantId() == null || tenant.getTenantName() == null) { + throw new Exception("Invalid tenant information retrieved: tenantId = " + tenant.getTenantId() + + " tenantName = " + tenant.getTenantName()); + } + } + return tenant; + } + protected ServiceSubscription getServiceSubscription(RequestDetails requestDetails, Customer customer) { org.onap.aai.domain.yang.ServiceSubscription aaiServiceSubscription = bbInputSetupUtils .getAAIServiceSubscription(customer.getGlobalCustomerId(), diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 108fd66488..fac2e9b8c3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -53,6 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; @@ -383,6 +384,14 @@ public class BBInputSetupMapperLayer { modelMapper.map(aaiCloudRegion, cloudRegion); return cloudRegion; } + + protected Tenant mapTenant(org.onap.aai.domain.yang.Tenant aaiTenant) { + Tenant tenant = new Tenant(); + if(aaiTenant != null) { + modelMapper.map(aaiTenant, tenant); + } + return tenant; + } protected Collection mapAAICollectionIntoCollection(org.onap.aai.domain.yang.Collection aaiCollection) { Collection collection = new Collection(); @@ -487,6 +496,16 @@ public class BBInputSetupMapperLayer { modelInfoConfiguration.setPolicyName(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName()); return modelInfoConfiguration; } + + protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration( + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization) { + ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); + modelInfoConfiguration.setModelVersionId(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationResource().getModelUUID()); + modelInfoConfiguration.setModelCustomizationId(vnfVfmoduleCvnfcConfigurationCustomization.getModelCustomizationUUID()); + modelInfoConfiguration.setModelInvariantId(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationResource().getModelInvariantUUID()); + modelInfoConfiguration.setPolicyName(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName()); + return modelInfoConfiguration; + } public NetworkResourceCustomization mapCollectionNetworkResourceCustToNetworkResourceCust( CollectionNetworkResourceCustomization collectionNetworkResourceCust) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index b3b4559f1d..a71c38f127 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -42,6 +42,8 @@ import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -53,6 +55,8 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -137,6 +141,16 @@ public class BBInputSetupUtils { return catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCustomizationId); } + public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) { + return catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelCustomizationUUID); + } + + public VnfVfmoduleCvnfcConfigurationCustomization getVnfVfmoduleCvnfcConfigurationCustomizationByActionAndIsALaCarteAndRequestScopeAndCloudOwner(String vnfCustomizationUuid, + String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) { + return catalogDbClient.getVnfVfmoduleCvnfcConfigurationCustomizationByVnfCustomizationUuidAndVfModuleCustomizationUuidAndCvnfcCustomizationUuid(vnfCustomizationUuid, + vfModuleCustomizationUuid, cvnfcCustomizationUuid); + } + public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroups(String modelCustomizationUUID) { return catalogDbClient.getVnfcInstanceGroupsByVnfResourceCust(modelCustomizationUUID); } @@ -173,7 +187,7 @@ public class BBInputSetupUtils { if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) { return injectionHelper.getAaiClient().get(CloudRegion.class, AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, - cloudRegionId)).orElse(null); + cloudRegionId).depth(Depth.TWO)).orElse(null); } else { return null; @@ -346,6 +360,26 @@ public class BBInputSetupUtils { } + public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId) throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId); + uri.relatedTo(AAIObjectPlurals.SERVICE_INSTANCE); + Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri); + ServiceInstance serviceInstance = null; + if (!serviceInstances.isPresent()) { + logger.debug("No ServiceInstances were found"); + return Optional.empty(); + } else { + if (serviceInstances.get().getServiceInstance().isEmpty()) { + throw new NoServiceInstanceFoundException("No ServiceInstances Returned"); + } else if (serviceInstances.get().getServiceInstance().size() > 1) { + throw new MultipleObjectsFoundException("Multiple ServiceInstances Returned"); + } else { + serviceInstance = serviceInstances.get().getServiceInstance().get(0); + } + return Optional.of(serviceInstance); + } + } + public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws Exception{ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); uri.relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java index 79f4a07974..d2d321f8f4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java @@ -90,6 +90,10 @@ public class ExtractPojosForBB { serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); result = lookupObjectInList(serviceInstance.getVpnBondingLinks(),value); break; + case INSTANCE_GROUP_ID: + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + result = lookupObjectInList(serviceInstance.getInstanceGroups(), value); + break; default: throw new BBObjectNotFoundException(key, value); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java new file mode 100644 index 0000000000..d63f98b6ce --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks.exceptions; + +public class MultipleObjectsFoundException extends Exception { + + private static final long serialVersionUID = -5045275644426587447L; + + public MultipleObjectsFoundException() { + super(); + } + + public MultipleObjectsFoundException(String message) { + super(message); + } + + public MultipleObjectsFoundException(String message, Throwable cause) { + super(message, cause); + } + + public MultipleObjectsFoundException(Throwable cause) { + super(cause); + } + + public MultipleObjectsFoundException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java new file mode 100644 index 0000000000..2ef1a80cce --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks.exceptions; + +public class NoServiceInstanceFoundException extends Exception { + + private static final long serialVersionUID = 3270499954054029908L; + + public NoServiceInstanceFoundException() { + super(); + } + + public NoServiceInstanceFoundException(String message) { + super(message); + } + + public NoServiceInstanceFoundException(String message, Throwable cause) { + super(message, cause); + } + + public NoServiceInstanceFoundException(Throwable cause) { + super(cause); + } + + public NoServiceInstanceFoundException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java index b8ab588a75..dfdef74886 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java @@ -24,6 +24,7 @@ public class CDSPropertiesImpl implements CDSProperties { private static final String ENDPOINT = "cds.endpoint"; private static final String PORT = "cds.port"; + private static final String AUTH = "cds.auth"; public CDSPropertiesImpl() { // Needed for service loader @@ -40,6 +41,11 @@ public class CDSPropertiesImpl implements CDSProperties { } @Override + public String getBasicAuth() { + return Objects.requireNonNull(UrnPropertiesReader.getVariable(AUTH)); + } + + @Override public URL getEndpoint() { return null; } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java index 634e0a6c9b..bc41b168ef 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java @@ -105,12 +105,18 @@ public class ExtractPojosForBBTest extends BaseTest{ allotedResourcePend.setId("abc"); allotedResourcesPend.add(allotedResourcePend); lookupKeyMap.put(ResourceKey.ALLOTTED_RESOURCE_ID, allotedResourcePend.getId()); - + Configuration configurationPend = new Configuration(); configurationPend.setConfigurationId("abc"); serviceInstancePend.getConfigurations().add(configurationPend); lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, configurationPend.getConfigurationId()); + List<InstanceGroup> instanceGroupsPend = serviceInstancePend.getInstanceGroups(); + InstanceGroup instanceGroupPend = new InstanceGroup(); + instanceGroupPend.setId("test-instance-group-1"); + instanceGroupsPend.add(instanceGroupPend); + lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupPend.getId()); + customer.getServiceSubscription().getServiceInstances().add(serviceInstancePend); gBBInput.setCustomer(customer); @@ -136,6 +142,9 @@ public class ExtractPojosForBBTest extends BaseTest{ VpnBondingLink extractVpnBondingLinkPend = extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID, "testVpnBondingLink"); assertEquals(extractVpnBondingLinkPend.getVpnBondingLinkId(), vpnBondingLinkPend.getVpnBondingLinkId()); + + InstanceGroup extractInstanceGroupPend = extractPojos.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID, "test-instance-group-1"); + assertEquals(instanceGroupPend.getId(), extractInstanceGroupPend.getId()); } @Test diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 3cb7b241dc..ff592f5603 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -50,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; @@ -604,6 +605,23 @@ public class BBInputSetupMapperLayerTest { assertThat(actual, sameBeanAs(expected)); } + + @Test + public void testMapTenant() { + Tenant expected = new Tenant(); + expected.setTenantId("tenantId"); + expected.setTenantName("tenantName"); + expected.setTenantContext("tenantContext"); + + org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant(); + aaiTenant.setTenantId("tenantId"); + aaiTenant.setTenantName("tenantName"); + aaiTenant.setTenantContext("tenantContext"); + + Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant); + + assertThat(actual, sameBeanAs(expected)); + } @Test public void testMapCloudRegionWithNullCheck() { @@ -641,6 +659,34 @@ public class BBInputSetupMapperLayerTest { } @Test + public void testmapCatalogConfigurationToFabricConfiguration() { + String modelCustUUID = "modelCustomizationUUID"; + String modelInvariantUUID = "modelInvariantUUID"; + String modelVersionUUID = "modelUUID"; + String policyName = "policyName"; + ModelInfoConfiguration expected = new ModelInfoConfiguration(); + expected.setModelCustomizationId(modelCustUUID); + expected.setModelInvariantId(modelInvariantUUID); + expected.setModelVersionId(modelVersionUUID); + expected.setPolicyName(policyName); + + VnfVfmoduleCvnfcConfigurationCustomization fabricCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + fabricCustomization.setCvnfcCustomization(new CvnfcCustomization()); + fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization()); + fabricCustomization.setPolicyName(policyName); + fabricCustomization.setModelCustomizationUUID(modelCustUUID); + + ConfigurationResource configurationResource = new ConfigurationResource(); + configurationResource.setModelUUID(modelVersionUUID); + configurationResource.setModelInvariantUUID(modelInvariantUUID); + fabricCustomization.setConfigurationResource(configurationResource); + + ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization); + + assertThat(actual, sameBeanAs(expected)); + } + + @Test public void testMapNameValueUserParams() throws IOException { RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class); Map<String,Object> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters()); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index cea8fc3cc2..4b10d513d6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -93,6 +93,7 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.ConfigurationResource; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; import org.onap.so.db.catalog.beans.InstanceGroupType; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; @@ -101,6 +102,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.serviceinstancebeans.CloudConfiguration; @@ -356,13 +358,61 @@ public class BBInputSetupTest { String resourceId = "123"; String requestAction = "createInstance"; - doReturn(null).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(ArgumentMatchers.isNull()); + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnf-001"); + + doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(SPY_bbInputSetupUtils).getAAIGenericVnf(ArgumentMatchers.isA(String.class)); + doReturn(null).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(ArgumentMatchers.isA(org.onap.aai.domain.yang.GenericVnf.class)); GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId); - assertThat(actual, sameBeanAs(expected)); } + + @Test + public void testGetGBBCMAddMembersAction() throws Exception { + GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockInstanceGroupExpected.json"), + GeneralBuildingBlock.class); + ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), + ExecuteBuildingBlock.class); + RequestDetails requestDetails = mapper.readValue( + new File(RESOURCE_PATH + "RequestDetailsInput_instanceGroupAddMembers.json"), RequestDetails.class); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + String requestAction = "addMembers"; + String instanceGroupId = "instance-group-001"; + + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setInstanceGroupId(instanceGroupId); + executeBB.setWorkflowResourceIds(workflowResourceIds); + + lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId); + + org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = new org.onap.aai.domain.yang.InstanceGroup(); + aaiInstanceGroup.setId(instanceGroupId); + aaiInstanceGroup.setInstanceGroupName("test instance group 1"); + + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); + aaiServiceInstance.setServiceInstanceId("service-instance-001"); + aaiServiceInstance.setServiceInstanceName("test service instance 1"); + Optional<org.onap.aai.domain.yang.ServiceInstance> optSI = Optional.of(aaiServiceInstance); + + org.onap.aai.domain.yang.GenericVnf vnf1 = new org.onap.aai.domain.yang.GenericVnf(); + vnf1.setVnfId("vnf-001"); + vnf1.setVnfName("test vnf 1"); + + org.onap.aai.domain.yang.GenericVnf vnf2 = new org.onap.aai.domain.yang.GenericVnf(); + vnf2.setVnfId("vnf-002"); + vnf2.setVnfName("test vnf 2"); + + doReturn(aaiInstanceGroup).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(instanceGroupId); + doReturn(optSI).when(SPY_bbInputSetupUtils).getRelatedServiceInstanceFromInstanceGroup(instanceGroupId); + doReturn(vnf1).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-001"); + doReturn(vnf2).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-002"); + + GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, + requestAction, instanceGroupId); + assertThat(actual, sameBeanAs(expected)); + } + @Test public void testGetGBBALaCarteNonService() throws Exception { GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), @@ -385,7 +435,7 @@ public class BBInputSetupTest { doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName", - serviceInstance, lookupKeyMap, resourceId, vnfType); + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null); doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); @@ -435,7 +485,7 @@ public class BBInputSetupTest { doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName", - serviceInstance, lookupKeyMap, resourceId, vnfType); + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null); doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, @@ -738,7 +788,7 @@ public class BBInputSetupTest { doReturn(ModelType.network).when(modelInfo).getModelType(); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, - lookupKeyMap, resourceId, vnfType); + lookupKeyMap, resourceId, vnfType, null, null); verify(SPY_bbInputSetup, times(1)).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); assertEquals("NetworkId populated", true, lookupKeyMap.get(ResourceKey.NETWORK_ID).equalsIgnoreCase(resourceId)); @@ -748,7 +798,7 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, - lookupKeyMap, resourceId, vnfType); + lookupKeyMap, resourceId, vnfType, null, null); verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId); assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId)); @@ -758,7 +808,7 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, - lookupKeyMap, resourceId, vnfType); + lookupKeyMap, resourceId, vnfType, null, null); verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId)); @@ -768,7 +818,7 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, - lookupKeyMap, resourceId, vnfType); + lookupKeyMap, resourceId, vnfType, null, null); verify(SPY_bbInputSetup, times(1)).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration); assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId)); @@ -787,7 +837,9 @@ public class BBInputSetupTest { ServiceInstance serviceInstance = mapper.readValue( new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"), ServiceInstance.class); - + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + cloudConfiguration.setTenantId("tenantId"); + requestDetails.setCloudConfiguration(cloudConfiguration); OrchestrationContext orchestrationContext = new OrchestrationContext(); orchestrationContext.setIsRollbackEnabled(false); @@ -808,17 +860,30 @@ public class BBInputSetupTest { customer.setSubscriberName("subscriberName"); customer.setSubscriberType("subscriberType"); customer.setServiceSubscription(serviceSubscription); + + org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant tenant = new org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant(); + tenant.setTenantContext("tenantContext"); + tenant.setTenantId("tenantId"); + tenant.setTenantName("tenantName"); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class); + org.onap.aai.domain.yang.Tenants aaiTenants = Mockito.mock(org.onap.aai.domain.yang.Tenants.class); + org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant(); + aaiTenant.setTenantId("tenantId"); + List<org.onap.aai.domain.yang.Tenant> tenants = new ArrayList<>(); + tenants.add(aaiTenant); String requestAction = "createInstance"; - + doReturn(uriKeys).when(SPY_bbInputSetupUtils).getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId()); doReturn(customer).when(SPY_bbInputSetup).mapCustomer(uriKeys.get("global-customer-id"),uriKeys.get("service-type")); doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(orchestrationContext).when(bbInputSetupMapperLayer).mapOrchestrationContext(requestDetails); doReturn(requestContext).when(bbInputSetupMapperLayer).mapRequestContext(requestDetails); doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion); + doReturn(tenant).when(bbInputSetupMapperLayer).mapTenant(aaiTenant); + doReturn(aaiTenants).when(aaiCloudRegion).getTenants(); + doReturn(tenants).when(aaiTenants).getTenant(); GeneralBuildingBlock actual = SPY_bbInputSetup.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); @@ -951,6 +1016,21 @@ public class BBInputSetupTest { } @Test + public void testPopulateInstanceGroup() throws Exception { + ModelInfo modelInfo = Mockito.mock(ModelInfo.class); + Service service = Mockito.mock(Service.class); + List<InstanceGroup> instanceGroups = Mockito.spy(new ArrayList<>()); + ServiceInstance serviceInstance = Mockito.spy(new ServiceInstance()); + serviceInstance.setServiceInstanceId("si-001"); + serviceInstance.setServiceInstanceName("test service instance"); + serviceInstance.setInstanceGroups(instanceGroups); + + SPY_bbInputSetup.populateInstanceGroup(modelInfo, service, serviceInstance, "instance-group-001", "test instance group"); + verify(SPY_bbInputSetup, times(1)).mapCatalogInstanceGroup(isA(InstanceGroup.class), isA(ModelInfo.class), isA(Service.class)); + verify(instanceGroups, times(1)).add(isA(InstanceGroup.class)); + } + + @Test public void testIsVlanTagging() throws Exception { boolean expected = true; Service service = Mockito.mock(Service.class); @@ -1171,6 +1251,43 @@ public class BBInputSetupTest { assertEquals(modelInfoNetwork, network.getModelInfoNetwork()); } + + @Test + public void testPopulateFabricConfiguration() throws JsonParseException, JsonMappingException, IOException { + String instanceName = "configurationName"; + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); + + ServiceInstance serviceInstance = new ServiceInstance(); + Configuration configuration = new Configuration(); + configuration.setConfigurationId("configurationId"); + configuration.setConfigurationName("configurationName"); + serviceInstance.getConfigurations().add(configuration); + String resourceId = "configurationId"; + // Mock service + Service service = mapper.readValue( + new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId"); + String bbName = AssignFlows.FABRIC_CONFIGURATION.toString(); + ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys(); + configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID"); + configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID"); + configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID"); + + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + ConfigurationResource configurationResource = new ConfigurationResource(); + configurationResource.setModelUUID("modelUUID"); + configurationResource.setModelInvariantUUID("modelInvariantUUID"); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource); + + doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service); + doReturn(vnfVfmoduleCvnfcConfigurationCustomization).when(SPY_bbInputSetup).findVnfVfmoduleCvnfcConfigurationCustomization("vfModuleCustomizationUUID","vnfResourceCustomizationUUID","cvnfcCustomizationUUID"); + + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys); + verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); + } @Test public void testPopulateGenericVnf() throws JsonParseException, JsonMappingException, IOException { @@ -1702,6 +1819,7 @@ public class BBInputSetupTest { String vfModuleId = "vfModuleId"; String volumeGroupId = "volumeGroupId"; String configurationId = "configurationId"; + String instanceGroupId = "instancegroupId"; expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId); expected.put(ResourceKey.NETWORK_ID, networkId); @@ -1709,6 +1827,7 @@ public class BBInputSetupTest { expected.put(ResourceKey.VF_MODULE_ID, vfModuleId); expected.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupId); expected.put(ResourceKey.CONFIGURATION_ID, configurationId); + expected.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId(serviceInstanceId); @@ -1717,7 +1836,8 @@ public class BBInputSetupTest { workflowResourceIds.setVfModuleId(vfModuleId); workflowResourceIds.setVolumeGroupId(volumeGroupId); workflowResourceIds.setConfigurationId(configurationId); - + workflowResourceIds.setInstanceGroupId(instanceGroupId); + SPY_bbInputSetup.populateLookupKeyMapWithIds(workflowResourceIds, actual); assertThat(actual, sameBeanAs(expected)); @@ -2587,4 +2707,4 @@ public class BBInputSetupTest { assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID)); } -} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index ae1af8f960..54e513e7d9 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -44,6 +44,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.CloudRegion; import org.onap.aai.domain.yang.Configuration; @@ -58,6 +59,8 @@ import org.onap.aai.domain.yang.VolumeGroups; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; @@ -181,10 +184,10 @@ public class BBInputSetupUtilsTest { expected.get().setCloudRegionId("lcpCloudRegionId"); doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.CloudRegion.class, AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), - cloudConfig.getLcpCloudRegionId())); + cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO)); AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), - cloudConfig.getLcpCloudRegionId()); + cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO); bbInputSetupUtils.getCloudRegion(cloudConfig); verify(MOCK_aaiResourcesClient, times(1)).get(CloudRegion.class, expectedUri); @@ -636,6 +639,41 @@ public class BBInputSetupUtilsTest { } @Test + public void getRelatedServiceInstanceFromInstanceGroupTest() throws Exception { + Optional<ServiceInstances> expected = Optional.of(new ServiceInstances()); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + serviceInstance.setServiceInstanceName("serviceInstanceName"); + expected.get().getServiceInstance().add(serviceInstance); + + doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class)); + Optional<ServiceInstance> actual = this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001"); + assertEquals(actual.get().getServiceInstanceId(), expected.get().getServiceInstance().get(0).getServiceInstanceId()); + } + + @Test + public void getRelatedServiceInstanceFromInstanceGroupMultipleTest() throws Exception { + expectedException.expect(MultipleObjectsFoundException.class); + Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances()); + ServiceInstance si1 = Mockito.mock(ServiceInstance.class); + ServiceInstance si2 = Mockito.mock(ServiceInstance.class); + serviceInstances.get().getServiceInstance().add(si1); + serviceInstances.get().getServiceInstance().add(si2); + + doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class)); + this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001"); + } + + @Test + public void getRelatedServiceInstanceFromInstanceGroupNotFoundTest() throws Exception { + expectedException.expect(NoServiceInstanceFoundException.class); + Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances()); + + doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class)); + this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001"); + } + + @Test public void getRelatedVnfByNameFromServiceInstanceTest() throws Exception { Optional<GenericVnfs> expected = Optional.of(new GenericVnfs()); GenericVnf vnf = new GenericVnf(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java new file mode 100644 index 0000000000..1cf70d050a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks.exceptions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; + +public class MultipleObjectsFoundExceptionTest { + private static final String MESSAGE = "message"; + private static final Throwable CAUSE = new Throwable(); + private MultipleObjectsFoundException MultipleObjectsFoundException; + + @Test + public void defaultConstructorTest() { + MultipleObjectsFoundException = new MultipleObjectsFoundException(); + assertEquals(null, MultipleObjectsFoundException.getMessage()); + assertEquals(null, MultipleObjectsFoundException.getCause()); + } + + @Test + public void messageConstructorTest() { + MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE); + assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage()); + assertEquals(null, MultipleObjectsFoundException.getCause()); + } + + @Test + public void causeConstructorTest() { + MultipleObjectsFoundException = new MultipleObjectsFoundException(CAUSE); + assertEquals(CAUSE.toString(), MultipleObjectsFoundException.getMessage()); + assertEquals(CAUSE, MultipleObjectsFoundException.getCause()); + } + + @Test + public void messageAndCauseConstructorTest() { + MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE); + assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage()); + assertEquals(CAUSE, MultipleObjectsFoundException.getCause()); + } + + @Test + public void messageAndCauseAndFlagsConstructorTest() { + MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE, true, true); + assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage()); + assertEquals(CAUSE, MultipleObjectsFoundException.getCause()); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java new file mode 100644 index 0000000000..344481dbed --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks.exceptions; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class NoServiceInstanceFoundExceptionTest { + private static final String MESSAGE = "message"; + private static final Throwable CAUSE = new Throwable(); + private NoServiceInstanceFoundException NoObjectFoundException; + + @Test + public void defaultConstructorTest() { + NoObjectFoundException = new NoServiceInstanceFoundException(); + assertEquals(null, NoObjectFoundException.getMessage()); + assertEquals(null, NoObjectFoundException.getCause()); + } + + @Test + public void messageConstructorTest() { + NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE); + assertEquals(MESSAGE, NoObjectFoundException.getMessage()); + assertEquals(null, NoObjectFoundException.getCause()); + } + + @Test + public void causeConstructorTest() { + NoObjectFoundException = new NoServiceInstanceFoundException(CAUSE); + assertEquals(CAUSE.toString(), NoObjectFoundException.getMessage()); + assertEquals(CAUSE, NoObjectFoundException.getCause()); + } + + @Test + public void messageAndCauseConstructorTest() { + NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE, CAUSE); + assertEquals(MESSAGE, NoObjectFoundException.getMessage()); + assertEquals(CAUSE, NoObjectFoundException.getCause()); + } + + @Test + public void messageAndCauseAndFlagsConstructorTest() { + NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE, CAUSE, true, true); + assertEquals(MESSAGE, NoObjectFoundException.getMessage()); + assertEquals(CAUSE, NoObjectFoundException.getCause()); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json index a53ed4dfde..fe33308d78 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json @@ -16,6 +16,8 @@ "cloudRegion": { "lcp-cloud-region-id" : "myRegionId", "cloud-owner": "CloudOwner" + }, + "tenant": { }, "userInput": null, "customer": { diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json index 5eb9a26901..b18cad0620 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json @@ -44,6 +44,11 @@ "tenant-id": "tenantId", "complex": "complexName" }, + "tenant": { + "tenant-name": "tenantName", + "tenant-context": "tenantContext", + "tenant-id": "tenantId" + }, "userInput": null, "customer": { "global-customer-id": "globalCustomerId", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json index 5ac07c6546..f07f060b06 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpectedWUserParamsInfo.json @@ -55,6 +55,11 @@ "complex": "complexName" }, "userInput": null, + "tenant": { + "tenant-id": "tenantId", + "tenant-name": "tenantName", + "tenant-context": "tenantContext" + }, "customer": { "global-customer-id": "globalCustomerId", "subscriber-name": "subscriberName", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json new file mode 100644 index 0000000000..f55717fc91 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockInstanceGroupExpected.json @@ -0,0 +1,323 @@ +{ + "requestContext": { + "product-family-id": null, + "source": "VID", + "requestor-id": "az2016", + "subscription-service-type": null, + "user-params": { + + }, + "action": "addMembers", + "callback-url": null, + "service-uri": null, + "mso-request-id": "requestId", + "requestParameters": { + + }, + "configurationParameters": [] + }, + "orchContext": { + "is-rollback-enabled": true + }, + "userInput": null, + "tenant": { + }, + "cloudRegion": { + "lcp-cloud-region-id": null, + "cloud-owner": null, + "tenant-id": null, + "complex": null, + "cloud-region-version": null + }, + "customer": { + "global-customer-id": null, + "subscriber-name": null, + "subscriber-type": null, + "subscriber-common-site-id": null, + "service-subscription": { + "service-type": null, + "temp-ub-sub-account-id": null, + "service-instances": [ + { + "service-instance-id": "service-instance-001", + "service-instance-name": "test service instance 1", + "orchestration-status": null, + "owning-entity": null, + "project": null, + "collection": null, + "vnfs": [], + "pnfs": [], + "allotted-resources": [], + "networks": [], + "vpn-bonding-links": [], + "vhn-portal-url": null, + "service-instance-location-id": null, + "selflink": null, + "metadata": null, + "configurations": [], + "solution-info": null, + "model-info-service-instance": null, + "instance-groups": [ + { + "id": "instance-group-001", + "description": null, + "resource-version": null, + "instance-group-name": "test instance group 1", + "orchestration-status": "INVENTORIED", + "model-info-instance-group": null, + "instance-group-function": null, + "vnfs": [ + { + "vnf-id": "vnf-001", + "vnf-name": "test vnf 1", + "vnf-type": null, + "orchestration-status": null, + "vf-modules": [], + "volume-groups": [], + "line-of-business": null, + "platform": null, + "cascaded": null, + "cloud-params": { + + }, + "cloud-context": null, + "solution": null, + "vnf-name-2": null, + "service-id": null, + "regional-resource-zone": null, + "prov-status": null, + "operational-status": null, + "equipment-role": null, + "management-option": null, + "ipv4-oam-address": null, + "ipv4-loopback0-address": null, + "nm-lan-v6-address": null, + "management-v6-address": null, + "vcpu": null, + "vcpu-units": null, + "vmemory": null, + "vmemory-units": null, + "vdisk": null, + "vdisk-units": null, + "in-maint": null, + "is-closed-loop-disabled": null, + "summary-status": null, + "encrypted-access-flag": null, + "as-number": null, + "regional-resource-subzone": null, + "self-link": null, + "ipv4-oam-gateway-address": null, + "ipv4-oam-gateway-address-prefix-length": null, + "vlan-id-outer": null, + "nm-profile-name": null, + "l-interfaces": [], + "lag-interfaces": [], + "license": null, + "entitlements": [], + "model-info-generic-vnf": null, + "instance-groups": [], + "call-homing": null, + "nf-function": null, + "nf-role": null + }, + { + "vnf-id": "vnf-002", + "vnf-name": "test vnf 2", + "vnf-type": null, + "orchestration-status": null, + "vf-modules": [], + "volume-groups": [], + "line-of-business": null, + "platform": null, + "cascaded": null, + "cloud-params": { + + }, + "cloud-context": null, + "solution": null, + "vnf-name-2": null, + "service-id": null, + "regional-resource-zone": null, + "prov-status": null, + "operational-status": null, + "equipment-role": null, + "management-option": null, + "ipv4-oam-address": null, + "ipv4-loopback0-address": null, + "nm-lan-v6-address": null, + "management-v6-address": null, + "vcpu": null, + "vcpu-units": null, + "vmemory": null, + "vmemory-units": null, + "vdisk": null, + "vdisk-units": null, + "in-maint": null, + "is-closed-loop-disabled": null, + "summary-status": null, + "encrypted-access-flag": null, + "as-number": null, + "regional-resource-subzone": null, + "self-link": null, + "ipv4-oam-gateway-address": null, + "ipv4-oam-gateway-address-prefix-length": null, + "vlan-id-outer": null, + "nm-profile-name": null, + "l-interfaces": [], + "lag-interfaces": [], + "license": null, + "entitlements": [], + "model-info-generic-vnf": null, + "instance-groups": [], + "call-homing": null, + "nf-function": null, + "nf-role": null + } + ] + } + ] + } + ] + }, + "vpn-bindings": [] + }, + "serviceInstance": { + "service-instance-id": "service-instance-001", + "service-instance-name": "test service instance 1", + "orchestration-status": null, + "owning-entity": null, + "project": null, + "collection": null, + "vnfs": [], + "pnfs": [], + "allotted-resources": [], + "networks": [], + "vpn-bonding-links": [], + "vhn-portal-url": null, + "service-instance-location-id": null, + "selflink": null, + "metadata": null, + "configurations": [], + "solution-info": null, + "model-info-service-instance": null, + "instance-groups": [ + { + "id": "instance-group-001", + "description": null, + "resource-version": null, + "instance-group-name": "test instance group 1", + "orchestration-status": "INVENTORIED", + "model-info-instance-group": null, + "instance-group-function": null, + "vnfs": [ + { + "vnf-id": "vnf-001", + "vnf-name": "test vnf 1", + "vnf-type": null, + "orchestration-status": null, + "vf-modules": [], + "volume-groups": [], + "line-of-business": null, + "platform": null, + "cascaded": null, + "cloud-params": { + + }, + "cloud-context": null, + "solution": null, + "vnf-name-2": null, + "service-id": null, + "regional-resource-zone": null, + "prov-status": null, + "operational-status": null, + "equipment-role": null, + "management-option": null, + "ipv4-oam-address": null, + "ipv4-loopback0-address": null, + "nm-lan-v6-address": null, + "management-v6-address": null, + "vcpu": null, + "vcpu-units": null, + "vmemory": null, + "vmemory-units": null, + "vdisk": null, + "vdisk-units": null, + "in-maint": null, + "is-closed-loop-disabled": null, + "summary-status": null, + "encrypted-access-flag": null, + "as-number": null, + "regional-resource-subzone": null, + "self-link": null, + "ipv4-oam-gateway-address": null, + "ipv4-oam-gateway-address-prefix-length": null, + "vlan-id-outer": null, + "nm-profile-name": null, + "l-interfaces": [], + "lag-interfaces": [], + "license": null, + "entitlements": [], + "model-info-generic-vnf": null, + "instance-groups": [], + "call-homing": null, + "nf-function": null, + "nf-role": null + }, + { + "vnf-id": "vnf-002", + "vnf-name": "test vnf 2", + "vnf-type": null, + "orchestration-status": null, + "vf-modules": [], + "volume-groups": [], + "line-of-business": null, + "platform": null, + "cascaded": null, + "cloud-params": { + + }, + "cloud-context": null, + "solution": null, + "vnf-name-2": null, + "service-id": null, + "regional-resource-zone": null, + "prov-status": null, + "operational-status": null, + "equipment-role": null, + "management-option": null, + "ipv4-oam-address": null, + "ipv4-loopback0-address": null, + "nm-lan-v6-address": null, + "management-v6-address": null, + "vcpu": null, + "vcpu-units": null, + "vmemory": null, + "vmemory-units": null, + "vdisk": null, + "vdisk-units": null, + "in-maint": null, + "is-closed-loop-disabled": null, + "summary-status": null, + "encrypted-access-flag": null, + "as-number": null, + "regional-resource-subzone": null, + "self-link": null, + "ipv4-oam-gateway-address": null, + "ipv4-oam-gateway-address-prefix-length": null, + "vlan-id-outer": null, + "nm-profile-name": null, + "l-interfaces": [], + "lag-interfaces": [], + "license": null, + "entitlements": [], + "model-info-generic-vnf": null, + "instance-groups": [], + "call-homing": null, + "nf-function": null, + "nf-role": null + } + ] + } + ] + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_instanceGroupAddMembers.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_instanceGroupAddMembers.json new file mode 100644 index 0000000000..96684b6680 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_instanceGroupAddMembers.json @@ -0,0 +1,27 @@ +{ + "requestInfo": { + "source": "VID", + "requestorId": "az2016" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "vnf-001", + "modelInfo": { + "modelType": "vnf" + } + } + }, + { + "relatedInstance": { + "instanceId": "vnf-002", + "modelInfo": { + "modelType": "vnf" + } + } + } + ], + "requestParameters": { + "userParams": [] + } +}
\ No newline at end of file |