Search in sources :

Example 1 with NotificationEffectiveStatement

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());
    }
}
Also used : SubscriptionStateNotificationEffectiveStatement(org.opendaylight.yangtools.rfc8639.model.api.SubscriptionStateNotificationEffectiveStatement) NotificationEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement) Test(org.junit.Test)

Example 2 with NotificationEffectiveStatement

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);
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) LeafEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement) NotificationEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Example 3 with NotificationEffectiveStatement

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);
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) CaseEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) ChoiceEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement) NotificationEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Example 4 with NotificationEffectiveStatement

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);
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) LeafListEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) NotificationEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Example 5 with NotificationEffectiveStatement

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);
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) NotificationEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement) AugmentEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Aggregations

NotificationEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement)10 Test (org.junit.Test)9 ContainerEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement)8 GroupingEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement)8 ModuleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)8 ChoiceEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement)2 LeafListEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement)2 GeneratedTypeBuilder (org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder)1 MethodSignatureBuilder (org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder)1 SubscriptionStateNotificationEffectiveStatement (org.opendaylight.yangtools.rfc8639.model.api.SubscriptionStateNotificationEffectiveStatement)1 WithStatus (org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus)1 AugmentEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement)1 CaseEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement)1 LeafEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement)1 ListEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ListEffectiveStatement)1