[ONOS-4744] Leafref implementation and UT
Change-Id: I151797185e0bb1695c0640b667ae76ef87c4d4b0
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RequireInstanceListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RequireInstanceListenerTest.java
new file mode 100644
index 0000000..70bb875
--- /dev/null
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RequireInstanceListenerTest.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafRef;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+/**
+ * Test cases for require-instance listener.
+ */
+public class RequireInstanceListenerTest {
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks require-statement with true as status.
+     */
+    @Test
+    public void processRequireInstanceTrue() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RequireInstanceTrue.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("PathListener"));
+
+        YangContainer container = (YangContainer) yangNode.getChild().getNextSibling();
+        ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // Check whether the require-instance value is set correctly in leafref.
+        assertThat(leafInfo.getName(), is("ifname"));
+        YangLeafRef yangLeafRef = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+        assertThat(yangLeafRef.getRequireInstance(), is(true));
+    }
+
+    /**
+     * Checks require-statement with false as status.
+     */
+    @Test
+    public void processRequireInstanceFalse() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RequireInstanceFalse.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("PathListener"));
+
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // Check whether the require-instance value is set correctly in instance-identifier.
+        assertThat(leafInfo.getName(), is("admin-status"));
+
+        YangType type = leafInfo.getDataType();
+
+        assertThat(type.getDataType(), is(YangDataTypes.INSTANCE_IDENTIFIER));
+        boolean status = ((YangType<Boolean>) type).getDataTypeExtendedInfo();
+
+        assertThat(status, is(false));
+    }
+
+    /**
+     * Checks require-statement default value when its not there in YANG under instance-identifier.
+     */
+    @Test
+    public void processRequireInstanceDefaultValueInInstanceIdentifier() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RequireInstanceDefaultValueInInstanceIdentifier.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("PathListener"));
+
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // Check whether the require-instance value is set correctly in instance-identifier.
+        assertThat(leafInfo.getName(), is("admin-status"));
+
+        YangType type = leafInfo.getDataType();
+
+        assertThat(type.getDataType(), is(YangDataTypes.INSTANCE_IDENTIFIER));
+
+        boolean status = ((YangType<Boolean>) type).getDataTypeExtendedInfo();
+        assertThat(status, is(true));
+    }
+
+    /**
+     * Checks require-statement default value when its not there in YANG under leafref.
+     */
+    @Test
+    public void processRequireInstanceDefaultValueForLeafref() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RequireInstanceDefaultValueForLeafref.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("PathListener"));
+
+        YangContainer container = (YangContainer) yangNode.getChild().getNextSibling();
+        ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // Check whether the require-instance value is set correctly in leafref.
+        assertThat(leafInfo.getName(), is("ifname"));
+        YangLeafRef yangLeafRef = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+        assertThat(yangLeafRef.getRequireInstance(), is(true));
+    }
+}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
index 3637f7c..8891108 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
@@ -20,6 +20,7 @@
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
 import org.onosproject.yangutils.datamodel.YangLeaf;
 import org.onosproject.yangutils.datamodel.YangLeafList;
@@ -121,20 +122,6 @@
     }
 
     /**
-     * Checks for unsupported type leafref.
-     */
-    @Test
-    public void processLeafrefType() throws IOException, ParserException {
-
-        thrown.expect(ParserException.class);
-        thrown.expectMessage("YANG file error : \"leafref\" is not supported in current version,"
-                + " please check wiki for YANG utils road map.");
-
-        YangNode node = manager
-                .getDataModel("src/test/resources/LeafrefInvalidIdentifier.yang");
-    }
-
-    /**
      * Checks for unsupported type identityref.
      */
     @Test
@@ -149,16 +136,29 @@
     }
 
     /**
-     * Checks for unsupported type instance identifier.
+     * Checks for type instance-identifier.
      */
     @Test
     public void processInstanceIdentifierType() throws IOException, ParserException {
 
-        thrown.expect(ParserException.class);
-        thrown.expectMessage("YANG file error : \"instance-identifier\" is not supported in current version,"
-                + " please check wiki for YANG utils road map.");
-
         YangNode node = manager
-                .getDataModel("src/test/resources/InstanceIdentifierInvalidIdentifier.yang");
+                .getDataModel("src/test/resources/InstanceIdentifierListener.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+        YangContainer container = (YangContainer) yangNode.getChild();
+        ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("instance-identifier"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INSTANCE_IDENTIFIER));
     }
 }
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterFileLinkingTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterFileLinkingTest.java
index 9265bbb..1554c5f 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterFileLinkingTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/InterFileLinkingTest.java
@@ -20,27 +20,34 @@
 import java.util.Iterator;
 import java.util.ListIterator;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
 import org.onosproject.yangutils.datamodel.YangGrouping;
 import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafRef;
