diff options
17 files changed, 151 insertions, 306 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 6c92224909..ebc705ce30 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -545,11 +545,7 @@ public class ToscaResourceInstaller { if (serviceProxyResourceList != null) { for (NodeTemplate spNode : serviceProxyResourceList) { serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct); - - ServiceProxyResourceCustomization serviceProxyResource = findExistingServiceProxyResource(serviceProxyList, serviceProxy.getModelCustomizationUUID()); - - if(serviceProxyResource == null){ - + serviceProxyList.add(serviceProxy); for (NodeTemplate configNode : configurationNodeTemplatesList) { @@ -564,8 +560,6 @@ public class ToscaResourceInstaller { } } } - - } } } @@ -928,7 +922,12 @@ public class ToscaResourceInstaller { spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); spCustomizationResource.setModelInstanceName(nodeTemplate.getName()); spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); - spCustomizationResource.setSourceService(service); + + String sourceServiceUUID = spMetadata.getValue("sourceModelUuid"); + + Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID); + + spCustomizationResource.setSourceService(sourceService); spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); serviceProxyCustomizationSet.add(spCustomizationResource); @@ -1561,21 +1560,7 @@ public class ToscaResourceInstaller { return configResource; } - - protected ServiceProxyResourceCustomization findExistingServiceProxyResource(List<ServiceProxyResourceCustomization> serviceProxyList, String modelCustomizationUUID) { - ServiceProxyResourceCustomization serviceProxyResourceCustomization = null; - for(ServiceProxyResourceCustomization serviceProxyResourceCustom : serviceProxyList){ - if (serviceProxyResourceCustom != null - && serviceProxyResourceCustom.getModelCustomizationUUID().equals(modelCustomizationUUID)) { - serviceProxyResourceCustomization = serviceProxyResourceCustom; - } - } - if(serviceProxyResourceCustomization==null) - serviceProxyResourceCustomization = serviceProxyCustomizationRepo.findResourceByModelCustomizationUUID(modelCustomizationUUID); - return serviceProxyResourceCustomization; - } - protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource, String vfModuleModelCustomizationUUID) { VfModuleCustomization vfModuleCustomization = null; 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 63f832d706..ca0a78a3f2 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 @@ -107,6 +107,7 @@ public class BBInputSetup implements JavaDelegate { private static final String NETWORK = "Network"; private static final String VNF = "Vnf"; private static final String NETWORK_COLLECTION = "NetworkCollection"; + private static final String PREPROV = "PREPROV"; @Autowired private BBInputSetupUtils bbInputSetupUtils; @@ -273,10 +274,11 @@ public class BBInputSetup implements JavaDelegate { throws Exception { ModelInfo modelInfo = requestDetails.getModelInfo(); String instanceName = requestDetails.getRequestInfo().getInstanceName(); + String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId(); ModelType modelType = modelInfo.getModelType(); RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList(); - org.onap.so.serviceinstancebeans.Platform platform = requestDetails.getPlatform(); + org.onap.so.serviceinstancebeans.Platform platform = requestDetails.getPlatform(); org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = requestDetails.getLineOfBusiness(); if (modelType.equals(ModelType.network)) { @@ -285,7 +287,7 @@ public class BBInputSetup implements JavaDelegate { } else if (modelType.equals(ModelType.vnf)) { lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, resourceId); this.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, - lookupKeyMap, relatedInstanceList, resourceId, vnfType, null); + lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId); } else if (modelType.equals(ModelType.volumeGroup)) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, resourceId); this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, @@ -579,7 +581,8 @@ public class BBInputSetup implements JavaDelegate { org.onap.so.serviceinstancebeans.Platform platform, org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, - RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType, List<Map<String, String>> instanceParams) { + RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType, List<Map<String, String>> instanceParams, + String productFamilyId) { GenericVnf vnf = null; ModelInfo instanceGroupModelInfo = null; String instanceGroupId = null; @@ -607,7 +610,7 @@ public class BBInputSetup implements JavaDelegate { } if (vnf == null && bbName.equalsIgnoreCase(AssignFlows.VNF.toString())) { vnf = createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, - resourceId, generatedVnfType, instanceParams); + resourceId, generatedVnfType, instanceParams, productFamilyId); serviceInstance.getVnfs().add(vnf); mapVnfcCollectionInstanceGroup(vnf, modelInfo, service); } @@ -658,13 +661,16 @@ public class BBInputSetup implements JavaDelegate { protected GenericVnf createGenericVnf(Map<ResourceKey, String> lookupKeyMap, String instanceName, org.onap.so.serviceinstancebeans.Platform platform, - org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, String vnfId, String vnfType, List<Map<String, String>> instanceParams) { + org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, String vnfId, String vnfType, List<Map<String, String>> instanceParams, + String productFamilyId) { lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId); GenericVnf genericVnf = new GenericVnf(); genericVnf.setVnfId(vnfId); genericVnf.setVnfName(instanceName); genericVnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED); genericVnf.setVnfType(vnfType); + genericVnf.setProvStatus(PREPROV); + genericVnf.setServiceId(productFamilyId); if (platform != null) { genericVnf.setPlatform(this.mapperLayer.mapRequestPlatform(platform)); } @@ -1169,8 +1175,10 @@ public class BBInputSetup implements JavaDelegate { if (request != null) { this.bbInputSetupUtils.updateInfraActiveRequestVnfId(request, vnfId); } + String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId(); this.populateGenericVnf(vnfs.getModelInfo(), vnfs.getInstanceName(), vnfs.getPlatform(), - vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType, vnfs.getInstanceParams()); + vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType, vnfs.getInstanceParams(), + productFamilyId); } else if (bbName.contains(VF_MODULE) || bbName.contains(VOLUME_GROUP)) { Pair<Vnfs, VfModules> vnfsAndVfModules = getVfModulesAndItsVnfsByKey(key, resources); vfModules = vnfsAndVfModules.getValue1(); 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 7068629c90..35a7005751 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 @@ -711,11 +711,12 @@ public class BBInputSetupTest { String instanceName = "instanceName"; String vnfType = "vnfType"; String resourceId = "networkId"; + String productFamilyId = "productFamilyId"; Service service = Mockito.mock(Service.class); ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); RequestDetails requestDetails = Mockito.mock(RequestDetails.class); ModelInfo modelInfo = Mockito.mock(ModelInfo.class); - RequestInfo requestInfo = Mockito.mock(RequestInfo.class); + RequestInfo requestInfo = Mockito.mock(RequestInfo.class); RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[] {}; CloudConfiguration cloudConfiguration = new CloudConfiguration(); org.onap.so.serviceinstancebeans.Platform platform = Mockito @@ -727,13 +728,14 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); doReturn(modelInfo).when(requestDetails).getModelInfo(); + doReturn(productFamilyId).when(requestInfo).getProductFamilyId(); doReturn(requestInfo).when(requestDetails).getRequestInfo(); doReturn(instanceName).when(requestInfo).getInstanceName(); doReturn(platform).when(requestDetails).getPlatform(); doReturn(lineOfBusiness).when(requestDetails).getLineOfBusiness(); doReturn(relatedInstanceList).when(requestDetails).getRelatedInstanceList(); doReturn(cloudConfiguration).when(requestDetails).getCloudConfiguration(); - + doReturn(ModelType.network).when(modelInfo).getModelType(); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, resourceId, vnfType); @@ -744,11 +746,11 @@ public class BBInputSetupTest { doReturn(ModelType.vnf).when(modelInfo).getModelType(); resourceId = "vnfId"; doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, - service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null); + service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, resourceId, vnfType); verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, - service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null); + service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId); assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId)); doReturn(ModelType.volumeGroup).when(modelInfo).getModelType(); @@ -1208,26 +1210,29 @@ public class BBInputSetupTest { doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any()); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, - serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, - serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId()); verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, - resourceId, vnfType, null); + resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId()); doReturn(vnf2).when(SPY_bbInputSetup).createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, - resourceId, vnfType, null); + resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId()); doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); doNothing().when(SPY_bbInputSetup).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId2"); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, - serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId()); verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); @@ -1297,17 +1302,19 @@ public class BBInputSetupTest { doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any()); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, - serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, - serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId()); verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, - resourceId, vnfType, null); + resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId()); org.onap.aai.domain.yang.GenericVnf vnf2AAI = new org.onap.aai.domain.yang.GenericVnf(); vnfAAI.setModelCustomizationId("modelCustId2"); @@ -1315,7 +1322,8 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service); doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, - serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null); + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId()); verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); @@ -1768,7 +1776,7 @@ public class BBInputSetupTest { verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), - isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any()); + isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), any(String.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); @@ -1943,7 +1951,7 @@ public class BBInputSetupTest { verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), - isA(ServiceInstance.class), any(),ArgumentMatchers.isNull(), any(String.class), ArgumentMatchers.isNull(), any()); + isA(ServiceInstance.class), any(),ArgumentMatchers.isNull(), any(String.class), ArgumentMatchers.isNull(), any(), any(String.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); @@ -2006,7 +2014,8 @@ public class BBInputSetupTest { verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), - isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any()); + isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), + any(String.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); @@ -2456,6 +2465,7 @@ public class BBInputSetupTest { String vnfType = "vnfType"; String platformName = "platformName"; String lineOfBusinessName = "lineOfBusinessName"; + String productFamilyId = "productFamilyId"; Platform platform = new Platform(); platform.setPlatformName(platformName); LineOfBusiness lineOfBusiness = new LineOfBusiness(); @@ -2470,6 +2480,8 @@ public class BBInputSetupTest { expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED); expected.setPlatform(platform); expected.setLineOfBusiness(lineOfBusiness); + expected.setProvStatus("PREPROV"); + expected.setServiceId(productFamilyId); Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); List<Map<String, String>> instanceParams = new ArrayList<>(); instanceParams.add(cloudParams); @@ -2481,13 +2493,14 @@ public class BBInputSetupTest { doReturn(platform).when(bbInputSetupMapperLayer).mapRequestPlatform(requestPlatform); doReturn(lineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(requestLineOfBusiness); - GenericVnf actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, instanceParams); + GenericVnf actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, instanceParams, + productFamilyId); assertThat(actual, sameBeanAs(expected)); assertEquals("LookupKeyMap is populated", vnfId, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); expected.getCloudParams().clear(); - actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, null); + actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, null, productFamilyId); assertThat(actual, sameBeanAs(expected)); } 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 bff320a0b6..0c0e1464b2 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 @@ -321,12 +321,13 @@ public class WorkflowAction { if (flowsToExecute.isEmpty()) { throw new IllegalStateException("Macro did not come up with a valid execution path."); } - + List<String> flowNames = new ArrayList<>(); logger.info("List of BuildingBlocks to execute:"); for (ExecuteBuildingBlock ebb : flowsToExecute) { logger.info(ebb.getBuildingBlock().getBpmnFlowName()); + flowNames.add(ebb.getBuildingBlock().getBpmnFlowName()); } - + execution.setVariable("flowNames", flowNames); execution.setVariable(G_CURRENT_SEQUENCE, 0); execution.setVariable("retryCount", 0); execution.setVariable("isRollback", false); diff --git a/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java b/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java deleted file mode 100644 index 02d8d56867..0000000000 --- a/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java +++ /dev/null @@ -1,159 +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.aai.objects; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"operational-environment-id", -"operational-environment-name", -"operational-environment-type", -"operational-environment-status", -"tenant-context", -"workload-context", -"resource-version" -}) -public class AAIOperationalEnvironment { - -@JsonProperty("operational-environment-id") -private String operationalEnvironmentId; -@JsonProperty("operational-environment-name") -private String operationalEnvironmentName; -@JsonProperty("operational-environment-type") -private String operationalEnvironmentType; -@JsonProperty("operational-environment-status") -private String operationalEnvironmentStatus; -@JsonProperty("tenant-context") -private String tenantContext; -@JsonProperty("workload-context") -private String workloadContext; -@JsonProperty("resource-version") -private String resourceVersion; - -@JsonProperty("operational-environment-id") -public String getOperationalEnvironmentId() { -return operationalEnvironmentId; - } - -@JsonProperty("operational-environment-id") -public void setOperationalEnvironmentId(String operationalEnvironmentId) { -this.operationalEnvironmentId = operationalEnvironmentId; - } - -public AAIOperationalEnvironment withOperationalEnvironmentId(String operationalEnvironmentId) { -this.operationalEnvironmentId = operationalEnvironmentId; -return this; - } - -@JsonProperty("operational-environment-name") -public String getOperationalEnvironmentName() { -return operationalEnvironmentName; - } - -@JsonProperty("operational-environment-name") -public void setOperationalEnvironmentName(String operationalEnvironmentName) { -this.operationalEnvironmentName = operationalEnvironmentName; - } - -public AAIOperationalEnvironment withOperationalEnvironmentName(String operationalEnvironmentName) { -this.operationalEnvironmentName = operationalEnvironmentName; -return this; - } - -@JsonProperty("operational-environment-type") -public String getOperationalEnvironmentType() { -return operationalEnvironmentType; - } - -@JsonProperty("operational-environment-type") -public void setOperationalEnvironmentType(String operationalEnvironmentType) { -this.operationalEnvironmentType = operationalEnvironmentType; - } - -public AAIOperationalEnvironment withOperationalEnvironmentType(String operationalEnvironmentType) { -this.operationalEnvironmentType = operationalEnvironmentType; -return this; - } - -@JsonProperty("operational-environment-status") -public String getOperationalEnvironmentStatus() { -return operationalEnvironmentStatus; - } - -@JsonProperty("operational-environment-status") -public void setOperationalEnvironmentStatus(String operationalEnvironmentStatus) { -this.operationalEnvironmentStatus = operationalEnvironmentStatus; - } - -public AAIOperationalEnvironment withOperationalEnvironmentStatus(String operationalEnvironmentStatus) { -this.operationalEnvironmentStatus = operationalEnvironmentStatus; -return this; - } - -@JsonProperty("tenant-context") -public String getTenantContext() { -return tenantContext; - } - -@JsonProperty("tenant-context") -public void setTenantContext(String tenantContext) { -this.tenantContext = tenantContext; - } - -public AAIOperationalEnvironment withTenantContext(String tenantContext) { -this.tenantContext = tenantContext; -return this; - } - -@JsonProperty("workload-context") -public String getWorkloadContext() { -return workloadContext; - } - -@JsonProperty("workload-context") -public void setWorkloadContext(String workloadContext) { -this.workloadContext = workloadContext; - } - -public AAIOperationalEnvironment withWorkloadContext(String workloadContext) { -this.workloadContext = workloadContext; -return this; - } - -@JsonProperty("resource-version") -public String getResourceVersion() { -return resourceVersion; - } - -@JsonProperty("resource-version") -public void setResourceVersion(String resourceVersion) { -this.resourceVersion = resourceVersion; - } - -public AAIOperationalEnvironment withResourceVersion(String resourceVersion) { -this.resourceVersion = resourceVersion; -return this; - } - -} diff --git a/common/src/test/java/org/onap/so/BeansTest.java b/common/src/test/java/org/onap/so/BeansTest.java index 2e825cf8c7..54cbced563 100644 --- a/common/src/test/java/org/onap/so/BeansTest.java +++ b/common/src/test/java/org/onap/so/BeansTest.java @@ -63,7 +63,6 @@ public class BeansTest { @Test public void pojoStructure() { - test("org.onap.so.client.aai.objects"); test("org.onap.so.client.policy.entities"); test("org.onap.so.client.grm.beans"); test("org.onap.so.client.ruby.beans"); diff --git a/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java b/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java deleted file mode 100644 index e2a3cbd6bd..0000000000 --- a/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* -* ============LICENSE_START======================================================= - * ONAP : SO - * ================================================================================ - * Copyright (C) 2018 TechMahindra - * ================================================================================ - * 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.aai.objects; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class AAIOperationalEnvironmentTest { - - AAIOperationalEnvironment aaiOE =new AAIOperationalEnvironment(); - - @Test - public void test() { - aaiOE.setOperationalEnvironmentId("operationalEnvironmentId"); - aaiOE.setOperationalEnvironmentName("operationalEnvironmentName"); - aaiOE.setOperationalEnvironmentStatus("operationalEnvironmentStatus"); - aaiOE.setOperationalEnvironmentType("operationalEnvironmentType"); - aaiOE.setResourceVersion("resourceVersion"); - aaiOE.setTenantContext("tenantContext"); - aaiOE.setWorkloadContext("workloadContext"); - assertEquals(aaiOE.getOperationalEnvironmentId(),"operationalEnvironmentId"); - assertEquals(aaiOE.getOperationalEnvironmentName(),"operationalEnvironmentName"); - assertEquals(aaiOE.getOperationalEnvironmentStatus(),"operationalEnvironmentStatus"); - assertEquals(aaiOE.getOperationalEnvironmentType(),"operationalEnvironmentType"); - assertEquals(aaiOE.getResourceVersion(),"resourceVersion"); - assertEquals(aaiOE.getTenantContext(),"tenantContext"); - assertEquals(aaiOE.getWorkloadContext(),"workloadContext"); - aaiOE.withOperationalEnvironmentId("operationalEnvironmentId"); - aaiOE.withOperationalEnvironmentName("operationalEnvironmentName"); - aaiOE.withOperationalEnvironmentStatus("operationalEnvironmentStatus"); - aaiOE.withOperationalEnvironmentType("operationalEnvironmentType"); - aaiOE.withResourceVersion("resourceVersion"); - aaiOE.withTenantContext("tenantContext"); - aaiOE.withWorkloadContext("workloadContext"); - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java index 6fd33a6afc..6a5de77c73 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java @@ -26,6 +26,7 @@ import java.util.Map; import javax.ws.rs.NotFoundException; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; @@ -33,7 +34,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.logger.MsoLogger; import org.springframework.stereotype.Component; @@ -51,7 +51,7 @@ public class AAIClientHelper { public AAIResultWrapper getAaiOperationalEnvironment(String id){ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); - uri.depth(Depth.ZERO); //Do not return relationships if any + uri.depth(Depth.ZERO); AAIResourcesClient client = this.getClient(); return client.get(uri, NotFoundException.class); } @@ -62,7 +62,7 @@ public class AAIClientHelper { * @param id = operationalEnvironmentId * @param AAIOperationalEnvironment object */ - public void updateAaiOperationalEnvironment(String id, AAIOperationalEnvironment aaiRequest){ + public void updateAaiOperationalEnvironment(String id, OperationalEnvironment aaiRequest){ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); AAIResourcesClient client = this.getClient(); @@ -87,7 +87,7 @@ public class AAIClientHelper { * Create an Operational Environment object in A&AI * @param AAIOperationalEnvironment object */ - public void createOperationalEnvironment(AAIOperationalEnvironment operationalEnvironment){ + public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment){ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironment.getOperationalEnvironmentId()); AAIResourcesClient client = this.getClient(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java index 23642bdfb4..dc6019c9cb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java @@ -20,15 +20,15 @@ package org.onap.so.apihandlerinfra.tenantisolation.helpers; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.springframework.stereotype.Component; @Component public class AAIClientObjectBuilder { - public AAIOperationalEnvironment buildAAIOperationalEnvironment(String status, CloudOrchestrationRequest cloudOrchestrationRequest) { - AAIOperationalEnvironment env = new AAIOperationalEnvironment(); + public OperationalEnvironment buildAAIOperationalEnvironment(String status, CloudOrchestrationRequest cloudOrchestrationRequest) { + OperationalEnvironment env = new OperationalEnvironment(); env.setOperationalEnvironmentId(cloudOrchestrationRequest.getOperationalEnvironmentId()); env.setOperationalEnvironmentName(cloudOrchestrationRequest.getRequestDetails().getRequestInfo().getInstanceName()); env.setOperationalEnvironmentType(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index ac9a000d3b..1d2a445c40 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -21,11 +21,16 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import java.util.List; +import java.util.Optional; import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.json.JSONObject; +import org.onap.aai.domain.yang.OperationalEnvironment; +import org.onap.aai.domain.yang.RelationshipList; +import org.onap.aai.domain.yang.Relationship; +import org.onap.aai.domain.yang.RelationshipData; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.apihandlerinfra.exceptions.ApiException; @@ -36,8 +41,10 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; +import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; +import org.onap.so.client.aai.entities.Relationships; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; import org.onap.so.logger.MessageEnum; @@ -54,6 +61,7 @@ public class ActivateVnfOperationalEnvironment { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class); private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; private static final String DISTRIBUTION_STATUS_SENT = "SENT"; + private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id"; @Autowired private ActivateVnfDBHelper dbHelper; @@ -77,24 +85,39 @@ public class ActivateVnfOperationalEnvironment { * @return void - nothing */ public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{ - String operationalEnvironmentId = request.getOperationalEnvironmentId(); + String vnfOperationalEnvironmentId = request.getOperationalEnvironmentId(); String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext(); List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList(); - + + String ecompOperationalEnvironmentId = null; + AAIResultWrapper wrapper = getAAIOperationalEnvironment(vnfOperationalEnvironmentId); + Optional<Relationships> optRelationships = wrapper.getRelationships(); + if (optRelationships.isPresent()) { + Relationships relationships = optRelationships.get(); + List<AAIResourceUri> operationalEnvironments = relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT); + if (!operationalEnvironments.isEmpty()) { + ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY); + } + } + msoLogger.debug(" vnfOperationalEnvironmentId : " + vnfOperationalEnvironmentId); + msoLogger.debug(" ecompOperationalEnvironmentId : " + ecompOperationalEnvironmentId); - AAIOperationalEnvironment operationalEnv = getAAIOperationalEnvironment(operationalEnvironmentId); + OperationalEnvironment operationalEnv = wrapper.asBean(OperationalEnvironment.class).get(); String workloadContext = operationalEnv.getWorkloadContext(); msoLogger.debug(" aai workloadContext: " + workloadContext); if (!vidWorkloadContext.equals(workloadContext)) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build(); throw new ValidateException.Builder(" The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); } + if (ecompOperationalEnvironmentId==null) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build(); + throw new ValidateException.Builder(" The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " + OPER_ENVIRONMENT_ID_KEY, + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + } - processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext); + processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext); } @@ -171,9 +194,8 @@ public class ActivateVnfOperationalEnvironment { * @param operationalEnvironmentId - String * @return operationalEnv - AAIOperationalEnvironment object */ - public AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { - AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); - return aaiResult.asBean(AAIOperationalEnvironment.class).orElse(new AAIOperationalEnvironment()); + public AAIResultWrapper getAAIOperationalEnvironment(String operationalEnvironmentId) { + return aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java index e95db6b188..36226aae68 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java @@ -27,6 +27,7 @@ import javax.ws.rs.NotFoundException; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; @@ -37,7 +38,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder; import org.onap.so.apihandlerinfra.tenantisolationbeans.RelatedInstanceList; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.client.grm.GRMClient; import org.onap.so.client.grm.beans.OperationalInfo; import org.onap.so.client.grm.beans.Property; @@ -75,7 +75,7 @@ public class CreateVnfOperationalEnvironment { if (aaiResultWrapper.isEmpty()) { throw new NotFoundException(getEcompManagingEnvironmentId() + " not found in A&AI"); } - AAIOperationalEnvironment aaiEnv = objectMapper.readValue(aaiResultWrapper.getJson(), AAIOperationalEnvironment.class); + OperationalEnvironment aaiEnv = aaiResultWrapper.asBean(OperationalEnvironment.class).get(); //Find ECOMP environments in GRM msoLogger.debug(" Start of GRM findRunningServicesAsString"); @@ -209,7 +209,7 @@ public class CreateVnfOperationalEnvironment { return tenantContext + "." + workloadContext + "." + serviceName; } - protected String getSearchKey(AAIOperationalEnvironment aaiEnv) { + protected String getSearchKey(OperationalEnvironment aaiEnv) { return aaiEnv.getTenantContext() + "." + aaiEnv.getWorkloadContext() + ".*"; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java index 2096011caa..977184e2c5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java @@ -24,6 +24,7 @@ import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; @@ -31,7 +32,6 @@ import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; @@ -51,7 +51,7 @@ public class DeactivateVnfOperationalEnvironment { public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { String operationalEnvironmentId = request.getOperationalEnvironmentId(); - AAIOperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId); + OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId); if (aaiOpEnv != null) { String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus(); @@ -81,9 +81,9 @@ public class DeactivateVnfOperationalEnvironment { } } - private AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { + private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); - Optional<AAIOperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(AAIOperationalEnvironment.class); + Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class); return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java index 0a57b4f245..b799394b7a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelperTest.java @@ -41,10 +41,10 @@ import java.util.Optional; import org.apache.http.HttpStatus; import org.junit.Test; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.client.aai.AAIVersion; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.springframework.beans.factory.annotation.Autowired; @@ -60,7 +60,7 @@ public class AAIClientHelperTest extends BaseTest{ .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001"); - Optional<AAIOperationalEnvironment> aaiOpEnv = wrapper.asBean(AAIOperationalEnvironment.class); + Optional<OperationalEnvironment> aaiOpEnv = wrapper.asBean(OperationalEnvironment.class); assertEquals("EMOE-001", aaiOpEnv.get().getOperationalEnvironmentId()); } @@ -69,13 +69,13 @@ public class AAIClientHelperTest extends BaseTest{ stubFor(post(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); - AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment(); + OperationalEnvironment ecompEnv = new OperationalEnvironment(); ecompEnv.setTenantContext("Test"); ecompEnv.setWorkloadContext("ECOMPL_PSL"); try { AAIClientHelper clientHelper = mock(AAIClientHelper.class); - doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class), any(AAIOperationalEnvironment.class)); + doNothing().when(clientHelper).updateAaiOperationalEnvironment(any(String.class), any(OperationalEnvironment.class)); clientHelper.updateAaiOperationalEnvironment("EMOE-001", ecompEnv); verify(clientHelper, times(1)).updateAaiOperationalEnvironment("EMOE-001", ecompEnv); @@ -109,14 +109,14 @@ public class AAIClientHelperTest extends BaseTest{ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); - AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment(); + OperationalEnvironment ecompEnv = new OperationalEnvironment(); ecompEnv.setOperationalEnvironmentId("opeEvnId"); ecompEnv.setTenantContext("Test"); ecompEnv.setWorkloadContext("ECOMPL_PSL"); try { AAIClientHelper clientHelper = mock(AAIClientHelper.class); - doNothing().when(clientHelper).createOperationalEnvironment(any(AAIOperationalEnvironment.class)); + doNothing().when(clientHelper).createOperationalEnvironment(any(OperationalEnvironment.class)); clientHelper.createOperationalEnvironment(ecompEnv); verify(clientHelper, times(1)).createOperationalEnvironment(ecompEnv); @@ -130,7 +130,7 @@ public class AAIClientHelperTest extends BaseTest{ stubFor(put(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED))); - AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment(); + OperationalEnvironment ecompEnv = new OperationalEnvironment(); ecompEnv.setTenantContext("Test"); ecompEnv.setWorkloadContext("ECOMPL_PSL"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java index cf6facc59f..3915fc8928 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilderTest.java @@ -35,7 +35,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class AAIClientObjectBuilderTest extends BaseTest{ - private String expectedAAIObject = "{\"operational-environment-name\":\"TEST_ECOMP_ENVIRONMENT\",\"operational-environment-type\":\"ECOMP\",\"operational-environment-status\":\"Active\",\"tenant-context\":\"TEST\",\"workload-context\":\"ECOMP_TEST\"}"; private CloudOrchestrationRequest request; private ObjectMapper mapper = new ObjectMapper(); @@ -62,8 +61,12 @@ public class AAIClientObjectBuilderTest extends BaseTest{ @Test public void testGetAaiClientObjectBuilder() throws Exception { AAIClientObjectBuilder builder = new AAIClientObjectBuilder(); - assertEquals(expectedAAIObject, mapper.writeValueAsString(builder.buildAAIOperationalEnvironment("Active", request))); + org.onap.aai.domain.yang.OperationalEnvironment operEnv = builder.buildAAIOperationalEnvironment("Active", request); + assertEquals("TEST", operEnv.getTenantContext()); + assertEquals("ECOMP_TEST", operEnv.getWorkloadContext()); + assertEquals("TEST_ECOMP_ENVIRONMENT", operEnv.getOperationalEnvironmentName()); + assertEquals(OperationalEnvironment.ECOMP.toString(), operEnv.getOperationalEnvironmentType()); } - - + + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java index c36eb2b063..18af7fbaa0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironmentTest.java @@ -42,6 +42,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; @@ -54,7 +55,6 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RecoveryAction; import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest; import org.onap.so.client.aai.AAIVersion; import org.onap.so.client.aai.entities.AAIResultWrapper; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.beans.factory.annotation.Autowired; @@ -99,16 +99,17 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ @Test public void getAAIOperationalEnvironmentTest() { - AAIOperationalEnvironment aaiOpEnv; + OperationalEnvironment aaiOpEnv; stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED))); AAIResultWrapper wrapper = clientHelper.getAaiOperationalEnvironment("EMOE-001"); - aaiOpEnv = wrapper.asBean(AAIOperationalEnvironment.class).get(); + aaiOpEnv = wrapper.asBean(OperationalEnvironment.class).get(); assertEquals("EMOE-001", aaiOpEnv.getOperationalEnvironmentId()); + assertEquals("1dfe7154-eae0-44f2-8e7a-8e5e7882e55d", aaiOpEnv.getRelationshipList().getRelationship().get(0).getRelationshipData().get(0).getRelationshipValue()); assertNotNull(activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId)); - assertEquals( "EMOE-001", activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId).getOperationalEnvironmentId()); + assertEquals( "EMOE-001", activateVnf.getAAIOperationalEnvironment(operationalEnvironmentId).asBean(OperationalEnvironment.class).get().getOperationalEnvironmentId()); } @@ -138,7 +139,7 @@ public class ActivateVnfOperationalEnvironmentTest extends BaseTest{ jsonObject.put("distributionId", sdcDistributionId); stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironment.json").withStatus(HttpStatus.SC_ACCEPTED))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/ecompOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED))); stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED))); activateVnf.execute(requestId, request); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java index 100bc82f7a..ac274dc8dc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironmentTest.java @@ -32,11 +32,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; +import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest; import org.onap.so.client.aai.AAIVersion; -import org.onap.so.client.aai.objects.AAIOperationalEnvironment; import org.onap.so.client.grm.beans.Property; import org.onap.so.client.grm.beans.ServiceEndPointList; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -102,7 +102,7 @@ public class CreateVnfOperationalEnvironmentTest extends BaseTest{ @Test public void testGetSearchKey() { createVnfOpEnv.setRequest(request); - AAIOperationalEnvironment ecompEnv = new AAIOperationalEnvironment(); + OperationalEnvironment ecompEnv = new OperationalEnvironment(); ecompEnv.setTenantContext("Test"); ecompEnv.setWorkloadContext("ECOMPL_PSL"); assertEquals("Test.ECOMPL_PSL.*", createVnfOpEnv.getSearchKey(ecompEnv)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/vnfoperenv/ecompOperationalEnvironmentWithRelationship.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/vnfoperenv/ecompOperationalEnvironmentWithRelationship.json new file mode 100644 index 0000000000..0a34cb385e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/vnfoperenv/ecompOperationalEnvironmentWithRelationship.json @@ -0,0 +1,27 @@ +{ + "operational-environment-id": "EMOE-001", + "operational-environment-name": "Test Managing ECOMP Environment", + "operational-environment-type": "ECOMP", + "operational-environment-status": "ACTIVE", + "tenant-context": "Test", + "workload-context": "PVT", + "resource-version": "1505228226913", + "relationship-list": { + "relationship": [{ + "related-to": "operational-environment", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v13/cloud-infrastructure/operational-environments/operational-environment/1dfe7154-eae0-44f2-8e7a-8e5e7882e55d", + "relationship-data": [{ + "relationship-key": "operational-environment.operational-environment-id", + "relationship-value": "1dfe7154-eae0-44f2-8e7a-8e5e7882e55d" + } + ], + "related-to-property": [{ + "property-key": "operational-environment.operational-environment-name", + "property-value": "myOpEnv_IST_un577h_0119" + } + ] + } + ] + } +}
\ No newline at end of file |