[ONOS-3880, 3881] Yang Listener for Module and Sub-Module

Change-Id: Iee75c3e04af9b66ebc38acb3396aa4c54af5a268
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java
new file mode 100644
index 0000000..f2415b2
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+
+/**
+ * Test cases for testing base rule listener functionality.
+ */
+public class BaseFileListenerTest {
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    /**
+     * Checks for exception if stack of parsable data is not empty at the entry
+     * of yang base rule.
+     */
+    @Test
+    public void processYangFileEntryNonEmptyStack() {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Internal parser error detected: Invalid holder for yangbase before processing.");
+
+        YangModule tmpModule = new YangModule();
+        TreeWalkListener listener = new TreeWalkListener();
+        listener.getParsedDataStack().push(tmpModule);
+        GeneratedYangParser.YangfileContext ctx = null;
+        BaseFileListener.processYangFileEntry(listener, ctx);
+    }
+
+    /**
+     * Checks that exception shouldn't be generated if stack of parsable data is
+     * empty at the entry of yang base rule.
+     */
+    @Test
+    public void processYangFileEntryEmptyStack() {
+
+        TreeWalkListener listener = new TreeWalkListener();
+        GeneratedYangParser.YangfileContext ctx = null;
+        BaseFileListener.processYangFileEntry(listener, ctx);
+    }
+
+    /**
+     * Checks that exception should be generated if stack of parsable data is
+     * not empty at the exit of yang base rule.
+     */
+    @Test
+    public void processYangFileExitEmptyStack() {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Internal parser error detected: Missing holder at yangbase after processing.");
+
+        TreeWalkListener listener = new TreeWalkListener();
+        GeneratedYangParser.YangfileContext ctx = null;
+        BaseFileListener.processYangFileExit(listener, ctx);
+    }
+
+    /**
+     * Checks that exception shouldn't be generated if stack of parsable data is
+     * empty at the exit of yang base rule.
+     */
+    @Test
+    public void processYangFileExitNonEmptyStack() {
+
+        TreeWalkListener listener = new TreeWalkListener();
+        GeneratedYangParser.YangfileContext ctx = null;
+        BaseFileListener.processYangFileEntry(listener, ctx);
+    }
+
+    /**
+     * Checks that after popping out the parsable node from stack it should be
+     * empty.
+     */
+    @Test
+    public void processYangFileExitStackErrorExtraEntryTest() {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Internal parser error detected: Invalid holder for yangbase after processing.");
+
+        YangModule tmpModule = new YangModule();
+        YangModule tmpModule2 = new YangModule();
+        TreeWalkListener listener = new TreeWalkListener();
+        listener.getParsedDataStack().push(tmpModule);
+        listener.getParsedDataStack().push(tmpModule2);
+        GeneratedYangParser.YangfileContext ctx = null;
+        BaseFileListener.processYangFileExit(listener, ctx);
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java
new file mode 100644
index 0000000..0bc6586
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.CustomExceptionMatcher;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing belongsto listener functionality.
+ */
+public class BelongstoListenerTest {
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if mandatory belongsto parameter "prefix" is not present.
+     */
+    @Test
+    public void processBelongsToWithoutPrefix() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("mismatched input '}' expecting 'prefix'");
+        thrown.expect(CustomExceptionMatcher.errorLocation(4, 0));
+        YangNode node = manager.getDataModel("src/test/resources/BelongsToWithoutPrefix.yang");
+    }
+
+    /**
+     * Checks that prefix must be present only once in belongsto.
+     */
+    @Test
+    public void processBelongsToDualPrefix() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("mismatched input 'prefix' expecting '}'");
+        thrown.expect(CustomExceptionMatcher.errorLocation(5, 0));
+        YangNode node = manager.getDataModel("src/test/resources/BelongsToDualPrefix.yang");
+    }
+
+    /**
+     * Checks if belongsto listener updates the date model tree.
+     */
+    @Test
+    public void processBelongsToWithPrefix() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/BelongsToWithPrefix.yang");
+        YangSubModule yangNode = (YangSubModule) node;
+        assertThat(yangNode.getBelongsTo().getBelongsToModuleName(), is("ONOS"));
+    }
+
+    /**
+     * Checks if mandatory parameter "belongsto" is present.
+     */
+    @Test
+    public void processSubModuleWithoutBelongsTo() throws IOException, ParserException {
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("mismatched input '}' expecting 'belongs-to'");
+        thrown.expect(CustomExceptionMatcher.errorLocation(3, 0));
+        YangNode node = manager.getDataModel("src/test/resources/SubModuleWithoutBelongsTo.yang");
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java
new file mode 100644
index 0000000..9791ba3
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing contact listener functionality.
+ */
+public class ContactListenerTest {
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if contact listener updates the data model tree.
+     */
+    @Test
+    public void processContactValidEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ContactValidEntry.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getContact(), is("\"WG List:  <mailto:spring@ietf.org>\nEditor:    "
+                + "Stephane Litkowski\n           " + "<mailto:stephane.litkowski@orange.com>\""));
+    }
+
+    /**
+     * Checks that contact must be present only once.
+     */
+    @Test(expected = ParserException.class)
+    public void processContactDualEntryTest() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ContactDualEntryTest.yang");
+
+    }
+
+    /**
+     * Checks if contact is not empty.
+     */
+    @Test(expected = ParserException.class)
+    public void processContactWithEmptyString() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ContactWithEmptyString.yang");
+    }
+
+    /**
+     * Checks that contact must be present after namespace.
+     */
+    @Test(expected = ParserException.class)
+    public void processContactIncorrectOrder() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ContactIncorrectOrder.yang");
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java
new file mode 100644
index 0000000..d003cc2
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing import listener functionality.
+ */
+public class ImportListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if mandatory parameter prefix is present in import.
+     */
+    @Test(expected = ParserException.class)
+    public void processImportWithoutPrefix() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ImportWithoutPrefix.yang");
+    }
+
+    /**
+     * Checks that prefix must be present only once in import.
+     */
+    @Test(expected = ParserException.class)
+    public void processImportWithDualPrefix() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ImportWithDualPrefix.yang");
+    }
+
+    /**
+     * Checks for the correct order of prefix in import.
+     */
+    @Test(expected = ParserException.class)
+    public void processImportInvalidOrder() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ImportInvalidOrder.yang");
+    }
+
+    /**
+     * Checks if import listener updates the data model tree.
+     */
+    @Test
+    public void processImportValidEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ImportValidEntry.yang");
+
+        // Checks for the revision value in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getRevision(), is("2015-02-03"));
+        // Checks for the prefix id in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getPrefixId(), is("On2"));
+        // Checks for the module name in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getModuleName(), is("ietf"));
+    }
+
+    /**
+     * Checks if optional parameter revision is not mandatory in import.
+     */
+    @Test
+    public void processImportWithoutRevision() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ImportWithoutRevision.yang");
+
+        // Checks for the prefix id in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getPrefixId(), is("On2"));
+        // Checks for the module name in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getModuleName(), is("ietf"));
+    }
+
+    /**
+     * Checks if multiple imports are allowed.
+     */
+    @Test()
+    public void processImportMultipleInstance() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ImportMultipleInstance.yang");
+
+        // Checks for the prefix id in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getPrefixId(), is("On2"));
+        // Checks for the module name in data model tree.
+        assertThat(((YangModule) node).getImportList().get(0).getModuleName(), is("ietf"));
+
+        // Checks for the prefix id in data model tree.
+        assertThat(((YangModule) node).getImportList().get(1).getPrefixId(), is("On3"));
+        // Checks for the module name in data model tree.
+        assertThat(((YangModule) node).getImportList().get(1).getModuleName(), is("itut"));
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java
new file mode 100644
index 0000000..313f5e9
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing include listener functionality.
+ */
+public class IncludeListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if include listener with ; is valid and updates the data
+     * model tree.
+     */
+    @Test
+    public void processIncludeWithStmtend() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/IncludeWithStmtend.yang");
+
+        // Checks for the sub module name in data model tree.
+        assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+    }
+
+    /**
+     * Checks if include listener with braces and without revision date is valid
+     * and updates the data model tree.
+     */
+    @Test
+    public void processIncludeWithEmptyBody() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/IncludeWithEmptyBody.yang");
+
+        // Checks for the sub module name in data model tree.
+        assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+    }
+
+    /**
+     * Checks if include listener with braces and with revision date is valid
+     * and updates the data model tree.
+     */
+    @Test
+    public void processIncludeWithDate() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/IncludeWithDate.yang");
+
+        // Checks for the sub module name in data model tree.
+        assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+    }
+
+    /**
+     * Checks if include has more than one occurrence.
+     */
+    @Test
+    public void processIncludeMultiInstance() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/IncludeMultiInstance.yang");
+
+        // Checks for the sub module name in data model tree.
+        assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+        assertThat(((YangModule) node).getIncludeList().get(1).getSubModuleName(), is("sdn"));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is("2014-02-03"));
+    }
+
+    /**
+     * Checks if include and import can come in any order.
+     */
+    @Test
+    public void processIncludeImportAnyOrder() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/IncludeImportAnyOrder.yang");
+
+        // Checks for the sub module name in data model tree.
+        assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+        assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+        assertThat(((YangModule) node).getIncludeList().get(1).getSubModuleName(), is("sdn"));
+        assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is("2014-02-03"));
+    }
+
+    /**
+     * Checks if syntax of Include is not correct.
+     */
+    @Test(expected = ParserException.class)
+    public void processIncludeInvalidSyntax() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/IncludeInvalidSyntax.yang");
+    }
+
+    /**
+     * Checks if syntax of revision date in Include is not correct.
+     */
+    @Test(expected = ParserException.class)
+    public void processIncludeInvalidDateSyntax() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/IncludeInvalidDateSyntax.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
new file mode 100644
index 0000000..ab7242a
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing module listener functionality.
+ */
+public class ModuleListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if module listener updates the data model root node.
+     */
+    @Test
+    public void processModuleValidEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ModuleValidEntry.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"));
+    }
+
+    /**
+     * Checks if module name is set correctly.
+     */
+    @Test(expected = ParserException.class)
+    public void processModuleInvalidEntryTest() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ModuleWithInvalidIdentifier.yang");
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java
new file mode 100644
index 0000000..50f8f54
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing namespace listener functionality.
+ */
+public class NamespaceListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks that value of namespace shouldn't have invalid spaces.
+     */
+    @Test(expected = ParserException.class)
+    public void processNamespaceWithInvalidSpaces() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NamespaceWithInvalidSpaces.yang");
+    }
+
+    /**
+     * Checks if namespace with double quotes is allowed.
+     */
+    @Test()
+    public void processNamespaceInDoubleQuotes() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NamespaceInDoubleQuotes.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getNameSpace().getUri(), is("\"urn:ietf:params:xml:ns:yang:ietf-ospf\""));
+    }
+
+    /**
+     * Checks if namespace without double quotes is allowed.
+     */
+    @Test()
+    public void processNamespaceWithoutQuotes() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NamespaceWithoutQuotes.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getNameSpace().getUri(), is("urn:ietf:params:xml:ns:yang:ietf-ospf"));
+    }
+
+    /**
+     * Checks if namespace is present only once.
+     */
+    @Test(expected = ParserException.class)
+    public void processNamespaceDualEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NamespaceDualEntry.yang");
+    }
+
+    /**
+     * Checks if mandatory parameter namespace is present.
+     */
+    @Test(expected = ParserException.class)
+    public void processNamespaceNoEntryTest() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/NamespaceNoEntryTest.yang");
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java
new file mode 100644
index 0000000..2c71e17
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing organization listener functionality.
+ */
+public class OrganizationListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if organization listener updates the data model tree.
+     */
+    @Test
+    public void processOrganizationValidEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/OrganizationValidEntry.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getOrganization(), is("\"IETF SPRING Working Group\""));
+    }
+
+    /**
+     * Checks that organization must be present only once.
+     */
+    @Test(expected = ParserException.class)
+    public void processOrganizationDualEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/OrganizationDualEntry.yang");
+    }
+
+    /**
+     * Checks if organization entry syntax is correct.
+     */
+    @Test(expected = ParserException.class)
+    public void processOrganizationMissingValue() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/OrganizationMissingValue.yang");
+    }
+
+    /**
+     * Checks if organization and namespace is present in correct order.
+     */
+    @Test(expected = ParserException.class)
+    public void processOrganizationInvalidOrder() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/OrganizationInvalidOrder.yang");
+    }
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..b090bd0
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing prefix listener functionality.
+ */
+public class PrefixListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if value of prefix is correct.
+     */
+    @Test(expected = ParserException.class)
+    public void processPrefixInvalidValue() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/PrefixInvalidValue.yang");
+    }
+
+    /**
+     * Checks if prefix listener updates the data model tree.
+     */
+    @Test
+    public void processPrefixValidEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/PrefixValidEntry.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getPrefix(), is("On"));
+    }
+
+    /**
+     * Checks that prefix should be present just once.
+     */
+    @Test(expected = ParserException.class)
+    public void processPrefixDualEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/PrefixDualEntry.yang");
+    }
+
+    /**
+     * Checks if prefix syntax is followed.
+     */
+    @Test(expected = ParserException.class)
+    public void processPrefixMissingValue() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/PrefixMissingValue.yang");
+    }
+
+    /**
+     * Checks that exception should be reported if prefix is missing.
+     */
+    @Test(expected = ParserException.class)
+    public void processPrefixOrder() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/PrefixOrder.yang");
+    }
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..df56913
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing revision date listener functionality.
+ */
+public class RevisionDateListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if revision date syntax is correct in include.
+     */
+    @Test(expected = ParserException.class)
+    public void processRevisionDateInvalidSyntaxAtInclude() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionDateInvalidSyntaxAtInclude.yang");
+    }
+
+    /**
+     * Checks if revision date syntax is correct in import.
+     */
+    @Test(expected = ParserException.class)
+    public void processRevisionDateInvalidSyntaxAtImport() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionDateInvalidSyntaxAtImport.yang");
+    }
+
+    /**
+     * Checks revision date should not be in quotes inside include.
+     */
+    @Test(expected = ParserException.class)
+    public void processRevisionDateInQuotesAtInclude() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionDateInQuotesAtInclude.yang");
+    }
+
+    /**
+     * Checks revision date should not be in quotes inside import.
+     */
+    @Test(expected = ParserException.class)
+    public void processRevisionDateInQuotesAtImport() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionDateInQuotesAtImport.yang");
+    }
+
+    /**
+     * Checks if revision date follows YYYY-MM-DD format.
+     */
+    @Test(expected = ParserException.class)
+    public void processRevisionDateInvalidFormat() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionDateInvalidFormat.yang");
+    }
+
+    /**
+     * Checks if revision date listener updates the data model tree.
+     */
+    @Test
+    public void processRevisionDateValidEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionDateValidEntry.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"));
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
new file mode 100644
index 0000000..8226442
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing revision listener functionality.
+ */
+public class RevisionListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if revision doesn't have optional parameters "revision and
+     * description".
+     */
+    @Test
+    public void processRevisionNoOptionalParameter() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionNoOptionalParameter.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getRevision().getRevDate(), is("2016-02-03"));
+    }
+
+    /**
+     * Checks if the syntax of revision is correct.
+     */
+    @Test(expected = ParserException.class)
+    public void processRevisionInValidSyntax() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionInValidSyntax.yang");
+    }
+
+    /**
+     * Checks if the correct order is followed.
+     */
+    @Test(expected = ParserException.class)
+    public void processRevisionInValidOrder() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/RevisionInValidOrder.yang");
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
new file mode 100644
index 0000000..c3028de
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing submodule listener functionality.
+ */
+public class SubModuleListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if the sub module listeners updates the data model tree.
+     */
+    @Test
+    public void processSubModuleValidEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SubModuleValidEntry.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangSubModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.SUB_MODULE_NODE));
+
+        YangSubModule yangNode = (YangSubModule) node;
+        // Check whether the module name is set correctly.
+        assertThat(yangNode.getName(), is("Test"));
+        // Checks for the version value in data model tree.
+        assertThat(yangNode.getVersion(), is((byte) 1));
+        // Checks identifier of belongsto in data model tree.
+        assertThat(yangNode.getBelongsTo().getBelongsToModuleName(), is("ONOS"));
+        // Checks for the version value in data model tree.
+        assertThat(yangNode.getBelongsTo().getPrefix(), is("On1"));
+    }
+
+    /**
+     * Checks if the yang version and belongs to can come in any order in sub
+     * module.
+     */
+    @Test
+    public void processSubModuleOrder() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SubModuleOrder.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangSubModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.SUB_MODULE_NODE));
+
+        YangSubModule yangNode = (YangSubModule) node;
+        // Check whether the module name is set correctly.
+        assertThat(yangNode.getName(), is("Test"));
+        // Checks for the version value in data model tree.
+        assertThat(yangNode.getVersion(), is((byte) 1));
+        // Checks identifier of belongsto in data model tree.
+        assertThat(yangNode.getBelongsTo().getBelongsToModuleName(), is("ONOS"));
+        // Checks for the version value in data model tree.
+        assertThat(yangNode.getBelongsTo().getPrefix(), is("On1"));
+    }
+
+    /**
+     * Checks if yang version is optional.
+     */
+    @Test
+    public void processSubModuleWithoutVersion() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SubModuleWithoutVersion.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangSubModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.SUB_MODULE_NODE));
+
+        YangSubModule yangNode = (YangSubModule) node;
+        // Check whether the module name is set correctly.
+        assertThat(yangNode.getName(), is("Test"));
+        // Checks identifier of belongsto in data model tree.
+        assertThat(yangNode.getBelongsTo().getBelongsToModuleName(), is("ONOS"));
+        // Checks for the version value in data model tree.
+        assertThat(yangNode.getBelongsTo().getPrefix(), is("On1"));
+    }
+
+    /**
+     * Checks if sub module name is correct.
+     */
+    @Test(expected = ParserException.class)
+    public void processSubModuleInvalidName() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SubModuleInvalidName.yang");
+    }
+
+    /**
+     * Checks if sub module has invalid modules construct eg namespace.
+     */
+    @Test(expected = ParserException.class)
+    public void processSubModuleWithNamespace() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SubModuleWithNamespace.yang");
+    }
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..2338604
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing version listener functionality.
+ */
+public class VersionListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks if value of version is correct.
+     */
+    @Test(expected = ParserException.class)
+    public void processVersionInvalidValue() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/VersionInvalidValue.yang");
+    }
+
+    /**
+     * Checks if version listener updates the data model tree.
+     */
+    @Test
+    public void processVersionValidEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/VersionValidEntry.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
+    public void processVersionNotPresent() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/VersionNotPresent.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getVersion(), is((byte) 0));
+    }
+
+    /**
+     * Checks that version should be present only once.
+     */
+    @Test(expected = ParserException.class)
+    public void processVersionDualEntry() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/VersionDualEntry.yang");
+    }
+
+    /**
+     * Checks if version can appear in any order in module header.
+     */
+    @Test
+    public void processVersionOrder() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/VersionOrder.yang");
+
+        // Checks for the version value in data model tree.
+        assertThat(((YangModule) node).getVersion(), is((byte) 1));
+    }
+
+    /**
+     * Checks if sytax of version entry is not correct.
+     */
+    @Test(expected = ParserException.class)
+    public void processVersionInvalidSyntax() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/VersionInvalidSyntax.yang");
+    }
+}
\ No newline at end of file