From 781b1a6df324419c846c84ea983c18fc8362bfd3 Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Wed, 13 Dec 2017 11:19:06 -0800 Subject: Third part of onap rename This part of the commit changes the folder structure on all other folders of appc. Change-Id: I8acfa11cdfcdcd36be0e137245d1dd7324f1abd3 Signed-off-by: Patrick Brady Issue-ID: APPC-13 --- .../main/java/org/onap/appc/dg/aai/AAIPlugin.java | 46 ++ .../appc/dg/aai/exception/AAIQueryException.java | 32 ++ .../org/onap/appc/dg/aai/impl/AAIPluginImpl.java | 401 +++++++++++++++ .../java/org/onap/appc/dg/aai/impl/Constants.java | 120 +++++ .../onap/appc/dg/aai/objects/AAIQueryResult.java | 52 ++ .../org/onap/appc/dg/aai/objects/Relationship.java | 69 +++ .../java/org/openecomp/appc/dg/aai/AAIPlugin.java | 46 -- .../appc/dg/aai/exception/AAIQueryException.java | 32 -- .../openecomp/appc/dg/aai/impl/AAIPluginImpl.java | 401 --------------- .../org/openecomp/appc/dg/aai/impl/Constants.java | 120 ----- .../appc/dg/aai/objects/AAIQueryResult.java | 52 -- .../appc/dg/aai/objects/Relationship.java | 69 --- .../org/onap/appc/dg/aai/impl/AAIClientMock.java | 547 +++++++++++++++++++++ .../onap/appc/dg/aai/impl/AAIPluginImplTest.java | 259 ++++++++++ .../openecomp/appc/dg/aai/impl/AAIClientMock.java | 547 --------------------- .../appc/dg/aai/impl/AAIPluginImplTest.java | 259 ---------- 16 files changed, 1526 insertions(+), 1526 deletions(-) create mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/AAIPlugin.java create mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/exception/AAIQueryException.java create mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/AAIPluginImpl.java create mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/Constants.java create mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/objects/AAIQueryResult.java create mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/objects/Relationship.java delete mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java delete mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/exception/AAIQueryException.java delete mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java delete mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java delete mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/AAIQueryResult.java delete mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/Relationship.java create mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/onap/appc/dg/aai/impl/AAIClientMock.java create mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/onap/appc/dg/aai/impl/AAIPluginImplTest.java delete mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIClientMock.java delete mode 100644 appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java (limited to 'appc-dg/appc-dg-shared/appc-dg-aai') diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/AAIPlugin.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/AAIPlugin.java new file mode 100644 index 000000000..64033dd38 --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/AAIPlugin.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.dg.aai; + +import java.util.Map; + +import org.onap.appc.exceptions.APPCException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; + +public interface AAIPlugin extends SvcLogicJavaPlugin { + void postGenericVnfData(Map params, SvcLogicContext ctx) throws APPCException; + + void getGenericVnfData(Map params, SvcLogicContext ctx) throws APPCException; + + void getVnfHierarchy(Map params, SvcLogicContext ctx) throws APPCException; + + void getResource(Map params, SvcLogicContext ctx) throws APPCException; + + void postResource(Map params, SvcLogicContext ctx) throws APPCException; + + void deleteResource(Map params, SvcLogicContext ctx) throws APPCException; + +} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/exception/AAIQueryException.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/exception/AAIQueryException.java new file mode 100644 index 000000000..2ec604dcd --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/exception/AAIQueryException.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.dg.aai.exception; + + +public class AAIQueryException extends Exception{ + public AAIQueryException(String message){ + super(message); + } +} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/AAIPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/AAIPluginImpl.java new file mode 100644 index 000000000..1b510a8ca --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/AAIPluginImpl.java @@ -0,0 +1,401 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.dg.aai.impl; +import org.onap.appc.domainmodel.Vnf; +import org.onap.appc.domainmodel.Vnfc; +import org.onap.appc.domainmodel.Vserver; +import org.onap.appc.exceptions.APPCException; +import org.onap.appc.i18n.Msg; +import com.att.eelf.i18n.EELFResourceManager; + +import org.onap.appc.dg.aai.AAIPlugin; +import org.onap.appc.dg.aai.exception.AAIQueryException; +import org.onap.appc.dg.aai.objects.AAIQueryResult; +import org.onap.appc.dg.aai.objects.Relationship; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.adaptors.aai.AAIClient; +import org.onap.ccsdk.sli.adaptors.aai.AAIService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + + +public class AAIPluginImpl implements AAIPlugin { + private AAIClient aaiClient; + private static final EELFLogger logger = EELFManager.getInstance().getLogger(AAIPluginImpl.class); + + @SuppressWarnings("unchecked") + public AAIPluginImpl() { + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + ServiceReference sref = bctx.getServiceReference(AAIService.class); + aaiClient = (AAIClient) bctx.getService(sref); + } + + @Override + public void postGenericVnfData(Map params, SvcLogicContext ctx) throws APPCException { + String vnf_id = ctx.getAttribute(Constants.VNF_ID_PARAM_NAME); + String prefix = ctx.getAttribute(Constants.AAI_PREFIX_PARAM_NAME); + + String key = "vnf-id = '" + vnf_id + "'"; + + Map data = new HashMap<>(); + for (Map.Entry entry : params.entrySet()) { + String paramKey = entry.getKey(); + int pos = paramKey.indexOf(Constants.AAI_INPUT_DATA); + if (pos == 0) { + data.put(paramKey.substring(Constants.AAI_INPUT_DATA.length()+1), entry.getValue()); + } + } + + try { + SvcLogicResource.QueryStatus response = aaiClient.update("generic-vnf", key, data, prefix, ctx); + if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) { + String msg = EELFResourceManager.format(Msg.VNF_NOT_FOUND, vnf_id); + ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); + throw new APPCException(msg); + } + logger.info("AAIResponse: " + response.toString()); + if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) { + String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id); + ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); + throw new APPCException(msg); + } + String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "PostGenericVnfData", "VNF ID " + vnf_id); + ctx.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg); + + } catch (SvcLogicException e) { + String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id); + ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); + logger.error(msg); + throw new APPCException(e); + } + } + + @Override + public void getGenericVnfData(Map params, SvcLogicContext ctx) throws APPCException { + String vnf_id = ctx.getAttribute(Constants.VNF_ID_PARAM_NAME); + String prefix = ctx.getAttribute(Constants.AAI_PREFIX_PARAM_NAME); + + String key = "vnf-id = '" + vnf_id + "'"; + try { + SvcLogicResource.QueryStatus response = aaiClient.query("generic-vnf", false, null, key, prefix, null, ctx); + if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) { + String msg = EELFResourceManager.format(Msg.VNF_NOT_FOUND, vnf_id); +// String errorMessage = String.format("VNF not found for vnf_id = %s", vnf_id); + ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); + throw new APPCException(msg); + } else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) { + String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id); + ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); + throw new APPCException(msg); + } + String aaiEntitlementPoolUuid = ctx.getAttribute(Constants.AAI_ENTITLMENT_POOL_UUID_NAME); + if (null == aaiEntitlementPoolUuid) aaiEntitlementPoolUuid = ""; + String aaiLicenseKeyGroupUuid = ctx.getAttribute(Constants.AAI_LICENSE_KEY_UUID_NAME); + if (null == aaiLicenseKeyGroupUuid) aaiLicenseKeyGroupUuid = ""; + + ctx.setAttribute(Constants.IS_RELEASE_ENTITLEMENT_REQUIRE, Boolean.toString(!aaiEntitlementPoolUuid.isEmpty())); + ctx.setAttribute(Constants.IS_RELEASE_LICENSE_REQUIRE, Boolean.toString(!aaiLicenseKeyGroupUuid.isEmpty())); + String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "GetGenericVnfData","VNF ID " + vnf_id); + ctx.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg); + + logger.info("AAIResponse: " + response.toString()); + } catch (SvcLogicException e) { + String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id); + ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); + logger.error(msg); + throw new APPCException(e); + } + } + + @Override + public void getVnfHierarchy(Map params, SvcLogicContext ctx) throws APPCException { + + Map> vnfcMap = new HashMap<>(); + String vnfType,vnfVersion; + String vnfId = params.get("resourceKey"); + AAIQueryResult vnfQueryResult; + int vmCount =0; + try { + vnfQueryResult = readVnf(vnfId); + + vnfType = vnfQueryResult.getAdditionProperties().get("vnf-type"); + vnfVersion = vnfQueryResult.getAdditionProperties().get(Constants.AAI_VNF_MODEL_VERSION_ID); + + for(Relationship vnfRelationship:vnfQueryResult.getRelationshipList()){ + if("vserver".equalsIgnoreCase(vnfRelationship.getRelatedTo())){ + vmCount++; + String tenantId = vnfRelationship.getRelationShipDataMap().get("tenant.tenant-id"); + String vmId = vnfRelationship.getRelationShipDataMap().get("vserver.vserver-id"); + String vmRelatedLink = vnfRelationship.getRelatedLink(); + String vmName = vnfRelationship.getRelatedProperties().get("vserver.vserver-name"); + String cloudOwner = vnfRelationship.getRelationShipDataMap().get("cloud-region.cloud-owner"); + String cloudRegionId = vnfRelationship.getRelationShipDataMap().get("cloud-region.cloud-region-id"); + + AAIQueryResult vmQueryResult = readVM(vmId,tenantId,cloudOwner,cloudRegionId); + String vmURL = vmQueryResult.getAdditionProperties().get("vserver-selflink"); + + Vserver vm = new Vserver(vmURL,tenantId,vmId,vmRelatedLink,vmName); + for(Relationship vmRelation:vmQueryResult.getRelationshipList()){ + + if("vnfc".equalsIgnoreCase(vmRelation.getRelatedTo())){ + String vnfcName = vmRelation.getRelationShipDataMap().get("vnfc.vnfc-name"); + AAIQueryResult vnfcQueryResult = readVnfc(vnfcName); + String vnfcType = vnfcQueryResult.getAdditionProperties().get("vnfc-type"); + + Vnfc vnfc = new Vnfc(vnfcType,null,vnfcName); + Set vmSet = vnfcMap.get(vnfc); + if(vmSet == null){ + vmSet = new HashSet<>(); + vnfcMap.put(vnfc,vmSet); + } + vmSet.add(vm); + } + } + } + } + ctx.setAttribute("VNF.VMCount",String.valueOf(vmCount)); + } catch (AAIQueryException e) { + ctx.setAttribute("getVnfHierarchy_result", "FAILURE"); + String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnfId); + ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); + logger.error("Failed in getVnfHierarchy, Error retrieving VNF details. Error message: " + ctx + .getAttribute("getResource_result")); + logger.warn("Incorrect or Incomplete VNF Hierarchy"); + throw new APPCException("Error Retrieving VNF hierarchy"); + } + + Vnf vnf = new Vnf(vnfId,vnfType,vnfVersion); + for(Vnfc vnfc:vnfcMap.keySet()){ + for(Vserver vm:vnfcMap.get(vnfc)){ + vnfc.addVm(vm); + } + vnf.addVnfc(vnfc); + } + + populateContext(vnf,ctx); + ctx.setAttribute("getVnfHierarchy_result", "SUCCESS"); + String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "GetVNFHierarchy","VNF ID " + vnfId); + ctx.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg); + + } + + private void populateContext(Vnf vnf ,SvcLogicContext ctx) { + ctx.setAttribute("vnf.type",vnf.getVnfType()); + ctx.setAttribute("vnf.version",vnf.getVnfVersion()); + ctx.setAttribute("vnf.vnfcCount",String.valueOf(vnf.getVnfcs().size())); + int vnfcCount =0; + for(Vnfc vnfc:vnf.getVnfcs()){ + ctx.setAttribute("vnf.vnfc["+vnfcCount+"].name",vnfc.getVnfcName()); + ctx.setAttribute("vnf.vnfc["+vnfcCount+"].type",vnfc.getVnfcType()); + ctx.setAttribute("vnf.vnfc["+vnfcCount+"].vm_count",String.valueOf(vnfc.getVserverList().size())); + int vmCount =0; + for(Vserver vm:vnfc.getVserverList()){ + ctx.setAttribute("vnf.vnfc["+vnfcCount+"].vm["+ vmCount++ +"].url",vm.getUrl()); + } + vnfcCount++; + } + } + + private AAIQueryResult readVnfc(String vnfcName) throws AAIQueryException { + String query = "vnfc.vnfc-name = '" + vnfcName + "'"; + String prefix = "VNFC"; + String resourceType = "vnfc"; + SvcLogicContext vnfContext = readResource(query,prefix,resourceType); + String[] additionalProperties = new String[]{"vnfc-type","vnfc-name", + "vnfc-function-code","in-maint","prov-status", + "is-closed-loop-disabled","orchestration-status","resource-version"}; + return readRelationDataAndProperties(prefix, vnfContext,additionalProperties); + } + + private AAIQueryResult readVM(String vmId,String tenantId,String cloudOwner,String cloudRegionId) + throws AAIQueryException { + String query = "vserver.vserver-id = '" + vmId + "' AND tenant.tenant_id = '" + tenantId + + "' AND cloud-region.cloud-owner = '" + cloudOwner + + "' AND cloud-region.cloud-region-id = '" + cloudRegionId + "'"; + String prefix = "VM"; + String resourceType = "vserver"; + SvcLogicContext vnfContext = readResource(query,prefix,resourceType); + String[] additionalProperties = new String[]{"vserver-id","vserver-selflink", + "vserver-name","in-maint","prov-status","is-closed-loop-disabled", + "vserver-name2","resource-version",}; + + return readRelationDataAndProperties(prefix, vnfContext,additionalProperties); + } + + private AAIQueryResult readVnf(String vnfId) throws AAIQueryException { + String query = "generic-vnf.vnf-id = '" + vnfId + "'"; + String prefix = "VNF"; + String resourceType = "generic-vnf"; + SvcLogicContext vnfContext = readResource(query,prefix,resourceType); + + String[] additionalProperties = new String[]{"vnf-type","vnf-name", + "in-maint","prov-status","heat-stack-id", + "is-closed-loop-disabled","orchestration-status","resource-version",Constants.AAI_VNF_MODEL_VERSION_ID}; + + return readRelationDataAndProperties(prefix, vnfContext,additionalProperties); + } + + private AAIQueryResult readRelationDataAndProperties(String prefix, + SvcLogicContext context, + String[] additionalProperties) { + AAIQueryResult result = new AAIQueryResult(); + + if (context != null && context.getAttribute(prefix + ".relationship-list.relationship_length") != null) { + Integer relationsCount = Integer.parseInt(context.getAttribute( + prefix + ".relationship-list.relationship_length")); + for (int i = 0; i < relationsCount; i++) { + String rsKey = prefix + ".relationship-list.relationship[" + i + "]"; + Relationship relationShip = new Relationship(); + relationShip.setRelatedLink(context.getAttribute(rsKey + ".related-link")); + relationShip.setRelatedTo(context.getAttribute(rsKey + ".related-to")); + Integer relationDataCount = + Integer.parseInt(context.getAttribute(rsKey + ".relationship-data_length")); + for (int j = 0; j < relationDataCount; j++) { + String rsDataKey = rsKey + ".relationship-data[" + j + "]"; + String key = context.getAttribute(rsDataKey + ".relationship-key"); + String value = context.getAttribute(rsDataKey + ".relationship-value"); + relationShip.getRelationShipDataMap().put(key, value); + } + Integer relatedPropertyCount = 0; + String relatedPropertyCountStr = null; + try { + relatedPropertyCountStr = context.getAttribute(rsKey + ".related-to-property_length"); + relatedPropertyCount = Integer.parseInt(relatedPropertyCountStr); + } catch (NumberFormatException e) { + logger.debug( + "Invalid value in the context for Related Property Count " + relatedPropertyCountStr); + } + + for (int j = 0; j < relatedPropertyCount; j++) { + String rsPropKey = rsKey + ".related-to-property[" + j + "]"; + String key = context.getAttribute(rsPropKey + ".property-key"); + String value = context.getAttribute(rsPropKey + ".property-value"); + relationShip.getRelatedProperties().put(key, value); + } + result.getRelationshipList().add(relationShip); + } + } else { + logger.error("Relationship-list not present in the SvcLogicContext attributes set." + + (context == null ? "" : "Attribute KeySet = "+ context.getAttributeKeySet())); + } + + if (context != null) { + for (String key : additionalProperties) { + result.getAdditionProperties().put(key, context.getAttribute(prefix + "." + key)); + } + } + return result; + } + + private SvcLogicContext readResource(String query, String prefix, String resourceType) throws AAIQueryException { + SvcLogicContext resourceContext = new SvcLogicContext(); + try { + SvcLogicResource.QueryStatus response = + aaiClient.query(resourceType,false,null,query,prefix,null,resourceContext); + logger.info("AAIResponse: " + response.toString()); + if(!SvcLogicResource.QueryStatus.SUCCESS.equals(response)){ + throw new AAIQueryException("Error Retrieving VNF hierarchy from A&AI"); + } + } catch (SvcLogicException e) { + logger.error(EELFResourceManager.format(Msg.AAI_GET_DATA_FAILED, query, "", e.getMessage())); + throw new AAIQueryException("Error Retrieving VNF hierarchy from A&AI"); + } + return resourceContext; + } + + @Override public void getResource(Map params, SvcLogicContext ctx) throws APPCException { + String resourceType = params.get("resourceType"), ctx_prefix = params.get("prefix"), resourceKey = + params.get("resourceKey"); + if (logger.isDebugEnabled()) { + logger.debug("inside getResorce"); + logger.debug("Retrieving " + resourceType + " details from A&AI for Key : " + resourceKey); + } + try { + SvcLogicResource.QueryStatus response = + aaiClient.query(resourceType, false, null, resourceKey, ctx_prefix, null, ctx); + logger.info("AAIResponse: " + response.toString()); + ctx.setAttribute("getResource_result", response.toString()); + } catch (SvcLogicException e) { + logger.error( + EELFResourceManager.format(Msg.AAI_GET_DATA_FAILED, resourceKey, "", e.getMessage())); + } + if (logger.isDebugEnabled()) { + logger.debug("exiting getResource======"); + } + } + + @Override public void postResource(Map params, SvcLogicContext ctx) throws APPCException { + String resourceType = params.get("resourceType"), ctx_prefix = params.get("prefix"), resourceKey = + params.get("resourceKey"), att_name = params.get("attributeName"), att_value = + params.get("attributeValue"); + if (logger.isDebugEnabled()) { + logger.debug("inside postResource"); + logger.debug("Updating " + resourceType + " details in A&AI for Key : " + resourceKey); + logger.debug("Updating " + att_name + " to : " + att_value); + } + Map data = new HashMap<>(); + data.put(att_name, att_value); + + try { + SvcLogicResource.QueryStatus response = aaiClient.update(resourceType, resourceKey, data, ctx_prefix, ctx); + logger.info("AAIResponse: " + response.toString()); + ctx.setAttribute("postResource_result", response.toString()); + } catch (SvcLogicException e) { + logger.error(EELFResourceManager.format(Msg.AAI_UPDATE_FAILED, resourceKey, att_value, e.getMessage())); + } + if (logger.isDebugEnabled()) { + logger.debug("exiting postResource======"); + } + } + + @Override public void deleteResource(Map params, SvcLogicContext ctx) throws APPCException { + String resourceType = params.get("resourceType"), resourceKey = params.get("resourceKey"); + + if (logger.isDebugEnabled()) { + logger.debug("inside deleteResource"); + logger.debug("Deleting " + resourceType + " details From A&AI for Key : " + resourceKey); + } + try { + SvcLogicResource.QueryStatus response = aaiClient.delete(resourceType, resourceKey, ctx); + logger.info("AAIResponse: " + response.toString()); + ctx.setAttribute("deleteResource_result", response.toString()); + } catch (SvcLogicException e) { + logger.error(EELFResourceManager.format(Msg.AAI_DELETE_FAILED, resourceKey, e.getMessage())); + } + if (logger.isDebugEnabled()) { + logger.debug("exiting deleteResource======"); + } + } +} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/Constants.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/Constants.java new file mode 100644 index 000000000..6a6818e06 --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/impl/Constants.java @@ -0,0 +1,120 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.dg.aai.impl; + + +public class Constants { + public final static String VNF_ID_PARAM_NAME = "aai.vnfID"; + public static final String AAI_PREFIX_PARAM_NAME = "aai.prefix"; + public static final String AAI_INPUT_DATA = "aai.input.data"; + public static final String AAI_ERROR_MESSAGE = "org.onap.appc.dg.error"; + + public static final String CONFIGURE_PATH = "/restconf/config/opendaylight-inventory:nodes/node/"; + public static final String CONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules"; + public static final String CHECK_CONNECTION_PATH = "/restconf/operational/opendaylight-inventory:nodes/node/"; + public static final String DISCONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/"; + + public static final String CONTROLLER_IP = "127.0.0.1"; + public static final int CONTROLLER_PORT = 8181; + public static final String PROTOCOL = "http"; + + public static final String VF_LICENSE = "VF_LICENSE"; + + // tables and fields + public static final String NETCONF_SCHEMA = "sdnctl"; + public static final String SDNCTL_SCHEMA = "sdnctl"; + public static final String DEVICE_AUTHENTICATION_TABLE_NAME = "DEVICE_AUTHENTICATION"; + public static final String CONFIGFILES_TABLE_NAME = "CONFIGFILES"; + public static final String DEVICE_INTERFACE_LOG_TABLE_NAME = "DEVICE_INTERFACE_LOG"; + public static final String FILE_CONTENT_TABLE_FIELD_NAME = "FILE_CONTENT"; + public static final String FILE_NAME_TABLE_FIELD_NAME = "FILE_NAME"; + public static final String USER_NAME_TABLE_FIELD_NAME = "USER_NAME"; + public static final String PASSWORD_TABLE_FIELD_NAME = "PASSWORD"; + public static final String PORT_NUMBER_TABLE_FIELD_NAME = "PORT_NUMBER"; + public static final String VNF_TYPE_TABLE_FIELD_NAME = "VNF_TYPE"; + public static final String SERVICE_INSTANCE_ID_FIELD_NAME = "SERVICE_INSTANCE_ID"; + public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID"; + public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE"; + public static final String LOG_FIELD_NAME = "LOG"; + public static final String SDC_ARTIFACTS_TABLE_NAME = "ASDC_ARTIFACTS"; + + // input fields names + public static final String PAYLOAD = "payload"; + + // constants fo DG + public static final String VNF_TYPE_FIELD_NAME = "org.onap.appc.vftype"; + public static final String VNF_VERSION_FIELD_NAME = "org.onap.appc.vfversion"; + public static final String VNF_RESOURCE_VERSION_FIELD_NAME = "org.onap.appc.resource-version"; + public static final String TARGET_VNF_TYPE = "target-vnf-type"; + public static final String FILE_CONTENT_FIELD_NAME = "file-content"; + public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details"; + public static final String CONFIGURATION_FILE_FIELD_NAME = "configuration-file-name"; + public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address"; + public static final String UPGRADE_VERSION = "upgrade-version"; + public static final String DG_ERROR_FIELD_NAME = "org.onap.appc.dg.error"; + public static final String ATTRIBUTE_ERROR_MESSAGE = "error-message"; + public static final String RESOURCEKEY = "resourceKey"; + public static final String REQ_ID_FIELD_NAME = "org.onap.appc.reqid"; + public static final String API_VERSION_FIELD_NAME = "org.onap.appc.apiversion"; + public static final String MODEL_ENTITLMENT_POOL_UUID_NAME = "model.entitlement.pool.uuid"; + public static final String MODEL_LICENSE_KEY_UUID_NAME = "model.license.key.uuid"; + public static final String ENTITLMENT_POOL_UUID_NAME = "entitlement.pool.uuid"; + public static final String LICENSE_KEY_UUID_NAME = "license.key.uuid"; + public static final String IS_ACQUIRE_LICENSE_REQUIRE ="is.acquire-license.require"; + public static final String IS_RELEASE_LICENSE_REQUIRE ="is.release-license.require"; + + public static final String AAI_ENTITLMENT_POOL_UUID_NAME = "aai.input.data.entitlement-assignment-group-uuid"; + public static final String AAI_LICENSE_KEY_UUID_NAME = "aai.input.data.license-assignment-group-uuid"; + public static final String AAI_LICENSE_KEY_VALUE = "aai.input.data.license-key"; + public static final String IS_AAI_ENTITLEMENT_UPDATE_REQUIRE = "is.aai-entitlement-update.require"; + public static final String IS_AAI_LICENSE_UPDATE_REQUIRE = "is.aai-license-update.require"; + public static final String IS_ACQUIRE_ENTITLEMENT_REQUIRE ="is.acquire-entitlement.require"; + public static final String IS_RELEASE_ENTITLEMENT_REQUIRE ="is.release-entitlement.require"; + + /** + * AAI property names + */ + public static final String AAI_VNF_MODEL_VERSION_ID ="model-version-id"; + + public enum SDC_ARTIFACTS_FIELDS { + SERVICE_UUID, + DISTRIBUTION_ID, + SERVICE_NAME, + SERVICE_DESCRIPTION, + RESOURCE_UUID, + RESOURCE_INSTANCE_NAME, + RESOURCE_NAME, + RESOURCE_VERSION, + RESOURCE_TYPE, + ARTIFACT_UUID, + ARTIFACT_TYPE, + ARTIFACT_VERSION, + ARTIFACT_DESCRIPTION, + INTERNAL_VERSION, + CREATION_DATE, + ARTIFACT_NAME, + ARTIFACT_CONTENT + } +} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/objects/AAIQueryResult.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/objects/AAIQueryResult.java new file mode 100644 index 000000000..674da55dd --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/objects/AAIQueryResult.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.dg.aai.objects; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class AAIQueryResult { + private List relationshipList; + + private Map additionProperties; + + + public AAIQueryResult(){ + relationshipList = new ArrayList<>(); + additionProperties = new HashMap<>(); + } + + + public List getRelationshipList() { + return relationshipList; + } + + public Map getAdditionProperties() { + return additionProperties; + } +} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/objects/Relationship.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/objects/Relationship.java new file mode 100644 index 000000000..d32898f1c --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/onap/appc/dg/aai/objects/Relationship.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.dg.aai.objects; + +import java.util.HashMap; +import java.util.Map; + + +public class Relationship { + + private String relatedTo; + + private String relatedLink; + + private Map relationShipDataMap; + + private Map relatedProperties; + + public Relationship(){ + relationShipDataMap = new HashMap<>(); + relatedProperties = new HashMap<>(); + } + + public String getRelatedTo() { + return relatedTo; + } + + public String getRelatedLink() { + return relatedLink; + } + + public Map getRelationShipDataMap() { + return relationShipDataMap; + } + + public Map getRelatedProperties() { + return relatedProperties; + } + + public void setRelatedTo(String relatedTo) { + this.relatedTo = relatedTo; + } + + public void setRelatedLink(String relatedLink) { + this.relatedLink = relatedLink; + } +} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java deleted file mode 100644 index 64033dd38..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.aai; - -import java.util.Map; - -import org.onap.appc.exceptions.APPCException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - -public interface AAIPlugin extends SvcLogicJavaPlugin { - void postGenericVnfData(Map params, SvcLogicContext ctx) throws APPCException; - - void getGenericVnfData(Map params, SvcLogicContext ctx) throws APPCException; - - void getVnfHierarchy(Map params, SvcLogicContext ctx) throws APPCException; - - void getResource(Map params, SvcLogicContext ctx) throws APPCException; - - void postResource(Map params, SvcLogicContext ctx) throws APPCException; - - void deleteResource(Map params, SvcLogicContext ctx) throws APPCException; - -} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/exception/AAIQueryException.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/exception/AAIQueryException.java deleted file mode 100644 index 2ec604dcd..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/exception/AAIQueryException.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.aai.exception; - - -public class AAIQueryException extends Exception{ - public AAIQueryException(String message){ - super(message); - } -} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java deleted file mode 100644 index 1b510a8ca..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java +++ /dev/null @@ -1,401 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.aai.impl; -import org.onap.appc.domainmodel.Vnf; -import org.onap.appc.domainmodel.Vnfc; -import org.onap.appc.domainmodel.Vserver; -import org.onap.appc.exceptions.APPCException; -import org.onap.appc.i18n.Msg; -import com.att.eelf.i18n.EELFResourceManager; - -import org.onap.appc.dg.aai.AAIPlugin; -import org.onap.appc.dg.aai.exception.AAIQueryException; -import org.onap.appc.dg.aai.objects.AAIQueryResult; -import org.onap.appc.dg.aai.objects.Relationship; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.adaptors.aai.AAIClient; -import org.onap.ccsdk.sli.adaptors.aai.AAIService; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - - -public class AAIPluginImpl implements AAIPlugin { - private AAIClient aaiClient; - private static final EELFLogger logger = EELFManager.getInstance().getLogger(AAIPluginImpl.class); - - @SuppressWarnings("unchecked") - public AAIPluginImpl() { - BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - ServiceReference sref = bctx.getServiceReference(AAIService.class); - aaiClient = (AAIClient) bctx.getService(sref); - } - - @Override - public void postGenericVnfData(Map params, SvcLogicContext ctx) throws APPCException { - String vnf_id = ctx.getAttribute(Constants.VNF_ID_PARAM_NAME); - String prefix = ctx.getAttribute(Constants.AAI_PREFIX_PARAM_NAME); - - String key = "vnf-id = '" + vnf_id + "'"; - - Map data = new HashMap<>(); - for (Map.Entry entry : params.entrySet()) { - String paramKey = entry.getKey(); - int pos = paramKey.indexOf(Constants.AAI_INPUT_DATA); - if (pos == 0) { - data.put(paramKey.substring(Constants.AAI_INPUT_DATA.length()+1), entry.getValue()); - } - } - - try { - SvcLogicResource.QueryStatus response = aaiClient.update("generic-vnf", key, data, prefix, ctx); - if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) { - String msg = EELFResourceManager.format(Msg.VNF_NOT_FOUND, vnf_id); - ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); - throw new APPCException(msg); - } - logger.info("AAIResponse: " + response.toString()); - if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) { - String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id); - ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); - throw new APPCException(msg); - } - String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "PostGenericVnfData", "VNF ID " + vnf_id); - ctx.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg); - - } catch (SvcLogicException e) { - String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id); - ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); - logger.error(msg); - throw new APPCException(e); - } - } - - @Override - public void getGenericVnfData(Map params, SvcLogicContext ctx) throws APPCException { - String vnf_id = ctx.getAttribute(Constants.VNF_ID_PARAM_NAME); - String prefix = ctx.getAttribute(Constants.AAI_PREFIX_PARAM_NAME); - - String key = "vnf-id = '" + vnf_id + "'"; - try { - SvcLogicResource.QueryStatus response = aaiClient.query("generic-vnf", false, null, key, prefix, null, ctx); - if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) { - String msg = EELFResourceManager.format(Msg.VNF_NOT_FOUND, vnf_id); -// String errorMessage = String.format("VNF not found for vnf_id = %s", vnf_id); - ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); - throw new APPCException(msg); - } else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) { - String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id); - ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); - throw new APPCException(msg); - } - String aaiEntitlementPoolUuid = ctx.getAttribute(Constants.AAI_ENTITLMENT_POOL_UUID_NAME); - if (null == aaiEntitlementPoolUuid) aaiEntitlementPoolUuid = ""; - String aaiLicenseKeyGroupUuid = ctx.getAttribute(Constants.AAI_LICENSE_KEY_UUID_NAME); - if (null == aaiLicenseKeyGroupUuid) aaiLicenseKeyGroupUuid = ""; - - ctx.setAttribute(Constants.IS_RELEASE_ENTITLEMENT_REQUIRE, Boolean.toString(!aaiEntitlementPoolUuid.isEmpty())); - ctx.setAttribute(Constants.IS_RELEASE_LICENSE_REQUIRE, Boolean.toString(!aaiLicenseKeyGroupUuid.isEmpty())); - String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "GetGenericVnfData","VNF ID " + vnf_id); - ctx.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg); - - logger.info("AAIResponse: " + response.toString()); - } catch (SvcLogicException e) { - String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id); - ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); - logger.error(msg); - throw new APPCException(e); - } - } - - @Override - public void getVnfHierarchy(Map params, SvcLogicContext ctx) throws APPCException { - - Map> vnfcMap = new HashMap<>(); - String vnfType,vnfVersion; - String vnfId = params.get("resourceKey"); - AAIQueryResult vnfQueryResult; - int vmCount =0; - try { - vnfQueryResult = readVnf(vnfId); - - vnfType = vnfQueryResult.getAdditionProperties().get("vnf-type"); - vnfVersion = vnfQueryResult.getAdditionProperties().get(Constants.AAI_VNF_MODEL_VERSION_ID); - - for(Relationship vnfRelationship:vnfQueryResult.getRelationshipList()){ - if("vserver".equalsIgnoreCase(vnfRelationship.getRelatedTo())){ - vmCount++; - String tenantId = vnfRelationship.getRelationShipDataMap().get("tenant.tenant-id"); - String vmId = vnfRelationship.getRelationShipDataMap().get("vserver.vserver-id"); - String vmRelatedLink = vnfRelationship.getRelatedLink(); - String vmName = vnfRelationship.getRelatedProperties().get("vserver.vserver-name"); - String cloudOwner = vnfRelationship.getRelationShipDataMap().get("cloud-region.cloud-owner"); - String cloudRegionId = vnfRelationship.getRelationShipDataMap().get("cloud-region.cloud-region-id"); - - AAIQueryResult vmQueryResult = readVM(vmId,tenantId,cloudOwner,cloudRegionId); - String vmURL = vmQueryResult.getAdditionProperties().get("vserver-selflink"); - - Vserver vm = new Vserver(vmURL,tenantId,vmId,vmRelatedLink,vmName); - for(Relationship vmRelation:vmQueryResult.getRelationshipList()){ - - if("vnfc".equalsIgnoreCase(vmRelation.getRelatedTo())){ - String vnfcName = vmRelation.getRelationShipDataMap().get("vnfc.vnfc-name"); - AAIQueryResult vnfcQueryResult = readVnfc(vnfcName); - String vnfcType = vnfcQueryResult.getAdditionProperties().get("vnfc-type"); - - Vnfc vnfc = new Vnfc(vnfcType,null,vnfcName); - Set vmSet = vnfcMap.get(vnfc); - if(vmSet == null){ - vmSet = new HashSet<>(); - vnfcMap.put(vnfc,vmSet); - } - vmSet.add(vm); - } - } - } - } - ctx.setAttribute("VNF.VMCount",String.valueOf(vmCount)); - } catch (AAIQueryException e) { - ctx.setAttribute("getVnfHierarchy_result", "FAILURE"); - String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnfId); - ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg); - logger.error("Failed in getVnfHierarchy, Error retrieving VNF details. Error message: " + ctx - .getAttribute("getResource_result")); - logger.warn("Incorrect or Incomplete VNF Hierarchy"); - throw new APPCException("Error Retrieving VNF hierarchy"); - } - - Vnf vnf = new Vnf(vnfId,vnfType,vnfVersion); - for(Vnfc vnfc:vnfcMap.keySet()){ - for(Vserver vm:vnfcMap.get(vnfc)){ - vnfc.addVm(vm); - } - vnf.addVnfc(vnfc); - } - - populateContext(vnf,ctx); - ctx.setAttribute("getVnfHierarchy_result", "SUCCESS"); - String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "GetVNFHierarchy","VNF ID " + vnfId); - ctx.setAttribute(org.onap.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg); - - } - - private void populateContext(Vnf vnf ,SvcLogicContext ctx) { - ctx.setAttribute("vnf.type",vnf.getVnfType()); - ctx.setAttribute("vnf.version",vnf.getVnfVersion()); - ctx.setAttribute("vnf.vnfcCount",String.valueOf(vnf.getVnfcs().size())); - int vnfcCount =0; - for(Vnfc vnfc:vnf.getVnfcs()){ - ctx.setAttribute("vnf.vnfc["+vnfcCount+"].name",vnfc.getVnfcName()); - ctx.setAttribute("vnf.vnfc["+vnfcCount+"].type",vnfc.getVnfcType()); - ctx.setAttribute("vnf.vnfc["+vnfcCount+"].vm_count",String.valueOf(vnfc.getVserverList().size())); - int vmCount =0; - for(Vserver vm:vnfc.getVserverList()){ - ctx.setAttribute("vnf.vnfc["+vnfcCount+"].vm["+ vmCount++ +"].url",vm.getUrl()); - } - vnfcCount++; - } - } - - private AAIQueryResult readVnfc(String vnfcName) throws AAIQueryException { - String query = "vnfc.vnfc-name = '" + vnfcName + "'"; - String prefix = "VNFC"; - String resourceType = "vnfc"; - SvcLogicContext vnfContext = readResource(query,prefix,resourceType); - String[] additionalProperties = new String[]{"vnfc-type","vnfc-name", - "vnfc-function-code","in-maint","prov-status", - "is-closed-loop-disabled","orchestration-status","resource-version"}; - return readRelationDataAndProperties(prefix, vnfContext,additionalProperties); - } - - private AAIQueryResult readVM(String vmId,String tenantId,String cloudOwner,String cloudRegionId) - throws AAIQueryException { - String query = "vserver.vserver-id = '" + vmId + "' AND tenant.tenant_id = '" + tenantId - + "' AND cloud-region.cloud-owner = '" + cloudOwner - + "' AND cloud-region.cloud-region-id = '" + cloudRegionId + "'"; - String prefix = "VM"; - String resourceType = "vserver"; - SvcLogicContext vnfContext = readResource(query,prefix,resourceType); - String[] additionalProperties = new String[]{"vserver-id","vserver-selflink", - "vserver-name","in-maint","prov-status","is-closed-loop-disabled", - "vserver-name2","resource-version",}; - - return readRelationDataAndProperties(prefix, vnfContext,additionalProperties); - } - - private AAIQueryResult readVnf(String vnfId) throws AAIQueryException { - String query = "generic-vnf.vnf-id = '" + vnfId + "'"; - String prefix = "VNF"; - String resourceType = "generic-vnf"; - SvcLogicContext vnfContext = readResource(query,prefix,resourceType); - - String[] additionalProperties = new String[]{"vnf-type","vnf-name", - "in-maint","prov-status","heat-stack-id", - "is-closed-loop-disabled","orchestration-status","resource-version",Constants.AAI_VNF_MODEL_VERSION_ID}; - - return readRelationDataAndProperties(prefix, vnfContext,additionalProperties); - } - - private AAIQueryResult readRelationDataAndProperties(String prefix, - SvcLogicContext context, - String[] additionalProperties) { - AAIQueryResult result = new AAIQueryResult(); - - if (context != null && context.getAttribute(prefix + ".relationship-list.relationship_length") != null) { - Integer relationsCount = Integer.parseInt(context.getAttribute( - prefix + ".relationship-list.relationship_length")); - for (int i = 0; i < relationsCount; i++) { - String rsKey = prefix + ".relationship-list.relationship[" + i + "]"; - Relationship relationShip = new Relationship(); - relationShip.setRelatedLink(context.getAttribute(rsKey + ".related-link")); - relationShip.setRelatedTo(context.getAttribute(rsKey + ".related-to")); - Integer relationDataCount = - Integer.parseInt(context.getAttribute(rsKey + ".relationship-data_length")); - for (int j = 0; j < relationDataCount; j++) { - String rsDataKey = rsKey + ".relationship-data[" + j + "]"; - String key = context.getAttribute(rsDataKey + ".relationship-key"); - String value = context.getAttribute(rsDataKey + ".relationship-value"); - relationShip.getRelationShipDataMap().put(key, value); - } - Integer relatedPropertyCount = 0; - String relatedPropertyCountStr = null; - try { - relatedPropertyCountStr = context.getAttribute(rsKey + ".related-to-property_length"); - relatedPropertyCount = Integer.parseInt(relatedPropertyCountStr); - } catch (NumberFormatException e) { - logger.debug( - "Invalid value in the context for Related Property Count " + relatedPropertyCountStr); - } - - for (int j = 0; j < relatedPropertyCount; j++) { - String rsPropKey = rsKey + ".related-to-property[" + j + "]"; - String key = context.getAttribute(rsPropKey + ".property-key"); - String value = context.getAttribute(rsPropKey + ".property-value"); - relationShip.getRelatedProperties().put(key, value); - } - result.getRelationshipList().add(relationShip); - } - } else { - logger.error("Relationship-list not present in the SvcLogicContext attributes set." - + (context == null ? "" : "Attribute KeySet = "+ context.getAttributeKeySet())); - } - - if (context != null) { - for (String key : additionalProperties) { - result.getAdditionProperties().put(key, context.getAttribute(prefix + "." + key)); - } - } - return result; - } - - private SvcLogicContext readResource(String query, String prefix, String resourceType) throws AAIQueryException { - SvcLogicContext resourceContext = new SvcLogicContext(); - try { - SvcLogicResource.QueryStatus response = - aaiClient.query(resourceType,false,null,query,prefix,null,resourceContext); - logger.info("AAIResponse: " + response.toString()); - if(!SvcLogicResource.QueryStatus.SUCCESS.equals(response)){ - throw new AAIQueryException("Error Retrieving VNF hierarchy from A&AI"); - } - } catch (SvcLogicException e) { - logger.error(EELFResourceManager.format(Msg.AAI_GET_DATA_FAILED, query, "", e.getMessage())); - throw new AAIQueryException("Error Retrieving VNF hierarchy from A&AI"); - } - return resourceContext; - } - - @Override public void getResource(Map params, SvcLogicContext ctx) throws APPCException { - String resourceType = params.get("resourceType"), ctx_prefix = params.get("prefix"), resourceKey = - params.get("resourceKey"); - if (logger.isDebugEnabled()) { - logger.debug("inside getResorce"); - logger.debug("Retrieving " + resourceType + " details from A&AI for Key : " + resourceKey); - } - try { - SvcLogicResource.QueryStatus response = - aaiClient.query(resourceType, false, null, resourceKey, ctx_prefix, null, ctx); - logger.info("AAIResponse: " + response.toString()); - ctx.setAttribute("getResource_result", response.toString()); - } catch (SvcLogicException e) { - logger.error( - EELFResourceManager.format(Msg.AAI_GET_DATA_FAILED, resourceKey, "", e.getMessage())); - } - if (logger.isDebugEnabled()) { - logger.debug("exiting getResource======"); - } - } - - @Override public void postResource(Map params, SvcLogicContext ctx) throws APPCException { - String resourceType = params.get("resourceType"), ctx_prefix = params.get("prefix"), resourceKey = - params.get("resourceKey"), att_name = params.get("attributeName"), att_value = - params.get("attributeValue"); - if (logger.isDebugEnabled()) { - logger.debug("inside postResource"); - logger.debug("Updating " + resourceType + " details in A&AI for Key : " + resourceKey); - logger.debug("Updating " + att_name + " to : " + att_value); - } - Map data = new HashMap<>(); - data.put(att_name, att_value); - - try { - SvcLogicResource.QueryStatus response = aaiClient.update(resourceType, resourceKey, data, ctx_prefix, ctx); - logger.info("AAIResponse: " + response.toString()); - ctx.setAttribute("postResource_result", response.toString()); - } catch (SvcLogicException e) { - logger.error(EELFResourceManager.format(Msg.AAI_UPDATE_FAILED, resourceKey, att_value, e.getMessage())); - } - if (logger.isDebugEnabled()) { - logger.debug("exiting postResource======"); - } - } - - @Override public void deleteResource(Map params, SvcLogicContext ctx) throws APPCException { - String resourceType = params.get("resourceType"), resourceKey = params.get("resourceKey"); - - if (logger.isDebugEnabled()) { - logger.debug("inside deleteResource"); - logger.debug("Deleting " + resourceType + " details From A&AI for Key : " + resourceKey); - } - try { - SvcLogicResource.QueryStatus response = aaiClient.delete(resourceType, resourceKey, ctx); - logger.info("AAIResponse: " + response.toString()); - ctx.setAttribute("deleteResource_result", response.toString()); - } catch (SvcLogicException e) { - logger.error(EELFResourceManager.format(Msg.AAI_DELETE_FAILED, resourceKey, e.getMessage())); - } - if (logger.isDebugEnabled()) { - logger.debug("exiting deleteResource======"); - } - } -} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java deleted file mode 100644 index 6a6818e06..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java +++ /dev/null @@ -1,120 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.aai.impl; - - -public class Constants { - public final static String VNF_ID_PARAM_NAME = "aai.vnfID"; - public static final String AAI_PREFIX_PARAM_NAME = "aai.prefix"; - public static final String AAI_INPUT_DATA = "aai.input.data"; - public static final String AAI_ERROR_MESSAGE = "org.onap.appc.dg.error"; - - public static final String CONFIGURE_PATH = "/restconf/config/opendaylight-inventory:nodes/node/"; - public static final String CONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules"; - public static final String CHECK_CONNECTION_PATH = "/restconf/operational/opendaylight-inventory:nodes/node/"; - public static final String DISCONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/"; - - public static final String CONTROLLER_IP = "127.0.0.1"; - public static final int CONTROLLER_PORT = 8181; - public static final String PROTOCOL = "http"; - - public static final String VF_LICENSE = "VF_LICENSE"; - - // tables and fields - public static final String NETCONF_SCHEMA = "sdnctl"; - public static final String SDNCTL_SCHEMA = "sdnctl"; - public static final String DEVICE_AUTHENTICATION_TABLE_NAME = "DEVICE_AUTHENTICATION"; - public static final String CONFIGFILES_TABLE_NAME = "CONFIGFILES"; - public static final String DEVICE_INTERFACE_LOG_TABLE_NAME = "DEVICE_INTERFACE_LOG"; - public static final String FILE_CONTENT_TABLE_FIELD_NAME = "FILE_CONTENT"; - public static final String FILE_NAME_TABLE_FIELD_NAME = "FILE_NAME"; - public static final String USER_NAME_TABLE_FIELD_NAME = "USER_NAME"; - public static final String PASSWORD_TABLE_FIELD_NAME = "PASSWORD"; - public static final String PORT_NUMBER_TABLE_FIELD_NAME = "PORT_NUMBER"; - public static final String VNF_TYPE_TABLE_FIELD_NAME = "VNF_TYPE"; - public static final String SERVICE_INSTANCE_ID_FIELD_NAME = "SERVICE_INSTANCE_ID"; - public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID"; - public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE"; - public static final String LOG_FIELD_NAME = "LOG"; - public static final String SDC_ARTIFACTS_TABLE_NAME = "ASDC_ARTIFACTS"; - - // input fields names - public static final String PAYLOAD = "payload"; - - // constants fo DG - public static final String VNF_TYPE_FIELD_NAME = "org.onap.appc.vftype"; - public static final String VNF_VERSION_FIELD_NAME = "org.onap.appc.vfversion"; - public static final String VNF_RESOURCE_VERSION_FIELD_NAME = "org.onap.appc.resource-version"; - public static final String TARGET_VNF_TYPE = "target-vnf-type"; - public static final String FILE_CONTENT_FIELD_NAME = "file-content"; - public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details"; - public static final String CONFIGURATION_FILE_FIELD_NAME = "configuration-file-name"; - public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address"; - public static final String UPGRADE_VERSION = "upgrade-version"; - public static final String DG_ERROR_FIELD_NAME = "org.onap.appc.dg.error"; - public static final String ATTRIBUTE_ERROR_MESSAGE = "error-message"; - public static final String RESOURCEKEY = "resourceKey"; - public static final String REQ_ID_FIELD_NAME = "org.onap.appc.reqid"; - public static final String API_VERSION_FIELD_NAME = "org.onap.appc.apiversion"; - public static final String MODEL_ENTITLMENT_POOL_UUID_NAME = "model.entitlement.pool.uuid"; - public static final String MODEL_LICENSE_KEY_UUID_NAME = "model.license.key.uuid"; - public static final String ENTITLMENT_POOL_UUID_NAME = "entitlement.pool.uuid"; - public static final String LICENSE_KEY_UUID_NAME = "license.key.uuid"; - public static final String IS_ACQUIRE_LICENSE_REQUIRE ="is.acquire-license.require"; - public static final String IS_RELEASE_LICENSE_REQUIRE ="is.release-license.require"; - - public static final String AAI_ENTITLMENT_POOL_UUID_NAME = "aai.input.data.entitlement-assignment-group-uuid"; - public static final String AAI_LICENSE_KEY_UUID_NAME = "aai.input.data.license-assignment-group-uuid"; - public static final String AAI_LICENSE_KEY_VALUE = "aai.input.data.license-key"; - public static final String IS_AAI_ENTITLEMENT_UPDATE_REQUIRE = "is.aai-entitlement-update.require"; - public static final String IS_AAI_LICENSE_UPDATE_REQUIRE = "is.aai-license-update.require"; - public static final String IS_ACQUIRE_ENTITLEMENT_REQUIRE ="is.acquire-entitlement.require"; - public static final String IS_RELEASE_ENTITLEMENT_REQUIRE ="is.release-entitlement.require"; - - /** - * AAI property names - */ - public static final String AAI_VNF_MODEL_VERSION_ID ="model-version-id"; - - public enum SDC_ARTIFACTS_FIELDS { - SERVICE_UUID, - DISTRIBUTION_ID, - SERVICE_NAME, - SERVICE_DESCRIPTION, - RESOURCE_UUID, - RESOURCE_INSTANCE_NAME, - RESOURCE_NAME, - RESOURCE_VERSION, - RESOURCE_TYPE, - ARTIFACT_UUID, - ARTIFACT_TYPE, - ARTIFACT_VERSION, - ARTIFACT_DESCRIPTION, - INTERNAL_VERSION, - CREATION_DATE, - ARTIFACT_NAME, - ARTIFACT_CONTENT - } -} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/AAIQueryResult.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/AAIQueryResult.java deleted file mode 100644 index 674da55dd..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/AAIQueryResult.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.aai.objects; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -public class AAIQueryResult { - private List relationshipList; - - private Map additionProperties; - - - public AAIQueryResult(){ - relationshipList = new ArrayList<>(); - additionProperties = new HashMap<>(); - } - - - public List getRelationshipList() { - return relationshipList; - } - - public Map getAdditionProperties() { - return additionProperties; - } -} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/Relationship.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/Relationship.java deleted file mode 100644 index d32898f1c..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/Relationship.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.aai.objects; - -import java.util.HashMap; -import java.util.Map; - - -public class Relationship { - - private String relatedTo; - - private String relatedLink; - - private Map relationShipDataMap; - - private Map relatedProperties; - - public Relationship(){ - relationShipDataMap = new HashMap<>(); - relatedProperties = new HashMap<>(); - } - - public String getRelatedTo() { - return relatedTo; - } - - public String getRelatedLink() { - return relatedLink; - } - - public Map getRelationShipDataMap() { - return relationShipDataMap; - } - - public Map getRelatedProperties() { - return relatedProperties; - } - - public void setRelatedTo(String relatedTo) { - this.relatedTo = relatedTo; - } - - public void setRelatedLink(String relatedLink) { - this.relatedLink = relatedLink; - } -} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/onap/appc/dg/aai/impl/AAIClientMock.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/onap/appc/dg/aai/impl/AAIClientMock.java new file mode 100644 index 000000000..3de308392 --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/onap/appc/dg/aai/impl/AAIClientMock.java @@ -0,0 +1,547 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.dg.aai.impl; + +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.adaptors.aai.AAIClient; +import org.onap.ccsdk.sli.adaptors.aai.AAIServiceException; +import org.onap.ccsdk.sli.adaptors.aai.data.*; +import org.onap.ccsdk.sli.adaptors.aai.data.notify.NotifyEvent; +import org.onap.ccsdk.sli.adaptors.aai.data.v1507.VServer; +import org.onap.ccsdk.sli.adaptors.aai.update.Update; + + +public class AAIClientMock implements AAIClient { + + Map mockAAI = new HashMap<>(); + + public void setMockAAI(Map mockAAI) { + this.mockAAI = mockAAI; + } + + @Override + public AAIResponse requestSdnZoneQuery(String s, String s1, String s2) throws AAIServiceException { + return null; + } + + @Override + public boolean postNetworkVceData(String s, Vce vce) throws AAIServiceException { + return false; + } + + @Override + public Vce requestNetworkVceData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean deleteNetworkVceData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public ServiceInstance requestServiceInterfaceData(String s) throws AAIServiceException { + return null; + } + + @Override + public ServiceInstance requestServiceInterfaceData(String s, String s1, String s2) throws AAIServiceException { + return null; + } + + @Override + public boolean postServiceInterfaceData(String s, String s1, String s2, ServiceInstance serviceInstance) throws AAIServiceException { + return false; + } + + @Override + public SearchResults requestServiceInstanceURL(String s) throws AAIServiceException { + return null; + } + + @Override + public Vpe requestNetworkVpeData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postNetworkVpeData(String s, Vpe vpe) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteNetworkVpeData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public Vserver requestVServerData(String s, String s1, String s2, String s3) throws AAIServiceException { + return null; + } + + @Override + public boolean postVServerData(String s, String s1, String s2, String s3, Vserver vserver) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteVServerData(String s, String s1, String s2, String s3, String s4) throws AAIServiceException { + return false; + } + + @Override + public URL requestVserverURLNodeQuery(String s) throws AAIServiceException { + return null; + } + + @Override + public String getTenantIdFromVserverUrl(URL url) { + return null; + } + + @Override + public String getCloudOwnerFromVserverUrl(URL url) { + return null; + } + + @Override + public String getCloudRegionFromVserverUrl(URL url) { + return null; + } + + @Override + public String getVServerIdFromVserverUrl(URL url, String s) { + return null; + } + + @Override + public Vserver requestVServerDataByURL(URL url) throws AAIServiceException { + return null; + } + + @Override + public VplsPe requestNetworkVplsPeData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postNetworkVplsPeData(String s, VplsPe vplsPe) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteNetworkVplsPeData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public Complex requestNetworkComplexData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postNetworkComplexData(String s, Complex complex) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteNetworkComplexData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public CtagPool requestCtagPoolData(String s, String s1, String s2) throws AAIServiceException { + return null; + } + + @Override + public VServer dataChangeRequestVServerData(URL url) throws AAIServiceException { + return null; + } + + @Override + public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException { + return null; + } + + @Override + public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException { + return null; + } + + @Override + public Vpe dataChangeRequestVpeData(URL url) throws AAIServiceException { + return null; + } + + @Override + public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException { + return null; + } + + @Override + public PServer dataChangeRequestPServerData(URL url) throws AAIServiceException { + return null; + } + + @Override + public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException { + return null; + } + + @Override + public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException { + return null; + } + + @Override + public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException { + return null; + } + + @Override + public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException { + return false; + } + + @Override + public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException { + return false; + } + + @Override + public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException { + return false; + } + + @Override + public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException { + return false; + } + + @Override + public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException { + return false; + } + + @Override + public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException { + return false; + } + + @Override + public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException { + return false; + } + + @Override + public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException { + return false; + } + + @Override + public GenericVnf requestGenericVnfData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postGenericVnfData(String s, GenericVnf genericVnf) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteGenericVnfData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public DvsSwitch requestDvsSwitchData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postDvsSwitchData(String s, DvsSwitch dvsSwitch) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteDvsSwitchData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public PInterface requestPInterfaceData(String s, String s1) throws AAIServiceException { + return null; + } + + @Override + public boolean postPInterfaceData(String s, String s1, PInterface pInterface) throws AAIServiceException { + return false; + } + + @Override + public boolean deletePInterfaceData(String s, String s1, String s2) throws AAIServiceException { + return false; + } + + @Override + public PhysicalLink requestPhysicalLinkData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postPhysicalLinkData(String s, PhysicalLink physicalLink) throws AAIServiceException { + return false; + } + + @Override + public boolean deletePhysicalLinkData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public PServer requestPServerData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postPServerData(String s, PServer pServer) throws AAIServiceException { + return false; + } + + @Override + public boolean deletePServerData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public L3Network requestL3NetworkData(String s) throws AAIServiceException { + return null; + } + + @Override + public L3Network requestL3NetworkQueryByName(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postL3NetworkData(String s, L3Network l3Network) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteL3NetworkData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public VpnBinding requestVpnBindingData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean deleteVpnBindingData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public VnfImage requestVnfImageData(String s) throws AAIServiceException { + return null; + } + + @Override + public VnfImage requestVnfImageDataByVendorModel(String s, String s1) throws AAIServiceException { + return null; + } + + @Override + public VnfImage requestVnfImageDataByVendorModelVersion(String s, String s1, String s2) throws AAIServiceException { + return null; + } + + @Override + public boolean sendNotify(NotifyEvent notifyEvent, String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public SitePairSet requestSitePairSetData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postSitePairSetData(String s, SitePairSet sitePairSet) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteSitePairSetData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public Service requestServiceData(String s) throws AAIServiceException { + return null; + } + + @Override + public boolean postServiceData(String s, Service service) throws AAIServiceException { + return false; + } + + @Override + public boolean deleteServiceData(String s, String s1) throws AAIServiceException { + return false; + } + + @Override + public QueryResponse requestNodeQuery(String s, String s1, String s2) throws AAIServiceException { + return null; + } + + @Override + public String requestDataByURL(URL url) throws AAIServiceException { + return null; + } + + @Override + public GenericVnf requestGenericVnfeNodeQuery(String s) throws AAIServiceException { + return null; + } + + @Override + public Tenant requestTenantData(String s, String s1, String s2) throws AAIServiceException { + return null; + } + + @Override + public Tenant requestTenantDataByName(String s, String s1, String s2) throws AAIServiceException { + return null; + } + + @Override + public boolean postTenantData(String s, String s1, String s2, Tenant tenant) throws AAIServiceException { + return false; + } + + @Override + public boolean updateAnAIEntry(Update update) throws AAIServiceException { + return false; + } + + @Override + public QueryStatus backup(Map map, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus restore(Map map, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus isAvailable(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus exists(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus query(String s, boolean b, String s1, String key, String prefix, String s4, SvcLogicContext ctx) throws SvcLogicException { + if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) { + for (Map.Entry entry : mockAAI.entrySet()) { + ctx.setAttribute(prefix + "." + entry.getKey(), entry.getValue()); + } + return QueryStatus.SUCCESS; + + + } else if (key.equals("vnf-id = 'test_VNF1'")){ + return QueryStatus.NOT_FOUND; + } + else if (key.equals("vnf-id = 'test_VNF3'")){ + throw new SvcLogicException(); + } + else { + return QueryStatus.FAILURE; + } + + + } + + @Override + public QueryStatus reserve(String s, String s1, String s2, String s3, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus save(String s, boolean b, boolean b1, String s1, Map map, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus release(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus delete(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus notify(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException { + return null; + } + + @Override + public QueryStatus update(String s, String key, Map data, String prefix, SvcLogicContext ctx) throws SvcLogicException { + if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) { + for (Map.Entry entry : data.entrySet()) { + mockAAI.put(entry.getKey(), entry.getValue()); + } + return QueryStatus.SUCCESS; + + + } else if (key.equals("vnf-id = 'test_VNF1'")){ + return QueryStatus.NOT_FOUND; + } + else if (key.equals("vnf-id = 'test_VNF3'")){ + throw new SvcLogicException(); + } + else { + return QueryStatus.FAILURE; + } + + } +} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/onap/appc/dg/aai/impl/AAIPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/onap/appc/dg/aai/impl/AAIPluginImplTest.java new file mode 100644 index 000000000..d2f08597e --- /dev/null +++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/onap/appc/dg/aai/impl/AAIPluginImplTest.java @@ -0,0 +1,259 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.dg.aai.impl; + +import org.junit.runner.RunWith; +import org.onap.appc.dg.aai.Constants; +import org.onap.appc.dg.aai.impl.AAIPluginImpl; +import org.onap.appc.dg.common.dao.DAOService; +import org.onap.appc.dg.common.impl.LicenseManagerImpl; +import org.onap.appc.exceptions.APPCException; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.adaptors.aai.AAIClient; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.*; + + +@RunWith(PowerMockRunner.class) +@PrepareForTest({AAIPluginImpl.class, FrameworkUtil.class}) +public class AAIPluginImplTest { + private AAIPluginImpl aaiPlugin; + private AAIClientMock aaiClient; + + private final BundleContext bundleContext= Mockito.mock(BundleContext.class); + private final Bundle bundleService=Mockito.mock(Bundle.class); + private final ServiceReference sref=Mockito.mock(ServiceReference.class); + + String prefix = "aai.input.data"; + String vnfId = "test_VNF"; + String vnfId1 = "test_VNF1"; + String vnfId2 = "test_VNF2"; + String vnfId3 = "test_VNF3"; + + @Before + public void setUp() throws NoSuchFieldException, IllegalAccessException { + aaiClient = new AAIClientMock(); + PowerMockito.mockStatic(FrameworkUtil.class); + PowerMockito.when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService); + PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext); + PowerMockito.when(bundleContext.getServiceReference(Matchers.any(Class.class))).thenReturn(sref); + PowerMockito.when(bundleContext.getService(sref)).thenReturn(aaiClient); + aaiPlugin = new AAIPluginImpl(); + + + } + + + + + @Test + public void testPostGenericVnfData() throws Exception { + Map params = new HashMap<>(); + params.put(prefix+"."+"license-key-uuid", "123"); + params.put(prefix+"."+"license-assignment-group-uuid", "1234"); + params.put(prefix+"."+"data.license-key", "12345"); + + HashMap mockAAI = new HashMap<>(); + aaiClient.setMockAAI(mockAAI); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("aai.vnfID", vnfId); + ctx.setAttribute("aai.prefix", prefix); + + aaiPlugin.postGenericVnfData(params, ctx); + + Assert.assertEquals("wrong license-key-uuid","123", mockAAI.get("license-key-uuid")); + Assert.assertEquals("wrong license-assignment-group-uuid","1234", mockAAI.get("license-assignment-group-uuid")); + Assert.assertEquals("wrong data.license-key","12345", mockAAI.get("data.license-key")); + } + + + @Test + public void testPostGenericVnfDataNegativeVnfNotFound() throws Exception { + Map params = new HashMap<>(); + params.put(prefix+"."+"license-key-uuid", "123"); + params.put(prefix+"."+"license-assignment-group-uuid", "1234"); + params.put(prefix+"."+"data.license-key", "12345"); + + HashMap mockAAI = new HashMap<>(); + + aaiClient.setMockAAI(mockAAI); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("aai.vnfID", vnfId1); + ctx.setAttribute("aai.prefix", prefix); + + try { + aaiPlugin.postGenericVnfData(params, ctx); + Assert.assertTrue(false); + } catch (APPCException e) { + Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); + } + + } + + + @Test + public void testPostGenericVnfDataNegativeFailure() throws Exception { + Map params = new HashMap<>(); + params.put(prefix+"."+"license-key-uuid", "123"); + params.put(prefix+"."+"license-assignment-group-uuid", "1234"); + params.put(prefix+"."+"data.license-key", "12345"); + + HashMap mockAAI = new HashMap<>(); + + aaiClient.setMockAAI(mockAAI); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("aai.vnfID", vnfId2); + ctx.setAttribute("aai.prefix", prefix); + + try { + aaiPlugin.postGenericVnfData(params, ctx); + Assert.assertTrue(false); + } catch (APPCException e) { + Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); + } + + } + + + @Test + public void testPostGenericVnfDataNegativeSvcLogicException() throws Exception { + Map params = new HashMap<>(); + params.put(prefix+"."+"license-key-uuid", "123"); + params.put(prefix+"."+"license-assignment-group-uuid", "1234"); + params.put(prefix+"."+"data.license-key", "12345"); + + HashMap mockAAI = new HashMap<>(); + + aaiClient.setMockAAI(mockAAI); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("aai.vnfID", vnfId3); + ctx.setAttribute("aai.prefix", prefix); + + try { + aaiPlugin.postGenericVnfData(params, ctx); + Assert.assertTrue(false); + } catch (APPCException e) { + Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); + } + + } + + @Test + public void testGetGenericVnfData() throws Exception { + String vnfNameKey = "vnf-name"; + String vnfType = "VSCP"; + String vnfTypeKey = "vnf-type"; + String provStatus = "Active"; + String provStatusKey = "prov-status"; + String orchestrationStatus = "Running"; + String orchestrationStatusKey = "orchestration-status"; + + Map params = new HashMap<>(); + HashMap mockAAI = new HashMap<>(); + mockAAI.put(vnfNameKey,vnfId); + mockAAI.put(vnfTypeKey,vnfType); + mockAAI.put(provStatusKey, provStatus); + mockAAI.put(orchestrationStatusKey, orchestrationStatus); + aaiClient.setMockAAI(mockAAI); + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("aai.vnfID", vnfId); + ctx.setAttribute("aai.prefix", prefix); + + + aaiPlugin.getGenericVnfData(params, ctx); + + Assert.assertEquals("wrong "+vnfNameKey,vnfId, ctx.getAttribute(prefix + "." + vnfNameKey)); + Assert.assertEquals("wrong "+orchestrationStatusKey,orchestrationStatus, ctx.getAttribute(prefix + "." + orchestrationStatusKey)); + Assert.assertEquals("wrong "+vnfTypeKey,vnfType, ctx.getAttribute(prefix + "." + vnfTypeKey)); + Assert.assertEquals("wrong "+provStatusKey,provStatus, ctx.getAttribute(prefix + "." + provStatusKey )); + } + + + + + @Test + public void testGetGenericVnfDataNegativeVnfNotFound() throws Exception { + + Map params = new HashMap<>(); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("aai.vnfID", vnfId1); + ctx.setAttribute("aai.prefix", prefix); + + + try { + aaiPlugin.getGenericVnfData(params, ctx); + Assert.assertTrue(false); + } catch (APPCException e) { + Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); + } + } + + + @Test + public void testGetGenericVnfDataNegativeFailure() throws Exception { + + Map params = new HashMap<>(); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("aai.vnfID", vnfId2); + ctx.setAttribute("aai.prefix", prefix); + + try { + aaiPlugin.getGenericVnfData(params, ctx); + Assert.assertTrue(false); + } catch (APPCException e) { + Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); + } + } + + + @Test + public void testGetGenericVnfDataNegativeSvcLogicException() throws Exception { + + Map params = new HashMap<>(); + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("aai.vnfID", vnfId3); + ctx.setAttribute("aai.prefix", prefix); + + try { + aaiPlugin.getGenericVnfData(params, ctx); + Assert.assertTrue(false); + } catch (APPCException e) { + Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); + } + } + +} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIClientMock.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIClientMock.java deleted file mode 100644 index 3de308392..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIClientMock.java +++ /dev/null @@ -1,547 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.aai.impl; - -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.adaptors.aai.AAIClient; -import org.onap.ccsdk.sli.adaptors.aai.AAIServiceException; -import org.onap.ccsdk.sli.adaptors.aai.data.*; -import org.onap.ccsdk.sli.adaptors.aai.data.notify.NotifyEvent; -import org.onap.ccsdk.sli.adaptors.aai.data.v1507.VServer; -import org.onap.ccsdk.sli.adaptors.aai.update.Update; - - -public class AAIClientMock implements AAIClient { - - Map mockAAI = new HashMap<>(); - - public void setMockAAI(Map mockAAI) { - this.mockAAI = mockAAI; - } - - @Override - public AAIResponse requestSdnZoneQuery(String s, String s1, String s2) throws AAIServiceException { - return null; - } - - @Override - public boolean postNetworkVceData(String s, Vce vce) throws AAIServiceException { - return false; - } - - @Override - public Vce requestNetworkVceData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean deleteNetworkVceData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public ServiceInstance requestServiceInterfaceData(String s) throws AAIServiceException { - return null; - } - - @Override - public ServiceInstance requestServiceInterfaceData(String s, String s1, String s2) throws AAIServiceException { - return null; - } - - @Override - public boolean postServiceInterfaceData(String s, String s1, String s2, ServiceInstance serviceInstance) throws AAIServiceException { - return false; - } - - @Override - public SearchResults requestServiceInstanceURL(String s) throws AAIServiceException { - return null; - } - - @Override - public Vpe requestNetworkVpeData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postNetworkVpeData(String s, Vpe vpe) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteNetworkVpeData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public Vserver requestVServerData(String s, String s1, String s2, String s3) throws AAIServiceException { - return null; - } - - @Override - public boolean postVServerData(String s, String s1, String s2, String s3, Vserver vserver) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteVServerData(String s, String s1, String s2, String s3, String s4) throws AAIServiceException { - return false; - } - - @Override - public URL requestVserverURLNodeQuery(String s) throws AAIServiceException { - return null; - } - - @Override - public String getTenantIdFromVserverUrl(URL url) { - return null; - } - - @Override - public String getCloudOwnerFromVserverUrl(URL url) { - return null; - } - - @Override - public String getCloudRegionFromVserverUrl(URL url) { - return null; - } - - @Override - public String getVServerIdFromVserverUrl(URL url, String s) { - return null; - } - - @Override - public Vserver requestVServerDataByURL(URL url) throws AAIServiceException { - return null; - } - - @Override - public VplsPe requestNetworkVplsPeData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postNetworkVplsPeData(String s, VplsPe vplsPe) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteNetworkVplsPeData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public Complex requestNetworkComplexData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postNetworkComplexData(String s, Complex complex) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteNetworkComplexData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public CtagPool requestCtagPoolData(String s, String s1, String s2) throws AAIServiceException { - return null; - } - - @Override - public VServer dataChangeRequestVServerData(URL url) throws AAIServiceException { - return null; - } - - @Override - public CtagPool dataChangeRequestCtagPoolData(URL url) throws AAIServiceException { - return null; - } - - @Override - public VplsPe dataChangeRequestVplsPeData(URL url) throws AAIServiceException { - return null; - } - - @Override - public Vpe dataChangeRequestVpeData(URL url) throws AAIServiceException { - return null; - } - - @Override - public DvsSwitch dataChangeRequestDvsSwitchData(URL url) throws AAIServiceException { - return null; - } - - @Override - public PServer dataChangeRequestPServerData(URL url) throws AAIServiceException { - return null; - } - - @Override - public OamNetwork dataChangeRequestOAMNetworkData(URL url) throws AAIServiceException { - return null; - } - - @Override - public AvailabilityZone dataChangeRequestAvailabilityZoneData(URL url) throws AAIServiceException { - return null; - } - - @Override - public Complex dataChangeRequestComplexData(URL url) throws AAIServiceException { - return null; - } - - @Override - public boolean dataChangeDeleteVServerData(URL url) throws AAIServiceException { - return false; - } - - @Override - public boolean dataChangeDeleteCtagPoolData(URL url) throws AAIServiceException { - return false; - } - - @Override - public boolean dataChangeDeleteVplsPeData(URL url) throws AAIServiceException { - return false; - } - - @Override - public boolean dataChangeDeleteVpeData(URL url) throws AAIServiceException { - return false; - } - - @Override - public boolean dataChangeDeleteDvsSwitchData(URL url) throws AAIServiceException { - return false; - } - - @Override - public boolean dataChangeDeleteOAMNetworkData(URL url) throws AAIServiceException { - return false; - } - - @Override - public boolean dataChangeDeleteAvailabilityZoneData(URL url) throws AAIServiceException { - return false; - } - - @Override - public boolean dataChangeDeleteComplexData(URL url) throws AAIServiceException { - return false; - } - - @Override - public GenericVnf requestGenericVnfData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postGenericVnfData(String s, GenericVnf genericVnf) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteGenericVnfData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public DvsSwitch requestDvsSwitchData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postDvsSwitchData(String s, DvsSwitch dvsSwitch) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteDvsSwitchData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public PInterface requestPInterfaceData(String s, String s1) throws AAIServiceException { - return null; - } - - @Override - public boolean postPInterfaceData(String s, String s1, PInterface pInterface) throws AAIServiceException { - return false; - } - - @Override - public boolean deletePInterfaceData(String s, String s1, String s2) throws AAIServiceException { - return false; - } - - @Override - public PhysicalLink requestPhysicalLinkData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postPhysicalLinkData(String s, PhysicalLink physicalLink) throws AAIServiceException { - return false; - } - - @Override - public boolean deletePhysicalLinkData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public PServer requestPServerData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postPServerData(String s, PServer pServer) throws AAIServiceException { - return false; - } - - @Override - public boolean deletePServerData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public L3Network requestL3NetworkData(String s) throws AAIServiceException { - return null; - } - - @Override - public L3Network requestL3NetworkQueryByName(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postL3NetworkData(String s, L3Network l3Network) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteL3NetworkData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public VpnBinding requestVpnBindingData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean deleteVpnBindingData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public VnfImage requestVnfImageData(String s) throws AAIServiceException { - return null; - } - - @Override - public VnfImage requestVnfImageDataByVendorModel(String s, String s1) throws AAIServiceException { - return null; - } - - @Override - public VnfImage requestVnfImageDataByVendorModelVersion(String s, String s1, String s2) throws AAIServiceException { - return null; - } - - @Override - public boolean sendNotify(NotifyEvent notifyEvent, String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public SitePairSet requestSitePairSetData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postSitePairSetData(String s, SitePairSet sitePairSet) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteSitePairSetData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public Service requestServiceData(String s) throws AAIServiceException { - return null; - } - - @Override - public boolean postServiceData(String s, Service service) throws AAIServiceException { - return false; - } - - @Override - public boolean deleteServiceData(String s, String s1) throws AAIServiceException { - return false; - } - - @Override - public QueryResponse requestNodeQuery(String s, String s1, String s2) throws AAIServiceException { - return null; - } - - @Override - public String requestDataByURL(URL url) throws AAIServiceException { - return null; - } - - @Override - public GenericVnf requestGenericVnfeNodeQuery(String s) throws AAIServiceException { - return null; - } - - @Override - public Tenant requestTenantData(String s, String s1, String s2) throws AAIServiceException { - return null; - } - - @Override - public Tenant requestTenantDataByName(String s, String s1, String s2) throws AAIServiceException { - return null; - } - - @Override - public boolean postTenantData(String s, String s1, String s2, Tenant tenant) throws AAIServiceException { - return false; - } - - @Override - public boolean updateAnAIEntry(Update update) throws AAIServiceException { - return false; - } - - @Override - public QueryStatus backup(Map map, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus restore(Map map, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus isAvailable(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus exists(String s, String s1, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus query(String s, boolean b, String s1, String key, String prefix, String s4, SvcLogicContext ctx) throws SvcLogicException { - if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) { - for (Map.Entry entry : mockAAI.entrySet()) { - ctx.setAttribute(prefix + "." + entry.getKey(), entry.getValue()); - } - return QueryStatus.SUCCESS; - - - } else if (key.equals("vnf-id = 'test_VNF1'")){ - return QueryStatus.NOT_FOUND; - } - else if (key.equals("vnf-id = 'test_VNF3'")){ - throw new SvcLogicException(); - } - else { - return QueryStatus.FAILURE; - } - - - } - - @Override - public QueryStatus reserve(String s, String s1, String s2, String s3, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus save(String s, boolean b, boolean b1, String s1, Map map, String s2, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus release(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus delete(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus notify(String s, String s1, SvcLogicContext svcLogicContext) throws SvcLogicException { - return null; - } - - @Override - public QueryStatus update(String s, String key, Map data, String prefix, SvcLogicContext ctx) throws SvcLogicException { - if (s.equals("generic-vnf") && key.equals("vnf-id = 'test_VNF'") && ctx != null) { - for (Map.Entry entry : data.entrySet()) { - mockAAI.put(entry.getKey(), entry.getValue()); - } - return QueryStatus.SUCCESS; - - - } else if (key.equals("vnf-id = 'test_VNF1'")){ - return QueryStatus.NOT_FOUND; - } - else if (key.equals("vnf-id = 'test_VNF3'")){ - throw new SvcLogicException(); - } - else { - return QueryStatus.FAILURE; - } - - } -} diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java deleted file mode 100644 index d2f08597e..000000000 --- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.dg.aai.impl; - -import org.junit.runner.RunWith; -import org.onap.appc.dg.aai.Constants; -import org.onap.appc.dg.aai.impl.AAIPluginImpl; -import org.onap.appc.dg.common.dao.DAOService; -import org.onap.appc.dg.common.impl.LicenseManagerImpl; -import org.onap.appc.exceptions.APPCException; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.adaptors.aai.AAIClient; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.*; - - -@RunWith(PowerMockRunner.class) -@PrepareForTest({AAIPluginImpl.class, FrameworkUtil.class}) -public class AAIPluginImplTest { - private AAIPluginImpl aaiPlugin; - private AAIClientMock aaiClient; - - private final BundleContext bundleContext= Mockito.mock(BundleContext.class); - private final Bundle bundleService=Mockito.mock(Bundle.class); - private final ServiceReference sref=Mockito.mock(ServiceReference.class); - - String prefix = "aai.input.data"; - String vnfId = "test_VNF"; - String vnfId1 = "test_VNF1"; - String vnfId2 = "test_VNF2"; - String vnfId3 = "test_VNF3"; - - @Before - public void setUp() throws NoSuchFieldException, IllegalAccessException { - aaiClient = new AAIClientMock(); - PowerMockito.mockStatic(FrameworkUtil.class); - PowerMockito.when(FrameworkUtil.getBundle(Matchers.any(Class.class))).thenReturn(bundleService); - PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext); - PowerMockito.when(bundleContext.getServiceReference(Matchers.any(Class.class))).thenReturn(sref); - PowerMockito.when(bundleContext.getService(sref)).thenReturn(aaiClient); - aaiPlugin = new AAIPluginImpl(); - - - } - - - - - @Test - public void testPostGenericVnfData() throws Exception { - Map params = new HashMap<>(); - params.put(prefix+"."+"license-key-uuid", "123"); - params.put(prefix+"."+"license-assignment-group-uuid", "1234"); - params.put(prefix+"."+"data.license-key", "12345"); - - HashMap mockAAI = new HashMap<>(); - aaiClient.setMockAAI(mockAAI); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("aai.vnfID", vnfId); - ctx.setAttribute("aai.prefix", prefix); - - aaiPlugin.postGenericVnfData(params, ctx); - - Assert.assertEquals("wrong license-key-uuid","123", mockAAI.get("license-key-uuid")); - Assert.assertEquals("wrong license-assignment-group-uuid","1234", mockAAI.get("license-assignment-group-uuid")); - Assert.assertEquals("wrong data.license-key","12345", mockAAI.get("data.license-key")); - } - - - @Test - public void testPostGenericVnfDataNegativeVnfNotFound() throws Exception { - Map params = new HashMap<>(); - params.put(prefix+"."+"license-key-uuid", "123"); - params.put(prefix+"."+"license-assignment-group-uuid", "1234"); - params.put(prefix+"."+"data.license-key", "12345"); - - HashMap mockAAI = new HashMap<>(); - - aaiClient.setMockAAI(mockAAI); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("aai.vnfID", vnfId1); - ctx.setAttribute("aai.prefix", prefix); - - try { - aaiPlugin.postGenericVnfData(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); - } - - } - - - @Test - public void testPostGenericVnfDataNegativeFailure() throws Exception { - Map params = new HashMap<>(); - params.put(prefix+"."+"license-key-uuid", "123"); - params.put(prefix+"."+"license-assignment-group-uuid", "1234"); - params.put(prefix+"."+"data.license-key", "12345"); - - HashMap mockAAI = new HashMap<>(); - - aaiClient.setMockAAI(mockAAI); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("aai.vnfID", vnfId2); - ctx.setAttribute("aai.prefix", prefix); - - try { - aaiPlugin.postGenericVnfData(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); - } - - } - - - @Test - public void testPostGenericVnfDataNegativeSvcLogicException() throws Exception { - Map params = new HashMap<>(); - params.put(prefix+"."+"license-key-uuid", "123"); - params.put(prefix+"."+"license-assignment-group-uuid", "1234"); - params.put(prefix+"."+"data.license-key", "12345"); - - HashMap mockAAI = new HashMap<>(); - - aaiClient.setMockAAI(mockAAI); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("aai.vnfID", vnfId3); - ctx.setAttribute("aai.prefix", prefix); - - try { - aaiPlugin.postGenericVnfData(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); - } - - } - - @Test - public void testGetGenericVnfData() throws Exception { - String vnfNameKey = "vnf-name"; - String vnfType = "VSCP"; - String vnfTypeKey = "vnf-type"; - String provStatus = "Active"; - String provStatusKey = "prov-status"; - String orchestrationStatus = "Running"; - String orchestrationStatusKey = "orchestration-status"; - - Map params = new HashMap<>(); - HashMap mockAAI = new HashMap<>(); - mockAAI.put(vnfNameKey,vnfId); - mockAAI.put(vnfTypeKey,vnfType); - mockAAI.put(provStatusKey, provStatus); - mockAAI.put(orchestrationStatusKey, orchestrationStatus); - aaiClient.setMockAAI(mockAAI); - - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("aai.vnfID", vnfId); - ctx.setAttribute("aai.prefix", prefix); - - - aaiPlugin.getGenericVnfData(params, ctx); - - Assert.assertEquals("wrong "+vnfNameKey,vnfId, ctx.getAttribute(prefix + "." + vnfNameKey)); - Assert.assertEquals("wrong "+orchestrationStatusKey,orchestrationStatus, ctx.getAttribute(prefix + "." + orchestrationStatusKey)); - Assert.assertEquals("wrong "+vnfTypeKey,vnfType, ctx.getAttribute(prefix + "." + vnfTypeKey)); - Assert.assertEquals("wrong "+provStatusKey,provStatus, ctx.getAttribute(prefix + "." + provStatusKey )); - } - - - - - @Test - public void testGetGenericVnfDataNegativeVnfNotFound() throws Exception { - - Map params = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("aai.vnfID", vnfId1); - ctx.setAttribute("aai.prefix", prefix); - - - try { - aaiPlugin.getGenericVnfData(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); - } - } - - - @Test - public void testGetGenericVnfDataNegativeFailure() throws Exception { - - Map params = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("aai.vnfID", vnfId2); - ctx.setAttribute("aai.prefix", prefix); - - try { - aaiPlugin.getGenericVnfData(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); - } - } - - - @Test - public void testGetGenericVnfDataNegativeSvcLogicException() throws Exception { - - Map params = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("aai.vnfID", vnfId3); - ctx.setAttribute("aai.prefix", prefix); - - try { - aaiPlugin.getGenericVnfData(params, ctx); - Assert.assertTrue(false); - } catch (APPCException e) { - Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE)); - } - } - -} -- cgit 1.2.3-korg