config ang key validation and UT for the same

Change-Id: I507740fc9da3f3da5fb3c88a7414f87db6251c5b
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
index 7957a1a..c38bbbc 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangContainer.java
@@ -99,7 +99,7 @@
     /**
      * If container maintains config data.
      */
-    private boolean isConfig;
+    private Boolean isConfig;
 
     /**
      * Description of container.
@@ -174,7 +174,7 @@
      *
      * @return the isConfig
      */
-    public boolean isConfig() {
+    public Boolean isConfig() {
         return isConfig;
     }
 
@@ -378,7 +378,70 @@
      */
     @Override
     public void validateDataOnExit() throws DataModelException {
-        // TODO auto-generated method stub, to be implemented by parser
+        List<YangLeaf> leaves = getListOfLeaf();
+        List<YangLeafList> leafLists = getListOfLeafList();
+
+        setDefaultConfigValueToChild(leaves, leafLists);
+        validateConfig(leaves, leafLists);
+    }
+
+    /**
+     * Sets the config's value to all leaf if leaf's config statement is not specified.
+     *
+     * @param leaves list of leaf attributes of container.
+     * @param leafLists list of leaf-list attributes of container.
+     */
+    private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
+
+        /* If "config" is not specified, the default is the same as the parent
+            schema node's "config" value.*/
+        if (leaves != null) {
+            for (YangLeaf leaf : leaves) {
+                if (leaf.isConfig() == null) {
+                    leaf.setConfig(isConfig);
+                }
+            }
+        }
+
+        /* If "config" is not specified, the default is the same as the parent
+           schema node's "config" value.*/
+        if (leafLists != null) {
+            for (YangLeafList leafList : leafLists) {
+                if (leafList.isConfig() == null) {
+                    leafList.setConfig(isConfig);
+                }
+            }
+        }
+    }
+
+    /**
+     * Validates config statement of container.
+     *
+     * @param leaves list of leaf attributes of container.
+     * @param leafLists list of leaf-list attributes of container.
+     * @throws DataModelException a violation of data model rules.
+     */
+    private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException {
+
+        /* If a node has "config" set to "false", no node underneath it can have
+             "config" set to "true".*/
+        if ((!isConfig) && (leaves != null)) {
+            for (YangLeaf leaf : leaves) {
+                if (leaf.isConfig()) {
+                    throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
+                            "it can have \"config\" set to \"true\".");
+                }
+            }
+        }
+
+        if ((!isConfig) && (leafLists != null)) {
+            for (YangLeafList leafList : leafLists) {
+                if (leafList.isConfig()) {
+                    throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
+                            "it can have \"config\" set to \"true\".");
+                }
+            }
+        }
     }
 
     /**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
index 764f498..888094e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
@@ -67,7 +67,7 @@
     /**
      * If the leaf is a config parameter.
      */
-    private boolean isConfig;
+    private Boolean isConfig;
 
     /**
      * description of leaf.
@@ -128,7 +128,7 @@
      *
      * @return if config flag.
      */
