Migrated all YANG testfiles counting 50 lines or less.
JIRA: YANGTOOLS-1506
Change-Id: Id4af3be83783c38236b2f11dff99b0e9f6f5b2ca
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
@BeforeEach
void before() {
- context = YangParserTestUtils.parseYangResource("/yt1050.yang");
+ context = YangParserTestUtils.parseYang("""
+ module yt1050 {
+ yang-version 1.1;
+ namespace "yt1050";
+ prefix "yt1050";
+
+ identity target-base;
+
+ typedef target-type {
+ type identityref {
+ base target-base;
+ }
+ }
+
+ grouping grp {
+ leaf id {
+ type string;
+ }
+ leaf type {
+ type target-type;
+ }
+
+ list secondary {
+ key "id type";
+ leaf id {
+ type leafref {
+ path "/grp-uses/id";
+ }
+ }
+ leaf type {
+ type leafref {
+ path "deref(../id)/../type";
+ }
+ }
+ }
+ }
+
+ list grp-uses {
+ uses grp;
+ key "id type";
+ }
+ }""");
module = context.getModules().iterator().next();
final var grpUses = assertInstanceOf(ListSchemaNode.class, module.getDataChildByName(GRP_USES));
@BeforeEach
void before() {
- context = YangParserTestUtils.parseYangResourceDirectory("/yt1060");
+ context = YangParserTestUtils.parseYang("""
+ submodule child {
+ belongs-to parent {
+ prefix par;
+ }
+
+ import imported {
+ prefix imp;
+ }
+
+ container cont {
+ leaf leaf1 {
+ type leafref {
+ path "/imp:root/imp:leaf1";
+ }
+ }
+ leaf leaf2 {
+ type imp:foo;
+ }
+ }
+ }""", """
+ module imported {
+ namespace "imported";
+ prefix imp;
+
+ typedef foo {
+ type string {
+ pattern 'S(\\d+G)?(\\d+M)?';
+ }
+ }
+
+ container root {
+ leaf leaf1 {
+ type string;
+ }
+ }
+ }""", """
+ module parent {
+ namespace "parent";
+ prefix par;
+
+ include child;
+ }""");
final var module = context.findModule(CONT.getModule()).orElseThrow();
final var cont = assertInstanceOf(ContainerSchemaNode.class, module.getDataChildByName(CONT));
class YT1100Test {
@Test
void testChoiceCaseRelativeLeafref() {
- final var context = YangParserTestUtils.parseYangResource("/yt1100.yang");
+ final var context = YangParserTestUtils.parseYang("""
+ module yt1100 {
+ yang-version 1.1;
+ namespace "a";
+ prefix a;
+
+ container foo {
+ list scheduler-node {
+ key "name";
+ leaf name {
+ type string;
+ }
+ choice children-type {
+ case scheduler-node {
+ list child-scheduler-nodes {
+ key "name";
+ leaf name {
+ type leafref {
+ path '../../../a:scheduler-node/a:name';
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }""");
final var module = context.findModule("yt1100").orElseThrow();
final var qnm = module.getQNameModule();
final var foo = QName.create(qnm, "foo");
@BeforeAll
static void beforeClass() {
- context = YangParserTestUtils.parseYangResource("/yt1127.yang");
+ context = YangParserTestUtils.parseYang("""
+ module foo {
+ namespace foo;
+ prefix foo;
+
+ grouping grp {
+ leaf leaf1 {
+ type leafref {
+ path "../../foo:foo_cont/foo:name";
+ }
+ }
+ }
+ container cont {
+ leaf leaf2 {
+ type leafref {
+ path "../../../foo:foo_cont/foo:name";
+ }
+ }
+ }
+ }""");
}
@AfterAll
@BeforeAll
static void beforeClass() {
- CONTEXT = YangParserTestUtils.parseYangResource("/yt1231.yang");
+ CONTEXT = YangParserTestUtils.parseYang("""
+ module foo {
+ namespace foo;
+ prefix foo;
+
+ container foo {
+ container foo;
+
+ choice baz {
+ description desc;
+ case baz {
+ description desc;
+ choice bar {
+ description desc;
+ case bar {
+ status deprecated;
+ container bar;
+ }
+ }
+ }
+ }
+
+ choice bar {
+ reference ref;
+ case bar {
+ reference ref;
+ choice baz {
+ reference ref;
+ case baz {
+ reference ref;
+ container xyzzy;
+ }
+ }
+ }
+ }
+ }
+ }""");
}
@Test
@BeforeAll
static void beforeClass() {
- context = YangParserTestUtils.parseYangResource("/yt1233.yang");
+ context = YangParserTestUtils.parseYang("""
+ module foo {
+ namespace foo;
+ prefix foo;
+
+ anyxml foo;
+
+ rpc bar;
+
+ grouping baz {
+ anyxml xyzzy;
+ }
+ }""");
}
@Test
@BeforeAll
static void beforeClass() {
- context = YangParserTestUtils.parseYangResource("/yt1282.yang");
+ context = YangParserTestUtils.parseYang("""
+ module foo {
+ prefix foo;
+ namespace foo;
+
+ typedef foo {
+ type leafref {
+ path /bar;
+ }
+ }
+
+ leaf bar {
+ type int64;
+ }
+ }""");
}
@Test
@BeforeAll
static void beforeClass() {
- context = YangParserTestUtils.parseYangResource("/yt1283.yang");
+ context = YangParserTestUtils.parseYang("""
+ module foo {
+ namespace foo;
+ prefix foo;
+
+ container foo {
+ choice foo {
+ case foo {
+ leaf foo {
+ type leafref {
+ path ../../bar;
+ }
+ }
+ }
+ }
+ }
+
+ leaf bar {
+ type string;
+ }
+ }""");
}
@Test
@BeforeAll
static void beforeClass() {
- context = YangParserTestUtils.parseYangResource("/yt1291.yang");
+ context = YangParserTestUtils.parseYang("""
+ module foo {
+ namespace foo;
+ prefix foo;
+
+ rpc foo;
+ }""");
}
@Test
@BeforeAll
static void beforeClass() {
- module = Iterables.getOnlyElement(YangParserTestUtils.parseYangResource("/yt1292.yang").getModuleStatements()
+ module = Iterables.getOnlyElement(YangParserTestUtils.parseYang("""
+ module foo {
+ namespace foo;
+ prefix foo;
+ yang-version 1.1;
+
+ rpc foo;
+
+ notification bar;
+
+ container baz {
+ action foo;
+ notification bar;
+ }
+ }""").getModuleStatements()
.values());
}
@Test
void testDeviatedEffectiveAugmentationSchema() {
- final var module = YangParserTestUtils.parseYangResourceDirectory("/yt1404").findModule("foo").orElseThrow();
+ final var module = YangParserTestUtils.parseYang("""
+ module dev {
+ namespace dev;
+ prefix dev;
+
+ import foo {
+ prefix foo;
+ }
+
+ deviation /foo:foo/foo:baz {
+ deviate not-supported;
+ }
+ }""", """
+ module foo {
+ namespace foo;
+ prefix foo;
+
+ container foo;
+
+ augment /foo {
+ leaf bar {
+ type string;
+ }
+ leaf baz {
+ type string;
+ }
+ }
+ }""").findModule("foo").orElseThrow();
final var augment = Iterables.getOnlyElement(module.getAugmentations());
assertEquals(2, augment.getChildNodes().size());
assertInstanceOf(LeafSchemaNode.class, augment.dataChildByName(BAR));
@Test
void testOfUntrustedSchemaTreeInference() {
- final var context = YangParserTestUtils.parseYangResource("/yt1414.yang");
+ final var context = YangParserTestUtils.parseYang("""
+ module foo {
+ namespace foo;
+ prefix foo;
+
+ container foo;
+
+ container bar {
+ list foo;
+ }
+ }""");
final var foo = context.findSchemaTreeNode(Absolute.of(FOO)).orElseThrow();
final var bar = context.findSchemaTreeNode(Absolute.of(BAR)).orElseThrow();
final var barFoo = context.findSchemaTreeNode(BAR_FOO_ID).orElseThrow();
@Test
void test() {
- final var context = YangParserTestUtils.parseYangResource("/yt588.yang");
+ final var context = YangParserTestUtils.parseYang("""
+ module foo {
+ namespace "foo";
+ prefix foo;
+ yang-version 1;
+
+ revision "2016-03-01" {
+ description "test";
+ }
+
+ grouping grp {
+ container con-grp {
+ leaf l {
+ type int16;
+ }
+ leaf leaf-ref {
+ type leafref {
+ path "../../con2/l2";
+ }
+ }
+ }
+ }
+
+ container root {
+ uses grp;
+ container con2 {
+ leaf l2 {
+ type binary;
+ }
+ }
+ }
+
+ augment "/root" {
+ leaf leaf-ref-2 {
+ type leaf-ref-type2;
+ }
+ }
+
+ typedef leaf-ref-type2 {
+ type leaf-ref-type;
+ }
+
+ typedef leaf-ref-type {
+ type leafref {
+ path "../con-grp/l";
+ }
+ }
+ }""");
final var root = QName.create(NS, REV, "root");
final var leafRef2 = QName.create(NS, REV, "leaf-ref-2");
final var conGrp = QName.create(NS, REV, "con-grp");
final var bar = new SourceIdentifier("bar", "2016-01-01");
final var sub1Bar = new SourceIdentifier("sub1-bar", "2016-01-01");
final var baz = new SourceIdentifier("baz", "2016-01-01");
- final var context = YangParserTestUtils.parseYangResourceDirectory("/yt691");
+ final var context = YangParserTestUtils.parseYang("""
+ module bar {
+ namespace "bar";
+ prefix bar;
+ revision 2016-01-01;
+
+ include sub1-bar;
+
+ leaf bar-leaf {
+ type string;
+ }
+ }""", """
+ submodule sub1-bar {
+ belongs-to bar {
+ prefix bar;
+ }
+
+ revision 2016-01-01;
+
+ leaf sub1-bar-leaf {
+ type string;
+ }
+ }""", """
+ module baz {
+ namespace "baz";
+ prefix baz;
+ revision 2016-01-01;
+
+ leaf baz-leaf {
+ type string;
+ }
+ }""", """
+ module foo {
+ namespace "foo";
+ prefix foo;
+ revision 2016-01-01;
+
+ include sub1-foo;
+ include sub2-foo;
+
+ leaf foo-leaf {
+ type string;
+ }
+ }""", """
+ submodule sub1-foo {
+ belongs-to foo {
+ prefix foo;
+ }
+
+ revision 2016-01-01;
+
+ leaf sub1-foo-leaf {
+ type string;
+ }
+ }""", """
+ submodule sub2-foo {
+ belongs-to foo {
+ prefix foo;
+ }
+
+ revision 2016-01-01;
+
+ leaf sub2-foo-leaf {
+ type string;
+ }
+ }""");
final var allModuleIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(context);
assertEquals(6, allModuleIdentifiers.size());
final var allModuleIdentifiersResolved = SchemaContextUtil.getConstituentModuleIdentifiers(
+++ /dev/null
-module yt1050 {
- yang-version 1.1;
- namespace "yt1050";
- prefix "yt1050";
-
- identity target-base;
-
- typedef target-type {
- type identityref {
- base target-base;
- }
- }
-
- grouping grp {
- leaf id {
- type string;
- }
- leaf type {
- type target-type;
- }
-
- list secondary {
- key "id type";
- leaf id {
- type leafref {
- path "/grp-uses/id";
- }
- }
- leaf type {
- type leafref {
- path "deref(../id)/../type";
- }
- }
- }
- }
-
- list grp-uses {
- uses grp;
- key "id type";
- }
-}
-
+++ /dev/null
-submodule child {
- belongs-to parent {
- prefix par;
- }
-
- import imported {
- prefix imp;
- }
-
- container cont {
- leaf leaf1 {
- type leafref {
- path "/imp:root/imp:leaf1";
- }
- }
- leaf leaf2 {
- type imp:foo;
- }
- }
-}
+++ /dev/null
-module imported {
- namespace "imported";
- prefix imp;
-
- typedef foo {
- type string {
- pattern 'S(\d+G)?(\d+M)?';
- }
- }
-
- container root {
- leaf leaf1 {
- type string;
- }
- }
-}
+++ /dev/null
-module parent {
- namespace "parent";
- prefix par;
-
- include child;
-}
+++ /dev/null
-module yt1100 {
- yang-version 1.1;
- namespace "a";
- prefix a;
-
- container foo {
- list scheduler-node {
- key "name";
- leaf name {
- type string;
- }
- choice children-type {
- case scheduler-node {
- list child-scheduler-nodes {
- key "name";
- leaf name {
- type leafref {
- path '../../../a:scheduler-node/a:name';
- }
- }
- }
- }
- }
- }
- }
-}
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
-
- grouping grp {
- leaf leaf1 {
- type leafref {
- path "../../foo:foo_cont/foo:name";
- }
- }
- }
- container cont {
- leaf leaf2 {
- type leafref {
- path "../../../foo:foo_cont/foo:name";
- }
- }
- }
-}
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
-
- container foo {
- container foo;
-
- choice baz {
- description desc;
- case baz {
- description desc;
- choice bar {
- description desc;
- case bar {
- status deprecated;
- container bar;
- }
- }
- }
- }
-
- choice bar {
- reference ref;
- case bar {
- reference ref;
- choice baz {
- reference ref;
- case baz {
- reference ref;
- container xyzzy;
- }
- }
- }
- }
- }
-}
-
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
-
- anyxml foo;
-
- rpc bar;
-
- grouping baz {
- anyxml xyzzy;
- }
-}
-
+++ /dev/null
-module foo {
- prefix foo;
- namespace foo;
-
- typedef foo {
- type leafref {
- path /bar;
- }
- }
-
- leaf bar {
- type int64;
- }
-}
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
-
- container foo {
- choice foo {
- case foo {
- leaf foo {
- type leafref {
- path ../../bar;
- }
- }
- }
- }
- }
-
- leaf bar {
- type string;
- }
-}
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
-
- rpc foo;
-}
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
- yang-version 1.1;
-
- rpc foo;
-
- notification bar;
-
- container baz {
- action foo;
-
- notification bar;
- }
-}
+++ /dev/null
-module dev {
- namespace dev;
- prefix dev;
-
- import foo {
- prefix foo;
- }
-
- deviation /foo:foo/foo:baz {
- deviate not-supported;
- }
-}
-
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
-
- container foo;
-
- augment /foo {
- leaf bar {
- type string;
- }
- leaf baz {
- type string;
- }
- }
-}
-
+++ /dev/null
-module foo {
- namespace foo;
- prefix foo;
-
- container foo;
-
- container bar {
- list foo;
- }
-}
+++ /dev/null
-module foo {
- namespace "foo";
- prefix foo;
- yang-version 1;
-
- revision "2016-03-01" {
- description "test";
- }
-
- grouping grp {
- container con-grp {
- leaf l {
- type int16;
- }
- leaf leaf-ref {
- type leafref {
- path "../../con2/l2";
- }
- }
- }
- }
-
- container root {
- uses grp;
- container con2 {
- leaf l2 {
- type binary;
- }
- }
- }
-
- augment "/root" {
- leaf leaf-ref-2 {
- type leaf-ref-type2;
- }
- }
-
- typedef leaf-ref-type2 {
- type leaf-ref-type;
- }
-
- typedef leaf-ref-type {
- type leafref {
- path "../con-grp/l";
- }
- }
-}
+++ /dev/null
-submodule sub1-bar {
- belongs-to bar {
- prefix bar;
- }
-
- revision 2016-01-01;
-
- leaf sub1-bar-leaf {
- type string;
- }
-}
\ No newline at end of file
+++ /dev/null
-module bar {
- namespace "bar";
- prefix bar;
- revision 2016-01-01;
-
- include sub1-bar;
-
- leaf bar-leaf {
- type string;
- }
-}
\ No newline at end of file
+++ /dev/null
-module baz {
- namespace "baz";
- prefix baz;
- revision 2016-01-01;
-
- leaf baz-leaf {
- type string;
- }
-}
\ No newline at end of file
+++ /dev/null
-submodule sub1-foo {
- belongs-to foo {
- prefix foo;
- }
-
- revision 2016-01-01;
-
- leaf sub1-foo-leaf {
- type string;
- }
-}
\ No newline at end of file
+++ /dev/null
-submodule sub2-foo {
- belongs-to foo {
- prefix foo;
- }
-
- revision 2016-01-01;
-
- leaf sub2-foo-leaf {
- type string;
- }
-}
\ No newline at end of file
+++ /dev/null
-module foo {
- namespace "foo";
- prefix foo;
- revision 2016-01-01;
-
- include sub1-foo;
- include sub2-foo;
-
- leaf foo-leaf {
- type string;
- }
-}
\ No newline at end of file