summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager-oran/provider/src/test
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2020-02-14 11:44:35 +0100
committerKAPIL SINGAL <ks220y@att.com>2020-02-14 16:21:50 +0000
commit635d0ff476db287c1d9ffe50e44e02d8326c2995 (patch)
tree8ee6c28942112eefe26c52092bb05c86f56fa623 /sdnr/wt/devicemanager-oran/provider/src/test
parent53f1c13a96a6ee7a12b7bc3642e6a63d54cd07f3 (diff)
Add Unit test cases
Add Unit tests to provide Code coverage for compliance Issue-ID: SDNC-1072 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: I496623ce12591b87119ff21198213a0944f09ef6
Diffstat (limited to 'sdnr/wt/devicemanager-oran/provider/src/test')
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java84
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java7
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java87
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java30
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java191
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java85
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java86
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfAccessorMock.java92
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java62
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java47
10 files changed, 771 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java
new file mode 100644
index 000000000..1b5ed9b86
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java
@@ -0,0 +1,84 @@
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.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.oran.impl.DeviceManagerORanImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class TestDeviceManagerORanImpl {
+ private static Path KARAF_ETC = Paths.get("etc");
+ private static final Logger LOG = LoggerFactory.getLogger(TestDeviceManagerORanImpl.class);
+ DeviceManagerORanImpl devMgrOran;
+
+ @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 {
+ devMgrOran = new DeviceManagerORanImpl();
+ /*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 {
+ devMgrOran.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-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java
new file mode 100644
index 000000000..caa4e6463
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java
@@ -0,0 +1,7 @@
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass;
+
+public interface TestHardwareClass extends HardwareClass {
+
+}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java
new file mode 100644
index 000000000..c309d86c1
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * ============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.oran.test;
+
+import static org.mockito.Mockito.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanChangeNotificationListener;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.EditOperationType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.EditBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
+
+public class TestORanChangeNotificationListener {
+
+ private static final String NODEID = "node1";
+
+ @Test
+ public void test() {
+
+ NetconfAccessor netconfAccessor = mock(NetconfAccessor.class);
+ DataProvider databaseService = mock(DataProvider.class);
+ ORanChangeNotificationListener notifListener = new ORanChangeNotificationListener(netconfAccessor,
+ databaseService);
+ when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
+ Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() {
+
+ @Override
+ public int compareTo(PathArgument arg0) {
+ return 0;
+ }
+
+ @Override
+ public Class<? extends DataObject> getType() {
+ return DataObject.class;
+ }
+ });
+ InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments);
+
+ notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create,target));
+ EventlogEntity event = new EventlogBuilder().setNodeId(NODEID)
+ .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build();
+ verify(databaseService).writeEventLog(event);
+
+ }
+
+ /**
+ * @param type
+ * @return
+ */
+ private static NetconfConfigChange createNotification(EditOperationType type,InstanceIdentifier<?> target) {
+ NetconfConfigChange change = mock(NetconfConfigChange.class);
+
+ @SuppressWarnings("null")
+ final @NonNull List<Edit> edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build());
+ when(change.nonnullEdit()).thenReturn(edits);
+ return change;
+ }
+}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java
new file mode 100644
index 000000000..9cdb83c1d
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * ============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.oran.test;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanFaultNotificationListener;
+
+public class TestORanFaultNotificationListener {
+
+ @Test
+ public void test() {
+ ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener();
+ faultListener.onAlarmNotif(null);
+ }
+}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java
new file mode 100644
index 000000000..4752b6802
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * ============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.oran.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
+
+import java.util.List;
+import java.util.Optional;
+import java.io.IOException;
+import java.util.Date;
+
+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.ne.service.NetworkElement;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.TransactionUtilsMock;
+import org.opendaylight.yang.gen.v1.urn.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
+import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.NetconfAccessorMock;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
+
+public class TestORanNetworkElement {
+
+ static NetconfAccessorMock accessor;
+ static DeviceManagerServiceProvider serviceProvider;
+ static Capabilities capabilities;
+ QName qCapability;
+
+ @SuppressWarnings("unchecked")
+ @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());
+
+ when(serviceProvider.getDataProvider()).thenReturn(new DataProvider() {
+
+ @Override
+ public void writeConnectionLog(ConnectionlogEntity event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void writeEventLog(EventlogEntity event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void writeFaultLog(FaultlogEntity fault) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateFaultCurrent(FaultcurrentEntity fault) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int clearFaultsCurrentOfNode(String nodeName) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public List<String> getAllNodesWithCurrentAlarms() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void writeInventory(Inventory internalEquipment) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNetworkConnectionDeviceType(
+ NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy,
+ String nodeId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeNetworkConnection(String nodeId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int doIndexClean(Date olderAreOutdated) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getNumberOfOldObjects(Date olderAreOutdated) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public List<NetworkElementConnectionEntity> getNetworkElementConnections() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void doWritePerformanceData(List<PmdataEntity> list) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+
+
+ }
+
+ @Test
+ public void test() {
+ Optional<NetworkElement> oRanNe;
+ when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
+ ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
+ oRanNe = factory.create(accessor, serviceProvider);
+ assertTrue((factory.create(accessor, serviceProvider)).isPresent());
+ oRanNe.get().register();
+ oRanNe.get().deregister();
+ oRanNe.get().getAcessor();
+ oRanNe.get().getDeviceType();
+ assertEquals(oRanNe.get().getNodeId().getValue(), "nSky");
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+
+ }
+}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java
new file mode 100644
index 000000000..3583bef2b
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * ============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.oran.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.oran.impl.ORanNetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.mock.NetconfAccessorMock;
+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.o.ran.hardware._1._0.rev190328.ORANHWCOMPONENT;
+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 TestORanNetworkElementFactory {
+
+ 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 testCreateORANHWComponent() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
+ ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
+ assertTrue((factory.create(accessor, serviceProvider)).isPresent());
+ }
+
+ @Test
+ public void testCreateSimulator() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true);
+ ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
+ assertTrue(factory.create(accessor, serviceProvider).isPresent());
+ }
+
+ @Test
+ public void testCreateNone() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
+ ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
+ assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+
+ }
+}
+
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java
new file mode 100644
index 000000000..c20b7e653
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * ============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.oran.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import java.util.Optional;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanToInternalDataModel;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.TestHardwareClass;
+
+public class TestORanToInternalDataModel {
+
+ NodeId nodeId;
+ Component component;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void init() throws InterruptedException, IOException {
+ nodeId = mock(NodeId.class);
+ component = mock(Component.class);
+
+ when(nodeId.getValue()).thenReturn("ORan-1000");
+ when(component.getParent()).thenReturn("Shelf");
+ when(component.getParentRelPos()).thenReturn(0);
+ when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB"));
+
+ List<String> list = new ArrayList<String>();
+ list.add("Card-01A");
+ list.add("Card-01B");
+
+ when (component.getContainsChild()).thenReturn(list);
+ when (component.getName()).thenReturn("Nokia");
+ when (component.getDescription()).thenReturn("ORAN Network Element NO-456");
+ Class<? extends HardwareClass> hwClass = TestHardwareClass.class;
+ Mockito.<Class<? extends HardwareClass>>when(component.getXmlClass()).thenReturn(hwClass);
+
+ DateAndTime dt = new DateAndTime("2020-02-05T12:30:45.283Z");
+ when (component.getMfgDate()).thenReturn(dt);
+
+ }
+
+ @Test
+ public void test() throws Exception {
+ ORanToInternalDataModel model = new ORanToInternalDataModel();
+ model.getInternalEquipment(nodeId, component);
+ assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB");
+ assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z");
+
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+
+ }
+}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfAccessorMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfAccessorMock.java
new file mode 100644
index 000000000..bf204d4c6
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/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.oran.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-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java
new file mode 100644
index 000000000..288bcc1d8
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * ============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.oran.test.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.ChangedBy;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+public class NetconfConfigChangeMock implements NetconfConfigChange {
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <E$$ extends Augmentation<NetconfConfigChange>> @Nullable E$$ augmentation(Class<E$$> augmentationType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable ChangedBy getChangedBy() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Datastore getDatastore() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable List<Edit> getEdit() {
+ List<Edit> list = new ArrayList<Edit>();
+ return list;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java
new file mode 100644
index 000000000..1e6a4800b
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/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.oran.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;
+ }
+
+}