summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager-onf14/provider/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/devicemanager-onf14/provider/src/test')
-rw-r--r--sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestDeviceManagerOnf14Impl.java56
-rw-r--r--sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java171
-rw-r--r--sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java108
-rw-r--r--sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElementFactory.java64
-rw-r--r--sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14ToInternalDataModel2.java125
-rw-r--r--sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/NetconfAccessorMock.java92
-rw-r--r--sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/TransactionUtilsMock.java44
-rw-r--r--sdnr/wt/devicemanager-onf14/provider/src/test/resources/simplelogger.properties61
8 files changed, 721 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestDeviceManagerOnf14Impl.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestDeviceManagerOnf14Impl.java
new file mode 100644
index 000000000..8dbfa2f5c
--- /dev/null
+++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestDeviceManagerOnf14Impl.java
@@ -0,0 +1,56 @@
+/*
+ * ============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.onf14;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.DeviceManagerOnf14Impl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
+
+public class TestDeviceManagerOnf14Impl extends Mockito {
+
+ DeviceManagerOnf14Impl devMgrOnf14;
+ private static NetconfNetworkElementService netconfElemService;
+
+ @Before
+ public void init() throws InterruptedException, IOException {
+ netconfElemService = mock(NetconfNetworkElementService.class);
+ }
+
+ @Test
+ public void test() throws Exception {
+ devMgrOnf14 = new DeviceManagerOnf14Impl();
+
+ try {
+ devMgrOnf14.setNetconfNetworkElementService(netconfElemService);
+ devMgrOnf14.init();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+ devMgrOnf14.close();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java
new file mode 100644
index 000000000..0cfd5ae01
--- /dev/null
+++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14AirInterfaceNotificationListener.java
@@ -0,0 +1,171 @@
+/*
+ * ============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.onf14;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14AirInterfaceNotificationListener;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.AttributeValueChangedNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ObjectCreationNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ObjectDeletionNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.ProblemNotification;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPE;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPECRITICAL;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPEMAJOR;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPEMINOR;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPENONALARMED;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.SEVERITYTYPEWARNING;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+
+public class TestOnf14AirInterfaceNotificationListener extends Mockito {
+ private NetconfAccessor accessor;
+ private NodeId nodeId;
+ private DeviceManagerServiceProvider serviceProvider;
+ private FaultService faultService;
+
+ private ObjectDeletionNotification deletionNotif;
+ private ObjectCreationNotification creationNotif;
+ private ProblemNotification problemNotif;
+ private AttributeValueChangedNotification attrValChangedNotif;
+
+ @Before
+ public void init() {
+ accessor = mock(NetconfAccessorMock.class);
+ nodeId = mock(NodeId.class);
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+ faultService = mock(FaultService.class);
+
+ problemNotif = mock(ProblemNotification.class);
+ deletionNotif = mock(ObjectDeletionNotification.class);
+ creationNotif = mock(ObjectCreationNotification.class);
+ attrValChangedNotif = mock(AttributeValueChangedNotification.class);
+
+ when(accessor.getNodeId()).thenReturn(nodeId);
+ when(problemNotif.getCounter()).thenReturn(10);
+ when(problemNotif.getTimestamp()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z"));
+ when(problemNotif.getObjectIdRef()).thenReturn(new UniversalId("12345678-0123-0abc-abcd-0123456789AB"));
+ when(problemNotif.getProblem()).thenReturn("modulationIsDownShifted");
+
+ when(serviceProvider.getFaultService()).thenReturn(faultService);
+ }
+
+ @Test
+ public void testOtherNotif() {
+ Onf14AirInterfaceNotificationListener notifListener =
+ new Onf14AirInterfaceNotificationListener(accessor, serviceProvider);
+
+ notifListener.onObjectDeletionNotification(deletionNotif);
+ notifListener.onObjectCreationNotification(creationNotif);
+ notifListener.onAttributeValueChangedNotification(attrValChangedNotif);
+ }
+
+ @Test
+ public void testProblemNotifCritical() {
+ Onf14AirInterfaceNotificationListener notifListener =
+ new Onf14AirInterfaceNotificationListener(accessor, serviceProvider);
+
+ when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() {
+ @Override
+ public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable {
+ return SEVERITYTYPECRITICAL.class;
+ }
+ });
+
+ notifListener.onProblemNotification(problemNotif);
+ }
+
+ @Test
+ public void testProblemNotifMajor() {
+ Onf14AirInterfaceNotificationListener notifListener =
+ new Onf14AirInterfaceNotificationListener(accessor, serviceProvider);
+
+ when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() {
+ @Override
+ public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable {
+ return SEVERITYTYPEMAJOR.class;
+ }
+ });
+
+ notifListener.onProblemNotification(problemNotif);
+ }
+
+ @Test
+ public void testProblemNotifMinor() {
+ Onf14AirInterfaceNotificationListener notifListener =
+ new Onf14AirInterfaceNotificationListener(accessor, serviceProvider);
+
+ when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() {
+ @Override
+ public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable {
+ return SEVERITYTYPEMINOR.class;
+ }
+ });
+
+ notifListener.onProblemNotification(problemNotif);
+ }
+
+ @Test
+ public void testProblemNotifWarning() {
+ Onf14AirInterfaceNotificationListener notifListener =
+ new Onf14AirInterfaceNotificationListener(accessor, serviceProvider);
+
+ when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() {
+ @Override
+ public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable {
+ return SEVERITYTYPEWARNING.class;
+ }
+ });
+
+ notifListener.onProblemNotification(problemNotif);
+ }
+
+ @Test
+ public void testProblemNotifNonalarmed() {
+ Onf14AirInterfaceNotificationListener notifListener =
+ new Onf14AirInterfaceNotificationListener(accessor, serviceProvider);
+
+ when(problemNotif.getSeverity()).thenAnswer(new Answer<Class<? extends SEVERITYTYPE>>() {
+ @Override
+ public Class<? extends SEVERITYTYPE> answer(InvocationOnMock invocation) throws Throwable {
+ return SEVERITYTYPENONALARMED.class;
+ }
+ });
+
+ notifListener.onProblemNotification(problemNotif);
+ }
+
+ @Test
+ public void testProblemNotifNull() {
+ Onf14AirInterfaceNotificationListener notifListener =
+ new Onf14AirInterfaceNotificationListener(accessor, serviceProvider);
+
+ when(problemNotif.getSeverity()).thenReturn(null);
+
+ notifListener.onProblemNotification(problemNotif);
+ }
+
+}
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java
new file mode 100644
index 000000000..ff4d1e1e2
--- /dev/null
+++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElement.java
@@ -0,0 +1,108 @@
+/*
+ * ============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.onf14;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+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.onf14.impl.Onf14NetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.test.mock.NetconfAccessorMock;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
+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.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.ControlConstruct;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public class TestOnf14NetworkElement extends Mockito {
+
+ static NetconfAccessorMock accessor;
+ static DeviceManagerServiceProvider serviceProvider;
+ static Capabilities capabilities;
+ QName qCapability;
+ static DataProvider dataProvider;
+ static FaultService faultService;
+ static DataBroker dataBroker;
+ static TransactionUtils transactionUtils;
+ static ControlConstruct controlConstruct;
+
+ @Before
+ public void init() {
+ capabilities = mock(Capabilities.class);
+ accessor = mock(NetconfAccessorMock.class);
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+
+ NodeId nNodeId = new NodeId("nSky");
+ when(accessor.getCapabilites()).thenReturn(capabilities);
+ when(accessor.getNodeId()).thenReturn(nNodeId);
+
+ dataProvider = mock(DataProvider.class);
+ when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
+
+ faultService = mock(FaultService.class);
+ when(serviceProvider.getFaultService()).thenReturn(faultService);
+
+ dataBroker = mock(DataBroker.class);
+ when(accessor.getDataBroker()).thenReturn(dataBroker);
+
+ controlConstruct = mock(ControlConstruct.class);
+ transactionUtils = mock(TransactionUtils.class);
+ when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
+
+ InstanceIdentifier<ControlConstruct> CONTROLCONSTRUCT_IID =
+ InstanceIdentifier.builder(ControlConstruct.class).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ CONTROLCONSTRUCT_IID)).thenReturn(controlConstruct);
+
+ List<UniversalId> topLevelEqList = null;
+ UniversalId uuid = new UniversalId("0Aabcdef-0abc-0cfD-0abC-0123456789AB");
+ topLevelEqList = Arrays.asList(uuid);
+
+ when(Optional.of(controlConstruct).get().getTopLevelEquipment()).thenReturn(topLevelEqList);
+ }
+
+ @Test
+ public void testGeneric() {
+ Optional<NetworkElement> onfNe;
+ when(accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)).thenReturn(true);
+ Onf14NetworkElementFactory factory = new Onf14NetworkElementFactory();
+ onfNe = factory.create(accessor, serviceProvider);
+ assertTrue(factory.create(accessor, serviceProvider).isPresent());
+
+ onfNe.get().register();
+ onfNe.get().deregister();
+ onfNe.get().getAcessor();
+ onfNe.get().getDeviceType();
+ onfNe.get().warmstart();
+ onfNe.get().getService(null);
+ assertEquals(onfNe.get().getNodeId().getValue(), "nSky");
+ }
+
+}
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElementFactory.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElementFactory.java
new file mode 100644
index 000000000..59e57da11
--- /dev/null
+++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14NetworkElementFactory.java
@@ -0,0 +1,64 @@
+/*
+ * ============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.onf14;
+
+import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14NetworkElementFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.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.yang.core.model._1._4.rev191127.ControlConstruct;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public class TestOnf14NetworkElementFactory extends Mockito {
+
+ 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 testCreateOnf14Component() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)).thenReturn(true);
+ Onf14NetworkElementFactory factory = new Onf14NetworkElementFactory();
+ assertTrue((factory.create(accessor, serviceProvider)).isPresent());
+ }
+
+ @Test
+ public void testCreateNone() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(ControlConstruct.QNAME)).thenReturn(false);
+ Onf14NetworkElementFactory factory = new Onf14NetworkElementFactory();
+ assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
+ }
+}
+
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14ToInternalDataModel2.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14ToInternalDataModel2.java
new file mode 100644
index 000000000..ca36f7946
--- /dev/null
+++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/TestOnf14ToInternalDataModel2.java
@@ -0,0 +1,125 @@
+/*
+ * ============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.onf14;
+
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.impl.Onf14ToInternalDataModel;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.Equipment;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.UniversalId;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ActualEquipment;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.detail.ManufacturedThing;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.EquipmentInstance;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.EquipmentType;
+import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.manufactured.thing.ManufacturerProperties;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+
+public class TestOnf14ToInternalDataModel2 extends Mockito {
+
+ private static NodeId nodeId;
+ private static Equipment currentEq;
+ private static Equipment parentEq;
+ private static ActualEquipment component;
+ private static ContainedHolder holder;
+ private static ManufacturedThing manThing;
+ private static ManufacturerProperties manProperties;
+ private static EquipmentInstance eqInstance;
+ private static EquipmentType eqType;
+
+ @BeforeClass
+ public static void init() {
+ nodeId = mock(NodeId.class);
+ currentEq = mock(Equipment.class);
+ parentEq = mock(Equipment.class);
+ component = mock(ActualEquipment.class);
+ holder = mock(ContainedHolder.class);
+ manThing = mock(ManufacturedThing.class);
+ manProperties = mock(ManufacturerProperties.class);
+ eqInstance = mock(EquipmentInstance.class);
+ eqType = mock(EquipmentType.class);
+
+ when(nodeId.getValue()).thenReturn("CoreModel-1-4-node");
+
+ when(component.getLocalId()).thenReturn("actLocalEq");
+ when(currentEq.getUuid()).thenReturn(new UniversalId("0Aabcdef-0abc-0cfD-0abC-0123456789AB"));
+ when(parentEq.getUuid()).thenReturn(new UniversalId("0Aabcdef-0123-0abc-abcd-0123456789AB"));
+
+ List<ContainedHolder> containedHolderList = new ArrayList<ContainedHolder>();
+ containedHolderList.add(holder);
+ when(currentEq.nonnullContainedHolder()).thenReturn(containedHolderList);
+
+ }
+
+ @Test
+ public void test1() {
+
+ Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
+
+ when(currentEq.getActualEquipment()).thenReturn(component);
+ when(holder.getOccupyingFru()).thenReturn(new UniversalId("12345678-0123-0abc-abcd-0123456789AB"));
+ when(component.getManufacturedThing()).thenReturn(manThing);
+ when(manThing.getManufacturerProperties()).thenReturn(manProperties);
+ when(manThing.getEquipmentInstance()).thenReturn(eqInstance);
+ when(eqInstance.getManufactureDate()).thenReturn(new DateAndTime("2020-02-05T12:30:45.283Z"));
+ when(manThing.getEquipmentType()).thenReturn(eqType);
+
+ model.getInternalEquipment(nodeId, currentEq, parentEq, 0);
+ assertEquals(currentEq.getActualEquipment().getLocalId(), "actLocalEq");
+ }
+
+ @Test
+ public void test2() {
+
+ Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
+
+ when(holder.getOccupyingFru()).thenReturn(null);
+ when(component.getManufacturedThing()).thenReturn(null);
+ when(manThing.getManufacturerProperties()).thenReturn(null);
+ when(manThing.getEquipmentInstance()).thenReturn(null);
+ when(manThing.getEquipmentType()).thenReturn(null);
+
+ model.getInternalEquipment(nodeId, currentEq, null, 0);
+ }
+
+
+ @Test
+ public void test3() {
+ Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
+
+ when(component.getManufacturedThing()).thenReturn(manThing);
+ when(manThing.getManufacturerProperties()).thenReturn(null);
+ when(manThing.getEquipmentInstance()).thenReturn(null);
+ when(manThing.getEquipmentType()).thenReturn(null);
+
+ model.getInternalEquipment(nodeId, currentEq, null, 0);
+ }
+
+ @Test
+ public void test4() {
+ Onf14ToInternalDataModel model = new Onf14ToInternalDataModel();
+
+ when(currentEq.getActualEquipment()).thenReturn(null);
+ model.getInternalEquipment(nodeId, currentEq, null, 0);
+ }
+}
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/NetconfAccessorMock.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/NetconfAccessorMock.java
new file mode 100644
index 000000000..138aa944a
--- /dev/null
+++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/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.onf14.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-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/TransactionUtilsMock.java
new file mode 100644
index 000000000..9546ae9f9
--- /dev/null
+++ b/sdnr/wt/devicemanager-onf14/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/test/mock/TransactionUtilsMock.java
@@ -0,0 +1,44 @@
+/*
+ * ============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.onf14.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) {
+ return null;
+ }
+
+ @Override
+ public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker,
+ LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication,
+ AtomicReference<String> statusIndicator) {
+ return null;
+ }
+
+}
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/test/resources/simplelogger.properties b/sdnr/wt/devicemanager-onf14/provider/src/test/resources/simplelogger.properties
new file mode 100644
index 000000000..9af26dc96
--- /dev/null
+++ b/sdnr/wt/devicemanager-onf14/provider/src/test/resources/simplelogger.properties
@@ -0,0 +1,61 @@
+#
+# ============LICENSE_START=======================================================
+# ONAP : ccsdk features
+# ================================================================================
+# Copyright (C) 2020 AT&T 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=======================================================
+#
+#
+
+# SLF4J's SimpleLogger configuration file
+# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
+
+# Default logging detail level for all instances of SimpleLogger.
+# Must be one of ("trace", "debug", "info", "warn", or "error").
+# If not specified, defaults to "info".
+org.slf4j.simpleLogger.defaultLogLevel=info
+
+# Logging detail level for a SimpleLogger instance named "xxx.yyy.zzz".
+# Must be one of ("trace", "debug", "info", "warn", or "error").
+# If not specified, the default logging detail level is used.
+# org.slf4j.simpleLogger.log.xxx.yyy=debug
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager=info
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.test=debug
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.database=debug
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice=info
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Resources=info
+org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container=info
+
+# Set to true if you want the current date and time to be included in output messages.
+# Default is false, and will output the number of milliseconds elapsed since startup.
+#org.slf4j.simpleLogger.showDateTime=false
+
+# The date and time format to be used in the output messages.
+# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
+# If the format is not specified or is invalid, the default format is used.
+# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
+#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
+
+# Set to true if you want to output the current thread name.
+# Defaults to true.
+#org.slf4j.simpleLogger.showThreadName=true
+
+# Set to true if you want the Logger instance name to be included in output messages.
+# Defaults to true.
+#org.slf4j.simpleLogger.showLogName=true
+
+# Set to true if you want the last component of the name to be included in output messages.
+# Defaults to false.
+#org.slf4j.simpleLogger.showShortLogName=false