summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/netconfnode-state-service/provider/src/test
diff options
context:
space:
mode:
authorMichael DÜrre <michael.duerre@highstreet-technologies.com>2021-04-08 06:34:22 +0200
committerMichael DÜrre <michael.duerre@highstreet-technologies.com>2021-04-08 06:34:46 +0200
commitf3969004c6ccac18e742c5fc48c844e315991023 (patch)
treef5486a62e842bb16ca7d3af47a8663df08feef55 /sdnr/wt/netconfnode-state-service/provider/src/test
parenta252be83694ae33260d99d5371ed48c1558aa2e8 (diff)
update websocketmanager
update complete notification flow Issue-ID: CCSDK-3252 Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com> Change-Id: I87ba00f615707b942471fcace57bcda50ce37e61
Diffstat (limited to 'sdnr/wt/netconfnode-state-service/provider/src/test')
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java78
1 files changed, 71 insertions, 7 deletions
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java
index dd61db0d1..10c3b2697 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java
@@ -23,28 +23,41 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfCommunicatorManager;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.binding.NetconfBindingNotificationsImpl;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.binding.NetconfBindingAccessorImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.NetconfDomAccessorImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.example.TestNetconfHelper;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.MountPoint;
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
+import org.opendaylight.mdsal.dom.api.DOMNotificationService;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.NotificationsService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder;
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.NetworkTopology;
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.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
public class TestNetconfAccessorImpl extends Mockito {
@@ -84,8 +97,8 @@ public class TestNetconfAccessorImpl extends Mockito {
when(mountPoint.getService(RpcConsumerRegistry.class)).thenReturn(Optional.of(rpcComerRegistry));
//Start here
- NetconfBindingNotificationsImpl test =
- new NetconfBindingNotificationsImpl(netconfAccessor, dataBroker, mountPoint);
+ NetconfBindingAccessorImpl test =
+ new NetconfBindingAccessorImpl(netconfAccessor, dataBroker, mountPoint);
String streamName = "NETCONF";
test.registerNotificationsStream(streamName);
@@ -114,10 +127,10 @@ public class TestNetconfAccessorImpl extends Mockito {
//Start here
- NetconfBindingNotificationsImpl test =
- new NetconfBindingNotificationsImpl(netconfAccessor, dataBroker, mountPoint);
+ NetconfBindingAccessorImpl test =
+ new NetconfBindingAccessorImpl(netconfAccessor, dataBroker, mountPoint);
- String streamName = NetconfNotifications.DefaultNotificationsStream+"ChangeIt";
+ String streamName = NetconfAccessor.DefaultNotificationsStream + "ChangeIt";
StreamNameType streamNameType = new StreamNameType(streamName);
Stream stream = new StreamBuilder().setName(streamNameType).build();
test.registerNotificationsStream(Arrays.asList(stream));
@@ -130,4 +143,55 @@ public class TestNetconfAccessorImpl extends Mockito {
}
+ @Test
+ public void testNetconfDomNotification() {
+
+ DOMDataBroker domDataBroker = mock(DOMDataBroker.class);
+ DomContext domContext = mock(DomContext.class);
+ DOMRpcService domRpcService = mock(DOMRpcService.class);
+ NetconfAccessorImpl netconfAccessor = TestNetconfHelper.getNetconfAcessorImpl();
+ DOMNotificationService domNotificationService = mock(DOMNotificationService.class);
+ DOMMountPoint domMountPoint = mock(DOMMountPoint.class);
+
+ when(domNotificationService.registerNotificationListener(any(DOMNotificationListener.class),
+ ArgumentMatchers.<Collection<SchemaPath>>any()))
+ .thenReturn(new ListenerRegistration<DOMNotificationListener>() {
+ @Override
+ public @NonNull DOMNotificationListener getInstance() {
+ return null;
+ }
+
+ @Override
+ public void close() {}
+ });
+
+ YangInstanceIdentifier mountpointPath = YangInstanceIdentifier.builder().node(NetworkTopology.QNAME).build();
+ when(domMountPoint.getIdentifier()).thenReturn(mountpointPath);
+ when(domMountPoint.getService(DOMNotificationService.class)).thenReturn(Optional.of(domNotificationService));
+ when(domMountPoint.getService(DOMRpcService.class)).thenReturn(Optional.of(domRpcService));
+
+ /* Remark: Throws WARN java.lang.UnsupportedOperationException
+ * "[main] WARN org.opendaylight.netconf.util.NetconfUtil -
+ * Unable to set namespace context, falling back to setPrefix()
+ * during initialization."
+ */
+ NetconfDomAccessorImpl netconfDomAccessor =
+ new NetconfDomAccessorImpl(netconfAccessor, domDataBroker, domMountPoint, domContext);
+
+ Collection<SchemaPath> types = Arrays.asList(SchemaPath.create(false, NetworkTopology.QNAME));
+ DOMNotificationListener listener = (notification) -> System.out.println("Notification: " + notification);
+ ListenerRegistration<DOMNotificationListener> res =
+ netconfDomAccessor.doRegisterNotificationListener(listener, types);
+
+ //Capture parameters and assert them
+ ArgumentCaptor<DOMNotificationListener> captor1 = ArgumentCaptor.forClass(DOMNotificationListener.class);
+ @SuppressWarnings("unchecked")
+ ArgumentCaptor<Collection<SchemaPath>> captor2 = ArgumentCaptor.forClass(Collection.class);
+ verify(domNotificationService).registerNotificationListener(captor1.capture(), captor2.capture());
+
+ assertEquals("Listener", listener, captor1.getValue());
+ assertEquals("SchemaPath", types, captor2.getValue());
+ res.close();
+ }
+
}