-    public boolean isConfig() {
+    public Boolean isConfig() {
         return isConfig;
     }
 
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
index 18653d2..6ce3430 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
@@ -62,7 +62,7 @@
     /**
      * If the leaf-list is a config parameter.
      */
-    private boolean isConfig;
+    private Boolean isConfig;
 
     /**
      * Description of leaf-list.
@@ -150,7 +150,7 @@
      *
      * @return the config flag.
      */
-    public boolean isConfig() {
+    public Boolean isConfig() {
         return isConfig;
     }
 
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
index 8a328e0..624790e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
@@ -77,7 +77,7 @@
     /**
      * If list maintains config data.
      */
-    private boolean isConfig;
+    private Boolean isConfig;
 
     /**
      * Description of list.
@@ -199,7 +199,7 @@
      *
      * @return the isConfig
      */
-    public boolean isConfig() {
+    public Boolean isConfig() {
         return isConfig;
     }
 
@@ -254,11 +254,18 @@
      * Add a key field name.
      *
      * @param key key field name.
+     * @throws DataModelException a violation of data model rules.
      */
-    public void addKey(String key) {
+    public void addKey(String key) throws DataModelException {
         if (getKeyList() == null) {
             setKeyList(new LinkedList<String>());
         }
+
+        if (getKeyList().contains(key)) {
+            throw new DataModelException("A leaf identifier must not appear more than once in the\n" +
+                    "   key");
+        }
+
         getKeyList().add(key);
     }
 
@@ -431,7 +438,167 @@
      */
     @Override
     public void validateDataOnExit() throws DataModelException {
-        // TODO auto-generated method stub, to be implemented by parser
+        List<String> keyList = getKeyList();
+        List<YangLeaf> leaves = getListOfLeaf();
+        List<YangLeafList> leafLists = getListOfLeafList();
+
+        setDefaultConfigValueToChild(leaves, leafLists);
+        validateConfig(leaves, leafLists);
+
+        /* A list must have atleast one key leaf if config is true */
+        if ((isConfig)
+            && ((keyList == null) || (leaves == null && leafLists == null))) {
+                throw new DataModelException("A list must have atleast one key leaf if config is true;");
+        } else if (keyList != null) {
+            if (leaves != null) {
+                validateLeafKey(leaves, keyList);
+            }
+
+            if (leafLists != null) {
+                validateLeafListKey(leafLists, keyList);
+            }
+        }
+    }
+
+    /**
+     * Sets the config's value to all leaf if leaf's config statement is not specified.
+     *
+     * @param leaves list of leaf attributes of YANG list.
+     * @param leafLists list of leaf-list attributes of YANG list.
+     */
+    private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
+
+        /* If "config" is not specified, the default is the same as the parent
+            schema node's "config" value.*/
+        if (leaves != null) {
+            for (YangLeaf leaf : leaves) {
+                if (leaf.isConfig() == null) {
+                    leaf.setConfig(isConfig);
+                }
+            }
+        }
+
+        /* If "config" is not specified, the default is the same as the parent
+           schema node's "config" value.*/
+        if (leafLists != null) {
+            for (YangLeafList leafList : leafLists) {
+                if (leafList.isConfig() == null) {
+                    leafList.setConfig(isConfig);
+                }
+            }
+        }
+    }
+
+    /**
+     * Validates config statement of YANG list.
+     *
+     * @param leaves list of leaf attributes of YANG list.
+     * @param leafLists list of leaf-list attributes of YANG list.
+     * @throws DataModelException a violation of data model rules.
+     */
+    private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException {
+
+        /* If a node has "config" set to "false", no node underneath it can have
+             "config" set to "true".*/
+        if ((!isConfig) && (leaves != null)) {
+            for (YangLeaf leaf : leaves) {
+                if (leaf.isConfig()) {
+                    throw new DataModelException("If a list has \"config\" set to \"false\", no node underneath " +
+                            "it can have \"config\" set to \"true\".");
+                }
+            }
+        }
+
+        if ((!isConfig) && (leafLists != null)) {
+            for (YangLeafList leafList : leafLists) {
+                if (leafList.isConfig()) {
+                    throw new DataModelException("If a list has \"config\" set to \"false\", no node underneath " +
+                            "it can have \"config\" set to \"true\".");
+                }
+            }
+        }
+    }
+
+    /**
+     * Validates key statement of list.
+     *
+     * @param leaves list of leaf attributes of list.
+     * @param keyList list of key attributes of list.
+     * @throws DataModelException a violation of data model rules.
+     */
+    private void validateLeafKey(List<YangLeaf> leaves, List<String> keyList) throws DataModelException {
+        boolean leafFound = false;
+        List<YangLeaf> keyLeaves = new LinkedList<>();
+
+        /* 1. Leaf identifier must refer to a child leaf of the list
+           2.  A leaf that is part of the key must not be the built-in type "empty". */
+        for (String key : keyList) {
+            for (YangLeaf leaf : leaves) {
+                if (key.equals(leaf.getLeafName())) {
+                    if (leaf.getDataType().getDataTypeName().replace("\"", "").equals("empty")) {
+                        throw new DataModelException(" A leaf that is part of the key must not be the built-in " +
+                                "type \"empty\".");
+                    }
+                    leafFound = true;
+                    keyLeaves.add(leaf);
+                    break;
+                }
+            }
+            if (!leafFound) {
+                throw new DataModelException("Leaf identifier must refer to a child leaf of the list");
+            }
+            leafFound = false;
+        }
+
+        /* All key leafs in a list MUST have the same value for their "config"
+           as the list itself. */
+        for (YangLeaf keyLeaf : keyLeaves) {
+            if (isConfig != keyLeaf.isConfig()) {
+                throw new DataModelException("All key leafs in a list must have the same value for their" +
+                        " \"config\" as the list itself.");
+            }
+        }
+    }
+
+    /**
+     * Validates key statement of list.
+     *
+     * @param leafLists list of leaf-list attributes of list.
+     * @param keyList list of key attributes of list.
+     * @throws DataModelException a violation of data model rules.
+     */
+    private void validateLeafListKey(List<YangLeafList> leafLists, List<String> keyList) throws DataModelException {
+        boolean leafFound = false;
+        List<YangLeafList> keyLeafLists = new LinkedList<>();
+
+        /* 1. Leaf identifier must refer to a child leaf of the list
+           2.  A leaf that is part of the key must not be the built-in type "empty". */
+        for (String key : keyList) {
+            for (YangLeafList leafList : leafLists) {
+                if (key.equals(leafList.getLeafName())) {
+                    if (leafList.getDataType().getDataTypeName().replace("\"", "").equals("empty")) {
+                        throw new DataModelException(" A leaf-list that is part of the key must not be the built-in " +
+                                "type \"empty\".");
+                    }
+                    leafFound = true;
+                    keyLeafLists.add(leafList);
+                    break;
+                }
+            }
+            if (!leafFound) {
+                throw new DataModelException("Leaf-list identifier must refer to a child leaf of the list");
+            }
+            leafFound = false;
+        }
+
+        /* All key leafs in a list MUST have the same value for their "config"
+             as the list itself. */
+        for (YangLeafList keyLeafList : keyLeafLists) {
+            if (isConfig() != keyLeafList.isConfig()) {
+                throw new DataModelException("All key leaf-lists in a list must have the same value for their" +
+                        " \"config\" as the list itself.");
+            }
+        }
     }
 
     /* (non-Javadoc)
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java
index 08be582f..2325be3 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListener.java
@@ -27,6 +27,7 @@
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
 
 import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
@@ -94,6 +95,7 @@
     public static void processContainerEntry(TreeWalkListener listener,
                                              GeneratedYangParser.ContainerStatementContext ctx) {
 
+        YangNode parentNode;
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY);
 
@@ -105,8 +107,14 @@
         YangContainer container = new YangContainer();
         container.setName(ctx.IDENTIFIER().getText());
 
-        Parsable curData = listener.getParsedDataStack().peek();
+        /* If "config" is not specified, the default is the same as the parent
+           schema node's "config" value. */
+        if (ctx.configStatement().isEmpty()) {
+            boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
+            container.setConfig(parentConfig);
+        }
 
+        Parsable curData = listener.getParsedDataStack().peek();
         if ((curData instanceof YangModule) || (curData instanceof YangContainer)
                 || (curData instanceof YangList)) {
             YangNode curNode = (YangNode) curData;
@@ -137,6 +145,13 @@
         checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), EXIT);
 
         if (listener.getParsedDataStack().peek() instanceof YangContainer) {
+            YangContainer yangContainer = (YangContainer) listener.getParsedDataStack().peek();
+            try {
+                yangContainer.validateDataOnExit();
+            } catch (DataModelException e) {
+                throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+                        CONTAINER_DATA, ctx.IDENTIFIER().getText(), EXIT, e.getMessage()));
+            }
             listener.getParsedDataStack().pop();
         } else {
             throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, CONTAINER_DATA,
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java
index 32677a5..268d535 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/KeyListener.java
@@ -17,15 +17,20 @@
 package org.onosproject.yangutils.parser.impl.listeners;
 
 import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.parser.ParsableDataType;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
+
+import static org.onosproject.yangutils.parser.ParsableDataType.KEY_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 
 /*
  * Reference: RFC6020 and YANG ANTLR Grammar
@@ -61,9 +66,7 @@
                                          GeneratedYangParser.KeyStatementContext ctx) {
 
         // Check for stack to be non empty.
-        ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
-                ParsableDataType.KEY_DATA, String.valueOf(ctx.string().getText()),
-                ListenerErrorLocation.ENTRY);
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, KEY_DATA, ctx.string().getText(), ENTRY);
 
         Parsable tmpData = listener.getParsedDataStack().peek();
         if (listener.getParsedDataStack().peek() instanceof YangList) {
@@ -72,17 +75,24 @@
             if (tmpKeyValue.contains(" ")) {
                 String[] keyValues = tmpKeyValue.split(" ");
                 for (String keyValue : keyValues) {
-                    yangList.addKey(keyValue);
+                    try {
+                        yangList.addKey(keyValue);
+                    } catch (DataModelException e) {
+                        throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, KEY_DATA,
+                                ctx.string().getText(), ENTRY, e.getMessage()));
+                    }
                 }
             } else {
-                yangList.addKey(tmpKeyValue);
+                try {
+                    yangList.addKey(tmpKeyValue);
+                } catch (DataModelException e) {
+                    throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, KEY_DATA,
+                            ctx.string().getText(), ENTRY, e.getMessage()));
+                }
             }
         } else {
-            throw new ParserException(ListenerErrorMessageConstruction
-                    .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
-                            ParsableDataType.KEY_DATA,
-                            String.valueOf(ctx.string().getText()),
-                            ListenerErrorLocation.ENTRY));
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, KEY_DATA, ctx.string().getText(),
+                            ENTRY));
         }
     }
 }
\ No newline at end of file
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java
index 82d69cb..2319b8e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ListListener.java
@@ -17,6 +17,8 @@
 package org.onosproject.yangutils.parser.impl.listeners;
 
 import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.datamodel.YangNodeType;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
@@ -26,11 +28,20 @@
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
 import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
 
+import static org.onosproject.yangutils.parser.ParsableDataType.LIST_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+
 /*
  * Reference: RFC6020 and YANG ANTLR Grammar
  *
@@ -89,40 +100,37 @@
 
         YangNode curNode;
 
-        ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
-                ParsableDataType.LIST_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
-                ListenerErrorLocation.ENTRY);
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY);
 
         boolean result = validateSubStatementsCardinality(ctx);
         if (!result) {
-            throw new ParserException(ListenerErrorMessageConstruction
-                    .constructListenerErrorMessage(ListenerErrorType.INVALID_CARDINALITY,
-                            yangConstruct, "", ListenerErrorLocation.ENTRY));
+            throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
         }
 
         YangList yangList = new YangList(YangNodeType.LIST_NODE);
         yangList.setName(ctx.IDENTIFIER().getText());
 
+        /* If "config" is not specified, the default is the same as the parent
+           schema node's "config" value. */
+        if (ctx.configStatement().isEmpty()) {
+            boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
+            yangList.setConfig(parentConfig);
+        }
+
         Parsable curData = listener.getParsedDataStack().peek();
-        if (curData instanceof YangNode) {
+        if ((curData instanceof YangModule) || (curData instanceof YangContainer)
+                || (curData instanceof YangList)) {
             curNode = (YangNode) curData;
             try {
                 curNode.addChild(yangList);
             } catch (DataModelException e) {
-                throw new ParserException(ListenerErrorMessageConstruction
-                        .constructExtendedListenerErrorMessage(ListenerErrorType.UNHANDLED_PARSED_DATA,
-                                ParsableDataType.LIST_DATA,
-                                String.valueOf(ctx.IDENTIFIER().getText()),
-                                ListenerErrorLocation.ENTRY,
-                                e.getMessage()));
+                throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+                        LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY, e.getMessage()));
             }
             listener.getParsedDataStack().push(yangList);
         } else {
-            throw new ParserException(ListenerErrorMessageConstruction
-                    .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
-                            ParsableDataType.LIST_DATA,
-                            String.valueOf(ctx.IDENTIFIER().getText()),
-                            ListenerErrorLocation.ENTRY));
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LIST_DATA,
+                            ctx.IDENTIFIER().getText(), ENTRY));
         }
     }
 
