use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug5335Test method correctTest1.
@Test
public void correctTest1() throws Exception {
final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-1");
final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B, MANDATORY_LEAF_B).orElse(null);
assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug5335Test method correctTest2.
@Test
public void correctTest2() throws Exception {
final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-2");
final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B, NON_PRESENCE_CONTAINER_B, MANDATORY_LEAF_B).orElse(null);
assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug394Test method testParseList.
@Test
public void testParseList() throws Exception {
final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug394-retest");
final Module bug394 = context.findModules("bug394").iterator().next();
final Module bug394_ext = context.findModules("bug394-ext").iterator().next();
final ContainerSchemaNode logrecords = (ContainerSchemaNode) bug394.getDataChildByName(QName.create(bug394.getQNameModule(), "logrecords"));
assertNotNull(logrecords);
final Collection<? extends UnrecognizedStatement> nodes = logrecords.asEffectiveStatement().getDeclared().declaredSubstatements(UnrecognizedStatement.class);
assertEquals(2, nodes.size());
final Set<QName> extensions = bug394_ext.getExtensionSchemaNodes().stream().map(ExtensionDefinition::getQName).collect(Collectors.toUnmodifiableSet());
assertEquals(3, extensions.size());
final Iterator<? extends UnrecognizedStatement> it = nodes.iterator();
assertTrue(extensions.contains(it.next().statementDefinition().getStatementName()));
assertTrue(extensions.contains(it.next().statementDefinition().getStatementName()));
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug4610Test method test.
@Test
public void test() throws Exception {
final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug4610");
final Revision revision = Revision.of("2015-12-12");
// Original
final QName c1Bar = QName.create(QNameModule.create(XMLNamespace.of("bar"), revision), "c1");
final ContainerEffectiveStatement g1container = findContainer(context, QName.create(c1Bar, "g1"), c1Bar);
final QName g1argument = g1container.argument();
final ContainerStatement g1original = g1container.getDeclared();
final ContainerEffectiveStatement g2container = findContainer(context, QName.create(c1Bar, "g2"), c1Bar);
assertEquals(g1argument, g2container.argument());
assertSame(g1original, g2container.getDeclared());
final QName c1Foo = QName.create(QNameModule.create(XMLNamespace.of("foo"), revision), "c1");
final ContainerEffectiveStatement g3container = findContainer(context, QName.create(c1Foo, "g3"), c1Foo);
assertNotEquals(g1argument, g3container.argument());
assertSame(g1original, g3container.getDeclared());
final SchemaTreeEffectiveStatement<?> rootContainer = context.getModuleStatement(c1Foo.getModule()).findSchemaTreeNode(QName.create(c1Foo, "root"), c1Foo).orElseThrow();
assertThat(rootContainer, instanceOf(ContainerEffectiveStatement.class));
assertNotEquals(g1argument, rootContainer.argument());
assertSame(g1original, rootContainer.getDeclared());
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug6884Test method testCircularIncludesYang10.
@Test
public void testCircularIncludesYang10() throws Exception {
final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSources("/rfc7950/bug6884/circular-includes");
DataSchemaNode node = schemaContext.findDataTreeChild(foo("sub-root"), foo("sub-foo-2-con")).orElse(null);
assertThat(node, instanceOf(ContainerSchemaNode.class));
node = schemaContext.findDataTreeChild(foo("sub-root-2"), foo("sub-foo-con")).orElse(null);
assertThat(node, instanceOf(ContainerSchemaNode.class));
}
Aggregations