[ONOS-4842] Leafref implementation for augment and uses
Change-Id: I919553a64d683aff65a8f16e2de783702dd5a45f
diff --git a/plugin/src/test/resources/ConfigFalseValidKeyValidLeafList.yang b/plugin/src/test/resources/ConfigFalseValidKeyValidLeafList.yang
deleted file mode 100644
index 4196be4..0000000
--- a/plugin/src/test/resources/ConfigFalseValidKeyValidLeafList.yang
+++ /dev/null
@@ -1,14 +0,0 @@
-module Test {
-    yang-version 1;
-    namespace http://huawei.com;
-    prefix Ant;
-    list valid {
-        key "invalid-interval";
-        leaf-list invalid-interval {
-            type "string";
-            units "seconds";
-            status current;
-            reference "RFC 6020";
-        }
-    }
-}
\ No newline at end of file
diff --git a/plugin/src/test/resources/InvalidLeafListIdentifier.yang b/plugin/src/test/resources/InvalidLeafListIdentifier.yang
deleted file mode 100644
index 6359d2a..0000000
--- a/plugin/src/test/resources/InvalidLeafListIdentifier.yang
+++ /dev/null
@@ -1,14 +0,0 @@
-module Test {
-    yang-version 1;
-    namespace http://huawei.com;
-    prefix Ant;
-    list valid {
-        key "invalid-interval";
-        leaf-list invalid {
-            type "string";
-            units "seconds";
-            status current;
-            reference "RFC 6020";
-        }
-    }
-}
\ No newline at end of file
diff --git a/plugin/src/test/resources/KeyLeafListTypeEmpty.yang b/plugin/src/test/resources/KeyLeafListTypeEmpty.yang
deleted file mode 100644
index 44c1617..0000000
--- a/plugin/src/test/resources/KeyLeafListTypeEmpty.yang
+++ /dev/null
@@ -1,14 +0,0 @@
-module Test {
-    yang-version 1;
-    namespace http://huawei.com;
-    prefix Ant;
-    list valid {
-        key "invalid-interval";
-        leaf-list invalid-interval {
-            type "empty";
-            units "seconds";
-            status current;
-            reference "RFC 6020";
-        }
-    }
-}
\ No newline at end of file
diff --git a/plugin/src/test/resources/ListSubStatementLeafList.yang b/plugin/src/test/resources/ListSubStatementLeafList.yang
index 5235295..672ebdd 100644
--- a/plugin/src/test/resources/ListSubStatementLeafList.yang
+++ b/plugin/src/test/resources/ListSubStatementLeafList.yang
@@ -4,7 +4,7 @@
     namespace http://huawei.com;
     prefix Ant;
     list valid {
-        key "invalid-interval";
+        key "invalid";
         leaf-list invalid-interval {
             type "uint16";
             units "seconds";
@@ -13,5 +13,8 @@
             status current;
             reference "RFC 6020";
         }
+        leaf invalid {
+            type "uint16";
+        }
     }
 }
\ No newline at end of file
diff --git a/plugin/src/test/resources/ListSubStatementMaxElements.yang b/plugin/src/test/resources/ListSubStatementMaxElements.yang
index de6139e..e74a5a8 100644
--- a/plugin/src/test/resources/ListSubStatementMaxElements.yang
+++ b/plugin/src/test/resources/ListSubStatementMaxElements.yang
@@ -3,12 +3,15 @@
     namespace http://huawei.com;
     prefix Ant;
     list valid {
-        key "invalid-interval";
+        key "invalid";
         max-elements 3;
         leaf-list invalid-interval {
             type "uint16";
             units "seconds";
             description "Interval before a route is declared invalid";
         }
+        leaf invalid {
+            type "uint16";
+        }
     }
 }
\ No newline at end of file
diff --git a/plugin/src/test/resources/ListSubStatementMinElements.yang b/plugin/src/test/resources/ListSubStatementMinElements.yang
index d6071e8..8454fdd 100644
--- a/plugin/src/test/resources/ListSubStatementMinElements.yang
+++ b/plugin/src/test/resources/ListSubStatementMinElements.yang
@@ -3,12 +3,15 @@
     namespace http://huawei.com;
     prefix Ant;
     list valid {
-        key "invalid-interval";
+        key "invalid";
         min-elements 3;
         leaf-list invalid-interval {
             type "uint16";
             units "seconds";
             description "Interval before a route is declared invalid";
         }
+        leaf invalid {
+            type "uint16";
+        }
     }
 }
\ No newline at end of file
diff --git a/plugin/src/test/resources/NoConfigListSubStatementLeafList.yang b/plugin/src/test/resources/ListSubStatementUnique.yang
similarity index 79%
rename from plugin/src/test/resources/NoConfigListSubStatementLeafList.yang
rename to plugin/src/test/resources/ListSubStatementUnique.yang
index e70155e..b500aa4 100644
--- a/plugin/src/test/resources/NoConfigListSubStatementLeafList.yang
+++ b/plugin/src/test/resources/ListSubStatementUnique.yang
@@ -3,12 +3,13 @@
     namespace http://huawei.com;
     prefix Ant;
     list valid {
+        unique "invalid-interval";
         key "invalid-interval";
-        leaf-list invalid-interval {
+        leaf invalid-interval {
             type "uint16";
             units "seconds";
             status current;
             reference "RFC 6020";
         }
     }
-}
\ No newline at end of file
+}
diff --git a/plugin/src/test/resources/MultipleUniqueValues.yang b/plugin/src/test/resources/MultipleUniqueValues.yang
new file mode 100644
index 0000000..28f7978
--- /dev/null
+++ b/plugin/src/test/resources/MultipleUniqueValues.yang
@@ -0,0 +1,21 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "ospf";
+        unique "ospf isis";
+        leaf ospf {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+        leaf isis {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
deleted file mode 100644
index cc6a9f1..0000000
--- a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
+++ /dev/null
@@ -1,28 +0,0 @@
-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/plugin/src/test/resources/UnionWhenTypeInLeafList.yang b/plugin/src/test/resources/UnionWhenTypeInLeafList.yang
index df2b428..f335960 100644
--- a/plugin/src/test/resources/UnionWhenTypeInLeafList.yang
+++ b/plugin/src/test/resources/UnionWhenTypeInLeafList.yang
@@ -3,7 +3,7 @@
     namespace http://huawei.com;
     prefix Ant;
     list valid {
-        key "invalid-interval";
+        key "invalid";
         leaf-list invalid-interval {
             type union {
             type int32;
@@ -12,5 +12,8 @@
                 }
             }
         }
+        leaf invalid {
+            type string;
+        }
     }
 }
