Input/Output map addition to handle RPC in YMS

Change-Id: I5543e6e07d9b10ae9b695bfd7d4e4b89ea433dba
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangInput.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangInput.java
index a1b82fd..496bf0b 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangInput.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangInput.java
@@ -72,7 +72,8 @@
  */
 public abstract class YangInput
         extends YangNode
-        implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode, YangIsFilterContentNodes {
+        implements YangLeavesHolder, Parsable, CollisionDetector,
+                   YangAugmentableNode, YangIsFilterContentNodes {
 
     private static final long serialVersionUID = 806201608L;
 
@@ -102,23 +103,6 @@
                                     YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
             throws DataModelException {
         getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
-        YangSchemaNodeContextInfo yangSchemaNodeContextInfo1 = new YangSchemaNodeContextInfo();
-        yangSchemaNodeContextInfo1.setSchemaNode(yangSchemaNodeContextInfo.getSchemaNode());
-        yangSchemaNodeContextInfo1.setContextSwitchedNode(this);
-        getParent().addToChildSchemaMap(schemaNodeIdentifier, yangSchemaNodeContextInfo1);
-    }
-
-    @Override
-    public void setNameSpaceAndAddToParentSchemaMap() {
-        // Get parent namespace.
-        String nameSpace = this.getParent().getNameSpace();
-        // Set namespace for self node.
-        setNameSpace(nameSpace);
-        /*
-         * Check if node contains leaf/leaf-list, if yes add namespace for leaf
-         * and leaf list.
-         */
-        setLeafNameSpaceAndAddToParentSchemaMap();
     }
 
     @Override
@@ -128,32 +112,36 @@
     }
 
     @Override
-    public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+    public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier,
+                                     YangSchemaNode yangSchemaNode) {
         //For non data nodes, default child to be added to parent node.
         // TODO
     }
 
     @Override
     public YangSchemaNodeType getYangSchemaNodeType() {
-        return YangSchemaNodeType.YANG_NON_DATA_NODE;
+        return YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
     }
 
     @Override
-    public void detectCollidingChild(String identifierName, YangConstructType dataType)
+    public void detectCollidingChild(String identifierName,
+                                     YangConstructType dataType)
             throws DataModelException {
         // Detect colliding child.
         detectCollidingChildUtil(identifierName, dataType, this);
     }
 
     @Override
-    public void detectSelfCollision(String identifierName, YangConstructType dataType)
+    public void detectSelfCollision(String identifierName,
+                                    YangConstructType dataType)
             throws DataModelException {
         if (getName().equals(identifierName)) {
-            throw new DataModelException("YANG file error: Duplicate input identifier detected, same as input \"" +
-                    getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition() +
-                    " in " + getFileName() + "\"");
+            throw new DataModelException("YANG file error: Duplicate input " +
+                                                 "identifier detected, same " +
+                                                 "as input \"" + getName() +
+                                                 " in " + getLineNumber() +
+                                                 " at " + getCharPosition() +
+                                                 " in " + getFileName() + "\"");
         }
     }
 
@@ -230,4 +218,27 @@
             yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
         }
     }
+
+    @Override
+    public void setNameSpaceAndAddToParentSchemaMap() {
+        // Get parent namespace.
+        if (this.getParent() != null) {
+            String nameSpace = this.getParent().getNameSpace();
+            // Set namespace for self node.
+            setNameSpace(nameSpace);
+            // Process addition of leaf to the child schema map of parent.
+            processAdditionOfSchemaNodeToParentMap("input", getNameSpace());
+        }
+        /*
+         * Check if node contains leaf/leaf-list, if yes add namespace for leaf
+         * and leaf list.
+         */
+        if (this instanceof YangLeavesHolder) {
+            ((YangLeavesHolder) this).setLeafNameSpaceAndAddToParentSchemaMap();
+        }
+    }
+    /*
+     * TODO analyze the reason to have RPC name prepended in input name in
+     * input Listener.
+     */
 }
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
index 7eb9fe0..bf8c8e5 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
@@ -20,6 +20,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.datamodel.utils.Parsable;
 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
@@ -411,7 +412,8 @@
     }
 
     @Override
