* 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.
/*
* 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);
}
}
--- /dev/null
+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();
+ }
+}
* 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.
* ============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 {