+import org.onosproject.yangutils.datamodel.YangList;
 import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.datamodel.YangNodeType;
 import org.onosproject.yangutils.datamodel.YangTypeDef;
 import org.onosproject.yangutils.datamodel.YangUses;
 import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
 import org.onosproject.yangutils.linker.impl.YangLinkerManager;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
 
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF;
 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
@@ -50,6 +57,10 @@
  */
 public class InterFileLinkingTest {
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
     private final YangUtilManager utilManager = new YangUtilManager();
     private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
 
@@ -726,4 +737,253 @@
         deleteDirectory(userDir + "/target/groupingNodeSameAsModule/");
 
     }
+
+    /**
+     * Checks inter file leafref linking.
+     */
+    @Test
+    public void processInterFileLeafrefLinking()
+            throws IOException, ParserException, MojoExecutionException {
+
+        String searchDir = "src/test/resources/interfileleafref";
+        utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+        utilManager.parseYangFileInfoSet();
+        utilManager.createYangNodeSet();
+        YangNode refNode = null;
+        YangNode selfNode = null;
+
+        // Create YANG node set
+        yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+        // Add references to import list.
+        yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+        // Carry out inter-file linking.
+        yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+        Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+        YangNode rootNode = yangNodeIterator.next();
+
+        if (rootNode.getName().equals("module1")) {
+            selfNode = rootNode;
+            refNode = yangNodeIterator.next();
+        } else {
+            refNode = rootNode;
+            selfNode = yangNodeIterator.next();
+        }
+
+        // Check whether the data model tree returned is of type module.
+        assertThat(selfNode instanceof YangModule, is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) selfNode;
+        assertThat(yangNode.getName(), is("module1"));
+
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+        // Check whether the data model tree returned is of type module.
+        assertThat(refNode instanceof YangModule, is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(refNode.getNodeType(), is(MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode1 = (YangModule) refNode;
+        assertThat(yangNode1.getName(), is("module2"));
+        YangLeaf leafInfo1 = yangNode1.getListOfLeaf().listIterator().next();
+
+        YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+        assertThat(leafref.getReferredLeafOrLeafList(), is(leafInfo1));
+        assertThat(leafref.getResolvableStatus(), is(RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.STRING));
+    }
+
+    /**
+     * Checks error scenerio where the node is invalid.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToInvalidNode()
+            throws IOException, ParserException {
+
+        thrown.expect(LinkerException.class);
+        thrown.expectMessage(
+                "YANG file error: Unable to find base leaf/leaf-list for given leafref");
+        String searchDir = "src/test/resources/interFileInvalidNode";
+        utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+        utilManager.parseYangFileInfoSet();
+        utilManager.createYangNodeSet();
+
+        YangNode selfNode = null;
+
+        // Create YANG node set
+        yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+        // Add references to import list.
+        yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+        // Carry out inter-file linking.
+        yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+    }
+
+    /**
+     * Checks the error scenerio when there is no referref leaf/leaf-list in any file.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList()
+            throws IOException, ParserException {
+
+        thrown.expect(LinkerException.class);
+        thrown.expectMessage(
+                "YANG file error: Unable to find base leaf/leaf-list for given leafref");
+        String searchDir = "src/test/resources/interfileleafrefwithinvaliddestinationnode";
+        utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+        utilManager.parseYangFileInfoSet();
+        utilManager.createYangNodeSet();
+        YangNode selfNode = null;
+
+        // Create YANG node set
+        yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+        // Add references to import list.
+        yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+        // Carry out inter-file linking.
+        yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+    }
+
+    /**
+     * Checks inter file resolution when leafref from grouping refers to other file.
+     */
+    @Test
+    public void processInterFileLeafrefFromGroupingRefersToOtherFile()
+            throws IOException, ParserException {
+
+        String searchDir = "src/test/resources/interfileleafreffromgroupingreferstootherfile";
+        utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+        utilManager.parseYangFileInfoSet();
+        utilManager.createYangNodeSet();
+        YangNode selfNode = null;
+        YangNode refNode = null;
+
+        // Create YANG node set
+        yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+        // Add references to import list.
+        yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+        // Carry out inter-file linking.
+        yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+        Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+
+        YangNode rootNode = yangNodeIterator.next();
+
+        if (rootNode.getName().equals("module1")) {
+            selfNode = rootNode;
+            refNode = yangNodeIterator.next();
+        } else {
+            refNode = rootNode;
+            selfNode = yangNodeIterator.next();
+        }
+
+        // Check whether the data model tree returned is of type module.
+        assertThat(selfNode instanceof YangModule, is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) selfNode;
+        assertThat(yangNode.getName(), is("module1"));
+
+        YangList list = (YangList) yangNode.getChild().getChild();
+        ListIterator<YangLeaf> leafIterator = list.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getName(), is("link-tp"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+        YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+        YangLeaf leafInfo2 = (YangLeaf) leafref.getReferredLeafOrLeafList();
+        assertThat(leafref.getReferredLeafOrLeafList(), is(leafInfo2));
+        assertThat(leafref.getResolvableStatus(), is(RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.STRING));
+    }
+
+    /**
+     * Checks inter file resolution when leafref refers to multiple leafrefs through many files.
+     */
+    @Test
+    public void processInterFileLeafrefRefersToMultipleLeafrefInMultipleFiles()
+            throws IOException, ParserException {
+
+        String searchDir = "src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles";
+        utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+        utilManager.parseYangFileInfoSet();
+        utilManager.createYangNodeSet();
+        YangNode refNode1 = null;
+        YangNode refNode2 = null;
+        YangNode selfNode = null;
+
+        // Create YANG node set
+        yangLinkerManager.createYangNodeSet(utilManager.getYangNodeSet());
+
+        // Add references to import list.
+        yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet());
+
+        // Carry out inter-file linking.
+        yangLinkerManager.processInterFileLinking(utilManager.getYangNodeSet());
+
+        for (YangNode rootNode : utilManager.getYangNodeSet()) {
+            if (rootNode.getName().equals("ietf-network-topology")) {
+                selfNode = rootNode;
+            } else if (rootNode.getName().equals("ietf-network")) {
+                refNode1 = rootNode;
+            } else {
+                refNode2 = rootNode;
+            }
+        }
+        // Check whether the data model tree returned is of type module.
+        assertThat(selfNode instanceof YangModule, is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) selfNode;
+        assertThat(yangNode.getName(), is("ietf-network-topology"));
+
+        YangList list = (YangList) yangNode.getChild().getChild();
+        ListIterator<YangLeaf> leafIterator = list.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getName(), is("link-tp"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(LEAFREF));
+
+        YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+        YangLeaf leafInfo2 = (YangLeaf) leafref.getReferredLeafOrLeafList();
+        assertThat(leafref.getReferredLeafOrLeafList(), is(leafInfo2));
+        assertThat(leafref.getResolvableStatus(), is(RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.STRING));
+    }
 }
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/IntraFileIfFeatureLinkingTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/IntraFileIfFeatureLinkingTest.java
index a44ae9a..55cf7d9 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/IntraFileIfFeatureLinkingTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/IntraFileIfFeatureLinkingTest.java
@@ -18,11 +18,15 @@
 
 import java.io.IOException;
 import java.util.List;
+import java.util.ListIterator;
+
 import org.junit.Test;
 import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
 import org.onosproject.yangutils.datamodel.YangFeature;
 import org.onosproject.yangutils.datamodel.YangIfFeature;
 import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafRef;
 import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.datamodel.YangNodeType;
@@ -217,4 +221,111 @@
         assertThat(ifFeature.getName().getName(), is("local-storage"));
         assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
     }
+
+    /**
+     * Checks addition of if-feature list to leafref.
+     */
+    @Test
+    public void processSelfFileLinkingWithFeatureReferredByLeafref()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("syslog"));
+
+        List<YangFeature> featureList = yangNode.getFeatureList();
+        YangFeature feature = featureList.iterator().next();
+        assertThat(feature.getName(), is("local-storage"));
+
+        YangContainer container = (YangContainer) yangNode.getChild();
+        assertThat(container.getName(), is("speed"));
+
+        List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+        YangLeaf leaf = listOfLeaf.iterator().next();
+        assertThat(leaf.getName(), is("local-storage-limit"));
+
+        List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+        YangIfFeature ifFeature = ifFeatureList.iterator().next();
+        assertThat(ifFeature.getName().getName(), is("local-storage"));
+        assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+        ListIterator<YangLeaf> listOfLeafInModule =  yangNode.getListOfLeaf().listIterator();
+        YangLeaf yangLeaf = listOfLeafInModule.next();
+        assertThat(yangLeaf.getName(), is("storage-value"));
+
+        YangLeafRef leafRef = (YangLeafRef) yangLeaf.getDataType().getDataTypeExtendedInfo();
+
+        assertThat(leafRef.getEffectiveDataType().getDataType(), is(YangDataTypes.UINT64));
+
+        List<YangIfFeature> ifFeatureListInLeafref = leafRef.getIfFeatureList();
+        YangIfFeature ifFeatureInLeafref = ifFeatureListInLeafref.iterator().next();
+        assertThat(ifFeatureInLeafref.getName().getName(), is("local-storage"));
+        assertThat(ifFeatureInLeafref.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+    }
+
+    /**
+     * Checks addition of if-feature list to leafref when referred leaf is again having leafref in it.
+     */
+    @Test
+    public void processSelfFileLinkingWithFeatureReferredByMultiLeafref()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("syslog"));
+
+        List<YangFeature> featureList = yangNode.getFeatureList();
+        YangFeature feature = featureList.iterator().next();
+        assertThat(feature.getName(), is("local-storage"));
+
+        YangContainer container = (YangContainer) yangNode.getChild();
+        assertThat(container.getName(), is("speed"));
+
+        List<YangLeaf> listOfLeaf = container.getListOfLeaf();
+        YangLeaf leaf = listOfLeaf.iterator().next();
+        assertThat(leaf.getName(), is("local-storage-limit"));
+
+        List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
+        YangIfFeature ifFeature = ifFeatureList.iterator().next();
+        assertThat(ifFeature.getName().getName(), is("local-storage"));
+        assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+        ListIterator<YangLeaf> listOfLeafInModule =  yangNode.getListOfLeaf().listIterator();
+        YangLeaf yangLeaf = listOfLeafInModule.next();
+        assertThat(yangLeaf.getName(), is("storage-value"));
+
+        YangLeafRef leafRef = (YangLeafRef) yangLeaf.getDataType().getDataTypeExtendedInfo();
+
+        assertThat(leafRef.getEffectiveDataType().getDataType(), is(YangDataTypes.UINT64));
+
+        List<YangIfFeature> ifFeatureListInLeafref = leafRef.getIfFeatureList();
+        YangIfFeature ifFeatureInLeafref = ifFeatureListInLeafref.iterator().next();
+
+        assertThat(ifFeatureInLeafref.getName().getName(), is("main-storage"));
+        assertThat(ifFeatureInLeafref.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+        YangIfFeature ifFeatureInLeafref1 = ifFeatureListInLeafref.iterator().next();
+
+        assertThat(ifFeatureInLeafref1.getName().getName(), is("main-storage"));
+        assertThat(ifFeatureInLeafref1.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
+
+    }
 }
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/IntraFileLeafrefLinkingTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/IntraFileLeafrefLinkingTest.java
new file mode 100644
index 0000000..368d5f9
--- /dev/null
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/IntraFileLeafrefLinkingTest.java
@@ -0,0 +1,1116 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.plugin.manager;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangAtomicPath;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangInput;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangLeafRef;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangPathArgType;
+import org.onosproject.yangutils.datamodel.YangPathOperator;
+import org.onosproject.yangutils.datamodel.YangPathPredicate;
+import org.onosproject.yangutils.datamodel.YangRelativePath;
+import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.nullValue;
+
+/**
+ * Test cases for testing leafref intra file linking.
+ */
+public class IntraFileLeafrefLinkingTest {
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks self resolution when leafref under module refers to leaf in container.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefReferToContainerLeaf()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to leaf in input of rpc.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to grouping rpc with input as name.
+     * Rpc has input child also. So here the node search must be done by taking input node.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to grouping under module.
+     * Grouping/typedef cannot be referred.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToGrouping()
+            throws IOException, ParserException {
+
+        thrown.expect(LinkerException.class);
+        thrown.expectMessage(
+                "YANG file error: The target node of leafref is invalid.");
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang");
+    }
+
+    /**
+     * Checks self resolution error scenerio where leafref is without path.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefDoesntHavePath()
+            throws IOException, ParserException {
+
+        thrown.expect(ParserException.class);
+        thrown.expectMessage(
+                "YANG file error : a type leafref must have one path statement.");
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang");
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to invalid node.
+     * Inter file linking also has to be done to know the error message.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToInvalidNode()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got intra file resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.INTRA_FILE_RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to invalid node.
+     * Inter file linking also has to be done to know the error message.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel(
+                "src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangContainer containerParent = (YangContainer) yangNode.getChild().getChild().getChild();
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = containerParent.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafInfo.getName(), is("name"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UNION));
+    }
+
+    /**
+     * Checks self resolution when leafref of leaf-list under module refers to leaf in container.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefReferToContainerLeafList()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafList.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeafList> leafListIterator;
+        YangLeafList leafListInfo;
+
+        leafListIterator = yangNode.getListOfLeafList().listIterator();
+        leafListInfo = leafListIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafListInfo.getName(), is("network-ref"));
+        assertThat(leafListInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref of leaf-list under module refers to leaf-list in input of rpc.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeafList> leafListIterator;
+        YangLeafList leafListInfo;
+
+        leafListIterator = yangNode.getListOfLeafList().listIterator();
+        leafListInfo = leafListIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafListInfo.getName(), is("network-ref"));
+        assertThat(leafListInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref of leaf-list under module refers to invalid node.
+     * Inter file linking also has to be done to know the error message.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel(
+                "src/test/resources/" +
+                        "SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangContainer containerParent = (YangContainer) yangNode.getChild().getChild().getChild();
+        ListIterator<YangLeafList> leafListListIterator;
+        YangLeafList leafListInfo;
+
+        leafListListIterator = containerParent.getListOfLeafList().listIterator();
+        leafListInfo = leafListListIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafListInfo.getName(), is("name"));
+        assertThat(leafListInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafListInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.ENUMERATION));
+    }
+
+    /**
+     * Checks the error scenerio when the referred node is not a leaf or leaf-list.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        //YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.INTRA_FILE_RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when leafref of leaf-list under module refers to leaf in container.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInTypedefReferToContainer()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        YangContainer yangContainer = (YangContainer) yangNode.getChild();
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+        leafIterator = yangContainer.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("network-id"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref of leaf-list under module refers to leaf-list in input of rpc.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel(
+                "src/test/resources/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        YangInput yangInput = (YangInput) yangNode.getChild().getChild();
+
+        ListIterator<YangLeafList> leafListIterator;
+        YangLeafList yangLeafListInfo;
+        leafListIterator = yangInput.getListOfLeafList().listIterator();
+        yangLeafListInfo = leafListIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(yangLeafListInfo.getName(), is("network-id"));
+        assertThat(yangLeafListInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+        YangLeafRef leafref = (YangLeafRef) (yangLeafListInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref of leaf-list under module refers to invalid node.
+     * Inter file linking also has to be done to know the error message.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel(
+                "src/test/resources/" +
+                        "SelfResolutionWhenLeafrefInTypedefIs" +
+                        "InDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangContainer yangContainer = (YangContainer) yangNode.getChild().getChild().getChild().getNextSibling();
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf yangLeafInfo;
+        leafIterator = yangContainer.getListOfLeaf().listIterator();
+        yangLeafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(yangLeafInfo.getName(), is("interval"));
+        assertThat(yangLeafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+        YangLeafRef leafref = (YangLeafRef) (yangLeafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.ENUMERATION));
+    }
+
+    /**
+     * Checks self resolution when grouping and uses are siblings.
+     * Grouping followed by uses.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefRefersAnotherLeafref()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        //YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref refers to many other leafref.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefReferToMultipleLeafref()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+        YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = containerInList.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("remove"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.ENUMERATION));
+    }
+
+    /**
+     * Checks self resolution when grouping and uses are siblings.
+     * Grouping followed by uses.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefRefersAnotherDerivedType()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        //YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.DERIVED));
+    }
+
+    /**
+     * Checks self resolution when leafref refers to many other leafref.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefReferToMultipleTypedef()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+        YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = containerInList.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("remove"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.DERIVED));
+    }
+
+    /**
+     * Checks self resolution when leafref refers to many other leaf with derived type
+     * which in turn referring to another leaf.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel(
+                "src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+        YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = containerInList.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("remove"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.ENUMERATION));
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to leaf in container with relative path.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefReferToContainerLeafRelPath()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to grouping rpc with input as name.
+     * Rpc has input child also. So here the node search must be done by taking input node using relative path.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel(
+                "src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to invalid root node with relative path.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath()
+            throws IOException, ParserException {
+
+        thrown.expect(LinkerException.class);
+        thrown.expectMessage(
+                "YANG file error: The target node of leafref is invalid.");
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang");
+    }
+
+    /**
+     * Checks self resolution when leafref under module refers to invalid node.
+     * Inter file linking also has to be done to know the error message with relative path.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = yangNode.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct.
+        assertThat(leafInfo.getName(), is("network-ref"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got intra file resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.INTRA_FILE_RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when leafref of leaf-list under module refers to leaf in container with relative path.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefInTypedefReferToContainerRelPath()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("ietf-network"));
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+        YangContainer yangContainer = (YangContainer) yangNode.getChild();
+        leafIterator = yangContainer.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("network-id"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        // Check whether leafref type got resolved.
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        // Check the effective type for the leaf.
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.UINT8));
+    }
+
+    /**
+     * Checks self resolution when leafref refers to many other leafref with relative path.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath()
+            throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+        YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = containerInList.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("remove"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) (leafInfo.getDataType().getDataTypeExtendedInfo());
+
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.ENUMERATION));
+    }
+
+    /**
+     * Checks self resolution when leafref refers to many other leaf with derived type
+     * which in turn referring to another leaf with relative type.
+     */
+    @Test
+    public void processSelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel(
+                "src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+        YangContainer containerInList = (YangContainer) containerInModule.getChild().getChild();
+
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        leafIterator = containerInList.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("remove"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+        assertThat(leafref.getResolvableStatus(),
+                is(ResolvableStatus.RESOLVED));
+
+        assertThat(leafref.getEffectiveDataType().getDataType(),
+                is(YangDataTypes.ENUMERATION));
+    }
+
+    /**
+     * Checks the valid scenerios of path argument having proper setters.
+     */
+    @Test
+    public void processPathArgumentStatement()
+            throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/PathListener.yang");
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("PathListener"));
+        YangList listInModule = (YangList) yangNode.getChild();
+
+        YangContainer containerInModule = (YangContainer) yangNode.getChild().getNextSibling();
+        ListIterator<YangLeaf> leafIterator;
+        YangLeaf leafInfo;
+
+        YangLeaf leafNameInList = listInModule.getListOfLeaf().listIterator().next();
+
+        leafIterator = containerInModule.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo.getName(), is("ifname"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+        YangLeafRef leafref = (YangLeafRef) leafInfo.getDataType().getDataTypeExtendedInfo();
+        assertThat(leafref.getPathType(), is(YangPathArgType.RELATIVE_PATH));
+
+        YangRelativePath relativePathForName = leafref.getRelativePath();
+        assertThat(relativePathForName.getAncestorNodeCount(), is(2));
+        List<YangAtomicPath> absPathForName = relativePathForName.getAtomicPathList();
+        Iterator<YangAtomicPath> absPathIteratorForName = absPathForName.listIterator();
+        YangAtomicPath abspathForName = absPathIteratorForName.next();
+        assertThat(abspathForName.getNodeIdentifier().getName(), is("interface"));
+        assertThat(abspathForName.getNodeIdentifier().getPrefix(), is("test"));
+        YangAtomicPath abspath1 = absPathIteratorForName.next();
+        assertThat(abspath1.getNodeIdentifier().getName(), is("name"));
+        assertThat(abspath1.getNodeIdentifier().getPrefix(), is("test"));
+
+        YangLeaf leafInfo1 = leafIterator.next();
+        // Check whether the information in the leaf is correct under grouping.
+        assertThat(leafInfo1.getName(), is("status"));
+        assertThat(leafInfo1.getDataType().getDataTypeName(), is("leafref"));
+        assertThat(leafInfo1.getDataType().getDataType(), is(YangDataTypes.LEAFREF));
+
+        YangLeafRef leafref1 = (YangLeafRef) leafInfo1.getDataType().getDataTypeExtendedInfo();
+        assertThat(leafref1.getPathType(), is(YangPathArgType.ABSOLUTE_PATH));
+
+        List<YangAtomicPath> absolutePathList = leafref1.getAtomicPath();
+        Iterator<YangAtomicPath> absPathIterator = absolutePathList.listIterator();
+        YangAtomicPath abspath = absPathIterator.next();
+        assertThat(abspath.getNodeIdentifier().getName(), is("interface"));
+        assertThat(abspath.getNodeIdentifier().getPrefix(), is("test"));
+
+        List<YangPathPredicate> pathPredicateList = abspath.getPathPredicatesList();
+        Iterator<YangPathPredicate> pathPredicate = pathPredicateList.listIterator();
+        YangPathPredicate pathPredicate1 = pathPredicate.next();
+        assertThat(pathPredicate1.getNodeIdentifier().getName(), is("name"));
+        assertThat(pathPredicate1.getNodeIdentifier().getPrefix(), nullValue());
+        assertThat(pathPredicate1.getRightRelativePath().getAncestorNodeCount(), is(1));
+        assertThat(pathPredicate1.getPathOperator(), is(YangPathOperator.EQUALTO));
+        assertThat(pathPredicate1.getRightRelativePath().getAtomicPathList().listIterator().next().getNodeIdentifier()
+                .getName(), is("ifname"));
+        YangAtomicPath abspath2 = absPathIterator.next();
+        assertThat(abspath2.getNodeIdentifier().getName(), is("admin-status"));
+        assertThat(abspath2.getNodeIdentifier().getPrefix(), is("test"));
+
+        assertThat(pathPredicate1.getLeftAxisNode(), is(leafNameInList));
+        assertThat(pathPredicate1.getRightAxisNode(), is(leafInfo));
+    }
+}
diff --git a/plugin/src/test/resources/InstanceIdentifierInvalidIdentifier.yang b/plugin/src/test/resources/InstanceIdentifierListener.yang
similarity index 100%
rename from plugin/src/test/resources/InstanceIdentifierInvalidIdentifier.yang
rename to plugin/src/test/resources/InstanceIdentifierListener.yang
diff --git a/plugin/src/test/resources/LeafrefInvalidIdentifier.yang b/plugin/src/test/resources/LeafrefInvalidIdentifier.yang
deleted file mode 100644
index 4737b6c..0000000
--- a/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/plugin/src/test/resources/PathListener.yang b/plugin/src/test/resources/PathListener.yang
new file mode 100644
index 0000000..c4dae28
--- /dev/null
+++ b/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/plugin/src/test/resources/RequireInstanceDefaultValueForLeafref.yang b/plugin/src/test/resources/RequireInstanceDefaultValueForLeafref.yang
new file mode 100644
index 0000000..c4dae28
--- /dev/null
+++ b/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/plugin/src/test/resources/RequireInstanceDefaultValueInInstanceIdentifier.yang b/plugin/src/test/resources/RequireInstanceDefaultValueInInstanceIdentifier.yang
new file mode 100644
index 0000000..e3e15bf
--- /dev/null
+++ b/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/plugin/src/test/resources/RequireInstanceFalse.yang b/plugin/src/test/resources/RequireInstanceFalse.yang
new file mode 100644
index 0000000..0a2ba4f
--- /dev/null
+++ b/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/plugin/src/test/resources/RequireInstanceTrue.yang b/plugin/src/test/resources/RequireInstanceTrue.yang
new file mode 100644
index 0000000..cace8c5
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang b/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang
new file mode 100644
index 0000000..941b56b
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang b/plugin/src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang
new file mode 100644
index 0000000..f57fa6b
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
new file mode 100644
index 0000000..e5de10b
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefDoesntHavePath.yang
new file mode 100644
index 0000000..90b9efc
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGrouping.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGrouping.yang
new file mode 100644
index 0000000..d5622d4
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingInModule.yang
new file mode 100644
index 0000000..85a7e42
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc.yang
new file mode 100644
index 0000000..cc6a9f1
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpcRelPath.yang
new file mode 100644
index 0000000..477832d
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
new file mode 100644
index 0000000..7f7f5d1
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidNodeRelPath.yang
new file mode 100644
index 0000000..9681d76
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToInvalidRootNodeRelPath.yang
new file mode 100644
index 0000000..7e3d216
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc.yang
new file mode 100644
index 0000000..0a397dd
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInModuleReferToLeafListInInputOfRpc.yang
new file mode 100644
index 0000000..917c434
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
new file mode 100644
index 0000000..b61be6a
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefModuleReferToLeafListInInputOfRpc.yang
new file mode 100644
index 0000000..59e7a98
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainer.yang
new file mode 100644
index 0000000..ae42100
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefInTypedefReferToContainerRelPath.yang
new file mode 100644
index 0000000..93d8e94
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafIsInModuleWithReferredTypeUnion.yang
new file mode 100644
index 0000000..edf6bfa
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefIsInDeepTreeAndLeafListIsInModuleWithReferredTypeEnumeration.yang
new file mode 100644
index 0000000..a3e0f29
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherDerivedType.yang
new file mode 100644
index 0000000..eb2668e
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToAnotherLeafref.yang
new file mode 100644
index 0000000..26ccd1f
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeaf.yang
new file mode 100644
index 0000000..81fc331
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafList.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafList.yang
new file mode 100644
index 0000000..ec9a6d3
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToContainerLeafRelPath.yang
new file mode 100644
index 0000000..05ef0d2
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafref.yang
new file mode 100644
index 0000000..1bf423d
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToDerivedTypeReferringToLeafWithLeafrefRelType.yang
new file mode 100644
index 0000000..5570f38
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafref.yang
new file mode 100644
index 0000000..fd75d32
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleLeafrefRelPath.yang
new file mode 100644
index 0000000..890bbaa
--- /dev/null
+++ b/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/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang b/plugin/src/test/resources/SelfResolutionWhenLeafrefReferToMultipleTypedef.yang
new file mode 100644
index 0000000..4b286d2
--- /dev/null
+++ b/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/plugin/src/test/resources/interFileInvalidNode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang b/plugin/src/test/resources/interFileInvalidNode/SelfResolutionWhenLeafrefInModuleReferToInvalidNode.yang
new file mode 100644
index 0000000..7f7f5d1
--- /dev/null
+++ b/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/plugin/src/test/resources/interfileleafref/module1.yang b/plugin/src/test/resources/interfileleafref/module1.yang
new file mode 100644
index 0000000..d33cf1e
--- /dev/null
+++ b/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/plugin/src/test/resources/interfileleafref/module2.yang b/plugin/src/test/resources/interfileleafref/module2.yang
new file mode 100644
index 0000000..28a869b
--- /dev/null
+++ b/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/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module1.yang b/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module1.yang
new file mode 100644
index 0000000..4cfb53d
--- /dev/null
+++ b/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/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module2.yang b/plugin/src/test/resources/interfileleafreffromgroupingreferstootherfile/module2.yang
new file mode 100644
index 0000000..822d90b
--- /dev/null
+++ b/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/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang b/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ieft-inet-types.yang
new file mode 100644
index 0000000..c393dbf
--- /dev/null
+++ b/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/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang b/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network-topology.yang
new file mode 100644
index 0000000..7e080c5
--- /dev/null
+++ b/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/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang b/plugin/src/test/resources/interfileleafrefreferstomultipleleafrefinmultiplefiles/ietf-network.yang
new file mode 100644
index 0000000..49a6a04
--- /dev/null
+++ b/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/plugin/src/test/resources/interfileleafrefwithinvaliddestinationnode/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang b/plugin/src/test/resources/interfileleafrefwithinvaliddestinationnode/SelfResolutionWhenLeafrefDoesNotReferToLeafOrLeafList.yang
new file mode 100644
index 0000000..e5de10b
--- /dev/null
+++ b/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