Search in sources :

Example 1 with StreamBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder in project netconf by opendaylight.

the class NetconfNotificationManagerTest method testCustomNotificationListeners.

@Test
public void testCustomNotificationListeners() throws Exception {
    final NetconfNotificationManager netconfNotificationManager = createManager();
    final StreamNameType testStreamName = new StreamNameType("TEST_STREAM");
    final Stream testStream = new StreamBuilder().setName(testStreamName).build();
    final NetconfNotificationListener listenerBase = mock(NetconfNotificationListener.class);
    netconfNotificationManager.registerNotificationListener(NetconfNotificationManager.BASE_NETCONF_STREAM.getName(), listenerBase);
    final NetconfNotificationListener listener = mock(NetconfNotificationListener.class);
    netconfNotificationManager.registerNotificationListener(testStream.getName(), listener);
    doNothing().when(listener).onNotification(eq(testStreamName), any(NetconfNotification.class));
    final NetconfNotification notification = new NetconfNotification(XmlUtil.readXmlToDocument("<notification/>"));
    netconfNotificationManager.onNotification(testStream.getName(), notification);
    verify(listener).onNotification(eq(testStream.getName()), eq(notification));
    netconfNotificationManager.close();
    netconfNotificationManager.onNotification(testStream.getName(), notification);
    verifyNoMoreInteractions(listener);
    verify(listenerBase, never()).onNotification(eq(testStream.getName()), eq(notification));
}
Also used : StreamNameType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType) NetconfNotificationListener(org.opendaylight.netconf.notifications.NetconfNotificationListener) Stream(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream) StreamBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder) NetconfNotification(org.opendaylight.netconf.notifications.NetconfNotification) Test(org.junit.Test)

Example 2 with StreamBuilder

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder in project netconf by opendaylight.

the class NotificationToMdsalWriterTest method testStreamRegisteration.

@Test
public void testStreamRegisteration() {
    final StreamNameType testStreamName = new StreamNameType("TESTSTREAM");
    final Stream testStream = new StreamBuilder().setName(testStreamName).build();
    final InstanceIdentifier<Stream> streamIdentifier = InstanceIdentifier.create(Netconf.class).child(Streams.class).child(Stream.class, testStream.key());
    writer.onStreamRegistered(testStream);
    verify(dataBroker.newWriteOnlyTransaction()).merge(LogicalDatastoreType.OPERATIONAL, streamIdentifier, testStream);
    writer.onStreamUnregistered(testStreamName);
    verify(dataBroker.newWriteOnlyTransaction()).delete(LogicalDatastoreType.OPERATIONAL, streamIdentifier);
}
Also used : StreamNameType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType) Stream(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream) StreamBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder) Streams(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 StreamNameType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType)2 Stream (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream)2 StreamBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder)2 NetconfNotification (org.opendaylight.netconf.notifications.NetconfNotification)1 NetconfNotificationListener (org.opendaylight.netconf.notifications.NetconfNotificationListener)1 Streams (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.Streams)1