import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
public class NotificationListenerTest {
private static final QNameModule MODULE = QNameModule.create(URI.create("notifi:mod"), Revision.of("2016-11-23"));
@Test
public void notifi_leafTest() throws Exception {
- final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-leaf"));
+ 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.getLastComponent(), leaf);
+ final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), leaf);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
when(notificationData.getBody()).thenReturn(notifiBody);
@Test
public void notifi_cont_leafTest() throws Exception {
- final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-cont"));
+ final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-cont"));
final DOMNotification notificationData = mock(DOMNotification.class);
final LeafNode<String> leaf = mockLeaf(QName.create(MODULE, "lf"));
final ContainerNode cont = mockCont(QName.create(MODULE, "cont"), leaf);
- final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), cont);
+ final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), cont);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
when(notificationData.getBody()).thenReturn(notifiBody);
@Test
public void notifi_list_Test() throws Exception {
- final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-list"));
+ final Absolute schemaPathNotifi = Absolute.of(QName.create(MODULE, "notifi-list"));
final DOMNotification notificationData = mock(DOMNotification.class);
final MapEntryNode entry = mockMapEntry(QName.create(MODULE, "lst"), leaf);
final MapNode list = mockList(QName.create(MODULE, "lst"), entry);
final ContainerNode cont = mockCont(QName.create(MODULE, "cont"), list);
- final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), cont);
+ final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), cont);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
when(notificationData.getBody()).thenReturn(notifiBody);
@Test
public void notifi_grpTest() throws Exception {
- final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-grp"));
+ 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.getLastComponent(), leaf);
+ final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), leaf);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
when(notificationData.getBody()).thenReturn(notifiBody);
@Test
public void notifi_augmTest() throws Exception {
- final SchemaPath schemaPathNotifi = SchemaPath.create(false, QName.create(MODULE, "notifi-augm"));
+ 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.getLastComponent(), augm);
+ final ContainerNode notifiBody = mockCont(schemaPathNotifi.lastNodeIdentifier(), augm);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
when(notificationData.getBody()).thenReturn(notifiBody);
return child;
}
- private String prepareJson(final DOMNotification notificationData, final SchemaPath schemaPathNotifi)
+ private String prepareJson(final DOMNotification notificationData, final Absolute schemaPathNotifi)
throws Exception {
final List<SchemaPath> paths = new ArrayList<>();
- paths.add(schemaPathNotifi);
+ paths.add(schemaPathNotifi.asSchemaPath());
final List<NotificationListenerAdapter> listNotifi =
Notificator.createNotificationListener(paths, "stream-name", NotificationOutputType.JSON.toString(),
controllerContext);