summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-05 13:59:47 +0000
committerPatrick Brady <patrick.brady@att.com>2019-02-06 21:32:54 +0000
commit4fc2e746a0c79e6f81fd08241733b02b781dc5d0 (patch)
treee616e5a7ec9236e6f8b021c0071363210e7baa16 /appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle
parente38c122ec2c57e63d0788148841fbe6231957482 (diff)
Test coverage for AppcNetconfAdapterActivator
Added 100% coverage for untested class. Moved other test file to correct package. Issue-ID: APPC-1389 Change-Id: I73e768f21d5cda8865f891c63b9ad3f3ea2cce80 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle')
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java6
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivatorTest.java42
-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 {