@@ -136,18 +144,20 @@
     public static void processListExit(TreeWalkListener listener,
                                             GeneratedYangParser.ListStatementContext ctx) {
 
-        ListenerValidation.checkStackIsNotEmpty(listener, ListenerErrorType.MISSING_HOLDER,
-                ParsableDataType.LIST_DATA, String.valueOf(ctx.IDENTIFIER().getText()),
-                ListenerErrorLocation.EXIT);
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), EXIT);
 
         if (listener.getParsedDataStack().peek() instanceof YangList) {
+            YangList yangList = (YangList) listener.getParsedDataStack().peek();
+            try {
+                yangList.validateDataOnExit();
+            } catch (DataModelException e) {
+                throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+                        LIST_DATA, ctx.IDENTIFIER().getText(), EXIT, e.getMessage()));
+            }
             listener.getParsedDataStack().pop();
         } else {
-            throw new ParserException(ListenerErrorMessageConstruction
-                    .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
-                            ParsableDataType.LIST_DATA,
-                            String.valueOf(ctx.IDENTIFIER().getText()),
-                            ListenerErrorLocation.EXIT));
+            throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, LIST_DATA,
+                            ctx.IDENTIFIER().getText(), EXIT));
         }
     }
 
@@ -157,7 +167,7 @@
      * @param ctx context object of the grammar rule.
      * @return true/false validation success or failure.
      */
