summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2020-08-19 16:33:48 +0200
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2020-08-19 16:34:29 +0200
commit7a80462a5fabf473bcb48e1b3ede695fbc067d2e (patch)
tree3faa2fb2b2244136b82e1441e36d6a90cc755d22 /sdnr/wt/devicemanager-adapter-manager/provider/src/test/java
parent6e164bc0f1f6688714033e95731942a89f5f1868 (diff)
New Devicemanager for NTSIM Functionality
devicemanager-adapter-manager for support of NTSIM functionality by removing from devicemanager-oran Issue-ID: CCSDK-2573 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: Ie9a667c954749055b81caad8131d54c412a47270 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-adapter-manager/provider/src/test/java')
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java82
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java73
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java95
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/NetconfAccessorMock.java92
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/TransactionUtilsMock.java47
5 files changed, 389 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java
new file mode 100644
index 000000000..0fa83c031
--- /dev/null
+++ b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java
@@ -0,0 +1,82 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+import java.io.IOException;
+import java.util.Optional;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.AdapterManagerNetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock.NetconfAccessorMock;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock.TransactionUtilsMock;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public class TestAdapterManagerNetworkElement {
+
+ static NetconfAccessorMock accessor;
+ static DeviceManagerServiceProvider serviceProvider;
+ static Capabilities capabilities;
+ QName qCapability;
+
+ @BeforeClass
+ public static void init() throws InterruptedException, IOException {
+ capabilities = mock(Capabilities.class);
+ //accessor = mock(NetconfAccessorMock.class);
+ accessor = spy(new NetconfAccessorMock(null, null, null, null));
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+
+ NodeId nNodeId = new NodeId("nSky");
+ when(accessor.getCapabilites()).thenReturn(capabilities);
+ when(accessor.getNodeId()).thenReturn(nNodeId);
+ when(accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock());
+
+ DataProvider dataProvider = mock(DataProvider.class);
+ when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
+ }
+
+ @Test
+ public void test() {
+ Optional<NetworkElement> adapterManagerNe;
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true);
+ AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory();
+ adapterManagerNe = factory.create(accessor, serviceProvider);
+ assertTrue(factory.create(accessor, serviceProvider).isPresent());
+ adapterManagerNe.get().register();
+ adapterManagerNe.get().deregister();
+ adapterManagerNe.get().getAcessor();
+ adapterManagerNe.get().getDeviceType();
+ assertEquals(adapterManagerNe.get().getNodeId().getValue(), "nSky");
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+
+ }
+}
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java
new file mode 100644
index 000000000..228401d6e
--- /dev/null
+++ b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java
@@ -0,0 +1,73 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.io.IOException;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.AdapterManagerNetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock.NetconfAccessorMock;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public class TestAdapterManagerNetworkElementFactory {
+
+ static NetconfAccessor accessor;
+ static DeviceManagerServiceProvider serviceProvider;
+ static Capabilities capabilities;
+ QName qCapability;
+
+ @BeforeClass
+ public static void init() throws InterruptedException, IOException {
+ capabilities = mock(Capabilities.class);
+ accessor = mock(NetconfAccessorMock.class);
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+
+ when(accessor.getCapabilites()).thenReturn(capabilities);
+ when(serviceProvider.getDataProvider()).thenReturn(null);
+
+
+ }
+
+ @Test
+ public void testCreateSimulator() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true);
+ AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory();
+ assertTrue(factory.create(accessor, serviceProvider).isPresent());
+ }
+
+ @Test
+ public void testCreateNone() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
+ AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory();
+ assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+
+ }
+}
+
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java
new file mode 100644
index 000000000..5f79d943a
--- /dev/null
+++ b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java
@@ -0,0 +1,95 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.DeviceManagerAdapterManagerImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestDeviceManagerAdapterManagerImpl {
+ private static Path KARAF_ETC = Paths.get("etc");
+ private static final Logger LOG = LoggerFactory.getLogger(TestDeviceManagerAdapterManagerImpl.class);
+ DeviceManagerAdapterManagerImpl devMgrAdapterManager;
+
+ @Before
+ public void init() throws InterruptedException, IOException {
+ /*System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName());
+ Path etc = KARAF_ETC;
+ delete(etc);
+
+ System.out.println("Create empty:" + etc.toString());
+ Files.createDirectories(etc);*/
+ }
+
+ @Test
+ public void test() throws Exception {
+ devMgrAdapterManager = new DeviceManagerAdapterManagerImpl();
+ /*DeviceManagerImpl devMgr = new DeviceManagerImpl();
+
+ try {
+ devMgr.init();
+ devMgrOran.setNetconfNetworkElementService(devMgr);
+ devMgrOran.init();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }*/
+ /*
+ * devMgrOran.setNetconfNetworkElementService(null); devMgrOran.init();
+ * NetconfNetworkElementService netConfNetworkElementService =
+ * mock(NetconfNetworkElementService.class); devMgrOran =
+ * mock(DeviceManagerORanImpl.class);
+ * when(netConfNetworkElementService.registerNetworkElementFactory(new
+ * ORanNetworkElementFactory())).thenReturn(null);
+ */
+
+
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+ devMgrAdapterManager.close();
+ }
+
+ private static void delete(Path etc) throws IOException {
+ if (Files.exists(etc)) {
+ System.out.println("Found, removing:" + etc.toString());
+ delete(etc.toFile());
+ }
+ }
+
+ private static void delete(File f) throws IOException {
+ if (f.isDirectory()) {
+ for (File c : f.listFiles()) {
+ delete(c);
+ }
+ }
+ if (!f.delete()) {
+ throw new FileNotFoundException("Failed to delete file: " + f);
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/NetconfAccessorMock.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/NetconfAccessorMock.java
new file mode 100644
index 000000000..fa0a9cb2f
--- /dev/null
+++ b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/NetconfAccessorMock.java
@@ -0,0 +1,92 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.eclipse.jdt.annotation.NonNull;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPoint;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+/**
+ */
+public class NetconfAccessorMock implements NetconfAccessor {
+
+ private final NodeId nNodeId;
+ private final NetconfNode netconfNode;
+ private final MountPoint mountpoint;
+ private final DataBroker netconfNodeDataBroker;
+
+ public NetconfAccessorMock(NodeId nNodeId, NetconfNode netconfNode, MountPoint mountpoint,
+ DataBroker netconfNodeDataBroker) {
+ this.nNodeId = nNodeId;
+ this.netconfNode = netconfNode;
+ this.mountpoint = mountpoint;
+ this.netconfNodeDataBroker = netconfNodeDataBroker;
+ }
+
+ @Override
+ public NodeId getNodeId() {
+ return nNodeId;
+ }
+
+ @Override
+ public NetconfNode getNetconfNode() {
+ return netconfNode;
+ }
+
+ @Override
+ public Capabilities getCapabilites() {
+ return null;
+ }
+
+ @Override
+ public DataBroker getDataBroker() {
+ return netconfNodeDataBroker;
+ }
+
+ @Override
+ public MountPoint getMountpoint() {
+ return mountpoint;
+ }
+
+ @Override
+ public TransactionUtils getTransactionUtils() {
+ return null;
+ }
+
+ @Override
+ public <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener(
+ @NonNull T listener) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(String streamName) {
+ return null;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/TransactionUtilsMock.java
new file mode 100644
index 000000000..e3aa0ae43
--- /dev/null
+++ b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/TransactionUtilsMock.java
@@ -0,0 +1,47 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class TransactionUtilsMock implements TransactionUtils {
+
+ @Override
+ public <T extends DataObject> @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
+ InstanceIdentifier<T> iid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker,
+ LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication,
+ AtomicReference<String> statusIndicator) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}