Search in sources :

Example 6 with ContainerEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement in project yangtools by opendaylight.

the class YT1208Test method testUsesStatementReuse.

@Test
public void testUsesStatementReuse() throws Exception {
    final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/uses.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
    assertNotNull(module);
    final List<GroupingEffectiveStatement> groupings = module.streamEffectiveSubstatements(GroupingEffectiveStatement.class).collect(Collectors.toList());
    assertEquals(2, groupings.size());
    final ContainerEffectiveStatement grpFoo = groupings.get(1).findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
    final ContainerEffectiveStatement foo = module.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow();
    assertNotSame(foo, grpFoo);
    assertSame(foo.findFirstEffectiveSubstatement(UsesEffectiveStatement.class).orElseThrow(), grpFoo.findFirstEffectiveSubstatement(UsesEffectiveStatement.class).orElseThrow());
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Aggregations

ContainerEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement)6 Test (org.junit.Test)5 GroupingEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement)4 ModuleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)4 QName (org.opendaylight.yangtools.yang.common.QName)2 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)2 ContainerStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement)2 Revision (org.opendaylight.yangtools.yang.common.Revision)1 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)1 NotificationEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement)1 PresenceStatement (org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement)1 WhenStatement (org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement)1 StatementStreamSource (org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource)1