Search in sources :

Example 11 with Absolute

use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project netconf by opendaylight.

the class XmlNotificationListenerTest method notifi_augmTest.

@Test
public void notifi_augmTest() throws Exception {
    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 = prepareXmlResult(notificationData, schemaPathNotifi);
    final String control = "<notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">" + "<eventTime>2020-06-29T14:23:46.086855+02:00</eventTime><notifi-augm xmlns=\"notifi:mod\">" + "<lf-augm>value</lf-augm></notifi-augm></notification>";
    assertXmlMatches(result, control);
}
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)

Example 12 with Absolute

use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project netconf by opendaylight.

the class XmlNotificationListenerTest method notifi_grpTest.

@Test
public void notifi_grpTest() throws Exception {
    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 = prepareXmlResult(notificationData, schemaPathNotifi);
    final String control = "<notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">" + "<eventTime>2020-06-29T14:23:46.086855+02:00</eventTime><notifi-grp xmlns=\"notifi:mod\">" + "<lf>value</lf></notifi-grp></notification>";
    assertXmlMatches(result, control);
}
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 13 with Absolute

use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project netconf by opendaylight.

the class JsonNotificationListenerTest method notifi_grpTest.

@Test
public void notifi_grpTest() throws Exception {
    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 14 with Absolute

use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project netconf by opendaylight.

the class JsonNotificationListenerTest method notifi_leafTest.

@Test
public void notifi_leafTest() throws Exception {
    final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-leaf"));
    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);
    LOG.info("json result: {}", result);
    assertTrue(result.contains("ietf-restconf:notification"));
    assertTrue(result.contains("event-time"));
    assertTrue(result.contains("notifi-module:notifi-leaf"));
    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 15 with Absolute

use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project netconf by opendaylight.

the class JsonNotificationListenerTest method notifi_augmTest.

@Test
public void notifi_augmTest() throws Exception {
    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

Absolute (org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute)31 Test (org.junit.Test)22 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)18 DOMNotification (org.opendaylight.mdsal.dom.api.DOMNotification)16 QName (org.opendaylight.yangtools.yang.common.QName)5 DOMActionResult (org.opendaylight.mdsal.dom.api.DOMActionResult)4 HashSet (java.util.HashSet)3 DOMDataTreeIdentifier (org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier)3 SimpleDOMActionResult (org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult)3 AugmentationNode (org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode)3 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)3 Futures (com.google.common.util.concurrent.Futures)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 ExecutionException (java.util.concurrent.ExecutionException)2 Collectors (java.util.stream.Collectors)2 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)2 DOMActionException (org.opendaylight.mdsal.dom.api.DOMActionException)2 DOMActionService (org.opendaylight.mdsal.dom.api.DOMActionService)2