-    public static boolean validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) {
+    private static boolean validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) {
 
         if ((!ctx.keyStatement().isEmpty())
                 && (ctx.keyStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
index 226a530..26e4907 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
@@ -16,6 +16,10 @@
 
 package org.onosproject.yangutils.parser.impl.parserutils;
 
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.parser.ParsableDataType;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -83,4 +87,25 @@
             throw new ParserException(message);
         }
     }
+
+    /**
+     * Returns parent node config value, if top node does not specify a config statement
+     * then default value true is returned.
+     *
+     * @param listener listener's object.
+     * @return true/false parent's config value.
+     */
+    public static boolean getParentNodeConfig(TreeWalkListener listener) {
+        YangNode parentNode;
+        Parsable curData = listener.getParsedDataStack().peek();
+        if (curData instanceof YangNode) {
+            parentNode = ((YangNode) curData).getParent();
+            if (parentNode instanceof YangContainer) {
+                return ((YangContainer) parentNode).isConfig();
+            } else if (parentNode instanceof YangList) {
+                return ((YangList) parentNode).isConfig();
+            }
+        }
+        return true;
+    }
 }
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
index c8db91a..bd634bb 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
@@ -240,4 +240,296 @@
         assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
         assertThat(leafListInfo.isConfig(), is(true));
     }