diff --git a/plugin/src/test/resources/interFileInvalidNode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang b/plugin/src/test/resources/interFileInvalidNode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
deleted file mode 100644
index 7f7f5d1..0000000
--- a/plugin/src/test/resources/interFileInvalidNode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
+++ /dev/null
@@ -1,19 +0,0 @@
-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/plugin/src/test/resources/interfileietf/ietf-network-topology.yang b/plugin/src/test/resources/interfileietf/ietf-network-topology.yang
index 10c8fb9..4c57482 100644
--- a/plugin/src/test/resources/interfileietf/ietf-network-topology.yang
+++ b/plugin/src/test/resources/interfileietf/ietf-network-topology.yang
@@ -103,7 +103,11 @@
      description
        "References a link in a specific network.";
      leaf link-ref {
-       type link-id;
+       type leafref {
+         path "/nd:networks/nd:network[nd:network-id=current()/../"+
+           "network-ref]/lnk:link/lnk:link-id";
+         require-instance false;
+       }
        description
          "A type for an absolute reference a link instance.
           (This type should not be used for relative references.
@@ -116,7 +120,12 @@
      description
        "References a termination point in a specific node.";
      leaf tp-ref {
-       type tp-id;
+       type leafref {
+         path "/nd:networks/nd:network[nd:network-id=current()/../"+
+           "network-ref]/nd:node[nd:node-id=current()/../"+
+           "node-ref]/lnk:termination-point/lnk:tp-id";
+         require-instance false;
+       }
        description
          "A type for an absolute reference to a termination point.
           (This type should not be used for relative references.
@@ -150,13 +159,18 @@
            "This container holds the logical source of a particular
             link.";
          leaf source-node {
-           type nd:node-id;
+           type leafref {
+             path "../../../nd:node/nd:node-id";
+           }
            mandatory true;
            description
              "Source node identifier, must be in same topology.";
          }
          leaf source-tp {
-           type tp-id;
+           type leafref {
+             path "../../../nd:node[nd:node-id=current()/../"+
+               "source-node]/termination-point/tp-id";
+           }
            description
              "Termination point within source node that terminates
               the link.";
@@ -167,14 +181,19 @@
            "This container holds the logical destination of a
             particular link.";
          leaf dest-node {
-           type nd:node-id;
+           type leafref {
+             path "../../../nd:node/nd:node-id";
+           }
            mandatory true;
            description
              "Destination node identifier, must be in the same
               network.";
          }
          leaf dest-tp {
-           type tp-id;
+           type leafref {
+             path "../../../nd:node[nd:node-id=current()/../"+
+               "dest-node]/termination-point/tp-id";
+           }
            description
              "Termination point within destination node that
               terminates the link.";
@@ -192,13 +211,20 @@
            "Identifies the link, or links, that this link
             is dependent on.";
          leaf network-ref {
-           type nd:network-id;
+           type leafref {
+             path "../../../nd:supporting-network/nd:network-ref";
+           require-instance false;
+           }
            description
              "This leaf identifies in which underlay topology
               supporting link is present.";
          }
          leaf link-ref {
-           type link-id;
+           type leafref {
+             path "/nd:networks/nd:network[nd:network-id=current()/"+
+               "../network-ref]/link/link-id";
+             require-instance false;
+           }
            description
              "This leaf identifies a link which is a part
               of this link's underlay. Reference loops, in which
@@ -237,19 +263,30 @@
             The corresponding information is simply provided by the
             implementing system.";
          leaf network-ref {
-           type nd:network-id;
+           type leafref {
+             path "../../../nd:supporting-node/nd:network-ref";
+           require-instance false;
+           }
            description
              "This leaf identifies in which topology the
               supporting termination point is present.";
          }
          leaf node-ref {
-           type nd:node-id;
+           type leafref {
+             path "../../../nd:supporting-node/nd:node-ref";
+           require-instance false;
+           }
            description
              "This leaf identifies in which node the supporting
               termination point is present.";
          }
          leaf tp-ref {
-           type tp-id;
+           type leafref {
+             path "/nd:networks/nd:network[nd:network-id=current()/"+
+               "../network-ref]/nd:node[nd:node-id=current()/../"+
+               "node-ref]/termination-point/tp-id";
+             require-instance false;
+           }
            description
              "Reference to the underlay node, must be in a
               different topology";
diff --git a/plugin/src/test/resources/interfileietf/ietf-network.yang b/plugin/src/test/resources/interfileietf/ietf-network.yang
index 9dbe38f..60c47ce 100644
--- a/plugin/src/test/resources/interfileietf/ietf-network.yang
+++ b/plugin/src/test/resources/interfileietf/ietf-network.yang
@@ -87,7 +87,10 @@
          "Contains the information necessary to reference a network,
           for example an underlay network.";
        leaf network-ref {
-         type network-id;
+         type leafref {
+           path "/nd:networks/nd:network/nd:network-id";
+         require-instance false;
+         }
          description
            "Used to reference a network, for example an underlay
             network.";
@@ -98,7 +101,11 @@
        description
          "Contains the information necessary to reference a node.";
        leaf node-ref {
-         type node-id;
+         type leafref {
+           path "/nd:networks/nd:network[nd:network-id=current()/../"+
+             "network-ref]/nd:node/nd:node-id";
+           require-instance false;
+         }
          description
            "Used to reference a node.
             Nodes are identified relative to the network they are
@@ -135,7 +142,10 @@
              "An underlay network, used to represent layered network
               topologies.";
            leaf network-ref {
-             type network-id;
+             type leafref {
+               path "/networks/network/network-id";
+             require-instance false;
+             }
              description
                "References the underlay network.";
            }
@@ -157,13 +167,19 @@
                 this node is supported by.  Used to represent layering
                 structure.";
              leaf network-ref {
-               type network-id;
+               type leafref {
+                 path "../../../supporting-network/network-ref";
+               require-instance false;
+               }
                description
                  "References the underlay network that the
                   underlay node is part of.";
              }
              leaf node-ref {
-               type node-id;
+               type leafref {
+                 path "/networks/network/node/node-id";
+               require-instance false;
+               }
                description
                  "References the underlay node itself.";
              }
diff --git a/plugin/src/test/resources/interfileietf/ietf-te-topology.yang b/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
index 5b65dff..582ba9e 100644
--- a/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
+++ b/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
@@ -515,14 +515,14 @@
          "A container controlling performance metric throttle.";
        container performance-metric-throttle {
          if-feature te-performance-metric;
-         /*must "suppression-interval >= measure-interval" {
+         must "suppression-interval >= measure-interval" {
            error-message
              "suppression-interval cannot be less then
               measure-interval.";
            description
              "Constraint on suppression-interval and
               measure-interval.";
-         }*/
+         }
          description
            "Link performance information in real time.";
          reference
@@ -549,7 +549,7 @@
          }
          leaf suppression-interval {
            type uint32 {
-             range "1..max";
+             range "1 .. max";
            }
            default 120;
            description
@@ -633,13 +633,25 @@
                    "Identify the sequence in the bundle.";
                }
                leaf src-tp-ref {
-                 type nt:tp-id;
+                 type leafref {
+                   path "../../../../../../nw:node[nw:node-id = "
+                     + "current()/../../../../../nt:source/"
+                     + "nt:source-node]/"
+                     + "nt:termination-point/nt:tp-id";
+                   require-instance true;
+                 }
                  description
                    "Reference to another TE termination point on the
                     same souruce node.";
                }
                leaf des-tp-ref {
-                 type nt:tp-id;
+                 type leafref {
+                   path "../../../../../../nw:node[nw:node-id = "
+                     + "current()/../../../../../nt:destination/"
+                     + "nt:dest-node]/"
+                     + "nt:termination-point/nt:tp-id";
+                   require-instance true;
+                 }
                  description
                    "Reference to another TE termination point on the
                     same destination node.";
@@ -682,7 +694,9 @@
 
        leaf-list te-link-template {
          if-feature template;
-         type te-template-name;
+         type leafref {
+           path "../../../../../te/templates/link-template/name";
+         }
          description
            "The reference to a TE link template.";
        }
@@ -862,12 +876,16 @@
             RFC4203: OSPF Extensions in Support of Generalized
             Multi-Protocol Label Switching (GMPLS).";
          leaf switching-capability {
-           type string;
+           type identityref {
+             base te-types:switching-capabilities;
+           }
            description
              "Switching Capability for this interface.";
          }
          leaf encoding {
-           type string;
+           type identityref {
+             base te-types:lsp-encoding-types;
+           }
            description
              "Encoding supported by this interface.";
          }
@@ -929,12 +947,16 @@
              "RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
               for Multi-Layer and Multi-Region Networks (MLN/MRN).";
            leaf upper-sc {
-             type string;
+             type identityref {
+               base te-types:switching-capabilities;
+             }
              description
                "Switching Capability for this interface.";
            }
            leaf upper-encoding {
-             type string;
+             type identityref {
+               base te-types:lsp-encoding-types;
+             }
              description
                "Encoding supported by this interface.";
            }
@@ -1140,13 +1162,17 @@
 
              uses te-node-tunnel-termination-capability;
              leaf switching-capability {
-               type string;
+               type identityref {
+                 base te-types:switching-capabilities;
+               }
                mandatory true;
                description
                  "Switching Capability.";
              }
              leaf encoding {
-               type string;
+               type identityref {
+                 base te-types:lsp-encoding-types;
+               }
                mandatory true;
                description
                  "Encoding type.";
@@ -1162,7 +1188,9 @@
 
        leaf-list te-node-template {
          if-feature template;
-         type te-template-name;
+         type leafref {
+           path "../../../../../te/templates/node-template/name";
+         }
          description
            "The reference to a TE node template.";
        }
@@ -1231,7 +1259,9 @@
          }
          container from {
            leaf tp-ref {
-             type nt:tp-id;
+             type leafref {
+               path "../../../../../../nt:termination-point/nt:tp-id";
+             }
              description
                "Relative reference to source termination point.";
            }
@@ -1240,7 +1270,9 @@
          }
          container to {
            leaf tp-ref {
-             type nt:tp-id;
+             type leafref {
+               path "../../../../../../nt:termination-point/nt:tp-id";
+             }
              description
                "Relative reference to destination termination point.";
            }
@@ -1402,7 +1434,9 @@
             The capability information can be used to compute
             the tunnel path.";
          leaf link-tp {
-           type nt:tp-id;
+           type leafref {
+             path "../../../../../nt:termination-point/nt:tp-id";
+           }
            description
              "Link termination point.";
          }
@@ -1562,22 +1596,37 @@
        description
          "References a TE topology.";
        leaf provider-id-ref {
-         type te-global-id;
+         type leafref {
+           path "/nw:networks/nw:network[nw:network-id = "
+             + "current()/../network-id-ref]/tet:te/tet:provider-id";
+           require-instance false;
+         }
          description
            "A reference to a provider-id.";
        }
        leaf client-id-ref {
-         type te-global-id;
+         type leafref {
+           path "/nw:networks/nw:network[nw:network-id = "
+             + "current()/../network-id-ref]/tet:te/tet:client-id";
+           require-instance false;
+         }
          description
            "A reference to a client-id.";
        }
        leaf te-topology-id-ref {
-         type tet:te-topology-id;
+         type leafref {
+           path "/nw:networks/nw:network[nw:network-id = "
+             + "current()/../network-id-ref]/tet:te/tet:te-topology-id";
+           require-instance false;
+         }
          description
            "A reference to a te-topology-id.";
        }
        leaf network-id-ref {
-         type nw:network-id;
+         type leafref {
+           path "/nw:networks/nw:network/nw:network-id";
+           require-instance false;
+         }
          description
            "A reference to a network-id in base ietf-network module.";
        }
diff --git a/plugin/src/test/resources/interfileietf/ietf-te-types.yang b/plugin/src/test/resources/interfileietf/ietf-te-types.yang
index 4b9d3be..9347f26 100644
--- a/plugin/src/test/resources/interfileietf/ietf-te-types.yang
+++ b/plugin/src/test/resources/interfileietf/ietf-te-types.yang
@@ -580,7 +580,7 @@
 
      typedef admin-group {
        type binary {
-          length 32;
+         length 32;
        }
        description
          "Administrative group/Resource class/Color.";
@@ -680,12 +680,18 @@
              "The tunnel path hop limit.";
          }
          leaf metric-type {
-           type string;
+           type identityref {
+             base path-metric-type;
+           }
+           default path-metric-te;
            description
              "The tunnel path metric type.";
          }
          leaf tiebreaker-type {
-           type string;
+           type identityref {
+             base path-tiebreaker-type;
+           }
+           default path-tiebreaker-maxfill;
            description
              "The tunnel path computation tie breakers.";
          }
@@ -729,7 +735,9 @@
              list constraints {
                key "usage";
                leaf usage {
-                 type string;
+                 type identityref {
+                   base resource-affinities-type;
+                 }
                  description "Affinities usage";
                }
                container constraint {
@@ -765,7 +773,9 @@
              "Type of SRLG representation";
            case values {
              leaf usage {
-               type string;
+               type identityref {
+                 base route-exclude-srlg;
+               }
                description "SRLG usage";
              }
              leaf-list values {
@@ -777,7 +787,9 @@
              list constraints {
                key "usage";
                leaf usage {
-                 type string;
+                 type identityref {
+                   base route-exclude-srlg;
+                 }
                  description "SRLG usage";
                }
                container constraint {
@@ -829,12 +841,17 @@
                source.";
            }
            leaf type {
-             type string;
+             type identityref {
+               base bidir-association-type;
+             }
+             default bidir-assoc-non-corouted;
              description
                "The TE tunnel association type.";
            }
            leaf provisioing {
-             type string;
+             type identityref {
+               base bidir-provisioning-mode;
+             }
              description
                "Describes the provisioning model of the
                associated bidirectional LSP";
diff --git a/plugin/src/test/resources/interfileleafrefwithinvaliddestinationnode/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang b/plugin/src/test/resources/interfileleafrefwithinvaliddestinationnode/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
deleted file mode 100644
index e5de10b..0000000
--- a/plugin/src/test/resources/interfileleafrefwithinvaliddestinationnode/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
+++ /dev/null
@@ -1,22 +0,0 @@
-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/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang b/plugin/src/test/resources/leafreflinker/iffeatuinleafref/featurebymultileafref/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang
similarity index 100%
rename from plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang
rename to plugin/src/test/resources/leafreflinker/iffeatuinleafref/featurebymultileafref/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang
diff --git a/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang b/plugin/src/test/resources/leafreflinker/iffeatuinleafref/simpleleafrefwithiffeature/SelfFileLinkingWithFeatureReferredByLeafref.yang
similarity index 100%
rename from plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang
rename to plugin/src/test/resources/leafreflinker/iffeatuinleafref/simpleleafrefwithiffeature/SelfFileLinkingWithFeatureReferredByLeafref.yang
diff --git a/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module1.yang b/plugin/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module1.yang
similarity index 93%
rename from plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module1.yang
rename to plugin/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module1.yang
index 4cfb53d..b8a5d98 100644
--- a/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module1.yang
+++ b/plugin/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module1.yang
@@ -5,7 +5,7 @@
     import module2 {
         prefix "nt";
     }
-    grouping te-node-tunnel-termination-capability {
+    container te-node-tunnel-termination-capability {
         description
         "Termination capability of a tunnel termination point on a
         TE node.";
@@ -25,4 +25,4 @@
             }
         } // termination-capability
     } // te-node-tunnel-termination-capability
-}
\ No newline at end of file
+}
diff --git a/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module2.yang b/plugin/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module2.yang
similarity index 100%
rename from plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module2.yang
rename to plugin/src/test/resources/leafreflinker/interfile/interfileleafreffromgroupingreferstootherfile/module2.yang
diff --git a/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang b/plugin/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang
similarity index 100%
rename from plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang
rename to plugin/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang
diff --git a/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang b/plugin/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
similarity index 93%
rename from plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
rename to plugin/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
index 7e080c5..b488f46 100644
--- a/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
+++ b/plugin/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
@@ -5,7 +5,7 @@
     import ietf-network {
         prefix "nt";
     }
-    grouping te-node-tunnel-termination-capability {
+    container te-node-tunnel-termination-capability {
         description
         "Termination capability of a tunnel termination point on a
         TE node.";
@@ -25,4 +25,4 @@
             }
         } // termination-capability
     } // te-node-tunnel-termination-capability
-}
\ No newline at end of file
+}
diff --git a/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang b/plugin/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang
similarity index 100%
rename from plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang
rename to plugin/src/test/resources/leafreflinker/interfile/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang
diff --git a/plugin/src/test/resources/interfileleafref/module1.yang b/plugin/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module1.yang
similarity index 100%
rename from plugin/src/test/resources/interfileleafref/module1.yang
rename to plugin/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module1.yang
diff --git a/plugin/src/test/resources/interfileleafref/module2.yang b/plugin/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module2.yang
similarity index 100%
rename from plugin/src/test/resources/interfileleafref/module2.yang
rename to plugin/src/test/resources/leafreflinker/interfile/interfileleafrefwithimport/module2.yang
diff --git a/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/GroupingCopiedInModule2.yang b/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/GroupingCopiedInModule2.yang
new file mode 100644
index 0000000..dae2db2
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/GroupingCopiedInModule2.yang
@@ -0,0 +1,12 @@
+module GroupingCopiedInModule2 {
+    yang-version 1;
+    namespace "onos-yang-19:level1:newlevel";
+    prefix test;
+    import LeafrefInGroupingOfModule1 {
+        prefix module1;
+    }
+    description "leaf scenario";
+    container value {
+        uses "module1:network-ref";
+    }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/LeafrefInGroupingOfModule1.yang b/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/LeafrefInGroupingOfModule1.yang
new file mode 100644
index 0000000..0753619
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefix/LeafrefInGroupingOfModule1.yang
@@ -0,0 +1,40 @@
+module LeafrefInGroupingOfModule1 {
+    yang-version 1;
+    namespace "onos-yang-19:level1:newlevel";
+    prefix test2;
+    description "leaf scenario";
+    container networks {
+        list network {
+            key "network-id";
+            description
+                "Describes a network.
+                A network typically contains an inventory of nodes,
+                topological information (augmented through
+                network-topology model), as well as layering
+                information.";
+            container network-types {
+                description
+                    "Serves as an augmentation target.
+                    The network type is indicated through corresponding
+                    presence containers augmented into this container.";
+            }
+            leaf network-id {
+                type string;
+                description
+                "Identifies a network.";
+            }
+        }
+        leaf network-ip {
+            type uint8;
+            description
+            "Identifies a network.";
+        }
+    }
+    grouping network-ref {
+        leaf network-ref {
+            type leafref {
+                path "/test2:networks/test2:network/test2:network-id";
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/GroupingCopiedInModule2.yang b/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/GroupingCopiedInModule2.yang
new file mode 100644
index 0000000..d988a3a
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/GroupingCopiedInModule2.yang
@@ -0,0 +1,37 @@
+module ietf-te-topology {
+    yang-version 1;
+    namespace "onos-yang-19:level1:newlevel";
+    prefix test;
+     import ietf-network {
+       prefix "nw";
+     }
+    description "leaf scenario";
+         typedef te-topology-event-type {
+           type enumeration {
+             enum "add" {
+               value 0;
+               description
+                 "A TE node or te-link has been added.";
+             }
+             enum "remove" {
+               value 1;
+               description
+                 "A TE node or te-link has been removed.";
+             }
+             enum "update" {
+               value 2;
+               description
+                 "A TE node or te-link has been updated.";
+             }
+           }
+           description "TE  Event type for notifications";
+         } // te-topology-event-type
+     container te-node-event {
+       leaf event-type {
+         type te-topology-event-type;
+         description "Event type.";
+       }
+       description "Notification event for TE node.";
+       uses nw:node-ref;
+     }
+}
diff --git a/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/LeafrefInGroupingOfModule1.yang b/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/LeafrefInGroupingOfModule1.yang
new file mode 100644
index 0000000..f2b7591
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/interfile/leafrefInGroupingWithPrefixAndManyReference/LeafrefInGroupingOfModule1.yang
@@ -0,0 +1,212 @@
+   module ietf-network {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+     revision 2015-12-08 {
+       description
+         "Initial revision.
+          NOTE TO RFC EDITOR: Please replace the following reference
+          to draft-ietf-i2rs-yang-network-topo-02 with
+          RFC number when published (i.e. RFC xxxx).";
+       reference
+         "draft-ietf-i2rs-yang-network-topo-02";
+     }
+
+     typedef node-id {
+       type string;
+       description
+         "Identifier for a node.";
+     }
+
+     typedef network-id {
+       type string;
+       description
+         "Identifier for a network.";
+     }
+     grouping network-ref {
+       description
+         "Contains the information necessary to reference a network,
+          for example an underlay network.";
+       leaf network-ref {
+         type leafref {
+           path "/nd:networks/nd:network/nd:network-id";
+         require-instance false;
+         }
+         description
+           "Used to reference a network, for example an underlay
+            network.";
+       }
+     }
+
+     grouping node-ref {
+       description
+         "Contains the information necessary to reference a node.";
+       leaf node-ref {
+         type leafref {
+           path "/nd:networks/nd:network[nd:network-id=current()/../"+
+             "network-ref]/nd:node/nd:node-id";
+           require-instance false;
+         }
+         description
+           "Used to reference a node.
+            Nodes are identified relative to the network they are
+            contained in.";
+       }
+       uses network-ref;
+     }
+
+     container networks {
+       description
+         "Serves as top-level container for a list of networks.";
+       list network {
+         key "network-id";
+         description
+           "Describes a network.
+            A network typically contains an inventory of nodes,
+            topological information (augmented through
+            network-topology model), as well as layering
+            information.";
+         container network-types {
+           description
+             "Serves as an augmentation target.
+              The network type is indicated through corresponding
+              presence containers augmented into this container.";
+         }
+         leaf network-id {
+           type network-id;
+           description
+             "Identifies a network.";
+         }
+         list supporting-network {
+           key "network-ref";
+           description
+             "An underlay network, used to represent layered network
+              topologies.";
+           leaf network-ref {
+             type leafref {
+               path "/networks/network/network-id";
+             require-instance false;
+             }
+             description
+               "References the underlay network.";
+           }
+         }
+         list node {
+           key "node-id";
+           description
+             "The inventory of nodes of this network.";
+           leaf node-id {
+             type node-id;
+             description
+               "Identifies a node uniquely within the containing
+                network.";
+           }
+           list supporting-node {
+             key "network-ref node-ref";
+             description
+               "Represents another node, in an underlay network, that
+                this node is supported by.  Used to represent layering
+                structure.";
+             leaf network-ref {
+               type leafref {
+                 path "../../../supporting-network/network-ref";
+               require-instance false;
+               }
+               description
+                 "References the underlay network that the
+                  underlay node is part of.";
+             }
+             leaf node-ref {
+               type leafref {
+                 path "/networks/network/node/node-id";
+               require-instance false;
+               }
+               description
+                 "References the underlay node itself.";
+             }
+           }
+         }
+       }
+     }
+     container networks-state {
+       config false;
+       description
+         "Serves as top-level container for a list of state information
+          for networks";
+       list network {
+         key "network-ref";
+         description
+           "Data nodes representing operational data and state of
+            networks.
+            An instance is automatically created for every network
+            in the corresponding list under the networks container.";
+         uses network-ref;
+         leaf server-provided {
+           type boolean;
+           description
+             "Indicates whether the information concerning this
+              particular network is populated by the server
+              (server-provided true, the general case for network
+              information discovered from the server),
+              or whether it is configured by a client
+              (server-provided true, possible e.g. for
+              service overlays managed through a controller).";
+         }
+       }
+     }
+   }
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang b/plugin/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
similarity index 85%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
index 85a7e42..a0bd03b 100644
--- a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
+++ b/plugin/src/test/resources/leafreflinker/intrafile/invalidscenerioforgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
@@ -1,4 +1,4 @@
-module ietf-network {
+module SelfResolutionWhenLeafrefInModuleReferToGroupingInModule {
     yang-version 1;
     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
     prefix nd;
@@ -16,4 +16,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang b/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
similarity index 87%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
index 7f7f5d1..c10ba2b 100644
--- a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
+++ b/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithinvalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
@@ -1,4 +1,4 @@
-module ietf-network {
+module SelfResolutionWhenLeafrefInModuleReferToInvalidNode {
     yang-version 1;
     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
     prefix nd;
@@ -16,4 +16,4 @@
             path "/define/network-id";
         }
     }
-}
\ No newline at end of file
+}
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang b/plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/invalidsceneriowithnorefleaf/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang
new file mode 100644
index 0000000..a208903
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefInAugment/SelfResolutionIfLeafrefInGroupingIsCopiedToAugment.yang
@@ -0,0 +1,64 @@
+module topology {
+    yang-version 1;
+    namespace "onos-yang-19:level1:newlevel";
+    prefix test;
+    organization "huawei";
+    contact "adarsh.m@huawei.com";
+    description "leaf scenario";
+    container networks {
+        list network {
+            key "network-id";
+            description
+                "Describes a network.
+                A network typically contains an inventory of nodes,
+                topological information (augmented through
+                network-topology model), as well as layering
+                information.";
+            container network-types {
+                description
+                    "Serves as an augmentation target.
+                    The network type is indicated through corresponding
+                    presence containers augmented into this container.";
+            }
+            leaf network-id {
+                type string;
+                description
+                "Identifies a network.";
+            }
+        }
+        leaf network-ip {
+            type uint8;
+            description
+            "Identifies a network.";
+        }
+    }
+    augment "/networks/network" {
+        container config {
+            description
+                "Configuration data.";
+            choice bundle-stack-level {
+                description
+                    "The TE link can be partitioned into bundled
+                    links, or component links.";
+                case bundle {
+                    container bundled-links {
+                        description
+                            "A set of bundled links.";
+                        reference
+                            "RFC4201: Link Bundling in MPLS Traffic Engineering
+                            (TE).";
+                        list bundled-link {
+                            key "src-tp-ref";
+                            leaf src-tp-ref {
+                                type leafref {
+                                    path "../../../../../network-ip";
+                                    require-instance true;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang
new file mode 100644
index 0000000..80b6ab0
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefingroupingonly/SelfResolutionWithLeafrefInGrouping.yang
@@ -0,0 +1,37 @@
+module ietf-network {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+     prefix nd;
+
+     import ietf-inet-types {
+       prefix inet;
+     }
+     typedef node-id {
+       type inet:uri;
+       description
+         "Identifier for a node.";
+     }
+
+     leaf xyz {
+         type string;
+     }
+     typedef network-id {
+       type inet:uri;
+       description
+         "Identifier for a network.";
+     }
+     grouping network-ref {
+       description
+         "Contains the information necessary to reference a network,
+          for example an underlay network.";
+       leaf network-ref {
+         type leafref {
+           path "/nd:xyz";
+         require-instance false;
+         }
+         description
+           "Used to reference a network, for example an underlay
+            network.";
+       }
+     }
+   }
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang
new file mode 100644
index 0000000..4eaa2bf
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/ietf-network.yang
@@ -0,0 +1,33 @@
+module ietf-network {
+    yang-version 1;
+    namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+    prefix nd;
+    import network {
+       prefix "nw";
+    }
+    grouping xyz {
+        leaf network-id-ref {
+            type leafref {
+                path "/nw:networks/nw:network/nw:network-id";
+                require-instance false;
+            }
+            description
+                "A reference to a network-id in base ietf-network module.";
+        }
+    }
+    grouping yzx {
+        container hi {
+        uses xyz;
+        }
+    }
+    container fine {
+        uses yzx;
+    }
+    container networks {
+        leaf network {
+            type string;
+        }
+    }
+}
+
+
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang
new file mode 100644
index 0000000..30e8b80
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefinusesundergrouping/network.yang
@@ -0,0 +1,212 @@
+   module network {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";
+
+     contact
+       "WG Web:    <http://tools.ietf.org/wg/i2rs/>
+        WG List:   <mailto:i2rs@ietf.org>
+
+        WG Chair:  Susan Hares
+                   <mailto:shares@ndzh.com>
+
+        WG Chair:  Jeffrey Haas
+                   <mailto:jhaas@pfrc.org>
+
+        Editor:    Alexander Clemm
+                   <mailto:alex@cisco.com>
+
+        Editor:    Jan Medved
+                   <mailto:jmedved@cisco.com>
+
+        Editor:    Robert Varga
+                   <mailto:rovarga@cisco.com>
+
+        Editor:    Tony Tkacik
+                   <mailto:ttkacik@cisco.com>
+
+        Editor:    Nitin Bahadur
+                   <mailto:nitin_bahadur@yahoo.com>
+
+        Editor:    Hariharan Ananthakrishnan
+                   <mailto:hari@packetdesign.com>";
+
+     description
+       "This module defines a common base model for a collection
+        of nodes in a network. Node definitions are further used
+        in network topologies and inventories.
+
+        Copyright (c) 2015 IETF Trust and the persons identified as
+        authors of the code.  All rights reserved.
+
+        Redistribution and use in source and binary forms, with or
+        without modification, is permitted pursuant to, and subject
+        to the license terms contained in, the Simplified BSD License
+        set forth in Section 4.c of the IETF Trust's Legal Provisions
+        Relating to IETF Documents
+        (http://trustee.ietf.org/license-info).
+
+        This version of this YANG module is part of
+        draft-ietf-i2rs-yang-network-topo-02;
+        see the RFC itself for full legal notices.
+
+        NOTE TO RFC EDITOR: Please replace above reference to
+        draft-ietf-i2rs-yang-network-topo-02 with RFC
+        number when published (i.e. RFC xxxx).";
+
+     revision 2015-12-08 {
+       description
+         "Initial revision.
+          NOTE TO RFC EDITOR: Please replace the following reference
+          to draft-ietf-i2rs-yang-network-topo-02 with
+          RFC number when published (i.e. RFC xxxx).";
+       reference
+         "draft-ietf-i2rs-yang-network-topo-02";
+     }
+
+     typedef node-id {
+       type string;
+       description
+         "Identifier for a node.";
+     }
+
+     typedef network-id {
+       type string;
+       description
+         "Identifier for a network.";
+     }
+     grouping network-ref {
+       description
+         "Contains the information necessary to reference a network,
+          for example an underlay network.";
+       leaf network-ref {
+         type leafref {
+           path "/nd:networks/nd:network/nd:network-id";
+         require-instance false;
+         }
+         description
+           "Used to reference a network, for example an underlay
+            network.";
+       }
+     }
+
+     grouping node-ref {
+       description
+         "Contains the information necessary to reference a node.";
+       leaf node-ref {
+         type leafref {
+           path "/nd:networks/nd:network[nd:network-id=current()/../"+
+             "network-ref]/nd:node/nd:node-id";
+           require-instance false;
+         }
+         description
+           "Used to reference a node.
+            Nodes are identified relative to the network they are
+            contained in.";
+       }
+       uses network-ref;
+     }
+
+     container networks {
+       description
+         "Serves as top-level container for a list of networks.";
+       list network {
+         key "network-id";
+         description
+           "Describes a network.
+            A network typically contains an inventory of nodes,
+            topological information (augmented through
+            network-topology model), as well as layering
+            information.";
+         container network-types {
+           description
+             "Serves as an augmentation target.
+              The network type is indicated through corresponding
+              presence containers augmented into this container.";
+         }
+         leaf network-id {
+           type network-id;
+           description
+             "Identifies a network.";
+         }
+         list supporting-network {
+           key "network-ref";
+           description
+             "An underlay network, used to represent layered network
+              topologies.";
+           leaf network-ref {
+             type leafref {
+               path "/networks/network/network-id";
+             require-instance false;
+             }
+             description
+               "References the underlay network.";
+           }
+         }
+         list node {
+           key "node-id";
+           description
+             "The inventory of nodes of this network.";
+           leaf node-id {
+             type node-id;
+             description
+               "Identifies a node uniquely within the containing
+                network.";
+           }
+           list supporting-node {
+             key "network-ref node-ref";
+             description
+               "Represents another node, in an underlay network, that
+                this node is supported by.  Used to represent layering
+                structure.";
+             leaf network-ref {
+               type leafref {
+                 path "../../../supporting-network/network-ref";
+               require-instance false;
+               }
+               description
+                 "References the underlay network that the
+                  underlay node is part of.";
+             }
+             leaf node-ref {
+               type leafref {
+                 path "/networks/network/node/node-id";
+               require-instance false;
+               }
+               description
+                 "References the underlay node itself.";
+             }
+           }
+         }
+       }
+     }
+     container networks-state {
+       config false;
+       description
+         "Serves as top-level container for a list of state information
+          for networks";
+       list network {
+         key "network-ref";
+         description
+           "Data nodes representing operational data and state of
+            networks.
+            An instance is automatically created for every network
+            in the corresponding list under the networks container.";
+         uses network-ref;
+         leaf server-provided {
+           type boolean;
+           description
+             "Indicates whether the information concerning this
+              particular network is populated by the server
+              (server-provided true, the general case for network
+              information discovered from the server),
+              or whether it is configured by a client
+              (server-provided true, possible e.g. for
+              service overlays managed through a controller).";
+         }
+       }
+     }
+   }
\ No newline at end of file
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreflinking/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreflinking/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafList.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafrefreferingtoleaflist/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoderivedtype/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreftoderivedtype/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreftoinputinrpc/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafref/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafref/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreftoleafrefwithtypedef/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftomultitypedef/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreftomultitypedef/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreftorpcinputleaflist/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafreftotypedefwithleafref/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
diff --git a/plugin/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang
new file mode 100644
index 0000000..3db511e
--- /dev/null
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefundernodeingrouping/ietf-network.yang
@@ -0,0 +1,95 @@
+module ietf-network {
+     yang-version 1;
+     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+     prefix nd;
+
+     organization
+       "IETF I2RS (Interface to the Routing System) Working Group";     
+    grouping node-ref {
+       description
+         "Contains the information necessary to reference a node.";
+       container node-from-grouping {
+             leaf node-ref {
+                type leafref {
+                 path "/networks/network/node/node-id";
+                   require-instance false;
+                  }
+              }
+         }
+     }
+     container networks {
+       description
+         "Serves as top-level container for a list of networks.";
+       list network {
+         key "network-id";
+         description
+           "Describes a network.
+            A network typically contains an inventory of nodes,
+            topological information (augmented through
+            network-topology model), as well as layering
+            information.";
+         container network-types {
+           description
+             "Serves as an augmentation target.
+              The network type is indicated through corresponding
+              presence containers augmented into this container.";
+         }
+         leaf network-id {
+           type string;
+           description
+             "Identifies a network.";
+         }
+         list supporting-network {
+           key "network-ref";
+           description
+             "An underlay network, used to represent layered network
+              topologies.";
+           leaf network-ref {
+             type leafref {
+               path "/networks/network/network-id";
+             require-instance false;
+             }
+             description
+               "References the underlay network.";
+           }
+         }
+         list node {
+           key "node-id";
+           description
+             "The inventory of nodes of this network.";
+           leaf node-id {
+             type uint8;
+             description
+               "Identifies a node uniquely within the containing
+                network.";
+           }
+           list supporting-node {
+             key "network-ref node-ref";
+             description
+               "Represents another node, in an underlay network, that
+                this node is supported by.  Used to represent layering
+                structure.";
+             leaf network-ref {
+               type leafref {
+                 path "../../../supporting-network/network-ref";
+               require-instance false;
+               }
+               description
+                 "References the underlay network that the
+                  underlay node is part of.";
+             }
+             leaf node-ref {
+               type leafref {
+                 path "/networks/network/node/node-id";
+               require-instance false;
+               }
+               description
+                 "References the underlay node itself.";
+             }
+           }
+         }
+       }
+       uses node-ref;
+     }
+
+}
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrefleafderived/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
similarity index 87%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
index 0a397dd..3dce93e 100644
--- a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpc/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
@@ -1,4 +1,4 @@
-module ietf-network {
+module SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc {
     yang-version 1;
     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
     prefix nd;
@@ -20,4 +20,4 @@
         path "/networks/input/network-id";
         }
     }
-}
\ No newline at end of file
+}
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGrouping.yang b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
similarity index 89%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGrouping.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
index d5622d4..e8debbd 100644
--- a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGrouping.yang
+++ b/plugin/src/test/resources/leafreflinker/intrafile/leafrefwithrpcandgrouping/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
@@ -1,4 +1,4 @@
-module ietf-network {
+module SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc {
     yang-version 1;
     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
     prefix nd;
@@ -19,12 +19,10 @@
                 "Identifies a network.";
             }
         }
-        output {
-        }
     }
     leaf network-ref {
         type leafref {
         path "/networks/input/network-id";
         }
     }
-}
\ No newline at end of file
+}
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidnode/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/relativepath/invalidrelativeancestoraccess/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafrefintypedef/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftoinputwithgroupinginrpc/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftomultileafref/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/relativepath/leafreftotypedef/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
diff --git a/plugin/src/test/resources/PathListener.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/pathlistener/PathListener.yang
similarity index 100%
rename from plugin/src/test/resources/PathListener.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/relativepath/pathlistener/PathListener.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang b/plugin/src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
similarity index 100%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/relativepath/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
diff --git a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang b/plugin/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
similarity index 88%
rename from plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
rename to plugin/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
index 81fc331..375cace 100644
--- a/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
+++ b/plugin/src/test/resources/leafreflinker/intrafile/simpleleafref/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
@@ -1,4 +1,4 @@
-module ietf-network {
+module SelfResolutionWhenLeafrefReferToContainerLeaf {
     yang-version 1;
     namespace "urn:ietf:params:xml:ns:yang:ietf-network";
     prefix nd;
@@ -16,4 +16,4 @@
         path "/networks/network-id";
         }
     }
-}
\ No newline at end of file
+}