[ONOS-4744] Leafref implementation and UT
Change-Id: I151797185e0bb1695c0640b667ae76ef87c4d4b0
diff --git a/utils/yangutils/plugin/src/test/resources/InstanceIdentifierInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/InstanceIdentifierListener.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/InstanceIdentifierInvalidIdentifier.yang
rename to utils/yangutils/plugin/src/test/resources/InstanceIdentifierListener.yang
diff --git a/utils/yangutils/plugin/src/test/resources/LeafrefInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/LeafrefInvalidIdentifier.yang
deleted file mode 100644
index 4737b6c..0000000
--- a/utils/yangutils/plugin/src/test/resources/LeafrefInvalidIdentifier.yang
+++ /dev/null
@@ -1,8 +0,0 @@
-module Test {
- yang-version 1;
- namespace http://huawei.com;
- prefix Ant;
- leaf-list invalid-interval {
- type leafref;
- }
-}
diff --git a/utils/yangutils/plugin/src/test/resources/PathListener.yang b/utils/yangutils/plugin/src/test/resources/PathListener.yang
new file mode 100644
index 0000000..c4dae28
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PathListener.yang
@@ -0,0 +1,31 @@
+module PathListener {
+ namespace "test";
+ prefix test;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type string;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type string;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../test:interface/test:name";
+ }
+ }
+ leaf status {
+ type leafref {
+ path "/test:interface[name = current()/../ifname]/test:admin-status";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/RequireInstanceDefaultValueForLeafref.yang b/utils/yangutils/plugin/src/test/resources/RequireInstanceDefaultValueForLeafref.yang
new file mode 100644
index 0000000..c4dae28
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RequireInstanceDefaultValueForLeafref.yang
@@ -0,0 +1,31 @@
+module PathListener {
+ namespace "test";
+ prefix test;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type string;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type string;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../test:interface/test:name";
+ }
+ }
+ leaf status {
+ type leafref {
+ path "/test:interface[name = current()/../ifname]/test:admin-status";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/RequireInstanceDefaultValueInInstanceIdentifier.yang b/utils/yangutils/plugin/src/test/resources/RequireInstanceDefaultValueInInstanceIdentifier.yang
new file mode 100644
index 0000000..e3e15bf
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RequireInstanceDefaultValueInInstanceIdentifier.yang
@@ -0,0 +1,7 @@
+module PathListener {
+ namespace "test";
+ prefix test;
+ leaf admin-status {
+ type instance-identifier;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/RequireInstanceFalse.yang b/utils/yangutils/plugin/src/test/resources/RequireInstanceFalse.yang
new file mode 100644
index 0000000..0a2ba4f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RequireInstanceFalse.yang
@@ -0,0 +1,9 @@
+module PathListener {
+ namespace "test";
+ prefix test;
+ leaf admin-status {
+ type instance-identifier {
+ require-instance "false";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/RequireInstanceTrue.yang b/utils/yangutils/plugin/src/test/resources/RequireInstanceTrue.yang
new file mode 100644
index 0000000..cace8c5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RequireInstanceTrue.yang
@@ -0,0 +1,32 @@
+module PathListener {
+ namespace "test";
+ prefix test;
+ list interface {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf admin-status {
+ type string;
+ }
+ list address {
+ key "ip";
+ leaf ip {
+ type string;
+ }
+ }
+ }
+ container default-address {
+ leaf ifname {
+ type leafref {
+ path "../../test:interface/test:name";
+ require-instance true;
+ }
+ }
+ leaf status {
+ type leafref {
+ path "/test:interface[name = current()/../ifname]/test:admin-status";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang
new file mode 100644
index 0000000..941b56b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang
@@ -0,0 +1,28 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+ feature local-storage {
+ description
+ "This feature means the device supports local
+ storage (memory, flash or disk) that can be used to
+ store syslog messages.";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature local-storage;
+ type uint64;
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+ leaf storage-value {
+ type leafref {
+ path "/speed/local-storage-limit";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang
new file mode 100644
index 0000000..f57fa6b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang
@@ -0,0 +1,40 @@
+module syslog {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix "sys";
+ feature local-storage {
+ description
+ "This feature means the device supports local
+ storage (memory, flash or disk) that can be used to
+ store syslog messages.";
+ }
+ feature main-storage {
+ description
+ "This feature means the device supports main
+ storage that can be used to
+ store syslog messages.";
+ }
+
+ container speed {
+ leaf local-storage-limit {
+ if-feature local-storage;
+ type leafref {
+ path "/value";
+ }
+ units "kilobyte";
+ config false;
+ description
+ "The amount of local storage that can be
+ used to hold syslog messages.";
+ }
+ }
+ leaf storage-value {
+ type leafref {
+ path "/speed/local-storage-limit";
+ }
+ }
+ leaf value {
+ if-feature main-storage;
+ type uint64;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
new file mode 100644
index 0000000..e5de10b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type status;
+ description
+ "Identifies a network.";
+ }
+ }
+ typedef status {
+ type uint8;
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang
new file mode 100644
index 0000000..90b9efc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang
@@ -0,0 +1,17 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf-list network-ref {
+ type leafref;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGrouping.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGrouping.yang
new file mode 100644
index 0000000..d5622d4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGrouping.yang
@@ -0,0 +1,30 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ grouping input {
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ output {
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
new file mode 100644
index 0000000..85a7e42
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ grouping networks {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ container current {
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
new file mode 100644
index 0000000..cc6a9f1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
@@ -0,0 +1,28 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ grouping input {
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
new file mode 100644
index 0000000..477832d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
@@ -0,0 +1,28 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ grouping input {
+ leaf network-id {
+ type string;
+ description
+ "Identifies a network.";
+ }
+ }
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
new file mode 100644
index 0000000..7f7f5d1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/define/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
new file mode 100644
index 0000000..9681d76
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../define/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
new file mode 100644
index 0000000..7e3d216
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../../../define/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
new file mode 100644
index 0000000..0a397dd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
@@ -0,0 +1,23 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ output {
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
new file mode 100644
index 0000000..917c434
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
@@ -0,0 +1,23 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf-list network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ output {
+ }
+ }
+ leaf-list network-ref {
+ type leafref {
+ path "/networks/input/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
new file mode 100644
index 0000000..b61be6a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
@@ -0,0 +1,33 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ typedef node {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ container present {
+ typedef name {
+ type node;
+ }
+ leaf interval {
+ type name;
+ }
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
new file mode 100644
index 0000000..59e7a98
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
@@ -0,0 +1,26 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ rpc networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ input {
+ leaf-list network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ output {
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "/networks/input/id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
new file mode 100644
index 0000000..ae42100
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "/networks/id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
new file mode 100644
index 0000000..93d8e94
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type network-ref;
+ description
+ "Identifies a network.";
+ }
+ leaf id {
+ type uint8;
+ }
+ }
+ typedef network-ref {
+ type leafref {
+ path "../id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
new file mode 100644
index 0000000..edf6bfa
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
@@ -0,0 +1,28 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf name {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ }
+ }
+ leaf invalid-interval {
+ type union {
+ type int32;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
new file mode 100644
index 0000000..a3e0f29
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
@@ -0,0 +1,27 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
new file mode 100644
index 0000000..eb2668e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type status;
+ description
+ "Identifies a network.";
+ }
+ }
+ typedef status {
+ type uint8;
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
new file mode 100644
index 0000000..26ccd1f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
@@ -0,0 +1,26 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type leafref {
+ path "/status/current";
+ }
+ description
+ "Identifies a network.";
+ }
+ }
+ container status {
+ leaf current {
+ type uint8;
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
new file mode 100644
index 0000000..81fc331
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafList.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
new file mode 100644
index 0000000..ec9a6d3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf-list network-ref {
+ type leafref {
+ path "/networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
new file mode 100644
index 0000000..05ef0d2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "../networks/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
new file mode 100644
index 0000000..1bf423d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
@@ -0,0 +1,45 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ leaf invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
new file mode 100644
index 0000000..5570f38
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
@@ -0,0 +1,45 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "../../../../valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type leafref {
+ path "../../../../invalid-interval";
+ }
+ }
+ leaf invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
new file mode 100644
index 0000000..fd75d32
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
@@ -0,0 +1,50 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "/transmitter/send";
+ }
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ list transmitter {
+ key "send";
+ leaf send {
+ type leafref {
+ path "/invalid-interval";
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
new file mode 100644
index 0000000..890bbaa
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
@@ -0,0 +1,50 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type leafref {
+ path "../../../../transmitter/send";
+ }
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "../../../../valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ list transmitter {
+ key "send";
+ leaf send {
+ type leafref {
+ path "../../invalid-interval";
+ }
+ }
+ }
+ leaf-list invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
new file mode 100644
index 0000000..4b286d2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
@@ -0,0 +1,43 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container standard {
+ container present {
+ leaf-list name {
+ type transmitter;
+ }
+ }
+ }
+ }
+ container reference {
+ list found {
+ key "define";
+ leaf define {
+ type string;
+ }
+ container reciever {
+ leaf remove {
+ type leafref {
+ path "/valid/standard/present/name";
+ }
+ }
+ }
+ }
+ }
+ typedef transmitter {
+ type invalid-interval;
+ }
+ typedef invalid-interval {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interFileInvalidNode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang b/utils/yangutils/plugin/src/test/resources/interFileInvalidNode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
new file mode 100644
index 0000000..7f7f5d1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interFileInvalidNode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
@@ -0,0 +1,19 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type uint8;
+ description
+ "Identifies a network.";
+ }
+ }
+ leaf network-ref {
+ type leafref {
+ path "/define/network-id";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/interfileleafref/module1.yang b/utils/yangutils/plugin/src/test/resources/interfileleafref/module1.yang
new file mode 100644
index 0000000..d33cf1e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileleafref/module1.yang
@@ -0,0 +1,16 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ }
+ leaf invalid-interval {
+ type leafref {
+ path "/p:hello";
+ }
+ }
+ leaf hello {
+ type string;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/interfileleafref/module2.yang b/utils/yangutils/plugin/src/test/resources/interfileleafref/module2.yang
new file mode 100644
index 0000000..28a869b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileleafref/module2.yang
@@ -0,0 +1,8 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant2;
+ leaf hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module1.yang b/utils/yangutils/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module1.yang
new file mode 100644
index 0000000..4cfb53d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module1.yang
@@ -0,0 +1,28 @@
+module module1 {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ prefix "tet";
+ import module2 {
+ prefix "nt";
+ }
+ grouping te-node-tunnel-termination-capability {
+ description
+ "Termination capability of a tunnel termination point on a
+ TE node.";
+ list termination-capability {
+ key "link-tp";
+ description
+ "The termination capabilities between
+ tunnel-termination-point and link termination-point.
+ The capability information can be used to compute
+ the tunnel path.";
+ leaf link-tp {
+ type leafref {
+ path "/nt:termination-point/nt:tp-id";
+ }
+ description
+ "Link termination point.";
+ }
+ } // termination-capability
+ } // te-node-tunnel-termination-capability
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module2.yang b/utils/yangutils/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module2.yang
new file mode 100644
index 0000000..822d90b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module2.yang
@@ -0,0 +1,11 @@
+module module2 {
+ yang-version 1;
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+ prefix inet;
+ container termination-point {
+ leaf tp-id {
+ type string;
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang b/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang
new file mode 100644
index 0000000..c393dbf
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang
@@ -0,0 +1,11 @@
+module ietf-inet-types {
+ yang-version 1;
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+ prefix inet;
+ typedef tp-ref {
+ type leafref {
+ path "/nwtp:value";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang b/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
new file mode 100644
index 0000000..7e080c5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
@@ -0,0 +1,28 @@
+module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ prefix "tet";
+ import ietf-network {
+ prefix "nt";
+ }
+ grouping te-node-tunnel-termination-capability {
+ description
+ "Termination capability of a tunnel termination point on a
+ TE node.";
+ list termination-capability {
+ key "link-tp";
+ description
+ "The termination capabilities between
+ tunnel-termination-point and link termination-point.
+ The capability information can be used to compute
+ the tunnel path.";
+ leaf link-tp {
+ type leafref {
+ path "/nt:termination-point/nt:tp-id";
+ }
+ description
+ "Link termination point.";
+ }
+ } // termination-capability
+ } // te-node-tunnel-termination-capability
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang b/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang
new file mode 100644
index 0000000..49a6a04
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang
@@ -0,0 +1,14 @@
+module ietf-network {
+ yang-version 1;
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+ prefix nw;
+ import ietf-inet-types {
+ prefix inet;
+ }
+ container termination-point {
+ leaf tp-id {
+ type string;
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/interfileleafrefwithinvaliddestinationnode/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang b/utils/yangutils/plugin/src/test/resources/interfileleafrefwithinvaliddestinationnode/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
new file mode 100644
index 0000000..e5de10b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileleafrefwithinvaliddestinationnode/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
@@ -0,0 +1,22 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ leaf network-id {
+ type status;
+ description
+ "Identifies a network.";
+ }
+ }
+ typedef status {
+ type uint8;
+ }
+ leaf network-ref {
+ type leafref {
+ path "/networks";
+ }
+ }
+}
\ No newline at end of file