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 --- .../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 ---------- 4 files changed, 806 insertions(+), 806 deletions(-) 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/src/main/test') 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