+
+    /**
+     * Checks config statement's default Value.
+     */
+    @Test
+    public void processConfigDefaultValue() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ConfigDefaultValue.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangContainer container = (YangContainer) yangNode.getChild();
+        assertThat(container.getName(), is("valid"));
+        assertThat(container.isConfig(), is(true));
+
+        // Check whether leaf properties as set correctly.
+        ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.isConfig(), is(true));
+    }
+
+    /**
+     * Checks whether exception is throw when node's parent config set to false,
+     * no node underneath it can have config set to true.
+     */
+    @Test
+    public void processConfigFalseParentContainerChildLeafList() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Internal parser error detected: Unhandled parsed data at container \"valid\" after "
+                + "processing.\nError Information: If a container has \"config\" set to \"false\", no node underneath "
+                + "it can have \"config\" set to \"true\".");
+        YangNode node = manager.getDataModel("src/test/resources/ConfigFalseParentContainerChildLeafList.yang");
+    }
+
+    /**
+     * Checks whether exception is throw when node's parent config set to false,
+     * no node underneath it can have config set to true.
+     */
+    @Test
+    public void processConfigFalseParentContainerChildLeaf() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Internal parser error detected: Unhandled parsed data at container \"valid\" after "
+                + "processing.\nError Information: If a container has \"config\" set to \"false\", no node underneath "
+                + "it can have \"config\" set to \"true\".");
+        YangNode node = manager.getDataModel("src/test/resources/ConfigFalseParentContainerChildLeaf.yang");
+    }
+
+    /**
+     * Checks whether exception is throw when node's parent config set to false,
+     * no node underneath it can have config set to true.
+     */
+    @Test
+    public void processConfigFalseParentListChildLeafList() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Internal parser error detected: Unhandled parsed data at list \"valid\" after"
+                + " processing.\nError Information: If a list has \"config\" set to \"false\", no node underneath"
+                + " it can have \"config\" set to \"true\".");
+        YangNode node = manager.getDataModel("src/test/resources/ConfigFalseParentListChildLeafList.yang");
+    }
+
+    /**
+     * Checks whether exception is throw when node's parent config set to false,
+     * no node underneath it can have config set to true.
+     */
+    @Test
+    public void processConfigFalseParentListChildLeaf() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Internal parser error detected: Unhandled parsed data at list \"valid\" after"
+                + " processing.\nError Information: If a list has \"config\" set to \"false\", no node underneath"
+                + " it can have \"config\" set to \"true\".");
+        YangNode node = manager.getDataModel("src/test/resources/ConfigFalseParentListChildLeaf.yang");
+    }
+
+    /**
+     * Checks when config is not specified, the default is same as the parent's schema node's
+     * config statement's value.
+     */
+    @Test
+    public void processNoConfigContainerSubStatementContainer() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NoConfigContainerSubStatementContainer.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangContainer container = (YangContainer) yangNode.getChild();
+        assertThat(container.getName(), is("hello"));
+        assertThat(container.isConfig(), is(true));
+
+        YangNode containerNode = container.getChild();
+        assertThat(containerNode instanceof YangContainer, is(true));
+        YangContainer childContainer = (YangContainer) containerNode;
+        assertThat(childContainer.getName(), is("valid"));
+        assertThat(childContainer.isConfig(), is(true));
+    }
+
+    /**
+     * Checks when config is not specified, the default is same as the parent's schema node's
+     * config statement's value.
+     */
+    @Test
+    public void processNoConfigContainerSubStatementLeafList() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NoConfigContainerSubStatementLeafList.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangContainer container = (YangContainer) yangNode.getChild();
+        assertThat(container.getName(), is("valid"));
+        assertThat(container.isConfig(), is(true));
+
+        ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator();
+        YangLeafList leafListInfo = leafListIterator.next();
+
+        // Check whether config value is set correctly.
+        assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafListInfo.isConfig(), is(true));
+
+    }
+
+    /**
+     * Checks when config is not specified, the default is same as the parent's schema node's
+     * config statement's value.
+     */
+    @Test
+    public void processNoConfigContainerSubStatementLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NoConfigContainerSubStatementLeaf.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangContainer container = (YangContainer) yangNode.getChild();
+        assertThat(container.getName(), is("valid"));
+        assertThat(container.isConfig(), is(true));
+
+        // Check whether leaf properties as set correctly.
+        ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.isConfig(), is(true));
+    }
+
+    /**
+     * Checks when config is not specified, the default is same as the parent's schema node's
+     * config statement's value.
+     */
+    @Test
+    public void processNoConfigContainerSubStatementList() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NoConfigContainerSubStatementList.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangContainer container = (YangContainer) yangNode.getChild();
+        assertThat(container.getName(), is("hello"));
+        assertThat(container.isConfig(), is(true));
+
+        YangNode listNode = container.getChild();
+        assertThat(listNode instanceof YangList, is(true));
+        YangList childList = (YangList) listNode;
+        assertThat(childList.getName(), is("valid"));
+        assertThat(childList.isConfig(), is(true));
+
+    }
+
+    /**
+     * Checks when config is not specified, the default is same as the parent's schema node's
+     * config statement's value.
+     */
+    @Test
+    public void processNoConfigListSubStatementContainer() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementContainer.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangList list1 = (YangList) yangNode.getChild();
+        assertThat(list1.getName(), is("list1"));
+        assertThat(list1.isConfig(), is(true));
+
+        YangNode containerNode = list1.getChild();
+        assertThat(containerNode instanceof YangContainer, is(true));
+        YangContainer childContainer = (YangContainer) containerNode;
+        assertThat(childContainer.getName(), is("container1"));
+        assertThat(childContainer.isConfig(), is(true));
+    }
+
+    /**
+     * Checks when config is not specified, the default is same as the parent's schema node's
+     * config statement's value.
+     */
+    @Test
+    public void processNoConfigListSubStatementLeafList() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementLeafList.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangList list1 = (YangList) yangNode.getChild();
+        assertThat(list1.getName(), is("valid"));
+        assertThat(list1.isConfig(), is(true));
+
+        ListIterator<YangLeafList> leafListIterator = list1.getListOfLeafList().listIterator();
+        YangLeafList leafListInfo = leafListIterator.next();
+
+        // Check whether config value is set correctly.
+        assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafListInfo.isConfig(), is(true));
+    }
+
+    /**
+     * Checks when config is not specified, the default is same as the parent's schema node's
+     * config statement's value.
+     */
+    @Test
+    public void processNoConfigListSubStatementLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementLeaf.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangList list1 = (YangList) yangNode.getChild();
+        assertThat(list1.getName(), is("valid"));
+        assertThat(list1.isConfig(), is(true));
+
+        // Check whether leaf properties as set correctly.
+        ListIterator<YangLeaf> leafIterator = list1.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.isConfig(), is(true));
+    }
+
+    /**
+     * Checks when config is not specified, the default is same as the parent's schema node's
+     * config statement's value.
+     */
+    @Test
+    public void processNoConfigListSubStatementList() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementList.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the config value is set correctly.
+        YangList list1 = (YangList) yangNode.getChild();
+        assertThat(list1.getName(), is("valid"));
+        assertThat(list1.isConfig(), is(true));
+
+        YangNode listNode = list1.getChild();
+        assertThat(listNode instanceof YangList, is(true));
+        YangList childList = (YangList) listNode;
+        assertThat(childList.getName(), is("list1"));
+        assertThat(childList.isConfig(), is(true));
+    }
 }
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java
index 727c1d2..542cd5a 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java
@@ -104,4 +104,141 @@
         thrown.expectMessage("mismatched input 'leaf' expecting {';', '+'}");
         YangNode node = manager.getDataModel("src/test/resources/KeyWithoutStatementEnd.yang");
     }
