Search in sources :

Example 1 with DOMNotification

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);
}
Also used : DOMNotification(org.opendaylight.mdsal.dom.api.DOMNotification) Test(org.junit.Test)

Example 2 with DOMNotification

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());
}
Also used : TwoLevelListChangedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChangedBuilder) DOMNotification(org.opendaylight.mdsal.dom.api.DOMNotification) BindingNormalizedNodeSerializer(org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Test(org.junit.Test)

Example 3 with DOMNotification

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());
    }
}
Also used : DOMNotification(org.opendaylight.mdsal.dom.api.DOMNotification) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 4 with DOMNotification

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"));
}
Also used : DOMNotification(org.opendaylight.mdsal.dom.api.DOMNotification) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Absolute(org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute) Test(org.junit.Test)

Example 5 with DOMNotification

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"));
}
Also used : DOMNotification(org.opendaylight.mdsal.dom.api.DOMNotification) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Absolute(org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode) Test(org.junit.Test)

Aggregations

DOMNotification (org.opendaylight.mdsal.dom.api.DOMNotification)25 Test (org.junit.Test)24 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)18 Absolute (org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute)16 AugmentationNode (org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)2 NetconfMessageTransformer (org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer)2 EmptyMountPointContext (org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext)2 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)2 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)2 Diff (org.custommonkey.xmlunit.Diff)1 BindingNormalizedNodeSerializer (org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer)1 DOMNotificationListener (org.opendaylight.mdsal.dom.api.DOMNotificationListener)1 DOMNotificationSubscriptionListener (org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener)1 VRFPREFIXTABLE (org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ip._static.cfg.rev130722.VRFPREFIXTABLE)1 TwoLevelListChangedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChangedBuilder)1 Notification (org.opendaylight.yangtools.yang.binding.Notification)1 QName (org.opendaylight.yangtools.yang.common.QName)1 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)1