diff options
Diffstat (limited to 'appc-adapters/appc-netconf-adapter')
-rw-r--r-- | appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java | 6 | ||||
-rw-r--r-- | appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivatorTest.java | 42 | ||||
-rw-r--r-- | appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/OperationalStateValidatorTest.java (renamed from appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java) | 10 |
3 files changed, 51 insertions, 7 deletions
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java index 2c44c69c3..f412223ec 100644 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs + * ================================================================================ + * Modifications Copyright (C) 2019 Ericsson * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,13 +63,13 @@ public class AppcNetconfAdapterActivator implements BundleActivator { /* * The reference to the actual implementation object that implements the services */ - NetconfClientFactory clientFactory = new NetconfClientFactory(); + NetconfClientFactory clientFactory = new NetconfClientFactory(); factoryRegistration = context.registerService(NetconfClientFactory.class, clientFactory, null); NetconfDataAccessService dataAccessService = new NetconfDataAccessServiceImpl(); //set dblib service ServiceReference sref = context.getServiceReference(DbLibService.class.getName()); dataAccessService.setDbLibService((DbLibService)context.getService(sref)); - /////////////////////////////////// + factoryRegistration = context.registerService(NetconfDataAccessService.class, dataAccessService, null); } } diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivatorTest.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivatorTest.java new file mode 100644 index 000000000..c1321ec10 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivatorTest.java @@ -0,0 +1,42 @@ +package org.onap.appc.adapter.netconf; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.appc.adapter.netconf.internal.NetconfDataAccessServiceImpl; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.powermock.reflect.Whitebox; + +public class AppcNetconfAdapterActivatorTest { + + private BundleContext bundle; + + @Before + public void setup() { + bundle = Mockito.mock(BundleContext.class); + } + + @Test + public void testStart() throws Exception { + AppcNetconfAdapterActivator activator = new AppcNetconfAdapterActivator(); + activator.start(bundle); + Mockito.verify(bundle, Mockito.times(2)).registerService(Mockito.any(Class.class), + Mockito.any(NetconfDataAccessServiceImpl.class), Mockito.any()); + } + + @Test + public void testStop() throws Exception { + AppcNetconfAdapterActivator activator = Mockito.spy(new AppcNetconfAdapterActivator()); + ServiceRegistration registration = Mockito.mock(ServiceRegistration.class); + ServiceRegistration reporterRegistration = Mockito.mock(ServiceRegistration.class); + ServiceRegistration factoryRegistration = Mockito.mock(ServiceRegistration.class); + ServiceRegistration dbRegistration = Mockito.mock(ServiceRegistration.class); + Whitebox.setInternalState(activator, "registration", registration); + Whitebox.setInternalState(activator, "reporterRegistration", reporterRegistration); + Whitebox.setInternalState(activator, "factoryRegistration", factoryRegistration); + Whitebox.setInternalState(activator, "dbRegistration", dbRegistration); + activator.stop(bundle); + Mockito.verify(dbRegistration).unregister(); + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/OperationalStateValidatorTest.java index e3521910e..5fe7c79c5 100644 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/OperationalStateValidatorTest.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs + * ================================================================================ + * Modifications Copyright (C) 2019 Ericsson * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +23,12 @@ * ============LICENSE_END========================================================= */ -import org.onap.appc.exceptions.APPCException; -import org.junit.Test; -import org.onap.appc.adapter.netconf.OperationalStateValidator; -import org.onap.appc.adapter.netconf.OperationalStateValidatorFactory; -import org.onap.appc.adapter.netconf.VnfType; +package org.onap.appc.adapter.netconf; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import org.junit.Test; +import org.onap.appc.exceptions.APPCException; public class OperationalStateValidatorTest { |