+
+    /**
+     * Checks key values are set correctly.
+     */
+    @Test
+    public void processConfigFalseNoKey() throws IOException, ParserException {
+        YangNode node = manager.getDataModel("src/test/resources/ConfigFalseNoKey.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the list is child of module
+        YangList yangList = (YangList) yangNode.getChild();
+        assertThat(yangList.getName(), is("valid"));
+    }
+
+    /**
+     * Checks key values are set correctly.
+     */
+    @Test
+    public void processConfigFalseValidKeyValidLeaf() throws IOException, ParserException {
+        YangNode node = manager.getDataModel("src/test/resources/ConfigFalseValidKeyValidLeaf.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the list is child of module
+        YangList yangList = (YangList) yangNode.getChild();
+        assertThat(yangList.getName(), is("valid"));
+
+        ListIterator<String> keyList = yangList.getKeyList().listIterator();
+        assertThat(keyList.next(), is("invalid-interval"));
+    }
+
+    /**
+     * Checks key values are set correctly.
+     */
+    @Test
+    public void processConfigFalseValidKeyValidLeafList() throws IOException, ParserException {
+        YangNode node = manager.getDataModel("src/test/resources/ConfigFalseValidKeyValidLeafList.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the list is child of module
+        YangList yangList = (YangList) yangNode.getChild();
+        assertThat(yangList.getName(), is("valid"));
+
+        ListIterator<String> keyList = yangList.getKeyList().listIterator();
+        assertThat(keyList.next(), is("invalid-interval"));
+    }
+
+    /**
+     * Checks whether exception is thrown when list's config is set to true and there is no key.
+     */
+    @Test
+    public void processConfigTrueNoKey() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("A list must have atleast one key leaf if config is true");
+        YangNode node = manager.getDataModel("src/test/resources/ConfigTrueNoKey.yang");
+    }
+
+    /**
+     * Checks whether exception is thrown when list's config is set to true and there is no leaf.
+     */
+    @Test
+    public void processConfigTrueNoleafNoLeafList() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("A list must have atleast one key leaf if config is true");
+        YangNode node = manager.getDataModel("src/test/resources/ConfigTrueNoleafNoLeafList.yang");
+    }
+
+    /**
+     * Checks key values are set correctly.
+     */
+    @Test
+    public void processConfigTrueValidKeyValidLeaf() throws IOException, ParserException {
+        YangNode node = manager.getDataModel("src/test/resources/ConfigTrueValidKeyValidLeaf.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        // Check whether the list is child of module
+        YangList yangList = (YangList) yangNode.getChild();
+        assertThat(yangList.getName(), is("valid"));
+
+        ListIterator<String> keyList = yangList.getKeyList().listIterator();
+        assertThat(keyList.next(), is("invalid-interval"));
+    }
+
+    /**
+     * Checks whether exception is thrown when key leaf identifier is not found in list.
+     */
+    @Test
+    public void processInvalidLeafIdentifier() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Leaf identifier must refer to a child leaf of the list");
+        YangNode node = manager.getDataModel("src/test/resources/InvalidLeafIdentifier.yang");
+    }
+
+    /**
+     * Checks whether exception is thrown when key leaf-list identifier is not found in list.
+     */
+    @Test
+    public void processInvalidLeafListIdentifier() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Leaf-list identifier must refer to a child leaf of the list");
+        YangNode node = manager.getDataModel("src/test/resources/InvalidLeafListIdentifier.yang");
+    }
+
+    /**
+     * Checks whether exception is thrown when key leaf-list is of type empty.
+     */
+    @Test
+    public void processKeyLeafListTypeEmpty() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("A leaf-list that is part of the key must not be the built-in type \"empty\".");
+        YangNode node = manager.getDataModel("src/test/resources/KeyLeafListTypeEmpty.yang");
+    }
+
+    /**
+     * Checks whether exception is thrown when key leaf is of type empty.
+     */
+    @Test
+    public void processKeyLeafTypeEmpty() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("A leaf that is part of the key must not be the built-in type \"empty\".");
+        YangNode node = manager.getDataModel("src/test/resources/KeyLeafTypeEmpty.yang");
+    }
 }
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
index f552387..0d2d29b 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
@@ -68,7 +68,7 @@
         assertThat(yangList.getName(), is("valid"));
 
         ListIterator<String> keyList = yangList.getKeyList().listIterator();
