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));
}
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);
}
Aggregations