use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.
the class Bug8126Test method testValidAugments.
@Test
public void testValidAugments() throws Exception {
final ModuleEffectiveStatement fooModule = StmtTestUtils.parseYangSources("/bugs/bug8126/valid").getModuleStatement(QNameModule.create(FOO_NS));
assertThat(fooModule.findSchemaTreeNode(foo("root"), bar("my-container"), bar("my-choice"), bar("one"), bar("one"), bar("mandatory-leaf")).orElse(null), instanceOf(LeafSchemaNode.class));
assertThat(fooModule.findSchemaTreeNode(foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2")).orElse(null), instanceOf(LeafSchemaNode.class));
assertEquals(Optional.empty(), fooModule.findSchemaTreeNode(foo("root"), bar("mandatory-list")));
assertEquals(Optional.empty(), fooModule.findSchemaTreeNode(foo("root"), bar("mandatory-container"), bar("mandatory-choice")));
assertEquals(Optional.empty(), fooModule.findSchemaTreeNode(foo("root"), bar("mandatory-container-2"), bar("one"), bar("mandatory-leaf-3")));
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement 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());
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement 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.ModuleEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testTypedefStatementReuse.
@Test
public void testTypedefStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/typedef.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final TypedefEffectiveStatement grpBar = module.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(TypedefEffectiveStatement.class).orElseThrow();
final TypedefEffectiveStatement contBar = module.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(TypedefEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement 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);
}
Aggregations