use of org.opendaylight.mdsal.dom.api.DOMNotification in project mdsal by opendaylight.
the class ForwardingDOMNotificationPublishServiceTest method basicTest.
@Test
public void basicTest() throws Exception {
final DOMNotification domNotification = mock(DOMNotification.class);
doReturn(null).when(domNotificationPublishService).putNotification(domNotification);
this.putNotification(domNotification);
verify(domNotificationPublishService).putNotification(domNotification);
doReturn(null).when(domNotificationPublishService).offerNotification(domNotification);
this.offerNotification(domNotification);
verify(domNotificationPublishService).offerNotification(domNotification);
doReturn(null).when(domNotificationPublishService).offerNotification(domNotification, 1, TimeUnit.MILLISECONDS);
this.offerNotification(domNotification, 1, TimeUnit.MILLISECONDS);
verify(domNotificationPublishService).offerNotification(domNotification, 1, TimeUnit.MILLISECONDS);
}
use of org.opendaylight.mdsal.dom.api.DOMNotification in project mdsal by opendaylight.
the class LazySerializedDOMNotificationTest method basicTest.
@Test
public void basicTest() throws Exception {
BindingNormalizedNodeSerializer codec = mock(BindingNormalizedNodeSerializer.class);
final DOMNotification lazySerializedDOMNotification = LazySerializedDOMNotification.create(codec, new TwoLevelListChangedBuilder().build(), Instant.now());
ContainerNode containerNode = mock(ContainerNode.class);
doReturn(containerNode).when(codec).toNormalizedNodeNotification(any());
assertEquals(containerNode, lazySerializedDOMNotification.getBody());
}
use of org.opendaylight.mdsal.dom.api.DOMNotification in project mdsal by opendaylight.
the class DOMNotificationRouterTest method testOfferNotificationWithBlocking.
@Test
public void testOfferNotificationWithBlocking() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final TestListener testListener = new TestListener(latch);
final DOMNotification domNotification = mock(DOMNotification.class);
doReturn("test").when(domNotification).toString();
doReturn(Absolute.of(TestModel.TEST_QNAME)).when(domNotification).getType();
doReturn(TEST_CHILD).when(domNotification).getBody();
try (TestRouter testRouter = new TestRouter(1)) {
assertNotNull(testRouter.registerNotificationListener(testListener, Absolute.of(TestModel.TEST_QNAME)));
assertNotNull(testRouter.registerNotificationListener(testListener, Absolute.of(TestModel.TEST2_QNAME)));
assertNotEquals(DOMNotificationPublishService.REJECTED, testRouter.offerNotification(domNotification, 3, TimeUnit.SECONDS));
assertTrue("Listener was not notified", latch.await(5, TimeUnit.SECONDS));
assertEquals("Received notifications", 1, testListener.getReceivedNotifications().size());
assertEquals(DOMNotificationPublishService.REJECTED, testRouter.offerNotification(domNotification, 1, TimeUnit.SECONDS));
assertEquals("Received notifications", 1, testListener.getReceivedNotifications().size());
}
}
use of org.opendaylight.mdsal.dom.api.DOMNotification in project netconf by opendaylight.
the class NotificationListenerTest method notifi_grpTest.
@Test
public void notifi_grpTest() {
final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-grp"));
final DOMNotification notificationData = mock(DOMNotification.class);
final LeafNode<String> leaf = mockLeaf(QName.create(MODULE, "lf"));
final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), leaf);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
when(notificationData.getBody()).thenReturn(notifiBody);
final String result = prepareJson(notificationData, schemaPathNotifi);
assertTrue(result.contains("ietf-restconf:notification"));
assertTrue(result.contains("event-time"));
assertTrue(result.contains("lf" + '"' + ":" + '"' + "value"));
}
use of org.opendaylight.mdsal.dom.api.DOMNotification in project netconf by opendaylight.
the class NotificationListenerTest method notifi_augmTest.
@Test
public void notifi_augmTest() {
final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-augm"));
final DOMNotification notificationData = mock(DOMNotification.class);
final LeafNode<String> leaf = mockLeaf(QName.create(MODULE, "lf-augm"));
final AugmentationNode augm = mockAugm(leaf);
final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), augm);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
when(notificationData.getBody()).thenReturn(notifiBody);
final String result = prepareJson(notificationData, schemaPathNotifi);
assertTrue(result.contains("ietf-restconf:notification"));
assertTrue(result.contains("event-time"));
assertTrue(result.contains("lf-augm" + '"' + ":" + '"' + "value"));
}
Aggregations