use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class AugmentTest method testAugmentRpc.
@Test
public void testAugmentRpc() throws Exception {
final EffectiveModelContext context = assertEffectiveModelDir("/augment-test/rpc");
final XMLNamespace NS_BAR = XMLNamespace.of("urn:opendaylight:bar");
final XMLNamespace NS_FOO = XMLNamespace.of("urn:opendaylight:foo");
final Revision revision = Revision.of("2013-10-11");
final Module bar = context.findModules("bar").iterator().next();
final Collection<? extends RpcDefinition> rpcs = bar.getRpcs();
assertEquals(2, rpcs.size());
RpcDefinition submit = null;
for (final RpcDefinition rpc : rpcs) {
if ("submit".equals(rpc.getQName().getLocalName())) {
submit = rpc;
break;
}
}
assertNotNull(submit);
final QName submitQName = QName.create(NS_BAR, revision, "submit");
assertEquals(submitQName, submit.getQName());
final InputSchemaNode input = submit.getInput();
final QName inputQName = QName.create(NS_BAR, revision, "input");
assertEquals(inputQName, input.getQName());
final ChoiceSchemaNode arguments = (ChoiceSchemaNode) input.getDataChildByName(QName.create(NS_BAR, revision, "arguments"));
final QName argumentsQName = QName.create(NS_BAR, revision, "arguments");
assertEquals(argumentsQName, arguments.getQName());
assertFalse(arguments.isAugmenting());
final Collection<? extends CaseSchemaNode> cases = arguments.getCases();
assertEquals(3, cases.size());
CaseSchemaNode attach = null;
CaseSchemaNode create = null;
CaseSchemaNode destroy = null;
for (final CaseSchemaNode child : cases) {
if ("attach".equals(child.getQName().getLocalName())) {
attach = child;
} else if ("create".equals(child.getQName().getLocalName())) {
create = child;
} else if ("destroy".equals(child.getQName().getLocalName())) {
destroy = child;
}
}
assertNotNull(attach);
assertNotNull(create);
assertNotNull(destroy);
assertTrue(attach.isAugmenting());
assertTrue(create.isAugmenting());
assertTrue(destroy.isAugmenting());
// case attach
assertEquals(QName.create(NS_FOO, revision, "attach"), attach.getQName());
final Collection<? extends DataSchemaNode> attachChildren = attach.getChildNodes();
assertEquals(1, attachChildren.size());
// case create
assertEquals(QName.create(NS_FOO, revision, "create"), create.getQName());
final Collection<? extends DataSchemaNode> createChildren = create.getChildNodes();
assertEquals(1, createChildren.size());
// case attach
assertEquals(QName.create(NS_FOO, revision, "destroy"), destroy.getQName());
final Collection<? extends DataSchemaNode> destroyChildren = destroy.getChildNodes();
assertEquals(1, destroyChildren.size());
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class Bug6869Test method identityNoFeaureTest.
@Test
public void identityNoFeaureTest() throws Exception {
final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6869/foo.yang", ImmutableSet.of());
assertNotNull(schemaContext);
final Collection<? extends IdentitySchemaNode> identities = getIdentities(schemaContext);
assertEquals(0, identities.size());
final DataSchemaNode findNode = schemaContext.findDataTreeChild(ROOT, GRP_LEAF).orElse(null);
assertThat(findNode, instanceOf(LeafSchemaNode.class));
final LeafSchemaNode grpLeaf = (LeafSchemaNode) findNode;
assertFalse(grpLeaf.isMandatory());
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class DeviationResolutionTest method testDeviateDelete.
@Test
public void testDeviateDelete() throws Exception {
final EffectiveModelContext schemaContext = TestUtils.parseYangSource("/deviation-resolution-test/deviation-delete/foo.yang", "/deviation-resolution-test/deviation-delete/bar.yang");
assertNotNull(schemaContext);
final Module barModule = schemaContext.findModule("bar", Revision.of("2017-01-20")).get();
final LeafSchemaNode myLeaf = (LeafSchemaNode) barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "my-leaf"));
assertNotNull(myLeaf);
assertEquals(Optional.empty(), myLeaf.getType().getDefaultValue());
assertEquals(Optional.empty(), myLeaf.getType().getUnits());
assertEquals(0, myLeaf.getUnknownSchemaNodes().size());
final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "my-leaf-list"));
assertNotNull(myLeafList);
assertEquals(0, myLeafList.getDefaults().size());
assertEquals(0, myLeafList.getMustConstraints().size());
final ListSchemaNode myList = (ListSchemaNode) barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "my-list"));
assertNotNull(myList);
assertEquals(0, myList.getUniqueConstraints().size());
assertEquals(0, myList.getUnknownSchemaNodes().size());
final ContainerSchemaNode myCont = (ContainerSchemaNode) barModule.getDataChildByName(QName.create(barModule.getQNameModule(), "my-cont"));
assertNotNull(myCont);
final LeafSchemaNode myAugLeaf = (LeafSchemaNode) myCont.getDataChildByName(QName.create(barModule.getQNameModule(), "my-aug-leaf"));
assertNotNull(myAugLeaf);
assertEquals(Optional.empty(), myAugLeaf.getType().getDefaultValue());
assertEquals(Optional.empty(), myAugLeaf.getType().getUnits());
assertEquals(0, myAugLeaf.getMustConstraints().size());
assertEquals(0, myAugLeaf.getUnknownSchemaNodes().size());
final LeafSchemaNode myUsedLeaf = (LeafSchemaNode) myCont.getDataChildByName(QName.create(barModule.getQNameModule(), "my-used-leaf"));
assertNotNull(myUsedLeaf);
assertEquals(Optional.empty(), myUsedLeaf.getType().getDefaultValue());
assertEquals(Optional.empty(), myUsedLeaf.getType().getUnits());
assertEquals(0, myUsedLeaf.getMustConstraints().size());
assertEquals(0, myUsedLeaf.getUnknownSchemaNodes().size());
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class MoreRevisionsTest method multipleRevisionsFullTest.
@Test
public void multipleRevisionsFullTest() throws Exception {
for (int i = 0; i < 100; i++) {
EffectiveModelContext context = StmtTestUtils.parseYangSources("/semantic-statement-parser/multiple-revisions/full");
assertEquals(6, context.getModules().size());
checkContentFullTest(context);
}
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project yangtools by opendaylight.
the class MoreRevisionsTest method nodeTest.
@Test
public void nodeTest() throws Exception {
EffectiveModelContext context = StmtTestUtils.parseYangSources("/semantic-statement-parser/multiple-revisions/node-test");
QName root = QName.create("foo", "2016-04-06", "foo-root");
QName container20160404 = QName.create("foo", "2016-04-06", "con20160404");
DataSchemaNode findDataSchemaNode = context.findDataTreeChild(root, container20160404).orElse(null);
assertThat(findDataSchemaNode, instanceOf(ContainerSchemaNode.class));
QName container20160405 = QName.create("foo", "2016-04-06", "con20160405");
findDataSchemaNode = context.findDataTreeChild(root, container20160405).orElse(null);
assertThat(findDataSchemaNode, instanceOf(ContainerSchemaNode.class));
QName container20160406 = QName.create("foo", "2016-04-06", "con20160406");
assertEquals(Optional.empty(), context.findDataTreeChild(root, container20160406));
}
Aggregations