Search in sources :

Example 96 with EffectiveModelContext

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

the class AbstractYangTest method assertEffectiveModel.

@SuppressWarnings("checkstyle:illegalCatch")
@NonNull
public static EffectiveModelContext assertEffectiveModel(final String... yangResourceName) {
    final EffectiveModelContext ret;
    try {
        ret = TestUtils.parseYangSource(yangResourceName);
    } catch (Exception e) {
        Throwables.throwIfUnchecked(e);
        throw new AssertionError("Failed to assemble effective model", e);
    }
    assertNotNull(ret);
    return ret;
}
Also used : InferenceException(org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException) SomeModifiersUnresolvedException(org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException) InvalidSubstatementException(org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException) SourceException(org.opendaylight.yangtools.yang.parser.spi.source.SourceException) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 97 with EffectiveModelContext

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

the class AugmentTest method testAugmentInUsesResolving.

@Test
public void testAugmentInUsesResolving() throws Exception {
    final EffectiveModelContext context = assertEffectiveModelDir("/augment-test/augment-in-uses");
    assertEquals(1, context.getModules().size());
    final Module test = context.getModules().iterator().next();
    final DataNodeContainer links = (DataNodeContainer) test.getDataChildByName(QName.create(test.getQNameModule(), "links"));
    final DataNodeContainer link = (DataNodeContainer) links.getDataChildByName(QName.create(test.getQNameModule(), "link"));
    final DataNodeContainer nodes = (DataNodeContainer) link.getDataChildByName(QName.create(test.getQNameModule(), "nodes"));
    final ContainerSchemaNode node = (ContainerSchemaNode) nodes.getDataChildByName(QName.create(test.getQNameModule(), "node"));
    final Collection<? extends AugmentationSchemaNode> augments = node.getAvailableAugmentations();
    assertEquals(1, augments.size());
    assertEquals(1, node.getChildNodes().size());
    final LeafSchemaNode id = (LeafSchemaNode) node.getDataChildByName(QName.create(test.getQNameModule(), "id"));
    assertTrue(id.isAugmenting());
}
Also used : ContainerSchemaNode(org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode) DataNodeContainer(org.opendaylight.yangtools.yang.model.api.DataNodeContainer) LeafSchemaNode(org.opendaylight.yangtools.yang.model.api.LeafSchemaNode) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Test(org.junit.Test)

Example 98 with EffectiveModelContext

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

the class Bug6876Test method yang11Test.

@Test
public void yang11Test() throws Exception {
    final EffectiveModelContext context = StmtTestUtils.parseYangSources("/rfc7950/bug6876/yang11");
    DataSchemaNode node = context.findDataTreeChild(bar("augment-target"), bar("my-leaf")).orElse(null);
    assertThat(node, instanceOf(LeafSchemaNode.class));
    node = context.findDataTreeChild(bar("augment-target"), foo("mandatory-leaf")).orElse(null);
    assertThat(node, 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 99 with EffectiveModelContext

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

the class Bug5335Test method correctTest4.

@Test
public void correctTest4() throws Exception {
    final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-4");
    final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, NON_PRESENCE_CONTAINER_F, MANDATORY_LEAF_F).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 100 with EffectiveModelContext

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

the class Bug5335Test method correctTest3.

@Test
public void correctTest3() throws Exception {
    final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-3");
    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)

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