-        assertThat(keyList.next(), is("invalid"));
+        assertThat(keyList.next(), is("invalid-interval"));
     }
 
     /**
@@ -95,7 +95,7 @@
         // Check whether the list is child of container
         YangList yangList = (YangList) yangContainer.getChild();
         assertThat(yangList.getName(), is("valid"));
-        assertThat(yangList.getKeyList().contains("invalid"), is(true));
+        assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
     }
 
     /**
@@ -123,7 +123,7 @@
         // Check whether the list is child of list
         YangList yangList = (YangList) yangList1.getChild();
         assertThat(yangList.getName(), is("valid"));
-        assertThat(yangList.getKeyList().contains("invalid"), is(true));
+        assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
     }
 
     /**
@@ -148,7 +148,7 @@
 
         // Check whether list properties as set correctly.
         assertThat(yangList.getName(), is("ospf"));
-        assertThat(yangList.getKeyList().contains("process-id"), is(true));
+        assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
 
         assertThat(yangList.isConfig(), is(true));
         assertThat(yangList.getMaxElelements(), is(10));
diff --git a/utils/yangutils/src/test/resources/ConfigDefaultValue.yang b/utils/yangutils/src/test/resources/ConfigDefaultValue.yang
new file mode 100644
index 0000000..7e19946
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigDefaultValue.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container valid {
+        leaf invalid-interval {
+            type "uint16";
+            units "seconds";
+            description "Interval before a route is declared invalid";
+            mandatory true;
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/ConfigFalseNoKey.yang b/utils/yangutils/src/test/resources/ConfigFalseNoKey.yang
new file mode 100644
index 0000000..66f141e
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseNoKey.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        config false;
+        leaf invalid-interval {
+            type "string";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildLeaf.yang b/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildLeaf.yang
new file mode 100644
index 0000000..ecc0806
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildLeaf.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container valid {
+        config false;
+        leaf invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            config true;
+            reference "RFC 6020";
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildLeafList.yang b/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildLeafList.yang
new file mode 100644
index 0000000..e3c7836
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildLeafList.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container valid {
+        config false;
+        leaf-list invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            config true;
+            reference "RFC 6020";
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildList.yang b/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildList.yang
new file mode 100644
index 0000000..78fbe15
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseParentContainerChildList.yang
@@ -0,0 +1,18 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container valid {
+        config false;
+    	list valid {
+            key "invalid-interval";
+            config true;
+            leaf invalid-interval {
+                type "uint16";
+                units "seconds";
+                status current;
+                reference "RFC 6020";
+            }
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/ConfigFalseParentListChildContainer.yang b/utils/yangutils/src/test/resources/ConfigFalseParentListChildContainer.yang
new file mode 100644
index 0000000..5a84595
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseParentListChildContainer.yang
@@ -0,0 +1,24 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        config false;
+        key "invalid-interval";
+        leaf invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+        container valid { 
+            config true;
+            leaf invalid-interval {
+                type "uint16";
+                units "seconds";
+                status current;
+                reference "RFC 6020";
+            }
+        }        
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigFalseParentListChildLeaf.yang b/utils/yangutils/src/test/resources/ConfigFalseParentListChildLeaf.yang
new file mode 100644
index 0000000..65171dd
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseParentListChildLeaf.yang
@@ -0,0 +1,16 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        config false;
+        leaf invalid-interval {
+            type "uint16";
+            config true;
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigFalseParentListChildLeafList.yang b/utils/yangutils/src/test/resources/ConfigFalseParentListChildLeafList.yang
new file mode 100644
index 0000000..33132cd
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseParentListChildLeafList.yang
@@ -0,0 +1,16 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        config false;
+        leaf-list invalid-interval {
+            type "uint16";
+            config true;
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigFalseValidKeyValidLeaf.yang b/utils/yangutils/src/test/resources/ConfigFalseValidKeyValidLeaf.yang
new file mode 100644
index 0000000..368a4b5
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseValidKeyValidLeaf.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        config false;
+        leaf invalid-interval {
+            type "string";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigFalseValidKeyValidLeafList.yang b/utils/yangutils/src/test/resources/ConfigFalseValidKeyValidLeafList.yang
new file mode 100644
index 0000000..4196be4
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalseValidKeyValidLeafList.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf-list invalid-interval {
+            type "string";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigTrueNoKey.yang b/utils/yangutils/src/test/resources/ConfigTrueNoKey.yang
new file mode 100644
index 0000000..7a0a538
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigTrueNoKey.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        config true;
+        leaf invalid-interval {
+            type "string";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigTrueNoleafNoLeafList.yang b/utils/yangutils/src/test/resources/ConfigTrueNoleafNoLeafList.yang
new file mode 100644
index 0000000..c553e60
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigTrueNoleafNoLeafList.yang
@@ -0,0 +1,13 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        config true;
+        container container1 {
+           leaf leaf1 {
+              type "string";
+           }
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigTrueValidKeyValidLeaf List.yang b/utils/yangutils/src/test/resources/ConfigTrueValidKeyValidLeaf List.yang
new file mode 100644
index 0000000..4196be4
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigTrueValidKeyValidLeaf List.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf-list invalid-interval {
+            type "string";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigTrueValidKeyValidLeaf.yang b/utils/yangutils/src/test/resources/ConfigTrueValidKeyValidLeaf.yang
new file mode 100644
index 0000000..fe8efe3
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigTrueValidKeyValidLeaf.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf invalid-interval {
+            type "string";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementList.yang b/utils/yangutils/src/test/resources/ContainerSubStatementList.yang
index 4450391..19810c7 100644
--- a/utils/yangutils/src/test/resources/ContainerSubStatementList.yang
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementList.yang
@@ -4,7 +4,7 @@
     prefix Ant;
     container ospf {
         list valid {
-            key "invalid";
+            key "invalid-interval";
             leaf invalid-interval {
                 type "uint16";
                 units "seconds";
diff --git a/utils/yangutils/src/test/resources/InvalidLeafIdentifier.yang b/utils/yangutils/src/test/resources/InvalidLeafIdentifier.yang
new file mode 100644
index 0000000..6faf092
--- /dev/null
+++ b/utils/yangutils/src/test/resources/InvalidLeafIdentifier.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf invalid {
+            type "string";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/InvalidLeafListIdentifier.yang b/utils/yangutils/src/test/resources/InvalidLeafListIdentifier.yang
new file mode 100644
index 0000000..6359d2a
--- /dev/null
+++ b/utils/yangutils/src/test/resources/InvalidLeafListIdentifier.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf-list invalid {
+            type "string";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/KeyLeafListTypeEmpty.yang b/utils/yangutils/src/test/resources/KeyLeafListTypeEmpty.yang
new file mode 100644
index 0000000..44c1617
--- /dev/null
+++ b/utils/yangutils/src/test/resources/KeyLeafListTypeEmpty.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf-list invalid-interval {
+            type "empty";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/KeyLeafTypeEmpty.yang b/utils/yangutils/src/test/resources/KeyLeafTypeEmpty.yang
new file mode 100644
index 0000000..859520c
--- /dev/null
+++ b/utils/yangutils/src/test/resources/KeyLeafTypeEmpty.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf invalid-interval {
+            type "empty";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementContainer.yang b/utils/yangutils/src/test/resources/ListSubStatementContainer.yang
index a81bda5..4ce6da4 100644
--- a/utils/yangutils/src/test/resources/ListSubStatementContainer.yang
+++ b/utils/yangutils/src/test/resources/ListSubStatementContainer.yang
@@ -12,5 +12,8 @@
                 reference "RFC 6020";
             }
         }
+        leaf process-id {
+            type "string";
+        }
     }
 }
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementList.yang b/utils/yangutils/src/test/resources/ListSubStatementList.yang
index 14cf270..2021469 100644
--- a/utils/yangutils/src/test/resources/ListSubStatementList.yang
+++ b/utils/yangutils/src/test/resources/ListSubStatementList.yang
@@ -5,7 +5,7 @@
     list ospf {
         key "process-id";
         list valid {
-            key "invalid";
+            key "invalid-interval";
             leaf invalid-interval {
                 type "uint16";
                 units "seconds";
@@ -13,5 +13,8 @@
                 reference "RFC 6020";
             }
         }
+        leaf process-id {
+            type "string";
+        }
     }
 }
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatements.yang b/utils/yangutils/src/test/resources/ListSubStatements.yang
index f684780..109fc17 100644
--- a/utils/yangutils/src/test/resources/ListSubStatements.yang
+++ b/utils/yangutils/src/test/resources/ListSubStatements.yang
@@ -3,7 +3,7 @@
     namespace http://huawei.com;
     prefix Ant;
     list ospf {
-        key "process-id";
+        key "invalid-interval";
         config true;
         max-elements 10;
         min-elements 3;
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementList.yang b/utils/yangutils/src/test/resources/ModuleSubStatementList.yang
index baf36e7..1bb3bf5 100644
--- a/utils/yangutils/src/test/resources/ModuleSubStatementList.yang
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementList.yang
@@ -3,7 +3,7 @@
     namespace http://huawei.com;
     prefix Ant;
     list valid {
-        key "invalid";
+        key "invalid-interval";
         leaf invalid-interval {
             type "uint16";
             units "seconds";
diff --git a/utils/yangutils/src/test/resources/NoConfigContainerSubStatementContainer.yang b/utils/yangutils/src/test/resources/NoConfigContainerSubStatementContainer.yang
new file mode 100644
index 0000000..1aded2d
--- /dev/null
+++ b/utils/yangutils/src/test/resources/NoConfigContainerSubStatementContainer.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container hello {
+        container valid {
+            leaf invalid-interval {
+                type "uint16";
+                units "seconds";
+                status current;
+                reference "RFC 6020";
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/NoConfigContainerSubStatementLeaf.yang b/utils/yangutils/src/test/resources/NoConfigContainerSubStatementLeaf.yang
new file mode 100644
index 0000000..35a91ad
--- /dev/null
+++ b/utils/yangutils/src/test/resources/NoConfigContainerSubStatementLeaf.yang
@@ -0,0 +1,13 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container valid {
+        leaf invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/NoConfigContainerSubStatementLeafList.yang b/utils/yangutils/src/test/resources/NoConfigContainerSubStatementLeafList.yang
new file mode 100644
index 0000000..79687c2
--- /dev/null
+++ b/utils/yangutils/src/test/resources/NoConfigContainerSubStatementLeafList.yang
@@ -0,0 +1,13 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container valid {
+        leaf-list invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/NoConfigContainerSubStatementList.yang b/utils/yangutils/src/test/resources/NoConfigContainerSubStatementList.yang
new file mode 100644
index 0000000..f10c686
--- /dev/null
+++ b/utils/yangutils/src/test/resources/NoConfigContainerSubStatementList.yang
@@ -0,0 +1,16 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container hello {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type "uint16";
+                units "seconds";
+                status current;
+                reference "RFC 6020";
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/NoConfigListSubStatementContainer.yang b/utils/yangutils/src/test/resources/NoConfigListSubStatementContainer.yang
new file mode 100644
index 0000000..19b4291
--- /dev/null
+++ b/utils/yangutils/src/test/resources/NoConfigListSubStatementContainer.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list list1 {
+        key "invalid-interval";
+        leaf invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+        container container1 {
+            leaf leaf1 {
+                type "uint16";
+                units "seconds";
+                status current;
+                reference "RFC 6020";
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/NoConfigListSubStatementLeaf.yang b/utils/yangutils/src/test/resources/NoConfigListSubStatementLeaf.yang
new file mode 100644
index 0000000..1bb3bf5
--- /dev/null
+++ b/utils/yangutils/src/test/resources/NoConfigListSubStatementLeaf.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/NoConfigListSubStatementLeafList.yang b/utils/yangutils/src/test/resources/NoConfigListSubStatementLeafList.yang
new file mode 100644
index 0000000..e70155e
--- /dev/null
+++ b/utils/yangutils/src/test/resources/NoConfigListSubStatementLeafList.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf-list invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/NoConfigListSubStatementList.yang b/utils/yangutils/src/test/resources/NoConfigListSubStatementList.yang
new file mode 100644
index 0000000..4de40cb
--- /dev/null
+++ b/utils/yangutils/src/test/resources/NoConfigListSubStatementList.yang
@@ -0,0 +1,23 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    list valid {
+        key "invalid-interval";
+        leaf invalid-interval {
+            type "uint16";
+            units "seconds";
+            status current;
+            reference "RFC 6020";
+        }
+        list list1 {
+            key "leaf1";
+            leaf leaf1 {
+                type "uint16";
+                units "seconds";
+                status current;
+                reference "RFC 6020";
+            }
+        }
+    }
+}