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;
}
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());
}
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));
}
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));
}
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));
}
Aggregations