Identifier issue fix for module, list, container, leaf, leaf-list, prefix + date agr string for revision fix

Change-Id: Id9d596512f35b54f6359d361402bcd0180b71678
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
index 961e902..eeb85bb 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
@@ -226,7 +226,7 @@
     @Test
     public void processContainerInvalidIdentifier() throws IOException, ParserException {
         thrown.expect(ParserException.class);
-        thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER");
+        thrown.expectMessage("YANG file error : container name 1valid is not valid.");
         YangNode node = manager.getDataModel("src/test/resources/ContainerInvalidIdentifier.yang");
     }
 }
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
index afa48da..43abb45 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
@@ -85,7 +85,7 @@
     @Test
     public void processLeafListInvalidIdentifier() throws IOException, ParserException {
         thrown.expect(ParserException.class);
-        thrown.expectMessage("mismatched input '1invalid-interval' expecting IDENTIFIER");
+        thrown.expectMessage("YANG file error : leaf-list name 1invalid-interval is not valid.");
         YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidIdentifier.yang");
     }
 
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
index 40afc03..554d651 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
@@ -85,7 +85,7 @@
     @Test
     public void processLeafInvalidIdentifier() throws IOException, ParserException {
         thrown.expect(ParserException.class);
-        thrown.expectMessage("mismatched input '1invalid-interval' expecting IDENTIFIER");
+        thrown.expectMessage("YANG file error : leaf name 1invalid-interval is not valid.");
         YangNode node = manager.getDataModel("src/test/resources/LeafInvalidIdentifier.yang");
     }
 
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 aa770a6..99d40dd 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
@@ -205,7 +205,7 @@
     @Test
     public void processListInvalidIdentifier() throws IOException, ParserException {
         thrown.expect(ParserException.class);
-        thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER");
+        thrown.expectMessage("YANG file error : list name 1valid is not valid.");
         YangNode node = manager.getDataModel("src/test/resources/ListInvalidIdentifier.yang");
     }
 }
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java
index ab7242a..66d8e9a 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java
@@ -16,7 +16,9 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.datamodel.YangNodeType;
@@ -35,6 +37,9 @@
 
     private final YangUtilsParserManager manager = new YangUtilsParserManager();
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     /**
      * Checks if module listener updates the data model root node.
      */
@@ -62,4 +67,15 @@
 
         YangNode node = manager.getDataModel("src/test/resources/ModuleWithInvalidIdentifier.yang");
     }
+
+    /**
+     * Checks whether exception is thrown when module length is greater than 64 characters.
+     */
+    @Test
+    public void processModuleInvalidIdentifierLength() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("YANG file error : module name Testttttttttttttttttttttttttttttttttttttttttttttttttttt" +
+                "tttttttttt is greater than 64 characters.");
+        YangNode node = manager.getDataModel("src/test/resources/ModuleInvalidIdentifierLength.yang");
+    }
 }
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PositionListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PositionListenerTest.java
index 7033ddd..e0e2ab0 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PositionListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PositionListenerTest.java
@@ -80,6 +80,45 @@
     }
 
     /**
+     * Checks position value with double quotes.
+     */
+    @Test
+    public void processPositionWithDoubleQuotes() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/PositionWithDoubleQuotes.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("mybits"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("bits"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.BITS));
+        assertThat(((YangBits) leafInfo.getDataType().getDataTypeExtendedInfo()).getBitsName(),
+                is("mybits"));
+
+        Set<YangBit> bitSet = ((YangBits) leafInfo.getDataType().getDataTypeExtendedInfo()).getBitSet();
+        for (YangBit tmp : bitSet) {
+            if (tmp.getBitName().equals("disable-nagle")) {
+                assertThat(tmp.getPosition(), is(0));
+            } else if (tmp.getBitName().equals("auto-sense-speed")) {
+                assertThat(tmp.getPosition(), is(1));
+            } else if (tmp.getBitName().equals("Ten-Mb-only")) {
+                assertThat(tmp.getPosition(), is(2));
+            }
+        }
+    }
+
+    /**
      * Checks explicit value and auto generated value.
      */
     @Test
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java
index b090bd0..3d7ff5c 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java
@@ -56,6 +56,16 @@
     }
 
     /**
+     * Checks prefix value with double quotes.
+     */
+    @Test
+    public void processPrefixWithDoubleQuotes() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/PrefixWithDoubleQuotes.yang");
+        assertThat(((YangModule) node).getPrefix(), is("On"));
+    }
+
+    /**
      * Checks that prefix should be present just once.
      */
     @Test(expected = ParserException.class)
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java
index 7ebcc85..7f19219 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java
@@ -53,21 +53,29 @@
     }
 
     /**
-     * Checks revision date should not be in quotes inside include.
+     * Checks revision date in quotes inside include.
      */
-    @Test(expected = ParserException.class)
+    @Test
     public void processRevisionDateInQuotesAtInclude() throws IOException, ParserException {
 
         YangNode node = manager.getDataModel("src/test/resources/RevisionDateInQuotesAtInclude.yang");
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is("2015-02-03"));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is("2014-02-03"));
     }
 
     /**
-     * Checks revision date should not be in quotes inside import.
+     * Checks revision date in quotes inside import.
      */
-    @Test(expected = ParserException.class)
+    @Test
     public void processRevisionDateInQuotesAtImport() throws IOException, ParserException {
 
         YangNode node = manager.getDataModel("src/test/resources/RevisionDateInQuotesAtImport.yang");
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is("2015-02-03"));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is("2014-02-03"));
     }
 
     /**
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
index 07df80c..324fe1ed 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
@@ -56,6 +56,18 @@
     }
 
     /**
+     * Checks version in double quotes.
+     */
+    @Test
+    public void processValidVersionWithDoubleQuotes() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ValidVersionWithDoubleQuotes.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getVersion(), is((byte) 1));
+    }
+
+    /**
      * Checks if version which is optional paramater is not present.
      */
     @Test
diff --git a/utils/yangutils/src/test/resources/ModuleInvalidIdentifierLength.yang b/utils/yangutils/src/test/resources/ModuleInvalidIdentifierLength.yang
new file mode 100644
index 0000000..fac16bc
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleInvalidIdentifierLength.yang
@@ -0,0 +1,5 @@
+module Testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/utils/yangutils/src/test/resources/PositionWithDoubleQuotes.yang b/utils/yangutils/src/test/resources/PositionWithDoubleQuotes.yang
new file mode 100644
index 0000000..0c9d358
--- /dev/null
+++ b/utils/yangutils/src/test/resources/PositionWithDoubleQuotes.yang
@@ -0,0 +1,18 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+     leaf mybits {
+         type bits {
+             bit disable-nagle {
+                 position "0";
+             }
+             bit auto-sense-speed {
+                 position "1";
+             }
+             bit Ten-Mb-only {
+                 position "2";
+             }
+         }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/PrefixWithDoubleQuotes.yang b/utils/yangutils/src/test/resources/PrefixWithDoubleQuotes.yang
new file mode 100644
index 0000000..e9590f1
--- /dev/null
+++ b/utils/yangutils/src/test/resources/PrefixWithDoubleQuotes.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix "On";
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/utils/yangutils/src/test/resources/ValidVersionWithDoubleQuotes.yang b/utils/yangutils/src/test/resources/ValidVersionWithDoubleQuotes.yang
new file mode 100644
index 0000000..a2c718a
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ValidVersionWithDoubleQuotes.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version "1";
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}