use of org.opendaylight.mdsal.dom.api.DOMNotification 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"));
}
use of org.opendaylight.mdsal.dom.api.DOMNotification 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"));
}
use of org.opendaylight.mdsal.dom.api.DOMNotification in project netconf by opendaylight.
the class NetconfNestedNotificationTest method testNestedNotificationToNotificationFunction.
@Test
public void testNestedNotificationToNotificationFunction() throws Exception {
final EffectiveModelContext schemaContext = getNotificationSchemaContext(Collections.singleton("/schemas/nested-notification.yang"));
final NetconfMessage notificationMessage = prepareNotification("/nested-notification-payload.xml");
NetconfMessageTransformer messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true, BASE_SCHEMAS.getBaseSchema());
final DOMNotification domNotification = messageTransformer.toNotification(notificationMessage);
final ContainerNode root = domNotification.getBody();
assertNotNull(root);
assertEquals(1, root.body().size());
assertEquals("interface-enabled", root.getIdentifier().getNodeType().getLocalName());
assertEquals(NetconfNotification.RFC3339_DATE_PARSER.apply("2008-07-08T00:01:00Z").toInstant(), ((DOMEvent) domNotification).getEventInstant());
assertEquals(Absolute.of(INTERFACES_QNAME, INTERFACE_QNAME, INTERFACE_ENABLED_NOTIFICATION_QNAME), domNotification.getType());
}
use of org.opendaylight.mdsal.dom.api.DOMNotification in project netconf by opendaylight.
the class NetconfToNotificationTest method testToNotificationFunction.
@Test
public void testToNotificationFunction() throws Exception {
final EffectiveModelContext schemaContext = getNotificationSchemaContext(getClass(), false);
messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true, BASE_SCHEMAS.getBaseSchema());
final DOMNotification domNotification = messageTransformer.toNotification(userNotification);
final ContainerNode root = domNotification.getBody();
assertNotNull(root);
assertEquals(6, root.body().size());
assertEquals("user-visited-page", root.getIdentifier().getNodeType().getLocalName());
assertEquals(NetconfNotification.RFC3339_DATE_PARSER.apply("2015-10-23T09:42:27.67175+00:00").toInstant(), ((DOMEvent) domNotification).getEventInstant());
}
use of org.opendaylight.mdsal.dom.api.DOMNotification in project netconf by opendaylight.
the class NetconfDeviceSalFacadeTest method testOnDeviceNotification.
@Test
public void testOnDeviceNotification() throws Exception {
final DOMNotification domNotification = mock(DOMNotification.class);
deviceFacade.onNotification(domNotification);
verify(mountInstance).publish(domNotification);
}
Aggregations