Search in sources :

Example 1 with IncludeStatement

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

the class DeclaredStatementsTest method testDeclaredModuleAndSubmodule.

@Test
public void testDeclaredModuleAndSubmodule() throws ReactorException {
    final StatementStreamSource parentModule = sourceForResource("/declared-statements-test/parent-module-declared-test.yang");
    final StatementStreamSource childModule = sourceForResource("/declared-statements-test/child-module-declared-test.yang");
    final SchemaContext schemaContext = StmtTestUtils.parseYangSources(parentModule, childModule);
    assertNotNull(schemaContext);
    final Module testModule = schemaContext.findModules("parent-module-declared-test").iterator().next();
    assertNotNull(testModule);
    final ModuleStatement moduleStatement = ((ModuleEffectiveStatement) testModule).getDeclared();
    assertNotNull(moduleStatement.argument());
    final YangVersionStatement moduleStatementYangVersion = moduleStatement.getYangVersion();
    assertNotNull(moduleStatementYangVersion);
    assertNotNull(moduleStatementYangVersion.argument());
    final NamespaceStatement moduleStatementNamspace = moduleStatement.getNamespace();
    assertNotNull(moduleStatementNamspace);
    assertNotNull(moduleStatementNamspace.argument());
    final PrefixStatement moduleStatementPrefix = moduleStatement.getPrefix();
    assertNotNull(moduleStatementPrefix);
    assertNotNull(moduleStatementPrefix.argument());
    assertEquals(1, moduleStatement.getIncludes().size());
    final IncludeStatement includeStatement = moduleStatement.getIncludes().iterator().next();
    assertEquals("child-module-declared-test", includeStatement.argument());
    final Collection<? extends Submodule> submodules = testModule.getSubmodules();
    assertNotNull(submodules);
    assertEquals(1, submodules.size());
    final Submodule submodule = submodules.iterator().next();
    final SubmoduleStatement submoduleStatement = ((SubmoduleEffectiveStatement) submodule).getDeclared();
    assertNotNull(submoduleStatement.argument());
    final YangVersionStatement submoduleStatementYangVersion = submoduleStatement.getYangVersion();
    assertNotNull(submoduleStatementYangVersion);
    final BelongsToStatement belongsToStatement = submoduleStatement.getBelongsTo();
    assertNotNull(belongsToStatement);
    assertNotNull(belongsToStatement.argument());
    assertNotNull(belongsToStatement.getPrefix());
}
Also used : NamespaceStatement(org.opendaylight.yangtools.yang.model.api.stmt.NamespaceStatement) StatementStreamSource(org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource) ModuleStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement) Submodule(org.opendaylight.yangtools.yang.model.api.Submodule) BelongsToStatement(org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) PrefixStatement(org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement) YangVersionStatement(org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement) SubmoduleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement) IncludeStatement(org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement) SubmoduleStatement(org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) Module(org.opendaylight.yangtools.yang.model.api.Module) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)1 Submodule (org.opendaylight.yangtools.yang.model.api.Submodule)1 BelongsToStatement (org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement)1 IncludeStatement (org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement)1 ModuleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)1 ModuleStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement)1 NamespaceStatement (org.opendaylight.yangtools.yang.model.api.stmt.NamespaceStatement)1 PrefixStatement (org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement)1 SubmoduleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement)1 SubmoduleStatement (org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement)1 YangVersionStatement (org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement)1 StatementStreamSource (org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource)1