use of org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement in project yangtools by opendaylight.
the class SubscribedNotificationsTest method testSubscribedNotifications.
@Test
public void testSubscribedNotifications() throws ReactorException, IOException, YangSyntaxErrorException {
final var context = reactor.newBuild().addLibSources(YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-inet-types@2013-07-15.yang")), YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-interfaces@2018-02-20.yang")), YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-ip@2018-02-22.yang")), YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-netconf-acm@2018-02-14.yang")), YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-network-instance@2019-01-21.yang")), YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-restconf@2017-01-26.yang")), YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-yang-schema-mount@2019-01-14.yang")), YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-yang-types@2013-07-15.yang"))).addSources(YangStatementStreamSource.create(YangTextSchemaSource.forResource("/ietf-subscribed-notifications@2019-09-09.yang"))).buildEffective();
final var notifications = context.getModuleStatement(SubscribedNotificationsConstants.RFC8639_MODULE).streamEffectiveSubstatements(NotificationEffectiveStatement.class).collect(Collectors.toUnmodifiableList());
assertEquals(7, notifications.size());
for (NotificationEffectiveStatement notif : notifications) {
final var sub = notif.findFirstEffectiveSubstatement(SubscriptionStateNotificationEffectiveStatement.class);
assertTrue("No marker in " + notif.argument(), sub.isPresent());
}
}
use of org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testLeafStatementReuse.
@Test
public void testLeafStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/leaf.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
assertNotNull(module);
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final LeafEffectiveStatement grpBar = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(LeafEffectiveStatement.class).orElseThrow();
final LeafEffectiveStatement contBar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(LeafEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testCaseStatementReuse.
@Test
public void testCaseStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/case.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final CaseEffectiveStatement grpBar = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(CaseEffectiveStatement.class).orElseThrow();
final CaseEffectiveStatement contBar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(CaseEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testLeafListStatementReuse.
@Test
public void testLeafListStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/leaflist.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final LeafListEffectiveStatement grpBar = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
final LeafListEffectiveStatement contBar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(LeafListEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testAugmentStatementReuse.
@Test
public void testAugmentStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/augment.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final AugmentEffectiveStatement grpAug = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(AugmentEffectiveStatement.class).orElseThrow();
final AugmentEffectiveStatement contAug = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(AugmentEffectiveStatement.class).orElseThrow();
assertSame(contAug, grpAug);
}
Aggregations