Search in sources :

Example 41 with EffectiveModelContext

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));
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 42 with EffectiveModelContext

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));
}
Also used : DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 43 with EffectiveModelContext

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()));
}
Also used : ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) QName(org.opendaylight.yangtools.yang.common.QName) Module(org.opendaylight.yangtools.yang.model.api.Module) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 44 with EffectiveModelContext

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());
}
Also used : Revision(org.opendaylight.yangtools.yang.common.Revision) ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) QName(org.opendaylight.yangtools.yang.common.QName) ContainerStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 45 with EffectiveModelContext

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));
}
Also used : ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Aggregations

EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)182 Test (org.junit.Test)99 Module (org.opendaylight.yangtools.yang.model.api.Module)37 QName (org.opendaylight.yangtools.yang.common.QName)29 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)28 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)26 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)24 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)24 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)21 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)18 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)16 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)16 NormalizedNodeStreamWriter (org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter)16 IRSchemaSource (org.opendaylight.yangtools.yang.parser.rfc7950.ir.IRSchemaSource)14 DOMMountPoint (org.opendaylight.mdsal.dom.api.DOMMountPoint)13 RestconfDocumentedException (org.opendaylight.restconf.common.errors.RestconfDocumentedException)13 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)13 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)11 IOException (java.io.IOException)9 Collection (java.util.Collection)9