-    public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier)
+    public YangSchemaNodeContextInfo getChildSchema(
+            YangSchemaNodeIdentifier dataNodeIdentifier)
             throws DataModelException {
         throw new DataModelException("leaf cannot have any child schema nodes " +
                 getName() + " in " +
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
index b2c003a..c0899dd 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
@@ -428,7 +428,8 @@
     }
 
     @Override
-    public YangSchemaNodeContextInfo getChildSchema(YangSchemaNodeIdentifier dataNodeIdentifier)
+    public YangSchemaNodeContextInfo getChildSchema(
+            YangSchemaNodeIdentifier dataNodeIdentifier)
             throws DataModelException {
         throw new DataModelException("leaf cannot have any child schema nodes" +
                 getName() + " in " +
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
index 2d419c9..89bda47 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
@@ -255,45 +255,48 @@
     public void addChild(YangNode newChild)
             throws DataModelException {
         if (newChild.getNodeType() == null) {
-            throw new DataModelException("Abstract node cannot be inserted into a tree " +
-                    getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition() +
-                    " in " + getFileName() + "\"");
+            throw new DataModelException("Abstract node cannot be inserted " +
+                                                 "into a tree " + getName() +
+                                                 " in " + getLineNumber() +
+                                                 " at " + getCharPosition() +
+                                                 " in " + getFileName() + "\"");
         }
 
         if (newChild.getParent() == null) {
             newChild.setParent(this);
         } else if (newChild.getParent() != this) {
             throw new DataModelException("Node is already part of a tree " +
-                    getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition() +
-                    " in " + getFileName() + "\"");
+                                                 getName() + " in " +
+                                                 getLineNumber() + " at " +
+                                                 getCharPosition() + " in " +
+                                                 getFileName() + "\"");
         }
 
         if (newChild.getChild() != null) {
-            throw new DataModelException("Child to be added is not atomic, it already has a child "
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("Child to be added is not atomic, " +
+                                                 "it already has a child " +
+                                                 getName() + " in " +
+                                                 getLineNumber() + " at " +
+                                                 getCharPosition() + " in " +
+                                                 getFileName() + "\"");
         }
 
         if (newChild.getNextSibling() != null) {
-            throw new DataModelException("Child to be added is not atomic, it already has a next sibling "
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("Child to be added is not atomic, " +
+                                                 "it already has a next " +
+                                                 "sibling " + getName() +
+                                                 " in " + getLineNumber() +
+                                                 " at " + getCharPosition() +
+                                                 " in " + getFileName() + "\"");
         }
 
         if (newChild.getPreviousSibling() != null) {
-            throw new DataModelException("Child to be added is not atomic, it already has a previous sibling "
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("Child to be added is not atomic, " +
+                                                 "it already has a previous " +
+                                                 "sibling " + getName() +
+                                                 " in " +    getLineNumber() +
+                                                 " at " + getCharPosition() +
+                                                 " in " + getFileName() + "\"");
         }
 
         /* First child to be added */
@@ -440,11 +443,14 @@
         try {
             while (nextNodeToClone != srcRootNode) {
                 if (nextNodeToClone == null) {
-                    throw new DataModelException("Internal error: Cloning failed, source tree null pointer reached "
-                            + nextNodeToClone.getName() + " in " +
-                            nextNodeToClone.getLineNumber() + " at " +
-                            nextNodeToClone.getCharPosition()
-                            + " in " + nextNodeToClone.getFileName() + "\"");
+                    throw new DataModelException("Internal error: Cloning " +
+                                                         "failed, source " +
+                                                         "tree null pointer " +
+                                                         "reached " +
+                                                         nextNodeToClone.getName() +
+                                                         " in " + nextNodeToClone.getLineNumber() +
+                                                         " at " + nextNodeToClone.getCharPosition() +
+                                                         " in " + nextNodeToClone.getFileName() + "\"");
                 }
                 if (curTraversal != PARENT) {
                     newNode = nextNodeToClone.clone(yangUses);
@@ -494,10 +500,11 @@
                 }
             }
         } catch (CloneNotSupportedException e) {
-            throw new DataModelException("Failed to clone the tree " + nextNodeToClone.getName() + " in " +
-                    nextNodeToClone.getLineNumber() + " at " +
-                    nextNodeToClone.getCharPosition()
-                    + " in " + nextNodeToClone.getFileName() + "\"");
+            throw new DataModelException("Failed to clone the tree " +
+                                                 nextNodeToClone.getName() +
+                                                 " in " + nextNodeToClone.getLineNumber() +
+                                                 " at " + nextNodeToClone.getCharPosition() +
+                                                 " in " + nextNodeToClone.getFileName() + "\"");
         }
 
     }
@@ -516,11 +523,12 @@
             throws DataModelException {
         if (!(currentNode instanceof CollisionDetector)
                 || !(newNode instanceof Parsable)) {
-            throw new DataModelException("Node in data model tree does not support collision detection " +
-                    newNode.getName() + " in " +
-                    newNode.getLineNumber() + " at " +
-                    newNode.getCharPosition()
-                    + " in " + newNode.getFileName() + "\"");
+            throw new DataModelException("Node in data model tree does not " +
+                                                 "support collision detection " +
+                                                 newNode.getName() + " in " +
+                                                 newNode.getLineNumber() + " at " +
+                                                 newNode.getCharPosition() +
+                                                 " in " + newNode.getFileName() + "\"");
         }
 
         CollisionDetector collisionDetector = (CollisionDetector) currentNode;
@@ -531,20 +539,22 @@
         } else if (addAs == TraversalType.SIBILING) {
             currentNode = currentNode.getParent();
             if (!(currentNode instanceof CollisionDetector)) {
-                throw new DataModelException("Node in data model tree does not support collision detection"
-                        + currentNode.getName() + " in " +
-                        currentNode.getLineNumber() + " at " +
-                        currentNode.getCharPosition()
-                        + " in " + currentNode.getFileName() + "\"");
+                throw new DataModelException("Node in data model tree does " +
+                                                     "not support collision " +
+                                                     "detection" + currentNode.getName() +
+                                                     " in " + currentNode.getLineNumber() +
+                                                     " at " + currentNode.getCharPosition() +
+                                                     " in " + currentNode.getFileName() + "\"");
             }
             collisionDetector = (CollisionDetector) currentNode;
             collisionDetector.detectCollidingChild(newNode.getName(),
                                                    parsable.getYangConstructType());
         } else {
-            throw new DataModelException("Error tree cloning " + currentNode.getName() + " in " +
-                    currentNode.getLineNumber() + " at " +
-                    currentNode.getCharPosition()
-                    + " in " + currentNode.getFileName() + "\"");
+            throw new DataModelException("Error tree cloning " +
+                                                 currentNode.getName() + " in" +
+                                                 " " + currentNode.getLineNumber() +
+                                                 " at " + currentNode.getCharPosition() +
+                                                 " in " + currentNode.getFileName() + "\"");
         }
 
     }
@@ -577,7 +587,8 @@
             throws DataModelException {
 
         if (newSibling.getNodeType() == null) {
-            throw new DataModelException("Cloned abstract node cannot be inserted into a tree "
+            throw new DataModelException("Cloned abstract node cannot be " +
+                                                 "inserted into a tree "
                     + getName() + " in " +
                     getLineNumber() + " at " +
                     getCharPosition()
@@ -592,38 +603,43 @@
             newSibling.setParent(getParent());
 
         } else {
-            throw new DataModelException("Node is already part of a tree, and cannot be added as a sibling "
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("Node is already part of a tree, " +
+                                                 "and cannot be added as a " +
+                                                 "sibling " + getName() + " in " +
+                                                 getLineNumber() + " at " +
+                                                 getCharPosition() + " in " +
+                                                 getFileName() + "\"");
         }
 
         if (newSibling.getPreviousSibling() == null) {
             newSibling.setPreviousSibling(this);
             setNextSibling(newSibling);
         } else {
-            throw new DataModelException("New sibling to be added is not atomic, it already has a previous sibling "
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("New sibling to be added is not " +
+                                                 "atomic, it already has a " +
+                                                 "previous sibling " +
+                                                 getName() + " in " +
+                                                 getLineNumber() + " at " +
+                                                 getCharPosition() + " in " +
+                                                 getFileName() + "\"");
         }
 
         if (newSibling.getChild() != null) {
-            throw new DataModelException("Sibling to be added is not atomic, it already has a child "
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("Sibling to be added is not atomic, " +
+                                                 "it already has a child " +
+                                                 getName() + " in " +
+                                                 getLineNumber() + " at " +
+                                                 getCharPosition() + " in " +
+                                                 getFileName() + "\"");
         }
 
         if (newSibling.getNextSibling() != null) {
-            throw new DataModelException("Sibling to be added is not atomic, it already has a next sibling "
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("Sibling to be added is not atomic, " +
+                                                 "it already has a next " +
+                                                 "sibling " + getName() +
+                                                 " in " + getLineNumber() +
+                                                 " at " + getCharPosition() +
+                                                 " in " + getFileName() + "\"");
         }
     }
 
@@ -633,11 +649,10 @@
         YangSchemaNodeContextInfo childSchemaContext =
                 ysnContextInfoMap.get(dataNodeIdentifier);
         if (childSchemaContext == null) {
-            throw new DataModelException("Requested " + dataNodeIdentifier.getName() + "is not child in "
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("Requested " +
+                                                 dataNodeIdentifier.getName() +
+                                                 " is not child in " +
+                                                 getName());
         }
         return childSchemaContext;
     }
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangOutput.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangOutput.java
index d3d9cb7..7ec9dfd 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangOutput.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangOutput.java
@@ -71,7 +71,8 @@
  */
 public abstract class YangOutput
         extends YangNode
-        implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentableNode, YangIsFilterContentNodes {
+        implements YangLeavesHolder, Parsable, CollisionDetector,
+                   YangAugmentableNode, YangIsFilterContentNodes {
 
     private static final long serialVersionUID = 806201612L;
 
@@ -101,23 +102,6 @@
                                     YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
             throws DataModelException {
         getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
-        YangSchemaNodeContextInfo yangSchemaNodeContextInfo1 = new YangSchemaNodeContextInfo();
-        yangSchemaNodeContextInfo1.setSchemaNode(yangSchemaNodeContextInfo.getSchemaNode());
-        yangSchemaNodeContextInfo1.setContextSwitchedNode(this);
-        getParent().addToChildSchemaMap(schemaNodeIdentifier, yangSchemaNodeContextInfo1);
-    }
-
-    @Override
-    public void setNameSpaceAndAddToParentSchemaMap() {
-        // Get parent namespace.
-        String nameSpace = this.getParent().getNameSpace();
-        // Set namespace for self node.
-        setNameSpace(nameSpace);
-        /*
-         * Check if node contains leaf/leaf-list, if yes add namespace for leaf
-         * and leaf list.
-         */
-        setLeafNameSpaceAndAddToParentSchemaMap();
     }
 
     @Override
@@ -127,32 +111,36 @@
     }
 
     @Override
-    public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier, YangSchemaNode yangSchemaNode) {
+    public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier,
+                                     YangSchemaNode yangSchemaNode) {
         // For non data nodes, default child to be added to parent node.
         // TODO
     }
 
     @Override
     public YangSchemaNodeType getYangSchemaNodeType() {
-        return YangSchemaNodeType.YANG_NON_DATA_NODE;
+        return YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
     }
 
     @Override
-    public void detectCollidingChild(String identifierName, YangConstructType dataType)
+    public void detectCollidingChild(String identifierName,
+                                     YangConstructType dataType)
             throws DataModelException {
         // Detect colliding child.
         detectCollidingChildUtil(identifierName, dataType, this);
     }
 
     @Override
-    public void detectSelfCollision(String identifierName, YangConstructType dataType)
+    public void detectSelfCollision(String identifierName,
+                                    YangConstructType dataType)
             throws DataModelException {
         if (getName().equals(identifierName)) {
-            throw new DataModelException("YANG file error: Duplicate identifier detected, same as output \""
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("YANG file error: Duplicate " +
+                                                 "identifier detected, same " +
+                                                 "as output \"" + getName() +
+                                                 " in " + getLineNumber() +
+                                                 " at " + getCharPosition() +
+                                                 " in " + getFileName() + "\"");
         }
     }
 
@@ -229,4 +217,27 @@
             yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
         }
     }
+
+    @Override
+    public void setNameSpaceAndAddToParentSchemaMap() {
+        // Get parent namespace.
+        if (this.getParent() != null) {
+            String nameSpace = this.getParent().getNameSpace();
+            // Set namespace for self node.
+            setNameSpace(nameSpace);
+            // Process addition of leaf to the child schema map of parent.
+            processAdditionOfSchemaNodeToParentMap("output", getNameSpace());
+        }
+        /*
+         * Check if node contains leaf/leaf-list, if yes add namespace for leaf
+         * and leaf list.
+         */
+        if (this instanceof YangLeavesHolder) {
+            ((YangLeavesHolder) this).setLeafNameSpaceAndAddToParentSchemaMap();
+        }
+    }
+        /*
+     * TODO analyze the reason to have RPC name prepended in input name in
+     * output Listener.
+     */
 }
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRpc.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRpc.java
index 68197ce..1ecfdab 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRpc.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRpc.java
@@ -63,7 +63,7 @@
 public abstract class YangRpc
         extends YangNode
         implements YangCommonInfo, Parsable,
-        CollisionDetector, YangIfFeatureHolder {
+                   CollisionDetector, YangIfFeatureHolder {
 
     private static final long serialVersionUID = 806201613L;
 
@@ -96,28 +96,27 @@
     }
 
     @Override
-    public void addToChildSchemaMap(YangSchemaNodeIdentifier schemaNodeIdentifier,
-                                    YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
+    public void addToChildSchemaMap(
+            YangSchemaNodeIdentifier schemaNodeIdentifier,
+            YangSchemaNodeContextInfo yangSchemaNodeContextInfo)
             throws DataModelException {
-        /*
-         * This will maintain all child schema which are there inside input and
-         * output as input/output is non data node.
-         */
         getYsnContextInfoMap().put(schemaNodeIdentifier, yangSchemaNodeContextInfo);
     }
 
     @Override
     public void incrementMandatoryChildCount() {
         /*
-         * This will maintain all mandatory child which are there inside input and
+         * This will maintain all mandatory child which are there inside
+         * input and
          * output as input/output is non data node.
          */
         // TODO
     }
 
     @Override
-    public void addToDefaultChildMap(YangSchemaNodeIdentifier yangSchemaNodeIdentifier,
-                                     YangSchemaNode yangSchemaNode) {
+    public void addToDefaultChildMap(
+            YangSchemaNodeIdentifier yangSchemaNodeIdentifier,
+            YangSchemaNode yangSchemaNode) {
         /*
          * This will maintain all default child which are there inside input and
          * output as input/output is non data node.
@@ -131,21 +130,24 @@
     }
 
     @Override
-    public void detectCollidingChild(String identifierName, YangConstructType dataType)
+    public void detectCollidingChild(String identifierName,
+                                     YangConstructType dataType)
             throws DataModelException {
         // Detect colliding child.
         detectCollidingChildUtil(identifierName, dataType, this);
     }
 
     @Override
-    public void detectSelfCollision(String identifierName, YangConstructType dataType)
+    public void detectSelfCollision(String identifierName,
+                                    YangConstructType dataType)
             throws DataModelException {
         if (getName().equals(identifierName)) {
-            throw new DataModelException("YANG file error: Duplicate input identifier detected, same as rpc \""
-                    + getName() + " in " +
-                    getLineNumber() + " at " +
-                    getCharPosition()
-                    + " in " + getFileName() + "\"");
+            throw new DataModelException("YANG file error: Duplicate input " +
+                                                 "identifier detected, same " +
+                                                 "as rpc \"" + getName() + " " +
+                                                 "in " + getLineNumber() +
+                                                 " at " + getCharPosition() +
+                                                 " in " + getFileName() + "\"");
         }
     }
 
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
index 861f2a1..91df3f7 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangSchemaNode.java
@@ -17,6 +17,7 @@
 package org.onosproject.yangutils.datamodel;
 
 import java.util.Map;
+
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 
 /**
@@ -64,18 +65,21 @@
             throws DataModelException;
 
     /**
-     * Returns map of default child nodes, this is used by YMS to identify whether
+     * Returns map of default child nodes, this is used by YMS to identify
+     * whether
      * in request all default child nodes are available.
      *
      * @param dataNodeIdentifier YANG data node identifier
      * @return map of default child nodes
      */
-    Map<YangSchemaNodeIdentifier, YangSchemaNode> getDefaultChild(YangSchemaNodeIdentifier dataNodeIdentifier);
+    Map<YangSchemaNodeIdentifier, YangSchemaNode> getDefaultChild(
+            YangSchemaNodeIdentifier dataNodeIdentifier);
 
     /**
      * Get Java class's package corresponding to the schema node.
      *
-     * @return java package, it is null, if the Java type is a built in data type
+     * @return java package, it is null, if the Java type is a built in data
+     * type
      */
     String getJavaPackage();
 
@@ -121,11 +125,14 @@
      * @return true if notification is present, false otherwise
      * @throws DataModelException a violation in data model rule
      */
-    boolean isNotificationPresent() throws DataModelException;
+    boolean isNotificationPresent()
+            throws DataModelException;
 
     /**
-     * Returns notification shcema node corresponding to the name of notification
-     * as per the generated code enumeration. This is to be used for notification
+     * Returns notification shcema node corresponding to the name of
+     * notification
+     * as per the generated code enumeration. This is to be used for
+     * notification
      * processing in YMS.
      *
      * @param notificationNameInEnum notification name as per the generated
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/SchemaNodeTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/SchemaNodeTest.java
index 5d77724..a38cf12 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/SchemaNodeTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/SchemaNodeTest.java
@@ -20,14 +20,16 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+
 import org.apache.maven.plugin.MojoExecutionException;
 import org.junit.Test;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.datamodel.YangLeaf;
 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
 import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
 import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
 import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.utils.io.YangPluginConfig;
 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
@@ -36,7 +38,8 @@
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils
+        .deleteDirectory;
 
 /**
  * Test cases for testing YANG schema node.
@@ -48,17 +51,19 @@
     /**
      * Checks method to get schema node from map.
      *
-     * @throws IOException a violation in IO rule
-     * @throws ParserException a violation in parser rule
+     * @throws IOException            a violation in IO rule
+     * @throws ParserException        a violation in parser rule
      * @throws MojoExecutionException a violation in mojo rule
-     * @throws DataModelException a violation in data model rule
+     * @throws DataModelException     a violation in data model rule
      */
     @Test
-    public void processSchemaNodeMap() throws IOException, ParserException,
-            MojoExecutionException, DataModelException {
+    public void processSchemaNodeMap()
+            throws IOException, ParserException,
+                   MojoExecutionException, DataModelException {
 
         String searchDir = "src/test/resources/schemaMap";
-        utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+        utilManager
+                .createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
         utilManager.parseYangFileInfoSet();
         utilManager.createYangNodeSet();
         utilManager.resolveDependenciesUsingLinker();
@@ -66,7 +71,8 @@
         yangPluginConfig.setCodeGenDir("target/schemaMap/");
         utilManager.translateToJava(yangPluginConfig);
 
-        Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+        Iterator<YangNode> yangNodeIterator =
+                utilManager.getYangNodeSet().iterator();
         YangNode rootNode = yangNodeIterator.next();
 
         // Validate the notification enum map
@@ -77,55 +83,101 @@
         assertThat(rootNode.getNotificationSchemaNode("TESTCONTAINER"),
                    is(nullValue()));
 
+        // Validation for RPC input/output node.
+        YangNode yangRpcNode = rootNode.getChild().getNextSibling()
+                .getNextSibling();
+        YangSchemaNodeIdentifier yangInputNode = new YangSchemaNodeIdentifier();
+        yangInputNode.setName("input");
+        yangInputNode.setNameSpace("http://huawei.com");
+        assertThat(yangRpcNode.getChildSchema(yangInputNode).getSchemaNode(),
+                   is(yangRpcNode.getChild()));
+
+        YangSchemaNodeIdentifier yangOutputNode = new
+                YangSchemaNodeIdentifier();
+        yangOutputNode.setName("output");
+        yangOutputNode.setNameSpace("http://huawei.com");
+        assertThat(yangRpcNode.getChildSchema(yangOutputNode).getSchemaNode(),
+                   is(yangRpcNode.getChild().getNextSibling()));
+
+        // Validate the input schema map
+        YangSchemaNode yangInput = yangRpcNode.getChild();
+        YangSchemaNodeIdentifier yangInputLeafNode = new
+                YangSchemaNodeIdentifier();
+        yangInputLeafNode.setName("image-name");
+        yangInputLeafNode.setNameSpace("http://huawei.com");
+        assertThat(yangInput.getChildSchema(yangInputLeafNode),
+                   is(notNullValue()));
+
+        YangSchemaNode yangOutput = yangRpcNode.getChild().getNextSibling();
+        YangSchemaNodeIdentifier yangOutputLeafNode = new
+                YangSchemaNodeIdentifier();
+        yangOutputLeafNode.setName("image-name");
+        yangOutputLeafNode.setNameSpace("http://huawei.com");
+        assertThat(yangOutput.getChildSchema(yangOutputLeafNode),
+                   is(notNullValue()));
+
+        // Validate schema node
         assertThat(rootNode.getYsnContextInfoMap(), is(notNullValue()));
         Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap =
                 rootNode.getYsnContextInfoMap();
-        YangSchemaNodeIdentifier yangSchemaNodeIdentifier = new YangSchemaNodeIdentifier();
+        YangSchemaNodeIdentifier yangSchemaNodeIdentifier =
+                new YangSchemaNodeIdentifier();
         yangSchemaNodeIdentifier.setName("testcontainer");
         yangSchemaNodeIdentifier.setNameSpace("http://huawei.com");
         assertThat(schemaMap.get(yangSchemaNodeIdentifier), is(notNullValue()));
         YangSchemaNodeContextInfo yangSchemaNodeContextInfo =
                 schemaMap.get(yangSchemaNodeIdentifier);
-        assertThat(yangSchemaNodeContextInfo.getSchemaNode(), is(rootNode.getChild()));
+        assertThat(yangSchemaNodeContextInfo.getSchemaNode(),
+                   is(rootNode.getChild()));
 
-        assertThat(rootNode.getChild().getYsnContextInfoMap(), is(notNullValue()));
-        Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap2 = rootNode.getChild()
-                .getYsnContextInfoMap();
+        assertThat(rootNode.getChild().getYsnContextInfoMap(),
+                   is(notNullValue()));
+        Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap2 =
+                rootNode.getChild()
+                        .getYsnContextInfoMap();
         yangSchemaNodeIdentifier.setName("testleaf");
         yangSchemaNodeIdentifier.setNameSpace("http://huawei.com");
-        assertThat(schemaMap2.get(yangSchemaNodeIdentifier), is(notNullValue()));
+        assertThat(schemaMap2.get(yangSchemaNodeIdentifier),
+                   is(notNullValue()));
 
         yangSchemaNodeIdentifier.setName("pretzel");
         yangSchemaNodeIdentifier.setNameSpace("http://huawei.com");
-        assertThat(schemaMap2.get(yangSchemaNodeIdentifier), is(notNullValue()));
+        assertThat(schemaMap2.get(yangSchemaNodeIdentifier),
+                   is(notNullValue()));
 
-        assertThat(rootNode.getChild().getChild().getYsnContextInfoMap(), is(notNullValue()));
+        assertThat(rootNode.getChild().getChild().getYsnContextInfoMap(),
+                   is(notNullValue()));
         Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap3 =
                 rootNode.getChild().getChild()
-                .getYsnContextInfoMap();
+                        .getYsnContextInfoMap();
         yangSchemaNodeIdentifier.setName("pretzel");
         yangSchemaNodeIdentifier.setNameSpace("http://huawei.com");
-        assertThat(schemaMap3.get(yangSchemaNodeIdentifier), is(notNullValue()));
+        assertThat(schemaMap3.get(yangSchemaNodeIdentifier),
+                   is(notNullValue()));
         YangSchemaNodeContextInfo yangSchemaNodeContextInfo3 =
                 schemaMap3.get(yangSchemaNodeIdentifier);
 
-        assertThat(rootNode.getChild().getChild().getChild().getYsnContextInfoMap(),
+        assertThat(rootNode.getChild().getChild().getChild()
+                           .getYsnContextInfoMap(),
                    is(notNullValue()));
         Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> schemaMap4 =
                 rootNode.getChild().getChild().getChild()
-                .getYsnContextInfoMap();
+                        .getYsnContextInfoMap();
         yangSchemaNodeIdentifier.setName("pretzel");
         yangSchemaNodeIdentifier.setNameSpace("http://huawei.com");
-        assertThat(schemaMap4.get(yangSchemaNodeIdentifier), is(notNullValue()));
+        assertThat(schemaMap4.get(yangSchemaNodeIdentifier),
+                   is(notNullValue()));
 
         YangSchemaNodeContextInfo yangSchemaNodeContextInfo2 =
                 schemaMap4.get(yangSchemaNodeIdentifier);
-        List<YangLeaf> yangListOfLeaf = ((YangLeavesHolder) rootNode.getChild().getChild().getChild()).getListOfLeaf();
+        List<YangLeaf> yangListOfLeaf = ((YangLeavesHolder) rootNode.getChild()
+                .getChild().getChild()).getListOfLeaf();
         YangLeaf yangLeaf = yangListOfLeaf.get(0);
         assertThat(yangSchemaNodeContextInfo2.getSchemaNode(), is(yangLeaf));
 
         assertThat(yangSchemaNodeContextInfo3.getSchemaNode(), is(yangLeaf));
-        assertThat(yangSchemaNodeContextInfo3.getContextSwitchedNode(), is(rootNode.getChild().getChild().getChild()));
+        assertThat(yangSchemaNodeContextInfo3.getContextSwitchedNode(),
+                   is(rootNode.getChild().getChild().getChild()));
 
         deleteDirectory("target/schemaMap/");
     }
@@ -133,18 +185,20 @@
     /**
      * Checks that notification map shouldn't be present in other YANG node.
      *
-     * @throws IOException a violation in IO rule
-     * @throws ParserException a violation in parser rule
+     * @throws IOException            a violation in IO rule
+     * @throws ParserException        a violation in parser rule
      * @throws MojoExecutionException a violation in mojo rule
-     * @throws DataModelException a violation in data model rule
+     * @throws DataModelException     a violation in data model rule
      */
     @Test(expected = DataModelException.class)
-    public void processNotificationEnumMapInvalidScenario() throws IOException,
-            ParserException, MojoExecutionException,
-            DataModelException {
+    public void processNotificationEnumMapInvalidScenario()
+            throws IOException,
+                   ParserException, MojoExecutionException,
+                   DataModelException {
 
         String searchDir = "src/test/resources/schemaMap";
-        utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+        utilManager
+                .createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
         utilManager.parseYangFileInfoSet();
         utilManager.createYangNodeSet();
         utilManager.resolveDependenciesUsingLinker();
@@ -152,7 +206,8 @@
         yangPluginConfig.setCodeGenDir("target/schemaMap/");
         utilManager.translateToJava(yangPluginConfig);
 
-        Iterator<YangNode> yangNodeIterator = utilManager.getYangNodeSet().iterator();
+        Iterator<YangNode> yangNodeIterator =
+                utilManager.getYangNodeSet().iterator();
         YangNode rootNode = yangNodeIterator.next();
 
         deleteDirectory("target/schemaMap/");
diff --git a/plugin/src/test/resources/schemaMap/SchemaMap.yang b/plugin/src/test/resources/schemaMap/SchemaMap.yang
index 34c989c..d4c00c7 100644
--- a/plugin/src/test/resources/schemaMap/SchemaMap.yang
+++ b/plugin/src/test/resources/schemaMap/SchemaMap.yang
@@ -22,4 +22,36 @@
             type string;
         }
     }
+
+    rpc activate-software-image {
+        description "description";
+        input {
+            leaf image-name {
+                type string;
+            }
+            list ospf {
+                key "invalid-interval";
+                config true;
+                max-elements 10;
+                min-elements 3;
+                leaf invalid-interval {
+                    type uint16;
+                }
+            }
+            container isis {
+               config true;
+               leaf invalid-interval {
+                   type uint16;
+               }
+           }
+        }
+        output {
+            leaf image-name {
+                type string;
+            }
+            leaf image-value {
+                type string;
+            }
+        }
+    }
 }