[ONOS-4350] Inter Jar dependency implementation and code restructuring.
Change-Id: Iacac75e4187aed93ce1754c170a9c19707e5b8c3
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java
new file mode 100644
index 0000000..0f0a514
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/ietfyang/IetfYangFileTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.ietfyang;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yangutils.linker.impl.YangLinkerManager;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.plugin.manager.YangUtilManager;
+import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+
+import java.io.IOException;
+
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Test cases for testing IETF YANG files.
+ */
+public class IetfYangFileTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ * Reference: https://datatracker.ietf.org/doc/draft-zha-l3sm-l3vpn-onos-deployment
+ */
+ @Test
+ public void l3vpnserviceyang()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/ietfyang/l3vpnservice";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ String userDir = System.getProperty("user.dir");
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/");
+
+ utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/ietfyang/");
+ }
+
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java
new file mode 100644
index 0000000..fd7b8ad
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterFileLinkingTest.java
@@ -0,0 +1,741 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.linker;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.ListIterator;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
+import org.onosproject.yangutils.datamodel.YangGrouping;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangUses;
+import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
+import org.onosproject.yangutils.linker.impl.YangLinkerManager;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.plugin.manager.YangFileInfo;
+import org.onosproject.yangutils.plugin.manager.YangUtilManager;
+import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Test cases for testing inter file linking.
+ */
+public class InterFileLinkingTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
+
+ /**
+ * Checks inter file type linking.
+ */
+ @Test
+ public void processInterFileTypeLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfiletype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+
+ Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+
+ if (yangFileInfo.getRootNode().getName().equals("module1")) {
+ selfNode = yangFileInfo.getRootNode();
+ refNode = yangFileInfoIterator.next().getRootNode();
+ } else {
+ refNode = yangFileInfo.getRootNode();
+ selfNode = yangFileInfoIterator.next().getRootNode();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks inter file uses linking.
+ */
+ @Test
+ public void processInterFileUsesLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileuses";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+
+ Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+
+ if (yangFileInfo.getRootNode().getName().equals("module1")) {
+ selfNode = yangFileInfo.getRootNode();
+ refNode = yangFileInfoIterator.next().getRootNode();
+ } else {
+ refNode = yangFileInfo.getRootNode();
+ selfNode = yangFileInfoIterator.next().getRootNode();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the sibling of module's child.
+ assertThat((refNode.getChild() instanceof YangGrouping), is(true));
+
+ YangGrouping grouping = (YangGrouping) refNode.getChild();
+ leafIterator = grouping.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is module's child.
+ assertThat((yangNode.getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) yangNode.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+// leafIterator = yangNode.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under module.
+// assertThat(leafInfo.getName(), is("hello"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ }
+
+ /**
+ * Checks inter file type linking with include list.
+ */
+ @Test
+ public void processInterFileTypeLinkingWithIncludeList()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfiletypewithinclude";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet());
+
+ // Add reference to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangFileInfoSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+
+ Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+
+ if (yangFileInfo.getRootNode().getName().equals("module1")) {
+ selfNode = yangFileInfo.getRootNode();
+ refNode = yangFileInfoIterator.next().getRootNode();
+ } else {
+ refNode = yangFileInfo.getRootNode();
+ selfNode = yangFileInfoIterator.next().getRootNode();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks inter file uses linking with include list.
+ */
+ @Test
+ public void processInterFileUsesLinkingWithInclude()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileuseswithinclude";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
+ // Carry out linking of sub module with module.
+ yangLinkerManager.linkSubModulesToParentModule(utilManager.getYangFileInfoSet());
+
+ // Add reference to include list.
+ yangLinkerManager.addRefToYangFilesIncludeList(utilManager.getYangFileInfoSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+
+ Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+
+ if (yangFileInfo.getRootNode().getName().equals("module1")) {
+ selfNode = yangFileInfo.getRootNode();
+ refNode = yangFileInfoIterator.next().getRootNode();
+ } else {
+ refNode = yangFileInfo.getRootNode();
+ selfNode = yangFileInfoIterator.next().getRootNode();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((selfNode instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the sibling of module's child.
+ assertThat((refNode.getChild() instanceof YangGrouping), is(true));
+
+ YangGrouping grouping = (YangGrouping) refNode.getChild();
+ leafIterator = grouping.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is module's child.
+ assertThat((yangNode.getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) yangNode.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+// leafIterator = yangNode.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under module.
+// assertThat(leafInfo.getName(), is("hello"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ }
+
+ /**
+ * Checks inter file type linking with revision.
+ */
+ @Test
+ public void processInterFileTypeLinkingWithRevision()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfiletypewithrevision";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+
+ Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+
+ if (yangFileInfo.getRootNode().getName().equals("module1")) {
+ selfNode = yangFileInfo.getRootNode();
+ refNode = yangFileInfoIterator.next().getRootNode();
+ } else {
+ refNode = yangFileInfo.getRootNode();
+ selfNode = yangFileInfoIterator.next().getRootNode();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks inter file type linking with revision in name.
+ */
+ @Test
+ public void processInterFileTypeLinkingWithRevisionInName()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfiletypewithrevisioninname";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+
+ YangNode refNode = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+
+ Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+
+ if (yangFileInfo.getRootNode().getName().equals("module1")) {
+ selfNode = yangFileInfo.getRootNode();
+ refNode = yangFileInfoIterator.next().getRootNode();
+ } else {
+ refNode = yangFileInfo.getRootNode();
+ selfNode = yangFileInfoIterator.next().getRootNode();
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("module1"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks hierarchical inter file type linking.
+ */
+ @Test
+ public void processHierarchicalInterFileTypeLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/hierarchicalinterfiletype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+
+ YangNode refNode1 = null;
+ YangNode refNode2 = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+
+ for (YangFileInfo yangFile : utilManager.getYangFileInfoSet()) {
+ if (yangFile.getRootNode().getName().equals("ietf-network-topology")) {
+ selfNode = yangFile.getRootNode();
+ } else if (yangFile.getRootNode().getName().equals("ietf-network")) {
+ refNode1 = yangFile.getRootNode();
+ } else {
+ refNode2 = yangFile.getRootNode();
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network-topology"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("source-node"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("node-id"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) refNode1.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void processHierarchicalIntraWithInterFileTypeLinking()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/hierarchicalintrawithinterfiletype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+
+ YangNode refNode1 = null;
+ YangNode selfNode = null;
+
+ // Create YANG node set
+ yangLinkerManager.createYangNodeSet(utilManager.getYangFileInfoSet());
+
+ // Add references to import list.
+ yangLinkerManager.addRefToYangFilesImportList(utilManager.getYangFileInfoSet());
+
+ // Carry out inter-file linking.
+ yangLinkerManager.processInterFileLinking(utilManager.getYangFileInfoSet());
+
+ for (YangFileInfo yangFile : utilManager.getYangFileInfoSet()) {
+ if (yangFile.getRootNode().getName().equals("ietf-network")) {
+ selfNode = yangFile.getRootNode();
+ } else if (yangFile.getRootNode().getName().equals("ietf-inet-types")) {
+ refNode1 = yangFile.getRootNode();
+ }
+ }
+
+ // Check whether the data model tree returned is of type module.
+ assertThat(selfNode instanceof YangModule, is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(selfNode.getNodeType(), is(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) selfNode;
+ assertThat(yangNode.getName(), is("ietf-network"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("node-ref"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("node-id"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) selfNode.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void interFileWithUsesReferringType()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfilewithusesreferringtype";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ String userDir = System.getProperty("user.dir");
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/");
+
+ utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/interfilewithusesreferringtype/");
+
+ }
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void file1UsesFile2TypeDefFile3Type()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/file1UsesFile2TypeDefFile3Type";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ String userDir = System.getProperty("user.dir");
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
+
+ utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/file1UsesFile2TypeDefFile3Type/");
+
+ }
+
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void interFileIetf()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/interfileietf";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ String userDir = System.getProperty("user.dir");
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/interfileietf/");
+
+ utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/interfileietf/");
+
+ }
+
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void usesInContainer()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/usesInContainer";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ String userDir = System.getProperty("user.dir");
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/usesInContainer/");
+
+ utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/usesInContainer/");
+
+ }
+
+
+ /**
+ * Checks hierarchical intra with inter file type linking.
+ */
+ @Test
+ public void groupingNodeSameAsModule()
+ throws IOException, ParserException, MojoExecutionException {
+
+ String searchDir = "src/test/resources/groupingNodeSameAsModule";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ String userDir = System.getProperty("user.dir");
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/");
+
+ utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/groupingNodeSameAsModule/");
+
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterJarLinkingTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterJarLinkingTest.java
new file mode 100644
index 0000000..39b03fe
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/InterJarLinkingTest.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.linker;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
+import org.onosproject.yangutils.datamodel.YangGrouping;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.plugin.manager.YangFileInfo;
+import org.onosproject.yangutils.plugin.manager.YangUtilManager;
+import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deSerializeDataModel;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.parseJarFile;
+
+/**
+ * Unit test case for inter-jar linker.
+ */
+public class InterJarLinkingTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+
+ private static final String TARGET = "target/interJarFileLinking";
+ private static final String SEARCH_DIR_FOR_YANG_FILES = "src/test/resources/interJarFileLinking/yangFiles";
+ private static final String SEARCH_DIR_FOR_SINGLE_JAR_FILES = "src/test/resources/interJarFileLinking/"
+ + "jarFiles/single";
+ private static final String SEARCH_DIR_FOR_MULTI_JAR_FILES = "src/test/resources/interJarFileLinking/"
+ + "jarFiles/multi";
+
+ /**
+ * Unit test case for a single jar dependency.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processSingleJarLinking()
+ throws IOException, MojoExecutionException {
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(SEARCH_DIR_FOR_YANG_FILES));
+
+ int size1 = utilManager.getYangFileInfoSet().size();
+
+ for (String file : getListOfTestJar(SEARCH_DIR_FOR_SINGLE_JAR_FILES)) {
+ addInterJarRootNodes(file);
+ }
+
+ utilManager.parseYangFileInfoSet();
+
+ utilManager.resolveDependenciesUsingLinker();
+
+ Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+
+ int size2 = utilManager.getYangFileInfoSet().size();
+ assertThat(true, is(size1 != size2));
+ assertThat(true, is(yangFileInfo.getRootNode().getName().equals("port-pair")));
+
+ deleteDirectory(TARGET);
+
+ }
+
+ /**
+ * Unit test case for a multiple jar dependency.
+ *
+ * @throws IOException when fails to do IO operations
+ * @throws MojoExecutionException when fails to do mojo operations
+ */
+ @Test
+ public void processMultipleJarLinking()
+ throws IOException, MojoExecutionException {
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(SEARCH_DIR_FOR_YANG_FILES));
+
+ int size1 = utilManager.getYangFileInfoSet().size();
+
+ for (String file : getListOfTestJar(SEARCH_DIR_FOR_MULTI_JAR_FILES)) {
+ addInterJarRootNodes(file);
+ }
+
+ utilManager.parseYangFileInfoSet();
+
+ utilManager.resolveDependenciesUsingLinker();
+
+ Iterator<YangFileInfo> yangFileInfoIterator = utilManager.getYangFileInfoSet().iterator();
+
+ YangFileInfo yangFileInfo = yangFileInfoIterator.next();
+
+ int size2 = utilManager.getYangFileInfoSet().size();
+ assertThat(true, is(size1 != size2));
+ assertThat(true, is(yangFileInfo.getRootNode().getName().equals("port-pair")));
+
+ yangFileInfo = yangFileInfoIterator.next();
+ assertThat(true, is(yangFileInfo.getRootNode().getName().equals("flow-classifier")));
+
+ /*
+ * grouping flow-classifier {
+ * container flow-classifier {
+ * leaf id {
+ * type flow-classifier-id;
+ * }
+ *
+ * leaf tenant-id {
+ * type port-pair:tenant-id;
+ * }
+ * .
+ * .
+ * .
+ *
+ */
+
+ YangNode node = yangFileInfo.getRootNode();
+ node = node.getChild();
+ while (node != null) {
+ if (node instanceof YangGrouping) {
+ break;
+ }
+ node = node.getNextSibling();
+ }
+
+ node = node.getChild();
+ ListIterator<YangLeaf> leafIterator = ((YangContainer) node).getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("id"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("flow-classifier-id"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("tenant-id"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(true, is(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef()
+ .getName().equals("tenant-id")));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ deleteDirectory(TARGET);
+ }
+
+ /**
+ * Returns list of test jar files.
+ *
+ * @param searchdir search directory
+ * @return list of test jar files
+ */
+ private List<String> getListOfTestJar(String searchdir) {
+ List<String> jarFiles = new ArrayList<>();
+
+ File directory = new File(searchdir + "/");
+ File[] files = directory.listFiles();
+
+ for (File file : files) {
+ jarFiles.add(file.toString());
+ }
+
+ return jarFiles;
+ }
+
+ /**
+ * Adds data model nodes of jar to file info set.
+ *
+ * @param jarFile jar file name
+ * @throws IOException when fails to do IO operations
+ */
+ private void addInterJarRootNodes(String jarFile) throws IOException {
+ try {
+ List<YangNode> interJarResolvedNodes = deSerializeDataModel(parseJarFile(jarFile, TARGET));
+
+ for (YangNode node : interJarResolvedNodes) {
+ YangFileInfo dependentFileInfo = new YangFileInfo();
+ dependentFileInfo.setRootNode(node);
+ dependentFileInfo.setForTranslator(false);
+ dependentFileInfo.setYangFileName(node.getName());
+ utilManager.getYangFileInfoSet().add(dependentFileInfo);
+ }
+ } catch (IOException e) {
+ throw new IOException("failed to resolve in interjar scenario.");
+ }
+ }
+
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
new file mode 100644
index 0000000..9fba40e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
@@ -0,0 +1,565 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.linker;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED;
+import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
+
+/**
+ * Test cases for testing "type" intra file linking.
+ */
+public class IntraFileTypeLinkingTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks self resolution when typedef and leaf using type are siblings.
+ */
+ @Test
+ public void processSelfResolutionWhenTypeAndTypedefAtRootLevel()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are at different
+ * level where typedef is at the root.
+ */
+ @Test
+ public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are at different
+ * level where typedef is at the root and defined after parent holder
+ * of type.
+ */
+ @Test
+ public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild().getNextSibling()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are at different
+ * level where typedef is at the level of root+1 and defined after parent
+ * holder of type.
+ */
+ @Test
+ public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks self resolution when typedef hierarchical references are present.
+ */
+ @Test
+ public void processSelfFileLinkingWithTypdefHierarchicalReference()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangList.getChild()));
+ assertThat(leafInfo.getDataType().getResolvableStatus(),
+ is(RESOLVED));
+
+ YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+ assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
+ is(RESOLVED));
+
+ YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+ assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
+ is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks self resolution when typedef hierarchical references are present
+ * with last type is unresolved.
+ */
+ @Test
+ public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangList.getChild()));
+ assertThat(leafInfo.getDataType().getResolvableStatus(),
+ is(INTRA_FILE_RESOLVED));
+
+ YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+ assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
+ is(INTRA_FILE_RESOLVED));
+
+ YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+ assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
+ is(INTRA_FILE_RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(nullValue()));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks self resolution when type uses prefix of self module.
+ */
+ @Test
+ public void processSelfFileLinkingWithTypeWithSelfModulePrefix()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangList.getChild()));
+ assertThat(leafInfo.getDataType().getResolvableStatus(),
+ is(RESOLVED));
+
+ YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+ assertThat(((YangDerivedInfo<?>) typeDef1.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+ assertThat(typeDef1.getTypeDefBaseType().getResolvableStatus(),
+ is(RESOLVED));
+
+ YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+ assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
+ is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Checks self resolution when some type uses prefix of self module
+ * some uses external prefix.
+ */
+ @Test
+ public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix()
+ throws IOException, ParserException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) yangList.getChild()));
+ assertThat(leafInfo.getDataType().getResolvableStatus(),
+ is(INTRA_FILE_RESOLVED));
+
+ YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+ YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+ assertThat(((YangDerivedInfo<?>) typeDef2.getTypeDefBaseType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+ assertThat(typeDef2.getTypeDefBaseType().getResolvableStatus(),
+ is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(nullValue()));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+
+ /**
+ * Check self resolution when type referred typedef is not available in
+ * file.
+ */
+ @Test(expected = LinkerException.class)
+ public void processSelfResolutionWhenTypeReferredTypedefNotDefined()
+ throws IOException, LinkerException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang");
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are at different
+ * level where typedef is is not an ancestor of type.
+ */
+ @Test(expected = LinkerException.class)
+ public void processSelfFileLinkingTypedefNotFound()
+ throws IOException, LinkerException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang");
+ }
+
+ /**
+ * Checks hierarchical self resolution with self resolution failure scenario.
+ */
+ @Test(expected = LinkerException.class)
+ public void processSelfFileLinkingWithHierarchicalTypeFailureScenario()
+ throws IOException, LinkerException {
+
+ YangNode node =
+ manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang");
+ }
+
+ /**
+ * Checks self resolution when typedef and leaf using type are siblings for binary type.
+ */
+ @Test
+ public void processSelfResolutionWhenTypeAndTypedefAtRootLevelForBinary()
+ throws IOException, ParserException {
+
+ YangNode node
+ = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevelForBinary.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(MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("ospf"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("typedef14"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("type14"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(BINARY));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
new file mode 100644
index 0000000..e960d62
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/IntraFileUsesLinkingTest.java
@@ -0,0 +1,756 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.linker;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangGrouping;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangUses;
+import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing uses intra file linking.
+ */
+public class IntraFileUsesLinkingTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks self resolution when grouping and uses are siblings.
+ * Grouping followed by uses.
+ */
+ @Test
+ public void processSelfResolutionWhenUsesAndGroupingAtRootLevel()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.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;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the sibling of module's child.
+ assertThat((yangNode.getChild().getNextSibling() instanceof YangGrouping), is(true));
+
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+ leafIterator = grouping.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is module's child.
+ assertThat((yangNode.getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) yangNode.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+// leafIterator = yangNode.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under module.
+// assertThat(leafInfo.getName(), is("hello"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ }
+
+ /**
+ * Checks self resolution when grouping and uses are siblings.
+ * Grouping has a child node.
+ */
+ @Test
+ public void processSelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel(
+ "src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.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;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the sibling of module's child.
+ assertThat((yangNode.getChild().getNextSibling() instanceof YangGrouping), is(true));
+
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getNextSibling();
+ leafIterator = grouping.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("treat"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether container is the child of grouping.
+ assertThat((grouping.getChild() instanceof YangContainer), is(true));
+ YangContainer container = (YangContainer) grouping.getChild();
+
+ // Check whether the container name is set correctly which is under grouping.
+ assertThat(container.getName(), is("test"));
+
+ leafIterator = container.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under container which is under grouping.
+ assertThat(leafInfo.getName(), is("leaf2"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is module's child.
+ assertThat((yangNode.getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) yangNode.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+// leafIterator = yangNode.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under module.
+// assertThat(leafInfo.getName(), is("treat"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+// // Check whether container is the child of module.
+// assertThat((grouping.getNextSibling() instanceof YangContainer), is(true));
+// container = (YangContainer) grouping.getNextSibling();
+//
+// // Check whether the container name is set correctly which is under module.
+// assertThat(container.getName(), is("test"));
+//
+// leafIterator = container.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under container which is under module.
+// assertThat(leafInfo.getName(), is("leaf2"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ }
+
+ /**
+ * Checks self resolution when grouping in rpc and uses in output of the same rpc.
+ * Uses is followed by grouping.
+ */
+ @Test
+ public void processSelfResolutionGroupingInRpcAndUsesInOutput()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionGroupingInRpcAndUsesInOutput.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("rock"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the child of rpc.
+ assertThat((yangNode.getChild().getChild() instanceof YangGrouping), is(true));
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getChild();
+
+ // Check whether the grouping name is set correctly.
+ assertThat(grouping.getName(), is("hello"));
+
+ // Check whether list is the child of grouping.
+ assertThat((grouping.getChild() instanceof YangList), is(true));
+ YangList yangListNode = (YangList) grouping.getChild();
+
+ // Check whether the list name is set correctly.
+ assertThat(yangListNode.getName(), is("valid"));
+
+ leafIterator = yangListNode.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under list which is under grouping.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+
+ // Check whether uses is input's child.
+ assertThat((yangNode.getChild().getChild().getNextSibling().getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) yangNode.getChild().getChild().getNextSibling().getChild();
+
+ // Check whether uses get resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+// // Check whether list is the sibling of uses which has been deep copied from grouping.
+// assertThat((yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling() instanceof YangList),
+// is(true));
+// YangList yangList = (YangList) yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling();
+//
+// // Check whether the list name is set correctly.
+// assertThat(yangList.getName(), is("valid"));
+//
+// leafIterator = yangList.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under list which is deep copied.
+// assertThat(leafInfo.getName(), is("invalid-interval"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+// assertThat(leafInfo.getUnits(), is("\"seconds\""));
+// assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+//
+// // Check whether uses is output's child.
+// assertThat((yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild() instanceof YangUses),
+// is(true));
+// YangUses usesInOuput = (YangUses) yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild();
+//
+// // Check whether uses get resolved.
+// assertThat(usesInOuput.getResolvableStatus(),
+// is(ResolvableStatus.RESOLVED));
+//
+// // Check whether list is the sibling of uses which has been deep copied from grouping.
+// assertThat((yangNode.getChild().getChild().getNextSibling().getChild().getNextSibling() instanceof YangList),
+// is(true));
+//
+// YangList yangListInOutput = (YangList) yangNode.getChild().getChild().getNextSibling().getNextSibling()
+// .getChild().getNextSibling();
+//
+// // Check whether the list name is set correctly.
+// assertThat(yangListInOutput.getName(), is("valid"));
+//
+// leafIterator = yangListInOutput.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under list which is deep copied.
+// assertThat(leafInfo.getName(), is("invalid-interval"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+// assertThat(leafInfo.getUnits(), is("\"seconds\""));
+// assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks the failure scenario when uses is referring to its own grouping directly.
+ */
+ @Test
+ public void processSelfResolutionGroupingReferencingItselfFailureScenerio()
+ throws IOException {
+
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: Duplicate input identifier detected, same as leaf \"zip-code\"");
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang");
+
+ }
+
+ /**
+ * Checks the when multiple uses are present and are referred to the grouping at different levels.
+ */
+ @Test
+ public void processSelfResolutionGroupingWithMultipleUses()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionGroupingWithMultipleUses.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;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the child of container.
+ assertThat((yangNode.getChild().getChild() instanceof YangGrouping), is(true));
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getChild();
+
+ // Check whether the grouping name is set correctly.
+ assertThat(grouping.getName(), is("endpoint"));
+
+ // Check whether uses is endpoint-grouping's child.
+ assertThat((grouping.getChild() instanceof YangUses), is(true));
+ YangUses firstUses = (YangUses) grouping.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(firstUses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check whether container is the sibling of uses.
+ assertThat((firstUses.getNextSibling() instanceof YangContainer), is(true));
+ YangContainer yangContainer = (YangContainer) firstUses.getNextSibling();
+
+ // Check whether the container name is set correctly.
+ assertThat(yangContainer.getName(), is("design"));
+
+// leafIterator = yangContainer.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under design-container.
+// assertThat(leafInfo.getName(), is("ink"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
+
+ // Check whether uses is design-container's child.
+ assertThat((yangContainer.getChild() instanceof YangUses), is(true));
+ YangUses secondUses = (YangUses) yangContainer.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(secondUses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check whether container is the sibling of uses.
+ assertThat((secondUses.getNextSibling() instanceof YangContainer), is(true));
+ YangContainer yangContainer2 = (YangContainer) secondUses.getNextSibling();
+ assertThat(yangContainer2.getName(), is("correct"));
+
+ leafIterator = yangContainer2.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under correct-container.
+ assertThat(leafInfo.getName(), is("newone"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether uses is correct container's child.
+ assertThat((yangContainer2.getChild() instanceof YangUses), is(true));
+ YangUses thirdUses = (YangUses) yangContainer2.getChild();
+
+ // Check whether uses get resolved.
+ assertThat(thirdUses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+// // Check whether container is the sibling of uses.
+// assertThat((thirdUses.getNextSibling() instanceof YangContainer), is(true));
+//
+// YangContainer yangContainer3 = (YangContainer) thirdUses.getNextSibling();
+// assertThat(yangContainer3.getName(), is("value"));
+//
+// leafIterator = yangContainer3.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under container
+// // which has been deep copied from grouping.
+// assertThat(leafInfo.getName(), is("zip-code"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+//
+// // Check whether uses is the sibling of container-design.
+// assertThat((yangContainer.getNextSibling() instanceof YangUses), is(true));
+// YangUses fourthUses = (YangUses) yangContainer.getNextSibling();
+//
+// // Check whether uses get resolved.
+// assertThat(fourthUses.getResolvableStatus(),
+// is(ResolvableStatus.RESOLVED));
+//
+// // Check whether uses is the sibling of previous uses.
+// assertThat((fourthUses.getNextSibling() instanceof YangUses), is(true));
+// YangUses fifthUses = (YangUses) fourthUses.getNextSibling();
+//
+// // Check whether uses get resolved.
+// assertThat(fifthUses.getResolvableStatus(),
+// is(ResolvableStatus.RESOLVED));
+//
+// // Check whether list is the sibling of uses.
+// assertThat((fifthUses.getNextSibling() instanceof YangList), is(true));
+// YangList yangList = (YangList) fifthUses.getNextSibling();
+// assertThat(yangList.getName(), is("valid"));
+//
+// leafIterator = yangList.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under list which has been deep copied from grouping.
+// assertThat(leafInfo.getName(), is("invalid-interval"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+// assertThat(leafInfo.getUnits(), is("\"seconds\""));
+// assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+//
+// // Check whether typedef is the sibling of list.
+// assertThat((yangList.getNextSibling() instanceof YangTypeDef), is(true));
+// YangTypeDef yangTypeDef = (YangTypeDef) yangList.getNextSibling();
+// assertThat(yangTypeDef.getName(), is("my-type"));
+//
+// leafIterator = grouping.getListOfLeaf().listIterator();
+// leafInfo = leafIterator.next();
+//
+// // Check whether the information in the leaf is correct under grouping.
+// assertThat(leafInfo.getName(), is("zip-code"));
+// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+//
+// // Check whether uses is endpoint-grouping's sibling.
+// assertThat((grouping.getNextSibling() instanceof YangUses), is(true));
+// YangUses endpointUses = (YangUses) grouping.getNextSibling();
+//
+// // Check whether uses get resolved.
+// assertThat(endpointUses.getResolvableStatus(),
+// is(ResolvableStatus.RESOLVED));
+//
+// assertThat((endpointUses.getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling()
+// .getNextSibling() instanceof YangUses), is(true));
+//
+// YangUses yangUsesInEndpoint = (YangUses) endpointUses.getNextSibling().getNextSibling().getNextSibling()
+// .getNextSibling().getNextSibling().getNextSibling();
+// assertThat(yangUsesInEndpoint.getResolvableStatus(),
+// is(ResolvableStatus.RESOLVED));
+//
+// assertThat((yangUsesInEndpoint.getNextSibling() instanceof YangContainer), is(true));
+// YangContainer yangContainerInEndPoint = (YangContainer) yangUsesInEndpoint.getNextSibling();
+//
+// assertThat(yangContainerInEndPoint.getName(), is("design"));
+ }
+
+ /**
+ * Checks the failure scenario when uses is present under the same node many times.
+ */
+ @Test
+ public void processSelfResolutionGroupingHavingSameUsesManyTimes()
+ throws IOException, ParserException {
+
+ thrown.expect(ParserException.class);
+ thrown.expectMessage(
+ "YANG file error: Duplicate input identifier detected, same as uses \"failure\"");
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang");
+ }
+
+ /**
+ * Checks the rpc having both typedef and grouping.
+ * It also checks that the grouping under different nodes will not give any problem in resolving uses.
+ */
+ @Test
+ public void processSelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel(
+ "src/test/resources/SelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode.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("rock"));
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+
+ // Check whether grouping is the child of input.
+ assertThat((yangNode.getChild().getChild().getChild() instanceof YangGrouping), is(true));
+ YangGrouping groupingUnderInput = (YangGrouping) yangNode.getChild().getChild().getChild();
+
+ // Check whether the grouping name is set correctly.
+ assertThat(groupingUnderInput.getName(), is("creative"));
+
+ leafIterator = groupingUnderInput.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("carry"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ // Check whether grouping is the child of output.
+ assertThat((yangNode.getChild().getChild().getNextSibling().getChild() instanceof YangGrouping), is(true));
+ YangGrouping grouping = (YangGrouping) yangNode.getChild().getChild().getNextSibling().getChild();
+ assertThat(grouping.getName(), is("creative"));
+
+ // Check whether typedef is the sibling of grouping.
+ assertThat((grouping.getNextSibling() instanceof YangTypeDef), is(true));
+
+ YangTypeDef typedef = (YangTypeDef) grouping.getNextSibling();
+ assertThat(typedef.getName(), is("my-type"));
+
+ // Check whether uses is the sibling of typedef.
+ assertThat((typedef.getNextSibling() instanceof YangUses), is(true));
+
+ // Check whether uses get resolved.
+ YangUses uses = (YangUses) typedef.getNextSibling();
+ assertThat(uses.getName(), is("creative"));
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+ }
+
+ /**
+ * Checks the failure scenario when uses is cannot resolve its grouping.
+ */
+ @Test
+ public void processSelfResolutionNestedGroupingWithUnresolvedUses()
+ throws IOException, LinkerException {
+
+ thrown.expect(LinkerException.class);
+ thrown.expectMessage(
+ "YANG file error: Unable to find base grouping for given uses");
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfResolutionNestedGroupingWithUnresolvedUses.yang");
+ }
+
+ /**
+ * Checks self resolution when typedef hierarchical references are present
+ * with last type is unresolved.
+ */
+ @Test
+ public void processSelfFileLinkingWithGroupingHierarchicalRefUnresolved()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithGroupingHierarchicalRefUnresolved.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"));
+
+ // Check whether container is the sibling of grouping.
+ assertThat((yangNode.getChild().getNextSibling() instanceof YangContainer), is(true));
+ YangContainer containerWithUses = (YangContainer) yangNode.getChild().getNextSibling();
+ assertThat(containerWithUses.getName(), is("test"));
+
+ // Check whether uses is the child of container.
+ assertThat((containerWithUses.getChild() instanceof YangUses), is(true));
+ YangUses uses = (YangUses) containerWithUses.getChild();
+ assertThat(uses.getName(), is("create"));
+
+ // Check whether uses is getting resolved.
+ assertThat(uses.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check whether grouping is the child of module.
+ assertThat((yangNode.getChild() instanceof YangGrouping), is(true));
+ YangGrouping groupingWithUses = (YangGrouping) yangNode.getChild();
+ assertThat(groupingWithUses.getName(), is("create"));
+
+ // Check whether uses with prefix from from other file, is the child of grouping.
+ assertThat((groupingWithUses.getChild() instanceof YangUses), is(true));
+ YangUses uses1 = (YangUses) groupingWithUses.getChild();
+ assertThat(uses1.getName(), is("valid"));
+
+ // Check whether this uses is getting intra-file-resolved.
+ assertThat(uses1.getResolvableStatus(),
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
+ }
+
+ /**
+ * Checks self resolution when uses has prefix of self module.
+ */
+ @Test
+ public void processSelfFileLinkingWithGroupingWithSelfModulePrefix()
+ throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.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"));
+
+ // Check whether container is the sibling of grouping.
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ // Check whether list is the child of container.
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ // Check whether uses is the child of list.
+ assertThat((yangList.getChild() instanceof YangUses), is(true));
+ YangUses yangUses1 = (YangUses) yangList.getChild();
+ assertThat(yangUses1.getName(), is("FirstClass"));
+
+ // Check whether uses is getting resolved.
+ assertThat(yangUses1.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check whether grouping is the sibling of uses.
+ YangGrouping yangGrouping1 = (YangGrouping) yangUses1.getNextSibling();
+ assertThat(yangGrouping1.getName(), is("FirstClass"));
+
+ // Check whether uses is the child of grouping.
+ YangUses yangUses2 = (YangUses) yangGrouping1.getChild();
+ assertThat(yangUses2.getName(), is("PassingClass"));
+
+ // Check the uses gets resolved.
+ assertThat(yangUses2.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check whether grouping is the sibling of list.
+ YangGrouping yangGrouping2 = (YangGrouping) yangList.getNextSibling();
+ assertThat(yangGrouping2.getName(), is("PassingClass"));
+
+ // Check uses is the child of that grouping which has prefix of the same module.
+ YangUses yangUses3 = (YangUses) yangGrouping2.getChild();
+ assertThat(yangUses3.getName(), is("Percentage"));
+
+ // Check uses is getting resolved.
+ assertThat(yangUses3.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check grouping is the child of module.
+ YangGrouping yangGrouping3 = (YangGrouping) node.getChild();
+
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+ leafIterator = yangGrouping3.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+
+ }
+
+ /**
+ * Checks self resolution when some type uses prefix of self module
+ * some uses external prefix.
+ */
+ @Test
+ public void processSelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix()
+ throws IOException, ParserException {
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.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"));
+
+ // Check whether container is the sibling of grouping.
+ YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+ // Check whether list is the child of container.
+ YangList yangList = (YangList) yangContainer.getChild();
+
+ // Check whether uses is the child of list.
+ assertThat((yangList.getChild() instanceof YangUses), is(true));
+ YangUses yangUses1 = (YangUses) yangList.getChild();
+ assertThat(yangUses1.getName(), is("FirstClass"));
+
+ // Check whether uses is getting resolved.
+ assertThat(yangUses1.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check whether grouping is the sibling of uses.
+ YangGrouping yangGrouping1 = (YangGrouping) yangUses1.getNextSibling();
+ assertThat(yangGrouping1.getName(), is("FirstClass"));
+
+ // Check whether uses is the child of grouping which has prefix from other module.
+ YangUses yangUses2 = (YangUses) yangGrouping1.getChild();
+ assertThat(yangUses2.getName(), is("PassingClass"));
+
+ // Check whether uses gets intra-file-resolved.
+ assertThat(yangUses2.getResolvableStatus(),
+ is(ResolvableStatus.INTRA_FILE_RESOLVED));
+
+ // Check whether grouping is the sibling of list.
+ YangGrouping yangGrouping2 = (YangGrouping) yangList.getNextSibling();
+ assertThat(yangGrouping2.getName(), is("PassingClass"));
+
+ // Check uses is the child of that grouping which has prefix of the same module.
+ YangUses yangUses3 = (YangUses) yangGrouping2.getChild();
+ assertThat(yangUses3.getName(), is("Percentage"));
+
+ // Check uses is getting resolved.
+ assertThat(yangUses3.getResolvableStatus(),
+ is(ResolvableStatus.RESOLVED));
+
+ // Check grouping is the child of module.
+ YangGrouping yangGrouping3 = (YangGrouping) node.getChild();
+ ListIterator<YangLeaf> leafIterator;
+ YangLeaf leafInfo;
+ leafIterator = yangGrouping3.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+
+ // Check whether the information in the leaf is correct under grouping.
+ assertThat(leafInfo.getName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ }
+
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/RestrictionResolutionTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/RestrictionResolutionTest.java
new file mode 100644
index 0000000..211f924
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/linker/RestrictionResolutionTest.java
@@ -0,0 +1,835 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.linker;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.ListIterator;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangPatternRestriction;
+import org.onosproject.yangutils.datamodel.YangRangeInterval;
+import org.onosproject.yangutils.datamodel.YangRangeRestriction;
+import org.onosproject.yangutils.datamodel.YangStringRestriction;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt32;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
+import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
+
+/**
+ * Test cases for testing restriction resolution.
+ */
+public final class RestrictionResolutionTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks length restriction in typedef.
+ */
+ @Test
+ public void processLengthRestrictionInTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthRestrictionInTypedef.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+
+ /**
+ * Checks length restriction in referred type.
+ */
+ @Test
+ public void processLengthRestrictionInRefType()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthRestrictionInRefType.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(notNullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+
+ /**
+ * Checks length restriction in typedef and in type with stricter value.
+ */
+ @Test
+ public void processLengthRestrictionInTypedefAndTypeValid()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthRestrictionInTypedefAndTypeValid.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(notNullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval1.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval1.getEndValue()).getValue(), is(BigInteger.valueOf(20)));
+
+ YangRangeInterval rangeInterval2 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval2.getStartValue()).getValue(), is(BigInteger.valueOf(201)));
+ assertThat(((YangUint64) rangeInterval2.getEndValue()).getValue(), is(BigInteger.valueOf(300)));
+ }
+
+ /**
+ * Checks length restriction in typedef and in type with not stricter value.
+ */
+ @Test(expected = LinkerException.class)
+ public void processLengthRestrictionInTypedefAndTypeInValid()
+ throws IOException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/LengthRestrictionInTypedefAndTypeInValid.yang");
+ }
+
+ /**
+ * Checks range restriction in typedef.
+ */
+ @Test
+ public void processRangeRestrictionInTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInTypedef.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval1.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval1.getEndValue()).getValue(), is(4));
+
+ YangRangeInterval rangeInterval2 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval2.getStartValue()).getValue(), is(10));
+ assertThat(((YangInt32) rangeInterval2.getEndValue()).getValue(), is(20));
+ }
+
+ /**
+ * Checks range restriction in referred type.
+ */
+ @Test
+ public void processRangeRestrictionInRefType()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefType.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(notNullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval1.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval1.getEndValue()).getValue(), is(4));
+
+ YangRangeInterval rangeInterval2 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval2.getStartValue()).getValue(), is(10));
+ assertThat(((YangInt32) rangeInterval2.getEndValue()).getValue(), is(20));
+ }
+
+ /**
+ * Checks range restriction in typedef and stricter in referred type.
+ */
+ @Test
+ public void processRangeRestrictionInRefTypeAndTypedefValid()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefTypeAndTypedefValid.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(INT32));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(notNullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval1.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval1.getEndValue()).getValue(), is(4));
+
+ YangRangeInterval rangeInterval2 = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval2.getStartValue()).getValue(), is(10));
+ assertThat(((YangInt32) rangeInterval2.getEndValue()).getValue(), is(20));
+ }
+
+ /**
+ * Checks range restriction in typedef and not stricter in referred type.
+ */
+ @Test(expected = LinkerException.class)
+ public void processRangeRestrictionInRefTypeAndTypedefInValid()
+ throws IOException, ParserException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang");
+ }
+
+ /**
+ * Checks range restriction for string.
+ */
+ @Test(expected = ParserException.class)
+ public void processRangeRestrictionInString()
+ throws IOException, ParserException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInString.yang");
+ }
+
+ /**
+ * Checks range restriction for string in referred type.
+ */
+ @Test(expected = LinkerException.class)
+ public void processRangeRestrictionInStringInRefType()
+ throws IOException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/RangeRestrictionInStringInRefType.yang");
+ }
+
+ /**
+ * Checks pattern restriction in typedef.
+ */
+ @Test
+ public void processPatternRestrictionInTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternRestrictionInTypedef.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks pattern restriction in referred type.
+ */
+ @Test
+ public void processPatternRestrictionInRefType()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternRestrictionInRefType.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks pattern restriction in referred type and typedef.
+ */
+ @Test
+ public void processPatternRestrictionInRefTypeAndTypedef()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternRestrictionInRefTypeAndTypedef.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-zA-Z]"));
+
+ String pattern2 = patternListIterator.next();
+
+ assertThat(pattern2, is("[0-9]"));
+ }
+
+ /**
+ * Checks multiple pattern restriction in referred type and typedef.
+ */
+ @Test
+ public void processMultiplePatternRestriction()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternRestrictionInRefTypeAndTypedef.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-z]"));
+
+ String pattern2 = patternListIterator.next();
+
+ assertThat(pattern2, is("[A-Z]"));
+
+ String pattern3 = patternListIterator.next();
+
+ assertThat(pattern3, is("[0-9]"));
+
+ String pattern4 = patternListIterator.next();
+
+ assertThat(pattern4, is("[\\n]"));
+ }
+
+ /**
+ * Checks multiple pattern and length restriction in referred type and
+ * typedef.
+ */
+ @Test
+ public void processMultiplePatternAndLengthRestriction()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternAndLengthRestriction.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(notNullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ // Check for pattern restriction.
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-z]"));
+
+ String pattern2 = patternListIterator.next();
+
+ assertThat(pattern2, is("[A-Z]"));
+
+ String pattern3 = patternListIterator.next();
+
+ assertThat(pattern3, is("[0-9]"));
+
+ String pattern4 = patternListIterator.next();
+
+ assertThat(pattern4, is("[\\n]"));
+
+ // Check for length restriction.
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval1.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval1.getEndValue()).getValue(), is(BigInteger.valueOf(20)));
+
+ YangRangeInterval rangeInterval2 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval2.getStartValue()).getValue(), is(BigInteger.valueOf(201)));
+ assertThat(((YangUint64) rangeInterval2.getEndValue()).getValue(), is(BigInteger.valueOf(300)));
+ }
+
+ /**
+ * Checks multiple pattern and length restriction in referred type and
+ * typedef.
+ */
+ @Test
+ public void processMultiplePatternAndLengthRestrictionValid()
+ throws IOException, ParserException, DataModelException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternAndLengthRestrictionValid.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(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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(DERIVED));
+
+ assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+ is((YangTypeDef) node.getChild()));
+
+ assertThat(leafInfo.getDataType().getResolvableStatus(), is(RESOLVED));
+
+ YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ // Check for the effective built-in type.
+ assertThat(derivedInfo.getEffectiveBuiltInType(), is(STRING));
+
+ // Check for the restriction.
+ assertThat(derivedInfo.getLengthRestrictionString(), is(notNullValue()));
+ assertThat(derivedInfo.getRangeRestrictionString(), is(nullValue()));
+ assertThat(derivedInfo.getPatternRestriction(), is(notNullValue()));
+ assertThat(derivedInfo.getResolvedExtendedInfo(), is(notNullValue()));
+
+ // Check for the restriction value.
+ YangStringRestriction stringRestriction = (YangStringRestriction) derivedInfo.getResolvedExtendedInfo();
+
+ // Check for pattern restriction.
+ YangPatternRestriction patternRestriction = stringRestriction.getPatternRestriction();
+ ListIterator<String> patternListIterator = patternRestriction.getPatternList().listIterator();
+ String pattern1 = patternListIterator.next();
+
+ assertThat(pattern1, is("[a-z]"));
+
+ String pattern2 = patternListIterator.next();
+
+ assertThat(pattern2, is("[A-Z]"));
+
+ String pattern3 = patternListIterator.next();
+
+ assertThat(pattern3, is("[0-9]"));
+
+ String pattern4 = patternListIterator.next();
+
+ assertThat(pattern4, is("[\\n]"));
+
+ // Check for length restriction.
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval1 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval1.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval1.getEndValue()).getValue(), is(BigInteger.valueOf(20)));
+
+ YangRangeInterval rangeInterval2 = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval2.getStartValue()).getValue(), is(BigInteger.valueOf(100)));
+ assertThat(((YangUint64) rangeInterval2.getEndValue()).getValue(),
+ is(new BigInteger("18446744073709551615")));
+ }
+
+ /**
+ * Checks multiple pattern and length restriction in referred type and
+ * typedef invalid scenario.
+ */
+ @Test(expected = LinkerException.class)
+ public void processMultiplePatternAndLengthRestrictionInValid()
+ throws IOException, DataModelException {
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternAndLengthRestrictionInValid.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/CustomExceptionMatcher.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/CustomExceptionMatcher.java
new file mode 100644
index 0000000..44d0c67
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/CustomExceptionMatcher.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl;
+
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+
+/**
+ * ExpectedException framework can use the Hamcrest matcher's to test
+ * custom/extended exceptions. This class extends the type safe matcher to
+ * define the custom exception matcher.
+ */
+public final class CustomExceptionMatcher extends TypeSafeMatcher<ParserException> {
+
+ private int actualLine;
+ private final int expectedLine;
+ private int actualCharPosition;
+ private final int expectedCharPosition;
+
+ /**
+ * Customized exception matcher to match error location.
+ *
+ * @param line error line
+ * @param charPosition error character position
+ * @return customized exception matcher to match error location
+ */
+ public static CustomExceptionMatcher errorLocation(int line, int charPosition) {
+ return new CustomExceptionMatcher(line, charPosition);
+ }
+
+ private CustomExceptionMatcher(int expectedLine, int expectedCharPosition) {
+ this.expectedLine = expectedLine;
+ this.expectedCharPosition = expectedCharPosition;
+ }
+
+ @Override
+ protected boolean matchesSafely(final ParserException exception) {
+ actualLine = exception.getLineNumber();
+ actualCharPosition = exception.getCharPositionInLine();
+ return ((actualLine == expectedLine) && (actualCharPosition == expectedCharPosition));
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(" Error reported location ")
+ .appendText("Line " + actualLine + ", " + "CharPosition " + actualCharPosition)
+ .appendText(" instead of expected ")
+ .appendText("Line " + expectedLine + ", " + "CharPosition " + expectedCharPosition);
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/TreeWalkListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/TreeWalkListenerTest.java
new file mode 100644
index 0000000..1056d98
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/TreeWalkListenerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl;
+
+import java.io.IOException;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+
+/**
+ * Test cases for testing tree walk listener functionality.
+ */
+public class TreeWalkListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * Checks whether exception is thrown for ordered statement.
+ */
+ @Test
+ public void processOrderedByStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : \"ordered-by\" is not supported in current version, please check wiki" +
+ " for YANG utils road map.");
+ manager.getDataModel("src/test/resources/OrderedByStatement.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown for anyxml statement.
+ */
+ @Test
+ public void processAnyXmlStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : \"anyxml\" is not supported.");
+ manager.getDataModel("src/test/resources/AnyxmlStatement.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when extra brace is added in the EOF.
+ */
+ @Test
+ public void processFileWithExtraBrace() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '}' expecting <EOF>");
+ manager.getDataModel("src/test/resources/ProcessFileWithExtraBrace.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf is given after module ends.
+ */
+ @Test
+ public void processFileWithExtraLeaf() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leaf' expecting <EOF>");
+ manager.getDataModel("src/test/resources/ProcessFileWithExtraLeaf.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when extra brace is added in between the EOF.
+ */
+ @Test
+ public void processFileWithExtraBraceInBetween() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'container' expecting <EOF>");
+ manager.getDataModel("src/test/resources/ProcessFileWithExtraBraceInBetween.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManagerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManagerTest.java
new file mode 100644
index 0000000..9b3effc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/YangUtilsParserManagerTest.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * Test case for testing YANG utils parser manager.
+ */
+public class YangUtilsParserManagerTest {
+
+ YangUtilsParserManager manager = new YangUtilsParserManager();
+ File file;
+ BufferedWriter out;
+
+ @Before
+ public void setUp() throws Exception {
+ file = new File("demo.yang");
+ out = new BufferedWriter(new FileWriter(file));
+ }
+ @After
+ public void tearDown() throws Exception {
+ file.delete();
+ }
+
+ /**
+ * This test case checks whether the null pointer exception is generated
+ * when the input YANG file is null.
+ */
+ @Test(expected = NullPointerException.class)
+ public void getDataModelNullFileTest() throws IOException, ParserException {
+ YangUtilsParserManager manager = new YangUtilsParserManager();
+ YangNode node = manager.getDataModel(null);
+ }
+
+ /**
+ * This test case checks whether the io exception is generated
+ * when the input YANG file is non existent.
+ */
+ @Test(expected = ParserException.class)
+ public void getDataModelNonExistentFileTest() throws IOException, ParserException {
+
+ YangUtilsParserManager manager = new YangUtilsParserManager();
+ YangNode node = manager.getDataModel("nonexistent.yang");
+ }
+
+ /**
+ * This test case checks if the input YANG file is correct no exception
+ * should be generated.
+ */
+ @Test
+ public void getDataModelCorrectFileTest() throws IOException, ParserException {
+
+ out.write("module ONOS {\n");
+ out.write("yang-version 1;\n");
+ out.write("namespace urn:ietf:params:xml:ns:yang:ietf-ospf;\n");
+ out.write("prefix On;\n");
+ out.write("}\n");
+ out.close();
+
+ YangNode node = manager.getDataModel("demo.yang");
+ }
+
+ /**
+ * This test case checks if the input YANG file with wrong YANG constructs
+ * than parser exception should be generated.
+ */
+ @Test(expected = ParserException.class)
+ public void getDataModelIncorrectFileTest() throws IOException, ParserException {
+
+ out.write("module ONOS {\n");
+ out.write("yang-version 1\n");
+ out.write("namespace urn:ietf:params:xml:ns:yang:ietf-ospf;\n");
+ out.write("prefix On;\n");
+ out.write("}\n");
+ out.close();
+
+ YangNode node = manager.getDataModel("demo.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/AugmentListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/AugmentListenerTest.java
new file mode 100644
index 0000000..3ce2fd0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/AugmentListenerTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangAugment;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing augment listener functionality.
+ */
+public class AugmentListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid augment statement.
+ */
+ @Test
+ public void processValidAugmentStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValidAugmentStatement.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangAugment yangAugment = (YangAugment) yangNode.getChild();
+ ListIterator<YangNodeIdentifier> nodeIdentifierIterator = yangAugment.getTargetNode().listIterator();
+ YangNodeIdentifier yangNodeIdentifier = nodeIdentifierIterator.next();
+ assertThat(yangNodeIdentifier.getPrefix(), is("if"));
+ assertThat(yangNodeIdentifier.getName(), is("interfaces"));
+
+ ListIterator<YangLeaf> leafIterator = yangAugment.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("ds0ChannelNumber"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("ChannelNumber"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java
new file mode 100644
index 0000000..ee418c2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java
new file mode 100644
index 0000000..927a2d6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java
new file mode 100644
index 0000000..6487172
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangBit;
+import org.onosproject.yangutils.datamodel.YangBits;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangUnion;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+
+/**
+ * Test cases for bit listener.
+ */
+public class BitListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks bit statement without position.
+ */
+ @Test
+ public void processBitTypeStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/BitTypeStatement.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.getName(), 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 bit statement with typedef.
+ */
+ @Test
+ public void processBitTypedefStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/BitTypedefStatement.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"));
+
+ YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
+ assertThat(typedef.getName(), is("type15"));
+
+ YangType type = typedef.getTypeList().iterator().next();
+ assertThat(type.getDataType(), is(YangDataTypes.BITS));
+ assertThat(type.getDataTypeName(), is("bits"));
+ Set<YangBit> bitSet = ((YangBits) type.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));
+ }
+ }
+ }
+
+ /**
+ * Checks bit statement with union.
+ */
+ @Test
+ public void processBitUnionStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/BitUnionStatement.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.getName(), is("type15"));
+
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UNION));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("union"));
+
+ YangUnion yangUnion = (YangUnion) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ List<YangType<?>> typeList = yangUnion.getTypeList();
+ ListIterator<YangType<?>> typeListIterator = typeList.listIterator();
+ YangType<?> yangType = typeListIterator.next();
+
+ assertThat(yangType.getDataType(), is(YangDataTypes.BITS));
+ assertThat(yangType.getDataTypeName(), is("bits"));
+ Set<YangBit> bitSet = ((YangBits) yangType.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));
+ }
+ }
+ }
+
+ /**
+ * Checks if enum with same name is not allowed.
+ */
+ @Test(expected = ParserException.class)
+ public void processBitWithDuplicateName() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/BitWithDuplicateName.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/CaseListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/CaseListenerTest.java
new file mode 100644
index 0000000..675a9e9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/CaseListenerTest.java
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangCase;
+import org.onosproject.yangutils.datamodel.YangChoice;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+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 java.util.ListIterator;
+
+/**
+ * Test cases for case listener.
+ */
+public class CaseListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks multiple case statement.
+ */
+ @Test
+ public void processCaseStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/CaseStatement.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("food"));
+
+ YangChoice yangChoice = (YangChoice) yangContainer.getChild();
+ assertThat(yangChoice.getName(), is("snack"));
+
+ YangCase yangCase1 = (YangCase) yangChoice.getChild();
+ assertThat(yangCase1.getName(), is("sports-arena"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator();
+ YangLeaf leafInfo1 = leafIterator1.next();
+
+ assertThat(leafInfo1.getName(), is("pretzel"));
+
+ YangCase yangCase2 = (YangCase) yangCase1.getNextSibling();
+ assertThat(yangCase2.getName(), is("late-night"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator2 = yangCase2.getListOfLeaf().listIterator();
+ YangLeaf leafInfo2 = leafIterator2.next();
+
+ assertThat(leafInfo2.getName(), is("chocolate"));
+ }
+
+ /**
+ * Checks duplicate case in choice.
+ */
+ @Test(expected = ParserException.class)
+ public void processDuplicateCaseInChoice() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DuplicateCaseInChoice.yang");
+ }
+
+ /**
+ * Checks duplicate leaf at different hierarchy.
+ */
+ @Test(expected = ParserException.class)
+ public void processDuplicateLeafInHierarchy() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DuplicateLeafInHierarchy.yang");
+ }
+
+ /**
+ * Checks duplicate leaf in different case within choice.
+ */
+ @Test(expected = ParserException.class)
+ public void processDuplicateLeafInChoice() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DuplicateLeafInChoice.yang");
+ }
+
+ /**
+ * Checks same case within different choice.
+ */
+ @Test
+ public void processCaseStatementSameEntryDifferentChoice() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/CaseStatementSameEntryDifferentChoice.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("food"));
+
+ YangChoice yangChoice = (YangChoice) yangContainer.getChild();
+ assertThat(yangChoice.getName(), is("snack"));
+
+ YangCase yangCase1 = (YangCase) yangChoice.getChild();
+ assertThat(yangCase1.getName(), is("sports-arena"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator();
+ YangLeaf leafInfo1 = leafIterator1.next();
+
+ assertThat(leafInfo1.getName(), is("pretzel"));
+
+ YangChoice yangChoice2 = (YangChoice) yangChoice.getNextSibling();
+ assertThat(yangChoice2.getName(), is("lunch"));
+
+ YangCase yangCase2 = (YangCase) yangChoice2.getChild();
+ assertThat(yangCase2.getName(), is("sports-arena"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator2 = yangCase2.getListOfLeaf().listIterator();
+ YangLeaf leafInfo2 = leafIterator2.next();
+
+ assertThat(leafInfo2.getName(), is("chocolate"));
+ }
+
+ /**
+ * Checks case choice hierarchy.
+ */
+ @Test
+ public void processCaseChoiceHierarchy() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/CaseChoiceHierarchy.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("food"));
+
+ YangChoice yangChoice1 = (YangChoice) yangContainer.getChild();
+ assertThat(yangChoice1.getName(), is("snack"));
+
+ YangCase yangCase1 = (YangCase) yangChoice1.getChild();
+ assertThat(yangCase1.getName(), is("sports-arena"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator();
+ YangLeaf leafInfo1 = leafIterator1.next();
+
+ assertThat(leafInfo1.getName(), is("pretzel"));
+
+ YangCase yangCase2 = (YangCase) yangCase1.getNextSibling();
+ assertThat(yangCase2.getName(), is("late-night"));
+
+ YangChoice yangChoice2 = (YangChoice) yangCase2.getChild();
+ assertThat(yangChoice2.getName(), is("dinner"));
+
+ YangCase yangCase3 = (YangCase) yangChoice2.getChild();
+ assertThat(yangCase3.getName(), is("late-night"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator2 = yangCase3.getListOfLeaf().listIterator();
+ YangLeaf leafInfo2 = leafIterator2.next();
+ assertThat(leafInfo2.getName(), is("beer"));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ChoiceListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ChoiceListenerTest.java
new file mode 100644
index 0000000..9dcf448
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ChoiceListenerTest.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangChoice;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+/**
+ * Test cases for choice listener.
+ */
+public class ChoiceListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks choice statement without body.
+ */
+ @Test
+ public void processChoiceStatementWithoutBody() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ChoiceStatementWithoutBody.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("food"));
+
+ YangChoice yangChoice = (YangChoice) yangContainer.getChild();
+ assertThat(yangChoice.getName(), is("snack"));
+ }
+
+ /**
+ * Checks choice statement with stmt end.
+ */
+ @Test
+ public void processChoiceStatementWithStmtend() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ChoiceStatementWithStmtend.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("food"));
+
+ YangChoice yangChoice = (YangChoice) yangContainer.getChild();
+ assertThat(yangChoice.getName(), is("snack"));
+ }
+
+ /**
+ * Checks choice statement duplicate entry.
+ */
+ @Test(expected = ParserException.class)
+ public void processChoiceStatementDuplicateEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ChoiceStatementDuplicateEntry.yang");
+ }
+
+ /**
+ * Checks choice statement with same entry in two different container.
+ */
+ @Test
+ public void processChoiceStatementSameEntryDifferentContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ChoiceStatementSameEntryDifferentContainer.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer1 = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer1.getName(), is("food1"));
+
+ YangChoice yangChoice1 = (YangChoice) yangContainer1.getChild();
+ assertThat(yangChoice1.getName(), is("snack"));
+
+ YangContainer yangContainer2 = (YangContainer) yangNode.getChild().getNextSibling();
+ assertThat(yangContainer2.getName(), is("food2"));
+
+ YangChoice yangChoice2 = (YangChoice) yangContainer2.getChild();
+ assertThat(yangChoice2.getName(), is("snack"));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
new file mode 100644
index 0000000..d129e38
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
@@ -0,0 +1,534 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for config listener.
+ */
+public class ConfigListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid config statement.
+ */
+ @Test
+ public void processConfigTrue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ConfigTrue.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();
+
+ // Check whether the Config value is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.isConfig(), is(true));
+ }
+
+ /**
+ * Checks valid config statement.
+ */
+ @Test
+ public void processConfigFalse() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalse.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();
+
+ // Check whether the Config value is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.isConfig(), is(false));
+ }
+
+ /**
+ * Checks invalid config statement and expects parser exception.
+ */
+ @Test
+ public void processConfigWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at '}'");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks invalid config statement and expects parser exception.
+ */
+ @Test
+ public void processConfigInvalidValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : config value invalid is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigInvalidValue.yang");
+ }
+
+ /**
+ * Checks invalid config statement and expects parser exception.
+ */
+ @Test
+ public void processConfigEmptyValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("no viable alternative at input ';'");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigEmptyValue.yang");
+ }
+
+ /**
+ * Checks config statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementConfig() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'config' expecting {'anyxml', 'augment', 'choice', 'contact', "
+ + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
+ + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference',"
+ + " 'revision', 'rpc', 'typedef', 'uses', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementConfig.yang");
+ }
+
+ /**
+ * Checks config statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementConfig() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementConfig.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"));
+
+ // Check whether the config value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.isConfig(), is(true));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks config statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementConfig() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementConfig.yang");
+
+ 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"));
+
+ // Check whether the list is child of module and config value is set.
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.isConfig(), is(true));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid config statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementConfig() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementConfig.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether config value is set correctly.
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.isConfig(), is(true));
+ }
+
+ /**
+ * Checks config statement's default Value.
+ */
+ @Test
+ public void processConfigDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ConfigDefaultValue.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.isConfig(), is(true));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.isConfig(), is(true));
+ }
+
+ /**
+ * Checks whether exception is throw when node's parent config set to false,
+ * no node underneath it can have config set to true.
+ */
+ @Test
+ public void processConfigFalseParentContainerChildLeafList() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Unhandled parsed data at container \"valid\" after "
+ + "processing.\nError Information: If a container has \"config\" set to \"false\", no node underneath "
+ + "it can have \"config\" set to \"true\".");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalseParentContainerChildLeafList.yang");
+ }
+
+ /**
+ * Checks whether exception is throw when node's parent config set to false,
+ * no node underneath it can have config set to true.
+ */
+ @Test
+ public void processConfigFalseParentContainerChildLeaf() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Unhandled parsed data at container \"valid\" after "
+ + "processing.\nError Information: If a container has \"config\" set to \"false\", no node underneath "
+ + "it can have \"config\" set to \"true\".");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalseParentContainerChildLeaf.yang");
+ }
+
+ /**
+ * Checks whether exception is throw when node's parent config set to false,
+ * no node underneath it can have config set to true.
+ */
+ @Test
+ public void processConfigFalseParentListChildLeafList() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Unhandled parsed data at list \"valid\" after"
+ + " processing.\nError Information: If a list has \"config\" set to \"false\", no node underneath"
+ + " it can have \"config\" set to \"true\".");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalseParentListChildLeafList.yang");
+ }
+
+ /**
+ * Checks whether exception is throw when node's parent config set to false,
+ * no node underneath it can have config set to true.
+ */
+ @Test
+ public void processConfigFalseParentListChildLeaf() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Unhandled parsed data at list \"valid\" after"
+ + " processing.\nError Information: If a list has \"config\" set to \"false\", no node underneath"
+ + " it can have \"config\" set to \"true\".");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalseParentListChildLeaf.yang");
+ }
+
+ /**
+ * Checks when config is not specified, the default is same as the parent's schema node's
+ * config statement's value.
+ */
+ @Test
+ public void processNoConfigContainerSubStatementContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NoConfigContainerSubStatementContainer.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("hello"));
+ assertThat(container.isConfig(), is(true));
+
+ YangNode containerNode = container.getChild();
+ assertThat(containerNode instanceof YangContainer, is(true));
+ YangContainer childContainer = (YangContainer) containerNode;
+ assertThat(childContainer.getName(), is("valid"));
+ assertThat(childContainer.isConfig(), is(true));
+ }
+
+ /**
+ * Checks when config is not specified, the default is same as the parent's schema node's
+ * config statement's value.
+ */
+ @Test
+ public void processNoConfigContainerSubStatementLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NoConfigContainerSubStatementLeafList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.isConfig(), is(true));
+
+ ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether config value is set correctly.
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.isConfig(), is(true));
+
+ }
+
+ /**
+ * Checks when config is not specified, the default is same as the parent's schema node's
+ * config statement's value.
+ */
+ @Test
+ public void processNoConfigContainerSubStatementLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NoConfigContainerSubStatementLeaf.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.isConfig(), is(true));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.isConfig(), is(true));
+ }
+
+ /**
+ * Checks when config is not specified, the default is same as the parent's schema node's
+ * config statement's value.
+ */
+ @Test
+ public void processNoConfigContainerSubStatementList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NoConfigContainerSubStatementList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("hello"));
+ assertThat(container.isConfig(), is(true));
+
+ YangNode listNode = container.getChild();
+ assertThat(listNode instanceof YangList, is(true));
+ YangList childList = (YangList) listNode;
+ assertThat(childList.getName(), is("valid"));
+ assertThat(childList.isConfig(), is(true));
+
+ }
+
+ /**
+ * Checks when config is not specified, the default is same as the parent's schema node's
+ * config statement's value.
+ */
+ @Test
+ public void processNoConfigListSubStatementContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementContainer.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangList list1 = (YangList) yangNode.getChild();
+ assertThat(list1.getName(), is("list1"));
+ assertThat(list1.isConfig(), is(true));
+
+ YangNode containerNode = list1.getChild();
+ assertThat(containerNode instanceof YangContainer, is(true));
+ YangContainer childContainer = (YangContainer) containerNode;
+ assertThat(childContainer.getName(), is("container1"));
+ assertThat(childContainer.isConfig(), is(true));
+ }
+
+ /**
+ * Checks when config is not specified, the default is same as the parent's schema node's
+ * config statement's value.
+ */
+ @Test
+ public void processNoConfigListSubStatementLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementLeafList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangList list1 = (YangList) yangNode.getChild();
+ assertThat(list1.getName(), is("valid"));
+ assertThat(list1.isConfig(), is(true));
+
+ ListIterator<YangLeafList> leafListIterator = list1.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether config value is set correctly.
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.isConfig(), is(true));
+ }
+
+ /**
+ * Checks when config is not specified, the default is same as the parent's schema node's
+ * config statement's value.
+ */
+ @Test
+ public void processNoConfigListSubStatementLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementLeaf.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangList list1 = (YangList) yangNode.getChild();
+ assertThat(list1.getName(), is("valid"));
+ assertThat(list1.isConfig(), is(true));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = list1.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.isConfig(), is(true));
+ }
+
+ /**
+ * Checks when config is not specified, the default is same as the parent's schema node's
+ * config statement's value.
+ */
+ @Test
+ public void processNoConfigListSubStatementList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the config value is set correctly.
+ YangList list1 = (YangList) yangNode.getChild();
+ assertThat(list1.getName(), is("valid"));
+ assertThat(list1.isConfig(), is(true));
+
+ YangNode listNode = list1.getChild();
+ assertThat(listNode instanceof YangList, is(true));
+ YangList childList = (YangList) listNode;
+ assertThat(childList.getName(), is("list1"));
+ assertThat(childList.isConfig(), is(true));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java
new file mode 100644
index 0000000..7c8c5e9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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 contact 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 that contact can have a string value without double quotes.
+ */
+ @Test
+ public void processContactWithoutQuotes() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContactWithoutQuotes.yang");
+
+ // Checks for the contact value in data model tree.
+ assertThat(((YangModule) node).getContact(), is("WG"));
+ }
+
+ /**
+ * 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
new file mode 100644
index 0000000..a149da2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing container listener.
+ */
+public class ContainerListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks container statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementContainer.yang");
+
+ 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"));
+
+ // Check whether the container is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("valid"));
+ }
+
+ /**
+ * Checks if container identifier in module is duplicate.
+ */
+ @Test(expected = ParserException.class)
+ public void processModuleDuplicateContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleDuplicateContainer.yang");
+ }
+
+ /**
+ * Checks if container identifier in container is duplicate.
+ */
+ @Test(expected = ParserException.class)
+ public void processContainerDuplicateContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerDuplicateContainer.yang");
+ }
+
+ /**
+ * Checks if container identifier in list is duplicate.
+ */
+ @Test(expected = ParserException.class)
+ public void processListDuplicateContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListDuplicateContainer.yang");
+ }
+
+ /**
+ * Checks if container identifier collides with list at same level.
+ */
+ @Test(expected = ParserException.class)
+ public void processDuplicateContainerAndList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DuplicateContainerAndList.yang");
+ }
+
+ /**
+ * Checks container statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementContainer.yang");
+
+ 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"));
+
+ // Check whether the container is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("ospf"));
+
+ // Check whether the container is child of container
+ YangContainer yangContainer1 = (YangContainer) yangContainer.getChild();
+ assertThat(yangContainer1.getName(), is("valid"));
+ }
+
+ /**
+ * Checks container statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementContainer.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList1 = (YangList) yangNode.getChild();
+ assertThat(yangList1.getName(), is("ospf"));
+
+ ListIterator<String> keyList = yangList1.getKeyList().listIterator();
+ assertThat(keyList.next(), is("process-id"));
+
+ // Check whether the list is child of list
+ YangContainer yangContainer = (YangContainer) yangList1.getChild();
+ assertThat(yangContainer.getName(), is("interface"));
+ }
+
+ /**
+ * Checks container with all its sub-statements.
+ */
+ @Test
+ public void processContainerSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatements.yang");
+
+ 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"));
+
+ // Check whether the container is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+
+ // Check whether container properties as set correctly.
+ assertThat(yangContainer.getName(), is("ospf"));
+
+ assertThat(yangContainer.isConfig(), is(true));
+ assertThat(yangContainer.getPresence(), is("\"ospf logs\""));
+ assertThat(yangContainer.getDescription(), is("\"container description\""));
+ assertThat(yangContainer.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(yangContainer.getReference(), is("\"container reference\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks cardinality of sub-statements of container.
+ */
+ @Test
+ public void processContainerSubStatementCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"reference\" is defined more than once in \"container valid\".");
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementCardinality.yang");
+ }
+
+ /**
+ * Checks container as root node.
+ */
+ @Test
+ public void processContainerRootNode() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("no viable alternative at input 'container'");
+ YangNode node = manager.getDataModel("src/test/resources/ContainerRootNode.yang");
+ }
+
+ /**
+ * Checks invalid identifier for container statement.
+ */
+ @Test
+ public void processContainerInvalidIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListenerTest.java
new file mode 100644
index 0000000..2aab556
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListenerTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangChoice;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing default listener functionality.
+ */
+public class DefaultListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if default value is set correctly.
+ */
+ @Test
+ public void processLeafSubStatementDefault() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafSubStatementDefault.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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDefaultValueInString(), is("\"1\""));
+ }
+
+ /**
+ * Checks if default value is set correctly.
+ */
+ @Test
+ public void processChoiceSubStatementDefault() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ChoiceSubStatementDefault.yang");
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("food"));
+
+ YangChoice yangChoice = (YangChoice) yangContainer.getChild();
+ assertThat(yangChoice.getName(), is("snack"));
+ assertThat(yangChoice.getDefaultValueInString(), is("\"hello\""));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java
new file mode 100644
index 0000000..c3989a6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for description listener.
+ */
+public class DescriptionListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid description statement.
+ */
+ @Test
+ public void processDescriptionValidStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DescriptionValidStatement.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();
+
+ // Check whether the description is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ }
+
+ /**
+ * Checks whether exception is thrown for invalid description statement.
+ */
+ @Test
+ public void processDescriptionWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("extraneous input '}' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/DescriptionWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks valid description statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementDescription() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementDescription.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"));
+
+ // Check whether the description is set correctly.
+ assertThat(yangNode.getDescription(), is("\"Interval before a route is declared invalid\""));
+ }
+
+ /**
+ * Checks valid description statement as sub-statement of module.
+ */
+ @Test
+ public void processDescriptionEmptyStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DescriptionEmptyStatement.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"));
+
+ // Check whether the description is set correctly.
+ assertThat(yangNode.getDescription(), is("\"\""));
+ }
+
+ /**
+ * Checks valid description statement as sub-statement of revision.
+ */
+ @Test
+ public void processRevisionSubStatementRevision() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionSubStatementRevision.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"));
+
+ // Check whether the description is set correctly.
+ assertThat(yangNode.getDescription(), is("\"module description\""));
+ assertThat(yangNode.getRevision().getDescription(), is("\"revision description\""));
+ }
+
+ /**
+ * Checks description statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementDescription() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementDescription.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"));
+
+ // Check whether the description value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.getDescription(), is("\"container description\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks description statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementDescription() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementDescription.yang");
+
+ 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"));
+
+ // Check whether the list is child of module and description value is set correctly.
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getDescription(), is("\"list description\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid description statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementDescription() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementDescription.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether description value is set correctly.
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/EnumListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/EnumListenerTest.java
new file mode 100644
index 0000000..a0bff1b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/EnumListenerTest.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangEnum;
+import org.onosproject.yangutils.datamodel.YangEnumeration;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+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 java.util.Iterator;
+import java.util.ListIterator;
+import java.util.SortedSet;
+
+/**
+ * Test cases for enum listener.
+ */
+public class EnumListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks enum statement without value.
+ */
+ @Test
+ public void processEnumTypeStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/EnumTypeStatement.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.getName(), is("speed"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("speed_enum"));
+
+ SortedSet<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
+ for (YangEnum tmp : enumSet) {
+ if (tmp.getNamedValue().equals("10m")) {
+ assertThat(tmp.getValue(), is(0));
+ } else if (tmp.getNamedValue().equals("100m")) {
+ assertThat(tmp.getValue(), is(1));
+ } else if (tmp.getNamedValue().equals("auto")) {
+ assertThat(tmp.getValue(), is(2));
+ }
+ }
+ }
+
+ /**
+ * Checks if enum with same name is not allowed.
+ */
+ @Test(expected = ParserException.class)
+ public void processEnumWithDuplicateName() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/EnumWithDuplicateName.yang");
+ }
+
+ /**
+ * Checks enum boundary value.
+ */
+ @Test
+ public void processEnumBoundaryValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : value value 21474836472147483647 is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/EnumBoundaryValue.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown if value is not specified following max enum value.
+ */
+ @Test
+ public void processEnumMaxNextValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : "
+ + "An enum value MUST be specified for enum substatements following the one"
+ + "with the current highest value");
+ YangNode node = manager.getDataModel("src/test/resources/EnumMaxNextValue.yang");
+ }
+
+ /**
+ * Checks enum values stored are sorted.
+ */
+ @Test
+ public void processEnumSorted() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/EnumSorted.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.getName(), is("ifType"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("ifType_enum"));
+
+ SortedSet<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
+ Iterator<YangEnum> enumIterator = enumSet.iterator();
+ assertThat(enumIterator.next().getNamedValue(), is("five"));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/GroupingListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/GroupingListenerTest.java
new file mode 100644
index 0000000..acd0c8a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/GroupingListenerTest.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangGrouping;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing grouping listener.
+ */
+public class GroupingListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks grouping statement inside module.
+ */
+ @Test
+ public void processGroupingInModule() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/GroupingInModule.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"));
+
+ YangGrouping yangGrouping = (YangGrouping) yangNode.getChild();
+ assertThat(yangGrouping.getName(), is("endpoint"));
+
+ ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("address"));
+ }
+
+ /**
+ * Checks grouping statement inside container.
+ */
+ @Test
+ public void processGroupingInContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/GroupingInContainer.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("valid"));
+
+ YangGrouping yangGrouping = (YangGrouping) yangContainer.getChild();
+ assertThat(yangGrouping.getName(), is("endpoint"));
+
+ ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("address"));
+ }
+
+ /**
+ * Checks grouping statement inside list.
+ */
+ @Test
+ public void processGroupingInList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/GroupingInList.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"));
+
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ YangGrouping yangGrouping = (YangGrouping) yangList.getChild();
+ assertThat(yangGrouping.getName(), is("endpoint"));
+
+ ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("address"));
+ }
+
+ /**
+ * Checks grouping with attributes.
+ */
+ @Test
+ public void processGroupingAttributes() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/GroupingAttributes.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"));
+
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ YangGrouping yangGrouping = (YangGrouping) yangList.getChild();
+ assertThat(yangGrouping.getName(), is("endpoint"));
+ assertThat(yangGrouping.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(yangGrouping.getReference(), is("\"RFC 6020\""));
+ assertThat(yangGrouping.getDescription(), is("\"grouping under test\""));
+
+ ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("address"));
+ }
+
+ /**
+ * Checks duplicate grouping in list.
+ */
+ @Test(expected = ParserException.class)
+ public void processDuplicateGroupingInList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DuplicateGroupingInList.yang");
+ }
+
+ /**
+ * Checks duplicate grouping in container.
+ */
+ @Test (expected = ParserException.class)
+ public void processDuplicateGroupingInContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DuplicateGroupingInContainer.yang");
+ }
+
+ /**
+ * Checks duplicate grouping in module.
+ */
+ @Test (expected = ParserException.class)
+ public void processDuplicateGroupingInModule() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DuplicateGroupingInModule.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java
new file mode 100644
index 0000000..9797e5e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java
new file mode 100644
index 0000000..452fc89
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
new file mode 100644
index 0000000..c85c1d5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangInput;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing Input listener functionality.
+ */
+public class InputListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks input statements with data definition statements as sub-statements.
+ */
+ @Test
+ public void processInputStatementWithDataDefinition() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/InputStatementWithDataDefinition.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("rock"));
+
+ YangRpc yangRpc = (YangRpc) yangNode.getChild();
+ assertThat(yangRpc.getName(), is("activate-software-image"));
+
+ YangInput yangInput = (YangInput) yangRpc.getChild();
+ assertThat(yangInput.getName(), is("activate-software-image_input"));
+ ListIterator<YangLeaf> leafIterator = yangInput.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("image-name"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+
+ YangList yangList = (YangList) yangInput.getChild();
+ assertThat(yangList.getName(), is("ospf"));
+ assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getMaxElements(), is(10));
+ assertThat(yangList.getMinElements(), is(3));
+ leafIterator = yangList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+
+ YangContainer yangContainer = (YangContainer) yangList.getNextSibling();
+ assertThat(yangContainer.getName(), is("isis"));
+
+ leafIterator = yangContainer.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ }
+
+ /**
+ * Checks input statements with type-def statement as sub-statements.
+ */
+ @Test
+ public void processInputStatementWithTypedef() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/InputStatementWithTypedef.yang");
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("rock"));
+
+ YangRpc yangRpc = (YangRpc) yangNode.getChild();
+ assertThat(yangRpc.getName(), is("activate-software-image"));
+
+ YangInput yangInput = (YangInput) yangRpc.getChild();
+ assertThat(yangInput.getName(), is("activate-software-image_input"));
+ YangTypeDef typeDef = (YangTypeDef) yangInput.getChild();
+ assertThat(typeDef.getName(), is("my-type"));
+ assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+ assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java
new file mode 100644
index 0000000..510b313
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for key listener.
+ */
+public class KeyListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks key statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementKey() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementKey.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ assertThat(keyList.next(), is("invalid-interval"));
+ }
+
+ /**
+ * Check multiple key values.
+ */
+ @Test
+ public void processMultipleKeyValues() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultipleKeyValues.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ List<String> keyList = yangList.getKeyList();
+ assertThat(keyList.contains("ospf"), is(true));
+ assertThat(keyList.contains("isis"), is(true));
+ }
+
+ /**
+ * Checks key statement without statement end.
+ */
+ @Test
+ public void processKeyWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leaf' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/KeyWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks key values are set correctly.
+ */
+ @Test
+ public void processConfigFalseNoKey() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalseNoKey.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ }
+
+ /**
+ * Checks key values are set correctly.
+ */
+ @Test
+ public void processConfigFalseValidKeyValidLeaf() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalseValidKeyValidLeaf.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ assertThat(keyList.next(), is("invalid-interval"));
+ }
+
+ /**
+ * Checks key values are set correctly.
+ */
+ @Test
+ public void processConfigFalseValidKeyValidLeafList() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalseValidKeyValidLeafList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ assertThat(keyList.next(), is("invalid-interval"));
+ }
+
+ /**
+ * Checks whether exception is thrown when list's config is set to true and there is no key.
+ */
+ @Test
+ public void processConfigTrueNoKey() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("A list must have atleast one key leaf if config is true");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigTrueNoKey.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when list's config is set to true and there is no leaf.
+ */
+ @Test
+ public void processConfigTrueNoleafNoLeafList() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("A list must have atleast one key leaf if config is true");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigTrueNoleafNoLeafList.yang");
+ }
+
+ /**
+ * Checks key values are set correctly.
+ */
+ @Test
+ public void processConfigTrueValidKeyValidLeaf() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/ConfigTrueValidKeyValidLeaf.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ assertThat(keyList.next(), is("invalid-interval"));
+ }
+
+ /**
+ * Checks key values are set correctly.
+ */
+ @Test
+ public void processKeyWithUsesInList() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/KeyWithUsesInList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild().getNextSibling();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ assertThat(keyList.next(), is("invalid-interval"));
+ }
+
+ /**
+ * Checks whether exception is thrown when key leaf identifier is not found in list.
+ */
+ @Test
+ public void processInvalidLeafIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("An identifier, in key, must refer to a child leaf of the list");
+ YangNode node = manager.getDataModel("src/test/resources/InvalidLeafIdentifier.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when key leaf-list identifier is not found in list.
+ */
+ @Test
+ public void processInvalidLeafListIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("An identifier, in key, must refer to a child leaf of the list");
+ YangNode node = manager.getDataModel("src/test/resources/InvalidLeafListIdentifier.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when key leaf-list is of type empty.
+ */
+ @Test
+ public void processKeyLeafListTypeEmpty() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("A leaf-list that is part of the key must not be the built-in type \"empty\".");
+ YangNode node = manager.getDataModel("src/test/resources/KeyLeafListTypeEmpty.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when key leaf is of type empty.
+ */
+ @Test
+ public void processKeyLeafTypeEmpty() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("A leaf that is part of the key must not be the built-in type \"empty\".");
+ YangNode node = manager.getDataModel("src/test/resources/KeyLeafTypeEmpty.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
new file mode 100644
index 0000000..8e7489b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing leaf-list listener.
+ */
+public class LeafListListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks all the values of leaf-list sub-statements are set correctly.
+ */
+ @Test
+ public void processLeafListSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatements.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafListInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafListInfo.isConfig(), is(true));
+ assertThat(leafListInfo.getMaxElelements(), is(3));
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf-list identifier starts with
+ * digit.
+ */
+ @Test
+ public void processLeafListInvalidIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : leaf-list name 1invalid-interval is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidIdentifier.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf-list keyword is incorrect.
+ */
+ @Test
+ public void processLeafListInvalidStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leaflist' expecting {'anyxml', 'augment', 'choice', 'contact', "
+ + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
+ + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference',"
+ + " 'revision', 'rpc', 'typedef', 'uses', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidStatement.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf-list keyword without Left
+ * brace as per grammar.
+ */
+ @Test
+ public void processLeafListWithoutLeftBrace() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing '{' at 'type'");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListWithoutLeftBrace.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when config statement cardinality is
+ * not as per grammar.
+ */
+ @Test
+ public void processLeafListConfigInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"config\" is defined more than once in \"leaf-list " +
+ "invalid-interval\".");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListConfigInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when units statement cardinality is
+ * not as per grammar.
+ */
+ @Test
+ public void processLeafListUnitsInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"units\" is defined more than once in \"leaf-list invalid-interval\"");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListUnitsInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks leaf-list statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementLeafList.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"));
+
+ //Check whether the container is child of module.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+
+ // Check whether leaf-list properties as set correctly.
+ ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafListInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafListInfo.isConfig(), is(true));
+ assertThat(leafListInfo.getMinElements(), is(1));
+ assertThat(leafListInfo.getMaxElelements(), is(2147483647));
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks leaf-list statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementLeafList.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ // Check whether leaf-list properties as set correctly.
+ ListIterator<YangLeafList> leafListIterator = yangList.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafListInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafListInfo.isConfig(), is(true));
+
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
new file mode 100644
index 0000000..b330e53
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing leaf listener.
+ */
+public class LeafListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks all the values of leaf sub-statements are set correctly.
+ */
+ @Test
+ public void processLeafSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafSubStatements.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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isConfig(), is(true));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf identifier starts with
+ * digit.
+ */
+ @Test
+ public void processLeafInvalidIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : leaf name 1invalid-interval is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/LeafInvalidIdentifier.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf keyword is incorrect.
+ */
+ @Test
+ public void processLeafInvalidStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leafs' expecting {'anyxml', 'augment', 'choice', 'contact', "
+ + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
+ + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference',"
+ + " 'revision', 'rpc', 'typedef', 'uses', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/LeafInvalidStatement.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf keyword without Left brace
+ * as per grammar.
+ */
+ @Test
+ public void processLeafWithoutLeftBrace() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing '{' at 'type'");
+ YangNode node = manager.getDataModel("src/test/resources/LeafWithoutLeftBrace.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when config statement cardinality is
+ * not as per grammar.
+ */
+ @Test
+ public void processLeafConfigInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"config\" is defined more than once in \"leaf invalid-interval\".");
+ YangNode node = manager.getDataModel("src/test/resources/LeafConfigInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when mandatory statement cardinality
+ * is not as per grammar.
+ */
+ @Test
+ public void processLeafMandatoryInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"mandatory\" is defined more than once in \"leaf invalid-interval\".");
+ YangNode node = manager.getDataModel("src/test/resources/LeafMandatoryInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks leaf statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementLeaf.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"));
+
+ //Check whether the container is child of module.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isConfig(), is(true));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks duplicate leaf statement as sub-statement of module.
+ */
+ @Test(expected = ParserException.class)
+ public void processModuleWithDuplicateLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleWithDuplicateLeaf.yang");
+ }
+
+ /**
+ * Checks duplicate leaf statement as sub-statement of container.
+ */
+ @Test(expected = ParserException.class)
+ public void processContainerWithDuplicateLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerWithDuplicateLeaf.yang");
+ }
+
+ /**
+ * Checks duplicate leaf statement as sub-statement of list.
+ */
+ @Test(expected = ParserException.class)
+ public void processListWithDuplicateLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListWithDuplicateLeaf.yang");
+ }
+
+ /**
+ * Checks leaf statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementLeaf.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isConfig(), is(true));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
new file mode 100644
index 0000000..0c862ba
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListenerTest.java
@@ -0,0 +1,302 @@
+/*
+ * 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 java.io.IOException;
+import java.math.BigInteger;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangRangeInterval;
+import org.onosproject.yangutils.datamodel.YangRangeRestriction;
+import org.onosproject.yangutils.datamodel.YangStringRestriction;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangUint64;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for length restriction listener.
+ */
+public class LengthRestrictionListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid length statement as sub-statement of leaf statement.
+ */
+ @Test
+ public void processValidLengthStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValidLengthStatement.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+
+ /**
+ * Checks valid length statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLengthStatementInsideLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthStatementInsideLeafList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(1)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+
+ /**
+ * Checks valid length statement as sub-statement of typedef.
+ */
+ @Test
+ public void processLengthStatementInsideTypeDef() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthStatementInsideTypeDef.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
+ YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getTypeDefBaseType()
+ .getDataTypeExtendedInfo();
+
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(1)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+
+ /**
+ * Checks length statement with invalid type.
+ */
+ @Test
+ public void processLengthWithInvalidType() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : length name \"1..100\" can be used to restrict the built-in type" +
+ " string/binary or types derived from string/binary.");
+ YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidType.yang");
+ }
+
+ /**
+ * Checks length statement with only start interval.
+ */
+ @Test
+ public void processLengthWithOneInterval() throws IOException, ParserException {
+
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthWithOneInterval.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(1)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(1)));
+ }
+
+ /**
+ * Checks length statement with min and max.
+ */
+ @Test
+ public void processLengthWithMinMax() throws IOException, ParserException {
+
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthWithMinMax.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(new BigInteger("18446744073709551615")));
+ }
+
+ /**
+ * Checks length statement with invalid integer pattern.
+ */
+ @Test
+ public void processLengthWithInvalidIntegerPattern() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : Input value \"a\" is not a valid uint64.");
+ YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidIntegerPattern.yang");
+ }
+
+ /**
+ * Checks length statement with invalid interval.
+ */
+ @Test
+ public void processLengthWithInvalidInterval() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : 18446744073709551617 is greater than maximum value" +
+ " 18446744073709551615.");
+ YangNode node = manager.getDataModel("src/test/resources/LengthWithInvalidInterval.yang");
+ }
+
+ /**
+ * Checks valid length substatements.
+ */
+ @Test
+ public void processLengthSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthSubStatements.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ assertThat(lengthRestriction.getDescription(), is("\"length description\""));
+ assertThat(lengthRestriction.getReference(), is("\"length reference\""));
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+
+ /**
+ * Checks whether space can be allowed when length statement is present.
+ */
+ @Test
+ public void processLengthStatementWithSpace() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LengthStatementWithSpace.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+ YangRangeRestriction lengthRestriction = stringRestriction.getLengthRestriction();
+
+ ListIterator<YangRangeInterval> lengthListIterator = lengthRestriction.getAscendingRangeIntervals()
+ .listIterator();
+
+ YangRangeInterval rangeInterval = lengthListIterator.next();
+
+ assertThat(((YangUint64) rangeInterval.getStartValue()).getValue(), is(BigInteger.valueOf(0)));
+ assertThat(((YangUint64) rangeInterval.getEndValue()).getValue(), is(BigInteger.valueOf(100)));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
new file mode 100644
index 0000000..526a645
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing list listener.
+ */
+public class ListListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks list statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementList.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ assertThat(keyList.next(), is("invalid-interval"));
+ }
+
+ /**
+ * Checks list statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementList.yang");
+
+ 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"));
+
+ // Check whether the container is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("ospf"));
+
+ // Check whether the list is child of container
+ YangList yangList = (YangList) yangContainer.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
+ }
+
+ /**
+ * Checks list statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementList.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList1 = (YangList) yangNode.getChild();
+ assertThat(yangList1.getName(), is("ospf"));
+ assertThat(yangList1.getKeyList().contains("process-id"), is(true));
+
+ // Check whether the list is child of list
+ YangList yangList = (YangList) yangList1.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
+ }
+
+ /**
+ * Checks list with all its sub-statements.
+ */
+ @Test
+ public void processListSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatements.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+
+ // Check whether list properties as set correctly.
+ assertThat(yangList.getName(), is("ospf"));
+ assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
+
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getMaxElements(), is(10));
+ assertThat(yangList.getMinElements(), is(3));
+ assertThat(yangList.getDescription(), is("\"list description\""));
+ assertThat(yangList.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(yangList.getReference(), is("\"list reference\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks cardinality of sub-statements of list.
+ */
+ @Test
+ public void processListSubStatementsCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"reference\" is defined more than once in \"list valid\".");
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementsCardinality.yang");
+ }
+
+ /**
+ * Checks list statement without child.
+ */
+ @Test
+ public void processListStatementWithoutChild() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: Missing \"data-def-substatements\" in \"list valid\".");
+ YangNode node = manager.getDataModel("src/test/resources/ListStatementWithoutChild.yang");
+ }
+
+ /**
+ * Checks list as root node.
+ */
+ @Test
+ public void processListAsRootNode() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("no viable alternative at input 'list'");
+ YangNode node = manager.getDataModel("src/test/resources/ListAsRootNode.yang");
+ }
+
+ /**
+ * Checks invalid identifier for list statement.
+ */
+ @Test
+ public void processListInvalidIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : list name 1valid is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/ListInvalidIdentifier.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java
new file mode 100644
index 0000000..52e43a9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+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 static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test case for mandatory listener.
+ */
+public class MandatoryListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid mandatory with value true statement.
+ */
+ @Test
+ public void processMandatoryTrue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryTrue.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();
+
+ // Check whether the mandatory value is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.isMandatory(), is(true));
+ }
+
+ /**
+ * Checks valid mandatory with value false statement.
+ */
+ @Test
+ public void processMandatoryFalse() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryFalse.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();
+
+ // Check whether the mandatory value is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.isMandatory(), is(false));
+ }
+
+ /**
+ * Checks default value of mandatory statement.
+ */
+ @Test
+ public void processMandatoryDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryDefaultValue.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();
+
+ // Check whether the mandatory value is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.isMandatory(), is(false));
+ }
+
+ /**
+ * Checks invalid of mandatory statement and expects exception.
+ */
+ @Test
+ public void processMandatoryEmptyStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("no viable alternative at input ';'");
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryEmptyStatement.yang");
+ }
+
+ /**
+ * Checks invalid mandatory statement(without statement end) and expects
+ * exception.
+ */
+ @Test
+ public void processMandatoryWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at '}'");
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks mandatory statement as sub-statement of module and expects
+ * exception.
+ */
+ @Test
+ public void processModuleSubStatementMandatory() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'mandatory' expecting {'anyxml', 'augment', 'choice', 'contact',"
+ + " 'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
+ + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference',"
+ + " 'revision', 'rpc', 'typedef', 'uses', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementMandatory.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
new file mode 100644
index 0000000..aa0cee2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing max-elements listener.
+ */
+public class MaxElementsListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks max-elements as sub-statements of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementMaxElements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementMaxElements.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getMaxElelements(), is(3));
+ }
+
+ /**
+ * Checks max-elements as sub-statements of list.
+ */
+ @Test
+ public void processListSubStatementMaxElements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementMaxElements.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.getMaxElements(), is(3));
+ }
+
+ /**
+ * Checks whether exception is thrown when invalid max-elements keyword is
+ * given as input.
+ */
+ @Test
+ public void processMaxElementsInvalidStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("extraneous input 'max-element' expecting {'config', 'description', 'if-feature',"
+ + " 'max-elements', 'min-elements', 'must', 'ordered-by', 'reference', 'status', 'type', 'units', "
+ + "'when', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsInvalidStatement.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when max-elements statement without
+ * statement end is given as input.
+ */
+ @Test
+ public void processMaxElementsWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at 'description'");
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when max-elements cardinality is not
+ * as per the grammar.
+ */
+ @Test
+ public void processMaxElementsCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"max-elements\" is defined more than once in \"leaf-list " +
+ "invalid-interval\".");
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsCardinality.yang");
+ }
+
+ /**
+ * Checks unbounded value of max-elements statement.
+ */
+ @Test
+ public void processMaxElementsUnbounded() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsUnbounded.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getMaxElelements(), is(2147483647));
+ }
+
+ /**
+ * Checks default value of max-elements statement.
+ */
+ @Test
+ public void processMaxElementsDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsDefaultValue.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getMaxElelements(), is(2147483647));
+ }
+
+ /**
+ * Checks whether exception is thrown when invalid min-elements value is
+ * given as input.
+ */
+ @Test
+ public void processMaxElementsMaxValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : max-elements value 77777777777777777777777 is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsMaxValue.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
new file mode 100644
index 0000000..c2f668b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing min-elements listener.
+ */
+public class MinElementsListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks min-elements as sub-statements of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementMinElements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementMinElements.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getMinElements(), is(3));
+ }
+
+ /**
+ * Checks min-elements as sub-statements of list.
+ */
+ @Test
+ public void processListSubStatementMinElements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementMinElements.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.getMinElements(), is(3));
+ }
+
+ /**
+ * Checks whether exception is thrown when invalid min-elements keyword is
+ * given as input.
+ */
+ @Test
+ public void processMinElementsInvalidKeyword() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("extraneous input 'min-element' expecting {'config', 'description', 'if-feature',"
+ + " 'max-elements', 'min-elements', 'must', 'ordered-by', 'reference', 'status', 'type', 'units',"
+ + " 'when', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidKeyword.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when invalid min-elements value is
+ * given as input.
+ */
+ @Test
+ public void processMinElementsInvalidValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : min-elements value asd is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidValue.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when invalid min-elements value is
+ * given as input.
+ */
+ @Test
+ public void processMinElementsMaxValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : min-elements value 77777777777777777777777 is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsMaxValue.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when min-elements statement without
+ * statement end is given as input.
+ */
+ @Test
+ public void processMinElementsWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at 'description'");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when min-elements cardinality is not
+ * as per the grammar.
+ */
+ @Test
+ public void processMinElementsInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"min-elements\" is defined more than once in \"leaf-list " +
+ "invalid-interval\".");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks min-element's default value.
+ */
+ @Test
+ public void processMinElementsDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsDefaultValue.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getMinElements(), is(0));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java
new file mode 100644
index 0000000..f77050a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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;
+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();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * 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");
+ }
+
+ /**
+ * 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java
new file mode 100644
index 0000000..0f35705
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NotificationListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NotificationListenerTest.java
new file mode 100644
index 0000000..7da2468
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NotificationListenerTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangNotification;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing notification listener functionality.
+ */
+public class NotificationListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid notification statement.
+ */
+ @Test
+ public void processValidNotificationStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValidNotificationStatement.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("rock"));
+
+ YangNotification yangNotification = (YangNotification) yangNode.getChild();
+ assertThat(yangNotification.getName(), is("link-failure"));
+ assertThat(yangNotification.getDescription(), is("\"A link failure has been detected\""));
+ assertThat(yangNotification.getStatus(), is(YangStatusType.DEPRECATED));
+ assertThat(yangNotification.getReference(), is("\"reference\""));
+
+ YangTypeDef typeDef = (YangTypeDef) yangNotification.getChild();
+ assertThat(typeDef.getName(), is("my-type"));
+ assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+
+ ListIterator<YangLeaf> leafIterator = yangNotification.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("if-name"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java
new file mode 100644
index 0000000..e9098d3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
new file mode 100644
index 0000000..a727092
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangOutput;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing output listener functionality.
+ */
+public class OutputListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks output statements with data definition statements as sub-statements.
+ */
+ @Test
+ public void processOutputStatementWithDataDefinition() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/OutputStatementWithDataDefinition.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("rock"));
+
+ YangRpc yangRpc = (YangRpc) yangNode.getChild();
+ assertThat(yangRpc.getName(), is("activate-software-image"));
+
+ YangOutput yangOutput = (YangOutput) yangRpc.getChild();
+ assertThat(yangOutput.getName(), is("activate-software-image_output"));
+ ListIterator<YangLeaf> leafIterator = yangOutput.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("image-name"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+
+ YangList yangList = (YangList) yangOutput.getChild();
+ assertThat(yangList.getName(), is("ospf"));
+ assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getMaxElements(), is(10));
+ assertThat(yangList.getMinElements(), is(3));
+ leafIterator = yangList.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+
+ YangContainer yangContainer = (YangContainer) yangList.getNextSibling();
+ assertThat(yangContainer.getName(), is("isis"));
+
+ leafIterator = yangContainer.getListOfLeaf().listIterator();
+ leafInfo = leafIterator.next();
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ }
+
+ /**
+ * Checks output statements with type-def statement as sub-statements.
+ */
+ @Test
+ public void processOutputStatementWithTypedef() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/OutputStatementWithTypedef.yang");
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("rock"));
+
+ YangRpc yangRpc = (YangRpc) yangNode.getChild();
+ assertThat(yangRpc.getName(), is("activate-software-image"));
+
+ YangOutput yangOutput = (YangOutput) yangRpc.getChild();
+ assertThat(yangOutput.getName(), is("activate-software-image_output"));
+ YangTypeDef typeDef = (YangTypeDef) yangOutput.getChild();
+ assertThat(typeDef.getName(), is("my-type"));
+ assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+ assertThat(typeDef.getName(), is("my-type"));
+ assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+ assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java
new file mode 100644
index 0000000..5216ef3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PatternRestrictionListenerTest.java
@@ -0,0 +1,205 @@
+/*
+ * 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 java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangPatternRestriction;
+import org.onosproject.yangutils.datamodel.YangStringRestriction;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for pattern restriction listener.
+ */
+public class PatternRestrictionListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid pattern statement as sub-statement of leaf statement.
+ */
+ @Test
+ public void processValidPatternStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValidPatternStatement.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+ ListIterator<String> patternListIterator = stringRestriction.getPatternRestriction()
+ .getPatternList().listIterator();
+ assertThat(patternListIterator.next(), is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks valid pattern statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processPatternStatementInsideLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternStatementInsideLeafList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+ ListIterator<String> patternListIterator = stringRestriction.getPatternRestriction()
+ .getPatternList().listIterator();
+ assertThat(patternListIterator.next(), is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks valid pattern statement as sub-statement of typedef.
+ */
+ @Test
+ public void processPatternStatementInsideTypeDef() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternStatementInsideTypeDef.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
+ YangStringRestriction stringRestriction = (YangStringRestriction) typedef.getTypeDefBaseType()
+ .getDataTypeExtendedInfo();
+
+ YangPatternRestriction yangPatternRestriction = stringRestriction.getPatternRestriction();
+ assertThat(yangPatternRestriction.getPatternList().listIterator().next(), is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks valid multiple pattern statements.
+ */
+ @Test
+ public void processMultiplePatternStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultiplePatternStatement.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+ ListIterator<String> patternListIterator = stringRestriction.getPatternRestriction()
+ .getPatternList().listIterator();
+ assertThat(patternListIterator.next(), is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks valid pattern statement with plus symbol in pattern.
+ */
+ @Test
+ public void processPatternStatementWithPlus() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternStatementWithPlus.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+ ListIterator<String> patternListIterator = stringRestriction.getPatternRestriction()
+ .getPatternList().listIterator();
+ assertThat(patternListIterator.next(), is("-[0-9]+|[0-9]+"));
+ }
+
+ /**
+ * Checks valid pattern substatement.
+ */
+ @Test
+ public void processPatternSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PatternSubStatements.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
+ YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+ assertThat(stringRestriction.getDescription(), is("\"pattern description\""));
+ assertThat(stringRestriction.getReference(), is("\"pattern reference\""));
+ ListIterator<String> patternListIterator = stringRestriction.getPatternRestriction()
+ .getPatternList().listIterator();
+ assertThat(patternListIterator.next(), is("[a-zA-Z]"));
+ }
+
+ /**
+ * Checks invalid pattern sub-statement.
+ */
+ @Test(expected = ParserException.class)
+ public void processInvalidPatternSubStatements() throws IOException, ParserException {
+ YangNode node = manager.getDataModel("src/test/resources/InvalidPatternSubStatements.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PositionListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PositionListenerTest.java
new file mode 100644
index 0000000..7d252ba
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PositionListenerTest.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangBit;
+import org.onosproject.yangutils.datamodel.YangBits;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+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 java.util.ListIterator;
+import java.util.Set;
+
+/**
+ * Test cases for position listener.
+ */
+public class PositionListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks explicitly configured value.
+ */
+ @Test
+ public void processPositionStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PositionStatement.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.getName(), 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 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.getName(), 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
+ public void processPositionImplicitAndExplicit() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PositionImplicitAndExplicit.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.getName(), 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 should not be repeated.
+ */
+ @Test(expected = ParserException.class)
+ public void processPositionDuplication() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PositionDuplication.yang");
+ }
+
+ /**
+ * Checks explicit or auto generated value should not be repeated.
+ */
+ @Test(expected = ParserException.class)
+ public void processPositionImplicitAndExplicitDuplication() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PositionImplicitAndExplicitDuplication.yang");
+ }
+
+ /**
+ * Checks if negative value of position is not allowed.
+ */
+ @Test(expected = ParserException.class)
+ public void processPositionNegativeValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PositionNegativeValue.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java
new file mode 100644
index 0000000..ef89a78
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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 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)
+ 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListenerTest.java
new file mode 100644
index 0000000..2d0e376
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListenerTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+
+/**
+ * Test cases for presence listener.
+ */
+public class PresenceListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks presence statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementPresence() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementPresence.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("valid"));
+ assertThat(yangContainer.getPresence(), is("\"invalid\""));
+ }
+
+ /**
+ * checks default value of presence statement.
+ */
+ @Test
+ public void processPresenceDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PresenceDefaultValue.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("valid"));
+ assertThat(yangContainer.getPresence(), is(nullValue()));
+ }
+
+ /**
+ * Checks presence statement without statement end.
+ */
+ @Test
+ public void processPresenceWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leaf' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/PresenceWithoutStatementEnd.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
new file mode 100644
index 0000000..0ed801f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListenerTest.java
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangRangeInterval;
+import org.onosproject.yangutils.datamodel.YangRangeRestriction;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt32;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for range restriction listener.
+ */
+public class RangeRestrictionListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid range statement as sub-statement of leaf statement.
+ */
+ @Test
+ public void processValidRangeStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValidRangeStatement.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+ assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
+ }
+
+ /**
+ * Checks valid range statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processRangeStatementInsideLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeStatementInsideLeafList.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("int32"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
+ }
+
+ /**
+ * Checks valid range statement with one interval.
+ */
+ @Test
+ public void processRangeWithOneInterval() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeWithOneInterval.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("int32"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(1));
+ }
+
+ /**
+ * Checks valid range statement with min and max.
+ */
+ @Test
+ public void processRangeWithMinMax() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeWithMinMax.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("int32"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafListInfo
+ .getDataType().getDataTypeExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+
+ assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(-2147483648));
+ assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(2147483647));
+ }
+
+ /**
+ * Checks valid range statement with invalid integer pattern.
+ */
+ @Test
+ public void processRangeWithInvalidIntegerPattern() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : Input value \"a\" is not a valid int32.");
+ YangNode node = manager.getDataModel("src/test/resources/RangeWithInvalidIntegerPattern.yang");
+ }
+
+ /**
+ * Checks valid range statement with description.
+ */
+ @Test
+ public void processRangeSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeSubStatements.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+
+ assertThat(rangeRestriction.getDescription(), is("\"range description\""));
+ assertThat(rangeRestriction.getReference(), is("\"range reference\""));
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+ assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
+ assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
+ }
+
+ /**
+ * Checks whether space can be allowed when range statement is present.
+ */
+ @Test
+ public void processRangeStatementWithSpace() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RangeStatementWithSpace.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
+ YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafInfo
+ .getDataType().getDataTypeExtendedInfo();
+
+ ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+ .listIterator();
+ YangRangeInterval rangeInterval = rangeListIterator.next();
+ assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
+ assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java
new file mode 100644
index 0000000..17a679a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test case for reference listener.
+ */
+public class ReferenceListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid reference statement.
+ */
+ @Test
+ public void processReferenceStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ReferenceStatement.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();
+
+ // Check whether the reference is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks whether exception is thrown for invalid reference statement.
+ */
+ @Test
+ public void processReferenceWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '}' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/ReferenceWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks valid reference statement under module.
+ */
+ @Test
+ public void processModuleSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementReference.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"));
+
+ // Check whether the reference is set correctly.
+ assertThat(yangNode.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid reference statement under module.
+ */
+ @Test
+ public void processReferenceEmptyStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ReferenceEmptyStatement.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"));
+
+ // Check whether the reference is set correctly.
+ assertThat(yangNode.getReference(), is("\"\""));
+ }
+
+ /**
+ * Checks valid reference statement as sub-statement of revision.
+ */
+ @Test
+ public void processRevisionSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionSubStatementReference.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"));
+
+ // Check whether the reference is set correctly.
+ assertThat(yangNode.getRevision().getReference(), is("\"revision reference\""));
+ }
+
+ /**
+ * Checks reference statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementReference.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"));
+
+ // Check whether the reference value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.getReference(), is("\"container reference\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks reference statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementReference.yang");
+
+ 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"));
+
+ // Check whether the list is child of module and description value is set correctly.
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getReference(), is("\"list reference\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid reference statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementReference.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether description value is set correctly.
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java
new file mode 100644
index 0000000..c12b377
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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 in quotes inside include.
+ */
+ @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 in quotes inside import.
+ */
+ @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"));
+ }
+
+ /**
+ * 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 is correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processRevisionDateInvalid() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionDateInvalid.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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
new file mode 100644
index 0000000..a5eeb04
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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.hamcrest.core.IsNull.notNullValue;
+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");
+ }
+
+ /**
+ * Checks the revision with current date is created for empty revision statement.
+ */
+ @Test
+ public void processWithoutRevision() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionAbsence.yang");
+ assertThat(((YangModule) node).getRevision().getRevDate(), notNullValue());
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java
new file mode 100644
index 0000000..3af045d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing Rpc listener functionality.
+ */
+public class RpcListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid rpc statements.
+ */
+ @Test
+ public void processValidRpcStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValidRpcStatement.yang");
+
+ assertThat((node instanceof YangModule), is(true));
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("rock"));
+
+ YangRpc yangRpc = (YangRpc) yangNode.getChild();
+ assertThat(yangRpc.getName(), is("rock-the-house"));
+ assertThat(yangRpc.getDescription(), is("\"description\""));
+ assertThat(yangRpc.getReference(), is("\"reference\""));
+ assertThat(yangRpc.getStatus(), is(YangStatusType.CURRENT));
+
+ YangTypeDef typeDef = (YangTypeDef) yangRpc.getChild();
+ assertThat(typeDef.getName(), is("my-type"));
+ assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+ assertThat(typeDef.getTypeDefBaseType().getDataType(), is(YangDataTypes.INT32));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ShortCaseListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ShortCaseListenerTest.java
new file mode 100644
index 0000000..132f7f4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ShortCaseListenerTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangCase;
+import org.onosproject.yangutils.datamodel.YangChoice;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+/**
+ * Test cases for short case listener.
+ */
+public class ShortCaseListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks short case listener with container.
+ */
+ @Test
+ public void processShortCaseListenerWithContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ShortCaseListenerWithContainer.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("food"));
+
+ YangChoice yangChoice = (YangChoice) yangContainer.getChild();
+ assertThat(yangChoice.getName(), is("snack"));
+
+ YangCase yangCase = (YangCase) yangChoice.getChild();
+ assertThat(yangCase.getName(), is("sports-arena"));
+
+ YangContainer yangContainer1 = (YangContainer) yangCase.getChild();
+ assertThat(yangContainer1.getName(), is("sports-arena"));
+ }
+
+ /**
+ * Checks short case listener with list.
+ */
+ @Test
+ public void processShortCaseListenerWithList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ShortCaseListenerWithList.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("food"));
+
+ YangChoice yangChoice = (YangChoice) yangContainer.getChild();
+ assertThat(yangChoice.getName(), is("snack"));
+
+ YangCase yangCase = (YangCase) yangChoice.getChild();
+ assertThat(yangCase.getName(), is("sports-arena"));
+
+ YangList yangList = (YangList) yangCase.getChild();
+ assertThat(yangList.getName(), is("sports-arena"));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
new file mode 100644
index 0000000..b2cbd71
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
@@ -0,0 +1,288 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for status listener.
+ */
+public class StatusListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid status statement.
+ */
+ @Test
+ public void processStatusStatementCurrent() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/StatusStatementCurrent.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();
+
+ // Check whether the status is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ }
+
+ /**
+ * Checks valid status statement.
+ */
+ @Test
+ public void processStatusStatementDeprecated() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/StatusStatementDeprecated.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();
+
+ // Check whether the status is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.DEPRECATED));
+ }
+
+ /**
+ * Checks valid status statement.
+ */
+ @Test
+ public void processStatusStatementObsolete() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/StatusStatementObsolete.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();
+
+ // Check whether the status is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.OBSOLETE));
+ }
+
+ /**
+ * Checks whether exception is thrown for invalid status statement.
+ */
+ @Test
+ public void processStatusWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at '}'");
+ YangNode node = manager.getDataModel("src/test/resources/StatusWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown for invalid status statement.
+ */
+ @Test
+ public void processStatusInvalidValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : status invalid is not valid.");
+ YangNode node = manager.getDataModel("src/test/resources/StatusInvalidValue.yang");
+ }
+
+ /**
+ * Checks status statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementStatus() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'status' expecting {'anyxml', 'augment', 'choice', 'contact', "
+ + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import',"
+ + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference', "
+ + "'revision', 'rpc', 'typedef', 'uses', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementStatus.yang");
+ }
+
+ /**
+ * Checks status statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementStatus() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementStatus.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"));
+
+ // Check whether status is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.isConfig(), is(true));
+ assertThat(container.getStatus(), is(YangStatusType.OBSOLETE));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks status statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementStatus() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementStatus.yang");
+
+ 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"));
+
+ // Check whether the list is child of module and status is set.
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getStatus(), is(YangStatusType.CURRENT));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid status statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementStatus() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementStatus.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether status is set correctly.
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.isConfig(), is(true));
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ }
+
+ /**
+ * Checks default value of status statement.
+ */
+ @Test
+ public void processStatusDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/StatusDefaultValue.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether status is set correctly.
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.isConfig(), is(true));
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
new file mode 100644
index 0000000..6a53cbe
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import 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.hamcrest.core.IsNull.notNullValue;
+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 the revision with current date is created for empty revision statement.
+ assertThat(((YangSubModule) node).getRevision().getRevDate(), notNullValue());
+ }
+
+ /**
+ * 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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
new file mode 100644
index 0000000..1b6a7c6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+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 static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test case for type listener.
+ */
+public class TypeListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks derived statement without contraints.
+ */
+ @Test
+ public void processDerivedTypeStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DerivedTypeStatement.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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ }
+
+ /**
+ * Checks valid yang data type.
+ */
+ @Test
+ public void processIntegerTypeStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IntegerTypeStatement.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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ }
+
+ /**
+ * Checks type for leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementType() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementType.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ }
+
+ /**
+ * Checks for unsupported type leafref.
+ */
+ @Test
+ public void processLeafrefType() throws IOException, ParserException {
+
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : \"leafref\" is not supported in current version,"
+ + " please check wiki for YANG utils road map.");
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/LeafrefInvalidIdentifier.yang");
+ }
+
+ /**
+ * Checks for unsupported type identityref.
+ */
+ @Test
+ public void processIdentityrefType() throws IOException, ParserException {
+
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : \"identityref\" is not supported in current version,"
+ + " please check wiki for YANG utils road map.");
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/IdentityrefInvalidIdentifier.yang");
+ }
+
+ /**
+ * Checks for unsupported type instance identifier.
+ */
+ @Test
+ public void processInstanceIdentifierType() throws IOException, ParserException {
+
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : \"instance-identifier\" is not supported in current version,"
+ + " please check wiki for YANG utils road map.");
+
+ YangNode node = manager
+ .getDataModel("src/test/resources/InstanceIdentifierInvalidIdentifier.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnionListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnionListenerTest.java
new file mode 100644
index 0000000..1ac199f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnionListenerTest.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ListIterator;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.YangUnion;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing union listener.
+ */
+public class UnionListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks union when type is in leaf.
+ */
+ @Test
+ public void processUnionWhenTypeInLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnionWhenTypeInLeaf.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"));
+
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UNION));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("union"));
+
+ YangUnion yangUnion = (YangUnion) leafInfo.getDataType().getDataTypeExtendedInfo();
+
+ List<YangType<?>> typeList = yangUnion.getTypeList();
+ ListIterator<YangType<?>> typeListIterator = typeList.listIterator();
+ YangType<?> yangType = typeListIterator.next();
+
+ assertThat(yangType.getDataTypeName(), is("int32"));
+ assertThat(yangType.getDataType(), is(YangDataTypes.INT32));
+
+ YangType<?> yangTypeEnum = typeListIterator.next();
+
+ assertThat(yangTypeEnum.getDataTypeName(), is("enumeration"));
+ assertThat(yangTypeEnum.getDataType(), is(YangDataTypes.ENUMERATION));
+ }
+
+ /**
+ * Checks union when type is in leaflist.
+ */
+ @Test
+ public void processUnionWhenTypeInLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnionWhenTypeInLeafList.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"));
+
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<YangLeafList> leafListIterator = yangList.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UNION));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("union"));
+
+ YangUnion yangUnion = (YangUnion) leafListInfo.getDataType().getDataTypeExtendedInfo();
+
+ List<YangType<?>> typeList = yangUnion.getTypeList();
+ ListIterator<YangType<?>> typeListIterator = typeList.listIterator();
+ YangType<?> yangType = typeListIterator.next();
+
+ assertThat(yangType.getDataTypeName(), is("int32"));
+ assertThat(yangType.getDataType(), is(YangDataTypes.INT32));
+
+ YangType<?> yangTypeEnum = typeListIterator.next();
+
+ assertThat(yangTypeEnum.getDataTypeName(), is("enumeration"));
+ assertThat(yangTypeEnum.getDataType(), is(YangDataTypes.ENUMERATION));
+ }
+
+ /**
+ * Checks union with empty type.
+ */
+ @Test (expected = ParserException.class)
+ public void processUnionWithEmptyType() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnionWithEmptyType.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
new file mode 100644
index 0000000..6684df5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for units listener.
+ */
+public class UnitsListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid units statement.
+ */
+ @Test
+ public void processUnitsStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnitsStatement.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();
+
+ // Check whether units value is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ }
+
+ /**
+ * Checks invalid units statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementUnits() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'type' expecting {'anyxml', 'augment', 'choice', 'contact', "
+ + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity',"
+ + " 'import', 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', "
+ + "'reference', 'revision', 'rpc', 'typedef', 'uses', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementUnits.yang");
+ }
+
+ /**
+ * Checks invalid units statement(without statement end).
+ */
+ @Test
+ public void processUnitsWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '}' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/UnitsWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks order of units statement in leaf.
+ */
+ @Test
+ public void processUnitsStatementOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnitsStatementOrder.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();
+
+ // Check whether leaf properties is set correctly.
+ assertThat(leafInfo.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isConfig(), is(true));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks the default value of unit statement.
+ */
+ @Test
+ public void processUnitsDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnitsDefaultValue.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.getName(), is("invalid-interval"));
+ assertThat(leafInfo.getUnits(), is(nullValue()));
+ }
+
+ /**
+ * Checks invalid occurance of units statement as sub-statement of leaf.
+ */
+ @Test
+ public void processUnitsStatementCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error: \"units\" is defined more than once in \"leaf invalid-interval\".");
+ YangNode node = manager.getDataModel("src/test/resources/UnitsStatementCardinality.yang");
+ }
+
+ /**
+ * Checks valid units statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementUnits() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementUnits.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<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether units value is set correctly.
+ assertThat(leafListInfo.getName(), is("invalid-interval"));
+ assertThat(leafListInfo.getUnits(), is("\"seconds\""));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UsesListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UsesListenerTest.java
new file mode 100644
index 0000000..a20c43e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UsesListenerTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangGrouping;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangUses;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing uses listener.
+ */
+public class UsesListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks uses statement inside module.
+ */
+ @Test
+ public void processUsesInModule() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UsesInModule.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"));
+
+ YangGrouping yangGrouping = (YangGrouping) yangNode.getChild();
+ assertThat(yangGrouping.getName(), is("endpoint"));
+
+ YangUses yangUses = (YangUses) yangGrouping.getNextSibling();
+ assertThat(yangUses.getName(), is("endpoint"));
+ }
+
+ /**
+ * Checks uses statement inside container.
+ */
+ @Test
+ public void processUsesInContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UsesInContainer.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"));
+
+ YangGrouping yangGrouping = (YangGrouping) yangNode.getChild();
+ assertThat(yangGrouping.getName(), is("endpoint"));
+
+ YangContainer yangContainer = (YangContainer) yangGrouping.getNextSibling();
+ assertThat(yangContainer.getName(), is("valid"));
+
+ YangUses yangUses = (YangUses) yangContainer.getChild();
+ assertThat(yangUses.getName(), is("endpoint"));
+
+ // Check attributes associated with uses.
+ assertThat(yangUses.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(yangUses.getReference(), is("\"RFC 6020\""));
+ assertThat(yangUses.getDescription(), is("\"grouping under test\""));
+ }
+
+ /**
+ * Checks uses statement inside list.
+ */
+ @Test
+ public void processUsesInList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UsesInList.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"));
+
+ YangGrouping yangGrouping = (YangGrouping) yangNode.getChild();
+ assertThat(yangGrouping.getName(), is("endpoint"));
+
+ YangList yangList = (YangList) yangGrouping.getNextSibling();
+ assertThat(yangList.getName(), is("valid"));
+
+ YangUses yangUses = (YangUses) yangList.getChild();
+ assertThat(yangUses.getName(), is("endpoint"));
+
+ // Check attributes associated with uses.
+ assertThat(yangUses.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(yangUses.getReference(), is("\"RFC 6020\""));
+ assertThat(yangUses.getDescription(), is("\"grouping under test\""));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ValueListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ValueListenerTest.java
new file mode 100644
index 0000000..6dae702
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ValueListenerTest.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangEnum;
+import org.onosproject.yangutils.datamodel.YangEnumeration;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+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 java.util.ListIterator;
+import java.util.Set;
+
+/**
+ * Test cases for value listener.
+ */
+public class ValueListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks explicitly configured value.
+ */
+ @Test
+ public void processValueStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValueStatement.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.getName(), is("speed"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("speed_enum"));
+
+ Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
+ for (YangEnum tmp : enumSet) {
+ if (tmp.getNamedValue().equals("10m")) {
+ assertThat(tmp.getValue(), is(10));
+ } else if (tmp.getNamedValue().equals("100m")) {
+ assertThat(tmp.getValue(), is(100));
+ } else if (tmp.getNamedValue().equals("auto")) {
+ assertThat(tmp.getValue(), is(1000));
+ }
+ }
+ }
+
+ /**
+ * Checks explicitly configured negative value.
+ */
+ @Test
+ public void processValueStatementWithNegativeValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValueStatementWithNegativeValue.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.getName(), is("speed"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("speed_enum"));
+
+ Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
+ for (YangEnum tmp : enumSet) {
+ if (tmp.getNamedValue().equals("10m")) {
+ assertThat(tmp.getValue(), is(-2));
+ } else if (tmp.getNamedValue().equals("100m")) {
+ assertThat(tmp.getValue(), is(-1));
+ } else if (tmp.getNamedValue().equals("auto")) {
+ assertThat(tmp.getValue(), is(0));
+ }
+ }
+ }
+
+ /**
+ * Checks explicitly configured value with double quotes.
+ */
+ @Test
+ public void processValueStatementWithQuotes() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValueStatementWithQuotes.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.getName(), is("speed"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("speed_enum"));
+
+ Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
+ for (YangEnum tmp : enumSet) {
+ if (tmp.getNamedValue().equals("10m")) {
+ assertThat(tmp.getValue(), is(10));
+ } else if (tmp.getNamedValue().equals("100m")) {
+ assertThat(tmp.getValue(), is(100));
+ } else if (tmp.getNamedValue().equals("auto")) {
+ assertThat(tmp.getValue(), is(1000));
+ }
+ }
+ }
+
+ /**
+ * Checks explicit value and auto generated value.
+ */
+ @Test
+ public void processValueAndAutoStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValueAndAutoStatement.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.getName(), is("speed"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
+ assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
+ is("speed_enum"));
+
+ Set<YangEnum> enumSet = ((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getEnumSet();
+ for (YangEnum tmp : enumSet) {
+ if (tmp.getNamedValue().equals("10m")) {
+ assertThat(tmp.getValue(), is(10));
+ } else if (tmp.getNamedValue().equals("100m")) {
+ assertThat(tmp.getValue(), is(11));
+ } else if (tmp.getNamedValue().equals("auto")) {
+ assertThat(tmp.getValue(), is(1000));
+ }
+ }
+ }
+
+ /**
+ * Checks explicit value should not be repeated.
+ */
+ @Test(expected = ParserException.class)
+ public void processValueDuplication() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValueDuplication.yang");
+ }
+
+ /**
+ * Checks explicit or auto generated value should not be repeated.
+ */
+ @Test(expected = ParserException.class)
+ public void processValueExplicitAndAutoDuplication() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ValueExplicitAndAutoDuplication.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
new file mode 100644
index 0000000..3d9de83
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+
+import 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 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 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
+ 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) 1));
+ }
+
+ /**
+ * 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
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/AugmentListnerUtilTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/AugmentListnerUtilTest.java
new file mode 100644
index 0000000..3cf6eaa
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/AugmentListnerUtilTest.java
@@ -0,0 +1,320 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.parseutils;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerUtil.clearOccurrenceCount;
+import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerUtil.createValidNameForAugment;
+import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerUtil.getAugmentJavaFileNameList;
+import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerUtil.updateNameWhenHasMultipleOuccrrence;
+
+/**
+ * Unit test case for augment listener utility.
+ */
+public class AugmentListnerUtilTest {
+
+ private static final String TEST1 = "test1Node";
+ private static final String PARENT_PREFIX = "if";
+ private static final String NODE_PREFIX = "rf";
+
+ private static final String TEST1_AUGMENTED_NAME_WITHOUT_PREFIX = "AugmentedTest1Node";
+ private static final String TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI1 = "AugmentedTest1Node1";
+ private static final String TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI2 = "AugmentedTest1Node2";
+ private static final String TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI3 = "AugmentedTest1Node3";
+
+ private static final String TEST1_AUGMENTED_NAME_WITH_PREFIX = "AugmentedRfTest1Node";
+ private static final String TEST1_AUGMENTED_NAME_WITH_PREFIX_MULTI1 = "AugmentedRfTest1Node1";
+ private static final String TEST1_AUGMENTED_NAME_WITH_PREFIX_MULTI2 = "AugmentedRfTest1Node2";
+ private static final String TEST1_AUGMENTED_NAME_WITH_PREFIX_MULTI3 = "AugmentedRfTest1Node3";
+
+ private static String testString = "";
+
+ /**
+ * Unit test case when parent's prefix is present and one occurrence of augment node to update same target node.
+ */
+ @Test
+ public void testForAugmentNameWhenOneOuccrrenceWithParentPrefix() {
+ clearData();
+ testString = createValidNameForAugment(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX)));
+ }
+
+ /**
+ * Unit test case when no prefix and one occurrence of augment node to update same target node.
+ */
+ @Test
+ public void testForAugmentNameWhenOneOuccrrenceWithNoPrefix() {
+ clearData();
+ testString = createValidNameForAugment(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX)));
+ }
+
+ /**
+ * Unit test case when different prefix then parent is present and
+ * one occurrence of augment node to update same target node.
+ */
+ @Test
+ public void testForAugmentNameWhenOneOuccrrenceWithDiffPrefix() {
+ clearData();
+ testString = createValidNameForAugment(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITH_PREFIX)));
+ }
+
+ /**
+ * Unit test case when parent's prefix is present and two occurrence of augment node to update
+ * same target node is present.
+ */
+ @Test
+ public void testForAugmentNameWhenTwoOuccrrenceWithParentPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+ testString = updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI2)));
+ }
+
+ /**
+ * Unit test case when no prefix and two occurrence of augment node to update
+ * same target node is present.
+ */
+ @Test
+ public void testForAugmentNameWhenTwoOuccrrenceWithNoPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+ testString = updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI2)));
+ }
+
+ /**
+ * Unit test case when different prefix then parent is present and
+ * two occurrence of augment node to update same target node is present.
+ */
+ @Test
+ public void testForAugmentNameWhenTwoOuccrrenceWithDiffPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+ testString = updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITH_PREFIX_MULTI2)));
+ }
+
+ /**
+ * Unit test case when parent prefix and three occurrence of augment node to update
+ * same target node is present.
+ */
+ @Test
+ public void testForAugmentNameWhenThreeOuccrrenceWithParentPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+
+ testString = updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI3)));
+ }
+
+ /**
+ * Unit test case when no prefix and three occurrence of augment node to update
+ * same target node is present.
+ */
+ @Test
+ public void testForAugmentNameWhenThreeOuccrrenceNoPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+
+ testString = updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI3)));
+ }
+
+ /**
+ * Unit test case when different prefix and three occurrence of augment node to update
+ * same target node is present.
+ */
+ @Test
+ public void testForAugmentNameWhenThreeOuccrrenceWithDiffPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+
+ testString = updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITH_PREFIX_MULTI3)));
+ }
+
+ /**
+ * Unit test case for when three occurrence is there and parent prefix is present,
+ * all the names need to be updated in list.
+ */
+ @Test
+ public void testForPreviousNamesGotUpdatedWhenParentPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithParentPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithParentPrefix()));
+
+ testString = getAugmentJavaFileNameList().get(0);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI1)));
+
+ testString = getAugmentJavaFileNameList().get(1);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI2)));
+
+ testString = getAugmentJavaFileNameList().get(2);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI3)));
+ }
+
+ /**
+ * Unit test case for when three occurrence is there and no prefix is present,
+ * all the names need to be updated in list.
+ */
+ @Test
+ public void testForPreviousNamesGotUpdatedWhenNoPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithNoPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithNoPrefix()));
+
+ testString = getAugmentJavaFileNameList().get(0);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI1)));
+
+ testString = getAugmentJavaFileNameList().get(1);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI2)));
+
+ testString = getAugmentJavaFileNameList().get(2);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITHOUT_PREFIX_MULTI3)));
+ }
+
+ /**
+ * Unit test case for when three occurrence is there and different prefix is present,
+ * all the names need to be updated in list.
+ */
+ @Test
+ public void testForPreviousNamesGotUpdatedWhenDifferentPrefix() {
+ clearData();
+
+ createValidNameForAugment(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+ updateNameWhenHasMultipleOuccrrence(getStubNodeIdetifierWithDiffPrefix(),
+ isPrefixPresent(getStubNodeIdetifierWithDiffPrefix()));
+
+ testString = getAugmentJavaFileNameList().get(0);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITH_PREFIX_MULTI1)));
+
+ testString = getAugmentJavaFileNameList().get(1);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITH_PREFIX_MULTI2)));
+
+ testString = getAugmentJavaFileNameList().get(2);
+ assertThat(true, is(testString.equals(TEST1_AUGMENTED_NAME_WITH_PREFIX_MULTI3)));
+ }
+
+ /**
+ * Returns stub node identifier when parent prefix is used.
+ *
+ * @param name name of node
+ * @param prefix prefix of node
+ * @return node identifier for node
+ */
+ private YangNodeIdentifier getStubNodeIdetifierWithParentPrefix() {
+ YangNodeIdentifier nodeId = new YangNodeIdentifier();
+ nodeId.setName(TEST1);
+ nodeId.setPrefix(PARENT_PREFIX);
+ return nodeId;
+ }
+
+ /**
+ * Returns stub node identifier when no prefix is used.
+ *
+ * @param name name of node
+ * @param prefix prefix of node
+ * @return node identifier for node
+ */
+ private YangNodeIdentifier getStubNodeIdetifierWithNoPrefix() {
+ YangNodeIdentifier nodeId = new YangNodeIdentifier();
+ nodeId.setName(TEST1);
+ nodeId.setPrefix(null);
+ return nodeId;
+ }
+
+ /**
+ * Returns stub node identifier when different prefix is used.
+ *
+ * @param name name of node
+ * @param prefix prefix of node
+ * @return node identifier for node
+ */
+ private YangNodeIdentifier getStubNodeIdetifierWithDiffPrefix() {
+ YangNodeIdentifier nodeId = new YangNodeIdentifier();
+ nodeId.setName(TEST1);
+ nodeId.setPrefix(NODE_PREFIX);
+ return nodeId;
+ }
+
+ /**
+ * Returns true if a prefix is present and it is not equals to parents prefix.
+ *
+ * @param nodeId YANG node identifier
+ * @param parentsPrefix parent's prefix
+ * @return true if a prefix is present and it is not equals to parents prefix
+ */
+ private static boolean isPrefixPresent(YangNodeIdentifier nodeId) {
+ return nodeId.getPrefix() != null && nodeId.getPrefix() != PARENT_PREFIX;
+ }
+
+ /**
+ * Clears list of names and occurrence count after each test case.
+ */
+ private void clearData() {
+ getAugmentJavaFileNameList().clear();
+ clearOccurrenceCount();
+ }
+
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerErrorMessageConstructionTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerErrorMessageConstructionTest.java
new file mode 100644
index 0000000..bcfaf20
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerErrorMessageConstructionTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.parseutils;
+
+import org.junit.Test;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CONTACT_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+
+/**
+ * Test case for testing listener error message construction util.
+ */
+public class ListenerErrorMessageConstructionTest {
+
+ /**
+ * Checks for error message construction with parsable data type name.
+ */
+ @Test
+ public void checkErrorMsgConstructionWithName() {
+
+ // Create an test error message
+ String testErrorMessage = constructListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "Test Instance", ENTRY);
+
+ // Check message.
+ assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact "
+ + "\"Test Instance\" before processing."));
+ }
+
+ /**
+ * Checks for error message construction without parsable data type name.
+ */
+ @Test
+ public void checkErrorMsgConstructionWithoutName() {
+
+ // Create an test error message
+ String testErrorMessage = constructListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "Test Instance", ENTRY);
+
+ // Check message.
+ assertThat(testErrorMessage,
+ is("Internal parser error detected: Invalid holder for contact \"Test Instance\""
+ + " before processing."));
+ }
+
+ /**
+ * Checks for extended error message construction with parsable data type
+ * name.
+ */
+ @Test
+ public void checkExtendedErrorMsgConstructionWithName() {
+
+ // Create an test error message
+ String testErrorMessage = constructExtendedListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA,
+ "Test Instance", ENTRY,
+ "Extended Information");
+
+ // Check message.
+ assertThat(testErrorMessage,
+ is("Internal parser error detected: Invalid holder for contact \"Test Instance\""
+ + " before processing.\n" + "Error Information: Extended Information"));
+ }
+
+ /**
+ * Checks for extended error message construction without parsable data type
+ * name.
+ */
+ @Test
+ public void checkExtendedErrorMsgConstructionWithoutName() {
+
+ // Create an test error message
+ String testErrorMessage = constructExtendedListenerErrorMessage(INVALID_HOLDER, CONTACT_DATA, "", ENTRY,
+ "Extended Information");
+
+ // Check message.
+ assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact"
+ + " before processing.\n" + "Error Information: Extended Information"));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerUtilTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerUtilTest.java
new file mode 100644
index 0000000..c29b126
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerUtilTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.parseutils;
+
+import java.io.IOException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+/**
+ * Test case for testing listener util.
+ */
+public class ListenerUtilTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks whether exception is thrown when identifier starts with xml.
+ */
+ @Test
+ public void validateIdentifierStartsWithXml() throws IOException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("YANG file error : module identifier xMlTest must not start" +
+ " with (('X'|'x') ('M'|'m') ('L'|'l'))");
+ manager.getDataModel("src/test/resources/InValidIdentifierXML.yang");
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerValidationTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerValidationTest.java
new file mode 100644
index 0000000..ce347d6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ListenerValidationTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.parseutils;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangRevision;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+
+import static org.onosproject.yangutils.datamodel.utils.YangConstructType.YANGBASE_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+
+/**
+ * Test case for testing listener validation util.
+ */
+public class ListenerValidationTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * Checks for exception in case parsable stack is empty while validating for
+ * not empty scenario.
+ */
+ @Test
+ public void validateStackIsNotEmptyForEmptyStack() {
+
+ String expectedError = constructListenerErrorMessage(MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
+
+ // Get the exception occurred during parsing.
+ thrown.expect(ParserException.class);
+ thrown.expectMessage(expectedError);
+
+ // Create test walker and assign test error to it.
+ TreeWalkListener testWalker = new TreeWalkListener();
+
+ checkStackIsNotEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
+ }
+
+ /**
+ * Checks if there is no exception in case parsable stack is not empty while
+ * validating for not empty scenario.
+ */
+ @Test
+ public void validateStackIsNotEmptyForNonEmptyStack() {
+
+ // Create test walker and assign test error to it.
+ TreeWalkListener testWalker = new TreeWalkListener();
+
+ // Create a temporary node of parsable.
+ YangRevision tmpNode = new YangRevision();
+ testWalker.getParsedDataStack().push(tmpNode);
+
+ checkStackIsNotEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
+ }
+
+ /**
+ * Checks for exception in case parsable stack is not empty while validating
+ * for empty scenario.
+ */
+ @Test
+ public void validateStackIsEmptyForNonEmptyStack() {
+
+ String expectedError = constructListenerErrorMessage(MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
+
+ // Get the exception occurred during parsing.
+ thrown.expect(ParserException.class);
+ thrown.expectMessage(expectedError);
+
+ // Create test walker and assign test error to it.
+ TreeWalkListener testWalker = new TreeWalkListener();
+
+ // Create a temporary node of parsable.
+ YangRevision tmpNode = new YangRevision();
+ testWalker.getParsedDataStack().push(tmpNode);
+
+ checkStackIsEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
+ }
+
+ /**
+ * Checks if there is no exception in case parsable stack is empty while
+ * validating for empty scenario.
+ */
+ @Test
+ public void validateStackIsEmptyForEmptyStack() {
+
+ // Create test walker and assign test error to it.
+ TreeWalkListener testWalker = new TreeWalkListener();
+
+ checkStackIsEmpty(testWalker, MISSING_HOLDER, YANGBASE_DATA, "", EXIT);
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ParseTreeErrorListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ParseTreeErrorListenerTest.java
new file mode 100644
index 0000000..4489e77
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/parseutils/ParseTreeErrorListenerTest.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.parseutils;
+
+import org.antlr.v4.runtime.ANTLRFileStream;
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangLexer;
+import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.CustomExceptionMatcher;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+import org.onosproject.yangutils.parser.impl.parserutils.ParseTreeErrorListener;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Test case for testing parse tree error listener.
+ */
+public class ParseTreeErrorListenerTest {
+
+ YangUtilsParserManager manager = new YangUtilsParserManager();
+ File file;
+ BufferedWriter out;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * Checks that no exception is generated for YANG file with valid syntax.
+ */
+ @Test
+ public void checkValidYangFileForNoSyntaxError() throws IOException {
+
+ ANTLRInputStream input = new ANTLRFileStream("src/test/resources/YangFileWithoutSyntaxError.yang");
+
+ // Create a lexer that feeds off of input char stream.
+ GeneratedYangLexer lexer = new GeneratedYangLexer(input);
+ // Create a buffer of tokens pulled from the lexer.
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ // Create a parser that feeds off the tokens buffer.
+ GeneratedYangParser parser = new GeneratedYangParser(tokens);
+ // Remove console error listener.
+ parser.removeErrorListeners();
+ // Create instance of customized error listener.
+ ParseTreeErrorListener parseTreeErrorListener = new ParseTreeErrorListener();
+ // Add customized error listener to catch errors during parsing.
+ parser.addErrorListener(parseTreeErrorListener);
+ // Begin parsing YANG file and generate parse tree.
+ ParseTree tree = parser.yangfile();
+ }
+
+ /**
+ * Checks that exception is generated for YANG file with invalid syntax.
+ */
+ @Test
+ public void checkInvalidYangFileForSyntaxError() throws IOException {
+
+ // Get the exception occurred during parsing.
+ thrown.expect(ParserException.class);
+ thrown.expect(CustomExceptionMatcher.errorLocation(3, 0));
+ thrown.expectMessage("no viable alternative at input 'yang-version 1\\nnamespace'");
+
+ ANTLRInputStream input = new ANTLRFileStream("src/test/resources/YangFileWithSyntaxError.yang");
+
+ // Create a lexer that feeds off of input char stream.
+ GeneratedYangLexer lexer = new GeneratedYangLexer(input);
+ // Create a buffer of tokens pulled from the lexer.
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ // Create a parser that feeds off the tokens buffer.
+ GeneratedYangParser parser = new GeneratedYangParser(tokens);
+ // Remove console error listener.
+ parser.removeErrorListeners();
+ // Create instance of customized error listener.
+ ParseTreeErrorListener parseTreeErrorListener = new ParseTreeErrorListener();
+ // Add customized error listener to catch errors during parsing.
+ parser.addErrorListener(parseTreeErrorListener);
+ // Begin parsing YANG file and generate parse tree.
+ ParseTree tree = parser.yangfile();
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
new file mode 100644
index 0000000..f2ca36e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataTypeTest.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.BOOLEAN;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.UINT8;
+import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaDataType;
+import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass;
+import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportPackage;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
+
+/**
+ * Unit test case for attribute java data type.
+ */
+public class AttributesJavaDataTypeTest {
+
+ private static final YangDataTypes TYPE1 = STRING;
+ private static final YangDataTypes TYPE2 = INT32;
+ private static final YangDataTypes TYPE3 = BOOLEAN;
+ private static final YangDataTypes TYPE4 = UINT8;
+ private static final YangDataTypes TYPE_DEF = DERIVED;
+ private static final String CLASS_INFO1 = "String";
+ private static final String CLASS_INFO2 = "int";
+ private static final String CLASS_INFO3 = "boolean";
+ private static final String CLASS_INFO4 = "short";
+ private static final String CLASS_INFO5 = "Integer";
+ private static final String TYPE_DEF_PKG = "target.test";
+ private static String test = "";
+ private static YangToJavaNamingConflictUtil pluginConfig = null;
+
+ /**
+ * Unit test for private constructor.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors()
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {AttributesJavaDataType.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * Unit test for java class info method test.
+ */
+ @Test
+ public void testgetJavaClassInfo() {
+ test = getJavaImportClass(getStubYangType(TYPE1), false, pluginConfig);
+ assertThat(true, is(test.equals(CLASS_INFO1)));
+
+ test = getJavaImportClass(getStubYangType(TYPE2), true, pluginConfig);
+ assertThat(true, is(test.equals(CLASS_INFO5)));
+
+ test = getJavaImportClass(getStubYangType(TYPE3), false, pluginConfig);
+ assertThat(null, is(test));
+
+ test = getJavaImportClass(getStubYangType(TYPE4), false, pluginConfig);
+ assertThat(null, is(test));
+ }
+
+ /**
+ * Unit test for java data type method.
+ */
+ @Test
+ public void testgetJavaDataType() {
+ test = getJavaDataType(getStubYangType(TYPE1));
+ assertThat(true, is(test.equals(CLASS_INFO1)));
+
+ test = getJavaDataType(getStubYangType(TYPE2));
+ assertThat(true, is(test.equals(CLASS_INFO2)));
+
+ test = getJavaDataType(getStubYangType(TYPE3));
+ assertThat(true, is(test.equals(CLASS_INFO3)));
+
+ test = getJavaDataType(getStubYangType(TYPE4));
+ assertThat(true, is(test.equals(CLASS_INFO4)));
+ }
+
+ /**
+ * Unit test for java package info method.
+ */
+ @Test
+ public void testgetJavaPkgInfo() {
+ test = getJavaImportPackage(getStubYangType(TYPE1), false, pluginConfig);
+ assertThat(true, is(test.equals(JAVA_LANG)));
+
+ test = getJavaImportPackage(getStubYangType(TYPE2), true, pluginConfig);
+ assertThat(true, is(test.equals(JAVA_LANG)));
+
+ test = getJavaImportPackage(getStubYangType(TYPE3), false, pluginConfig);
+ assertThat(null, is(test));
+
+ test = getJavaImportPackage(getStubYangType(TYPE4), false, pluginConfig);
+ assertThat(null, is(test));
+ }
+
+ /**
+ * Unit test case for typedef.
+ *
+ * @throws DataModelException when fails to do data model operations
+ */
+ @Test
+ public void testForTypeDef() throws DataModelException {
+ test = getJavaImportPackage(getStubExtendedInfo(getStubYangType(TYPE_DEF)), false, pluginConfig);
+ assertThat(true, is(test.equals(TYPE_DEF_PKG)));
+ }
+
+ /**
+ * Returns stub YANG type for test.
+ *
+ * @param dataTypes YANG data types
+ * @return YANG type
+ */
+ private YangType<?> getStubYangType(YangDataTypes dataTypes) {
+ YangType<?> type = new YangType<>();
+ type.setDataType(dataTypes);
+ return type;
+ }
+
+ /**
+ * Returns YANG type with extended info.
+ *
+ * @param type YANG type
+ * @return YANG type with extended info
+ * @throws DataModelException when fails to do data model operations
+ */
+ @SuppressWarnings("unchecked")
+ private YangType<?> getStubExtendedInfo(YangType<?> type) throws DataModelException {
+ YangJavaTypeDef typedef = new YangJavaTypeDef();
+ getStubParent().addChild(typedef);
+ YangDerivedInfo<?> derInfo = new YangDerivedInfo<>();
+ derInfo.setReferredTypeDef(typedef);
+ ((YangType<YangDerivedInfo<?>>) type).setDataTypeExtendedInfo(derInfo);
+ return type;
+ }
+
+ /**
+ * Returns java file info.
+ *
+ * @return java file info
+ */
+ private JavaFileInfo addStubJavaFileInfo() {
+ JavaFileInfo fileInfo = new JavaFileInfo();
+ fileInfo.setJavaName("test");
+ fileInfo.setPackage("target");
+ return fileInfo;
+ }
+
+ /**
+ * Adds stub parent module for typedef.
+ *
+ * @return stub parent module
+ */
+ private YangNode getStubParent() {
+ YangJavaModule parent = new YangJavaModule();
+ parent.setJavaFileInfo(addStubJavaFileInfo());
+ return parent;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ChoiceCaseTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ChoiceCaseTranslatorTest.java
new file mode 100644
index 0000000..74043f6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ChoiceCaseTranslatorTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Unit tests for choice-case translator.
+ */
+public final class ChoiceCaseTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks choice-case translation should not result in any exception.
+ */
+ @Test
+ public void processChoiceCaseTranslator() throws IOException, ParserException {
+
+ String userDir = System.getProperty("user.dir");
+ YangNode node = manager.getDataModel("src/test/resources/ChoiceCaseTranslator.yang");
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(userDir + "/target/ChoiceCaseTestGenFile/");
+
+ generateJavaCode(node, yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/ChoiceCaseTestGenFile/");
+ }
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGeneratorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGeneratorTest.java
new file mode 100644
index 0000000..39d5205
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGeneratorTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Test;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition;
+
+/**
+ * Unit tests for class definition generator for generated files.
+ */
+public final class ClassDefinitionGeneratorTest {
+
+ private static final String CLASS_NAME = "TestClass";
+ private static final String INTERFACE_CLASS_DEF = "public interface TestClass {\n";
+ private static final String BULDER_INTERFACE_CLASS_DEF = "interface TestClassBuilder {\n\n";
+ private static final String BUILDER_CLASS_DEF = "public class TestClassBuilder implements "
+ + "TestClass.TestClassBuilder {\n";
+ private static final String IMPL_CLASS_DEF = "public final class TestClassImpl implements TestClass {\n";
+ private static final String TYPE_DEF_CLASS_DEF = "public final class TestClass {\n";
+
+ /**
+ * Unit test for private constructor.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors()
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {ClassDefinitionGenerator.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * Unit test for builder class definition.
+ */
+ @Test
+ public void generateBuilderClassDefinitionTest() {
+ String builderClassDefinition = generateClassDefinition(BUILDER_CLASS_MASK, CLASS_NAME);
+ assertThat(true, is(builderClassDefinition.equals(BUILDER_CLASS_DEF)));
+ }
+
+ /**
+ * Unit test for builder interface definition.
+ */
+ @Test
+ public void generateBuilderInterfaceDefinitionTest() {
+ String builderInterfaceDefinition = generateClassDefinition(BUILDER_INTERFACE_MASK, CLASS_NAME);
+ assertThat(true, is(builderInterfaceDefinition.equals(BULDER_INTERFACE_CLASS_DEF)));
+ }
+
+ /**
+ * Unit test for impl class definition.
+ */
+ @Test
+ public void generateImplDefinitionTest() {
+ String implDefinition = generateClassDefinition(IMPL_CLASS_MASK, CLASS_NAME);
+ assertThat(true, is(implDefinition.equals(IMPL_CLASS_DEF)));
+ }
+
+ /**
+ * Unit test for interface definition.
+ */
+ @Test
+ public void generateinterfaceDefinitionTest() {
+ // TODO: need to add this test case.
+ }
+
+ /**
+ * Unit test for typedef generated type.
+ */
+ @Test
+ public void generateTypeDefTest() {
+ String typeDef = generateClassDefinition(GENERATE_TYPEDEF_CLASS, CLASS_NAME);
+ assertThat(true, is(typeDef.equals(TYPE_DEF_CLASS_DEF)));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/EnumTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/EnumTranslatorTest.java
new file mode 100644
index 0000000..2a950fc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/EnumTranslatorTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Unit test case for enum translator.
+ */
+public final class EnumTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks enum translation should not result in any exception.
+ */
+ @Test
+ public void processEnumTranslator()
+ throws IOException, ParserException {
+
+ String userDir = System.getProperty("user.dir");
+ YangNode node = manager.getDataModel("src/test/resources/EnumTranslator.yang");
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(userDir + "/target/EnumTestGenFile/");
+
+ generateJavaCode(node, yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/EnumTestGenFile/");
+ }
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGenTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGenTest.java
new file mode 100644
index 0000000..fd5c0d3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGenTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getImportText;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
+import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
+import static org.onosproject.yangutils.utils.UtilConstants.LIST;
+import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
+import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
+import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
+import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
+import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
+
+/**
+ * Unit test cases for java code snippet generator.
+ */
+public class JavaCodeSnippetGenTest {
+
+ private static final String PKG_INFO = "org.onosproject.unittest";
+ private static final String CLASS_INFO = "JavaCodeSnippetGenTest";
+ private static final String YANG_NAME = "Test";
+
+ /**
+ * Unit test for private constructor.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors()
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {JavaCodeSnippetGen.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * Unit test case for import text.
+ */
+ @Test
+ public void testForImportText() {
+ JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo();
+ importInfo.setPkgInfo(PKG_INFO);
+ importInfo.setClassInfo(CLASS_INFO);
+
+ String imports = getImportText(importInfo);
+
+ assertThat(true, is(imports.equals(IMPORT + PKG_INFO + PERIOD + CLASS_INFO + SEMI_COLAN + NEW_LINE)));
+ }
+
+ /**
+ * Unit test case for java class interface definition close.
+ */
+ @Test
+ public void testForJavaClassDefClose() {
+ String interfaceDef = getJavaClassDefClose();
+ assertThat(true, is(interfaceDef.equals(CLOSE_CURLY_BRACKET)));
+ }
+
+ /**
+ * Unit test case for java attribute info.
+ */
+ @Test
+ public void testForJavaAttributeInfo() {
+
+ String attributeWithoutTypePkg = getJavaAttributeDefination(null, STRING_DATA_TYPE, YANG_NAME, false);
+ assertThat(true, is(attributeWithoutTypePkg.equals(
+ PRIVATE + SPACE + STRING_DATA_TYPE + SPACE + YANG_NAME + SEMI_COLAN + NEW_LINE)));
+
+ String attributeWithTypePkg = getJavaAttributeDefination(JAVA_LANG, STRING_DATA_TYPE, YANG_NAME, false);
+ assertThat(true, is(attributeWithTypePkg.equals(PRIVATE + SPACE + JAVA_LANG + PERIOD
+ + STRING_DATA_TYPE + SPACE + YANG_NAME + SEMI_COLAN + NEW_LINE)));
+
+ String attributeWithListPkg = getJavaAttributeDefination(JAVA_LANG, STRING_DATA_TYPE, YANG_NAME, true);
+ assertThat(true, is(attributeWithListPkg.equals(
+ PRIVATE + SPACE + LIST + DIAMOND_OPEN_BRACKET + JAVA_LANG + PERIOD + STRING_DATA_TYPE
+ + DIAMOND_CLOSE_BRACKET + SPACE + YANG_NAME + SEMI_COLAN + NEW_LINE)));
+
+ String attributeWithListWithoutPkg = getJavaAttributeDefination(null, STRING_DATA_TYPE, YANG_NAME, true);
+ assertThat(true, is(attributeWithListWithoutPkg.equals(
+ PRIVATE + SPACE + LIST + DIAMOND_OPEN_BRACKET + STRING_DATA_TYPE + DIAMOND_CLOSE_BRACKET + SPACE
+ + YANG_NAME + SEMI_COLAN + NEW_LINE)));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
new file mode 100644
index 0000000..6b86b9c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
@@ -0,0 +1,284 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.translator.exception.TranslatorException;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
+import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG;
+import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+
+/**
+ * Unit tests for java identifier syntax.
+ */
+public final class JavaIdentifierSyntaxTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private static final String PARENT_PACKAGE = "test5/test6/test7";
+ private static final String CHILD_PACKAGE = "test1:test2:test3";
+ private static final String DATE1 = "2000-1-5";
+ private static final String DATE2 = "1992-01-25";
+ private static final String PARENT_WITH_PERIOD = "test5.test6.test7";
+ private static final String CHILD_WITH_PERIOD = "test1.test2.test3";
+ private static final String DATE_WITH_REV1 = "rev20000105";
+ private static final String DATE_WITH_REV2 = "rev19920125";
+ private static final String VERSION_NUMBER = "v1";
+ private static final String VALID_PREFIX = "123add-prefix";
+ private static final String INVALID_PREFIX = "-*()&^&#$%";
+ private static final String INVALID_PREFIX1 = "abc~!@#$%^&*()_+}{:<>?`1234567890-=[]''|,./SS";
+ private static final String INVALID_NAME_SPACE_FOR_INVALID_PREFIX = "try:#test3:9case3";
+ private static final String INVALID_NAME_SPACE1 = "byte:#test2:9test3";
+ private static final String INVALID_NAME_SPACE2 = "const:#test2://9test3";
+ private static final String INVALID_NAME_SPACE3 = "CONST:TRY://9test3";
+ private static final String VALID_NAME_SPACE1 = "123addprefixbyte.test2.123addprefix9test3";
+ private static final String VALID_NAME_SPACE2 = "yangautoprefixconst.test2.yangautoprefix9test3";
+ private static final String VALID_NAME_SPACE3 = "abc1234567890ssconst.test2.abc1234567890ss9test3";
+ private static final String VALID_NAME_SPACE4 = "yangautoprefixconst.yangautoprefixtry.yangautoprefix9test3";
+ private static final String WITHOUT_CAMEL_CASE = "test-camel-case-identifier";
+ private static final String WITH_CAMEL_CASE = "testCamelCaseIdentifier";
+ private static final String WITHOUT_CAMEL_CASE1 = ".-_try-._-.123";
+ private static final String WITH_CAMEL_CASE1 = "try123";
+ private static final String WITHOUT_CAMEL_CASE2 = "_try";
+ private static final String WITH_CAMEL_CASE2 = "yangAutoPrefixTry";
+ private static final String WITHOUT_CAMEL_CASE3 = "-1-123g-123ga-a";
+ private static final String WITH_CAMEL_CASE3 = "yangAutoPrefix1123G123Gaa";
+ private static final String WITHOUT_CAMEL_CASE4 = "a-b-c-d-e-f-g-h";
+ private static final String WITH_CAMEL_CASE4 = "aBcDeFgh";
+ private static final String WITHOUT_CAMEL_CASE5 = "TestName";
+ private static final String WITH_CAMEL_CASE5 = "testName";
+ private static final String WITHOUT_CAMEL_CASE6 = "TEST-NAME";
+ private static final String WITH_CAMEL_CASE6 = "testName";
+ private static final String WITHOUT_CAMEL_CASE7 = "TESTNAME";
+ private static final String WITH_CAMEL_CASE7 = "testname";
+ private static final String WITHOUT_CAMEL_CASE8 = "TE-ST-NA-ME";
+ private static final String WITH_CAMEL_CASE8 = "teStNaMe";
+ private static final String WITHOUT_CAMEL_CASE9 = "TEST3NAME";
+ private static final String WITH_CAMEL_CASE9 = "test3Name";
+ private static final String WITHOUT_CAMEL_CASE10 = "TEST3";
+ private static final String WITH_CAMEL_CASE10 = "test3";
+ private static final String WITHOUT_CAMEL_CASE11 = "TEST3nAMe";
+ private static final String WITH_CAMEL_CASE11 = "test3Name";
+ private static final String WITHOUT_CAMEL_CASE12 = "TEST3name";
+ private static final String WITH_CAMEL_CASE12 = "test3Name";
+ private static final String WITHOUT_CAMEL_CASE13 = "t-RY";
+ private static final String WITH_CAMEL_CASE13 = "tRy";
+ private static final String WITHOUT_CAMEL_CASE14 = "TRY";
+ private static final String WITH_CAMEL_CASE14 = "yangAutoPrefixTry";
+ private static final String WITHOUT_CAPITAL = "test_this";
+ private static final String WITH_CAPITAL = "Test_this";
+ private static final String WITH_SMALL = "test_this";
+ private static final String WITH_CAMEL_CASE_WITH_PREFIX = "123addPrefixTry";
+ private static final String WITH_CAMEL_CASE_WITH_PREFIX1 = "abc1234567890Ss1123G123Gaa";
+ private static YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil();
+
+ /**
+ * Unit test for private constructor.
+ *
+ * @throws SecurityException if any security violation is observed.
+ * @throws NoSuchMethodException if when the method is not found.
+ * @throws IllegalArgumentException if there is illegal argument found.
+ * @throws InstantiationException if instantiation is provoked for the
+ * private constructor.
+ * @throws IllegalAccessException if instance is provoked or a method is
+ * provoked.
+ * @throws InvocationTargetException when an exception occurs by the method
+ * or constructor.
+ */
+ @Test
+ public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {JavaIdentifierSyntax.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * Unit test for root package generation with revision complexity.
+ */
+ @Test
+ public void getRootPackageTest() {
+ conflictResolver.setPrefixForIdentifier(null);
+ String rootPackage = getRootPackage((byte) 1, CHILD_PACKAGE, DATE1, conflictResolver);
+ assertThat(rootPackage.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ + PERIOD + CHILD_WITH_PERIOD + PERIOD + DATE_WITH_REV1), is(true));
+ }
+
+ /**
+ * Unit test for root package generation with invalid prefix.
+ */
+ @Test
+ public void getRootPackageWithInvalidPrefix() throws TranslatorException {
+ thrown.expect(TranslatorException.class);
+ thrown.expectMessage("The given prefix in pom.xml is invalid.");
+ conflictResolver.setPrefixForIdentifier(INVALID_PREFIX);
+ String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE_FOR_INVALID_PREFIX, DATE1, conflictResolver);
+ }
+
+ /**
+ * Unit test for root package generation with special characters presence.
+ */
+ @Test
+ public void getRootPackageWithSpecialCharactersTest() {
+ conflictResolver.setPrefixForIdentifier(VALID_PREFIX);
+ String rootPackage = getRootPackage((byte) 1, INVALID_NAME_SPACE1, DATE1, conflictResolver);
+ assertThat(rootPackage.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ + PERIOD + VALID_NAME_SPACE1 + PERIOD + DATE_WITH_REV1), is(true));
+ conflictResolver.setPrefixForIdentifier(null);
+ String rootPackage1 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, DATE1, conflictResolver);
+ assertThat(rootPackage1.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ + PERIOD + VALID_NAME_SPACE2 + PERIOD + DATE_WITH_REV1), is(true));
+ String rootPackage2 = getRootPackage((byte) 1, INVALID_NAME_SPACE3, DATE1, conflictResolver);
+ assertThat(rootPackage2.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ + PERIOD + VALID_NAME_SPACE4 + PERIOD + DATE_WITH_REV1), is(true));
+ conflictResolver.setPrefixForIdentifier(INVALID_PREFIX1);
+ String rootPackage3 = getRootPackage((byte) 1, INVALID_NAME_SPACE2, DATE1, conflictResolver);
+ assertThat(rootPackage3.equals(DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER
+ + PERIOD + VALID_NAME_SPACE3 + PERIOD + DATE_WITH_REV1), is(true));
+
+ }
+
+ /**
+ * Unit test for root package generation without complexity in revision.
+ */
+ @Test
+ public void getRootPackageWithRevTest() {
+ String rootPkgWithRev = getRootPackage((byte) 1, CHILD_PACKAGE, DATE2, null);
+ assertThat(rootPkgWithRev.equals(
+ DEFAULT_BASE_PKG + PERIOD + VERSION_NUMBER + PERIOD + CHILD_WITH_PERIOD + PERIOD + DATE_WITH_REV2),
+ is(true));
+ }
+
+ /**
+ * Unit test for capitalizing the incoming string.
+ */
+ @Test
+ public void getCapitalCaseTest() {
+ String capitalCase = getCapitalCase(WITHOUT_CAPITAL);
+ assertThat(capitalCase.equals(WITH_CAPITAL), is(true));
+ }
+
+ /**
+ * Unit test for getting the camel case for the received string.
+ */
+ @Test
+ public void getCamelCaseTest() {
+ conflictResolver.setPrefixForIdentifier(null);
+ String camelCase = getCamelCase(WITHOUT_CAMEL_CASE, conflictResolver);
+ assertThat(camelCase.equals(WITH_CAMEL_CASE), is(true));
+ String camelCase1 = getCamelCase(WITHOUT_CAMEL_CASE1, conflictResolver);
+ assertThat(camelCase1.equals(WITH_CAMEL_CASE1), is(true));
+ String camelCase2 = getCamelCase(WITHOUT_CAMEL_CASE2, conflictResolver);
+ assertThat(camelCase2.equals(WITH_CAMEL_CASE2), is(true));
+ String camelCase3 = getCamelCase(WITHOUT_CAMEL_CASE3, conflictResolver);
+ assertThat(camelCase3.equals(WITH_CAMEL_CASE3), is(true));
+ String camelCase4 = getCamelCase(WITHOUT_CAMEL_CASE4, conflictResolver);
+ assertThat(camelCase4.equals(WITH_CAMEL_CASE4), is(true));
+ String camelCase5 = getCamelCase(WITHOUT_CAMEL_CASE5, conflictResolver);
+ assertThat(camelCase5.equals(WITH_CAMEL_CASE5), is(true));
+ String camelCase6 = getCamelCase(WITHOUT_CAMEL_CASE6, conflictResolver);
+ assertThat(camelCase6.equals(WITH_CAMEL_CASE6), is(true));
+ String camelCase7 = getCamelCase(WITHOUT_CAMEL_CASE7, conflictResolver);
+ assertThat(camelCase7.equals(WITH_CAMEL_CASE7), is(true));
+ String camelCase8 = getCamelCase(WITHOUT_CAMEL_CASE8, conflictResolver);
+ assertThat(camelCase8.equals(WITH_CAMEL_CASE8), is(true));
+ String camelCase9 = getCamelCase(WITHOUT_CAMEL_CASE9, conflictResolver);
+ assertThat(camelCase9.equals(WITH_CAMEL_CASE9), is(true));
+ String camelCase10 = getCamelCase(WITHOUT_CAMEL_CASE10, conflictResolver);
+ assertThat(camelCase10.equals(WITH_CAMEL_CASE10), is(true));
+ String camelCase11 = getCamelCase(WITHOUT_CAMEL_CASE11, conflictResolver);
+ assertThat(camelCase11.equals(WITH_CAMEL_CASE11), is(true));
+ String camelCase12 = getCamelCase(WITHOUT_CAMEL_CASE12, conflictResolver);
+ assertThat(camelCase12.equals(WITH_CAMEL_CASE12), is(true));
+ String camelCase13 = getCamelCase(WITHOUT_CAMEL_CASE13, conflictResolver);
+ assertThat(camelCase13.equals(WITH_CAMEL_CASE13), is(true));
+ String camelCase14 = getCamelCase(WITHOUT_CAMEL_CASE14, conflictResolver);
+ assertThat(camelCase14.equals(WITH_CAMEL_CASE14), is(true));
+ }
+
+ /**
+ * Unit test for getting the camel case along with the prefix provided.
+ */
+ @Test
+ public void getCamelCaseWithPrefixTest() {
+
+ conflictResolver.setPrefixForIdentifier(VALID_PREFIX);
+ String camelCase = getCamelCase(WITHOUT_CAMEL_CASE2, conflictResolver);
+ assertThat(camelCase.equals(WITH_CAMEL_CASE_WITH_PREFIX), is(true));
+ conflictResolver.setPrefixForIdentifier(INVALID_PREFIX1);
+ String camelCase2 = getCamelCase(WITHOUT_CAMEL_CASE3, conflictResolver);
+ assertThat(camelCase2.equals(WITH_CAMEL_CASE_WITH_PREFIX1), is(true));
+ }
+
+ /**
+ * Unit test for getting the camel case along with the invalid prefix provided.
+ */
+ @Test
+ public void getCamelCaseWithInvalidPrefixTest() throws TranslatorException {
+
+ thrown.expect(TranslatorException.class);
+ thrown.expectMessage("The given prefix in pom.xml is invalid.");
+ conflictResolver.setPrefixForIdentifier(INVALID_PREFIX);
+ String camelCase = getCamelCase(WITHOUT_CAMEL_CASE3, conflictResolver);
+ }
+
+ /**
+ * Unit test for getting the camel case for the received string.
+ */
+ @Test
+ public void getSmallCaseTest() {
+ String smallCase = getSmallCase(WITHOUT_CAPITAL);
+ assertThat(smallCase.equals(WITH_SMALL), is(true));
+ }
+
+ /**
+ * Unit test for getting the camel case for the received string.
+ */
+ @Test
+ public void getPackageFromPathTest() {
+ String pkg = getJavaPackageFromPackagePath(PARENT_PACKAGE);
+ assertThat(pkg.equals(PARENT_WITH_PERIOD), is(true));
+ }
+
+ /**
+ * Unit test for getting the camel case for the received string.
+ */
+ @Test
+ public void getPathFromPackageTest() {
+ String path = getPackageDirPathFromJavaJPackage(PARENT_WITH_PERIOD);
+ assertThat(path.equals(PARENT_PACKAGE), is(true));
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
new file mode 100644
index 0000000..05fe52d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
@@ -0,0 +1,318 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
+import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuild;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildForInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getCheckNotNull;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForInterface;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForTypeDefClass;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc;
+import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.BUILD;
+import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
+import static org.onosproject.yangutils.utils.UtilConstants.CHECK_NOT_NULL_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
+import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
+import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
+import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX;
+import static org.onosproject.yangutils.utils.UtilConstants.IMPL;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
+import static org.onosproject.yangutils.utils.UtilConstants.NEW;
+import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
+import static org.onosproject.yangutils.utils.UtilConstants.OBJECT;
+import static org.onosproject.yangutils.utils.UtilConstants.OBJECT_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.OF;
+import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
+import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
+import static org.onosproject.yangutils.utils.UtilConstants.OVERRIDE;
+import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
+import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
+import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
+import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
+import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX;
+import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
+import static org.onosproject.yangutils.utils.UtilConstants.STATIC;
+import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
+import static org.onosproject.yangutils.utils.UtilConstants.SUFFIX_S;
+import static org.onosproject.yangutils.utils.UtilConstants.THIS;
+import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
+import static org.onosproject.yangutils.utils.UtilConstants.VOID;
+
+/**
+ * Unit tests for generated methods from the file type.
+ */
+public final class MethodsGeneratorTest {
+
+ private static final String CLASS_NAME = "testname";
+ private static final String ATTRIBUTE_NAME = "testname";
+
+ /**
+ * Unit test for private constructor.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors()
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {MethodsGenerator.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * Unit test case for checking the parse builder and type constructor.
+ */
+ @Test
+ public void getTypeConstructorTest() {
+
+ YangPluginConfig pluginConfig = new YangPluginConfig();
+ JavaAttributeInfo testAttr = getTestAttribute();
+ String test = getTypeConstructorStringAndJavaDoc(testAttr, CLASS_NAME, pluginConfig);
+ assertThat(true, is(test.contains(PUBLIC + SPACE + CLASS_NAME + OPEN_PARENTHESIS)));
+ }
+
+ /**
+ * Test for build method for class.
+ */
+ @Test
+ public void getBuildTest() {
+ String method = getBuild(CLASS_NAME);
+ assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + PUBLIC + SPACE + CLASS_NAME + SPACE + BUILD
+ + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
+ + RETURN + SPACE + NEW + SPACE + CLASS_NAME + IMPL + OPEN_PARENTHESIS + THIS + CLOSE_PARENTHESIS
+ + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET)));
+
+ }
+
+ /**
+ * Test for build method of interface.
+ */
+ @Test
+ public void getBuildForInterfaceTest() {
+ String method = getBuildForInterface(CLASS_NAME);
+ assertThat(true, is(method.equals(FOUR_SPACE_INDENTATION + CLASS_NAME + SPACE + BUILD +
+ OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE)));
+ }
+
+ /**
+ * Test for check not null method.
+ */
+ @Test
+ public void getCheckNotNullTest() {
+ String method = getCheckNotNull(CLASS_NAME);
+ assertThat(true, is(method.equals(EIGHT_SPACE_INDENTATION + CHECK_NOT_NULL_STRING + OPEN_PARENTHESIS
+ + CLASS_NAME + COMMA + SPACE + CLASS_NAME + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE)));
+ }
+
+ /**
+ * Test case for constructor.
+ */
+ @Test
+ public void getConstructorTest() {
+ JavaAttributeInfo testAttr = getTestAttribute();
+ YangPluginConfig pluginConfig = new YangPluginConfig();
+ String method = getConstructor(CLASS_NAME, testAttr, GENERATE_SERVICE_AND_MANAGER, pluginConfig);
+ assertThat(true, is(method.contains(THIS + PERIOD + CLASS_NAME + SPACE + EQUAL + SPACE + "builder" + OBJECT
+ + PERIOD + GET_METHOD_PREFIX + "Testname" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN)));
+ }
+
+ /**
+ * Test for constrcutor start method.
+ */
+ @Test
+ public void getConstructorStartTest() {
+ YangPluginConfig pluginConfig = new YangPluginConfig();
+ String method = getConstructorStart(CLASS_NAME, pluginConfig);
+ assertThat(true, is(method.contains(PUBLIC + SPACE + CLASS_NAME + IMPL + OPEN_PARENTHESIS + CLASS_NAME
+ + BUILDER + SPACE + BUILDER.toLowerCase() + OBJECT + CLOSE_PARENTHESIS + SPACE
+ + OPEN_CURLY_BRACKET + NEW_LINE)));
+ }
+
+ /**
+ * Test case for equals method.
+ */
+ @Test
+ public void getEqualsMethodTest() {
+ JavaAttributeInfo testAttr = getTestAttribute();
+ String method = getEqualsMethod(testAttr);
+ assertThat(true, is(method.contains(SIXTEEN_SPACE_INDENTATION + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD
+ + EQUALS_STRING + OPEN_PARENTHESIS)));
+ }
+
+ /**
+ * Test for to string method.
+ */
+ @Test
+ public void getToStringMethodTest() {
+ JavaAttributeInfo testAttr = getTestAttribute();
+ String method = getToStringMethod(testAttr);
+ assertThat(true, is(method.equals(
+ TWELVE_SPACE_INDENTATION + PERIOD + ADD_STRING + OPEN_PARENTHESIS + QUOTES + testAttr.getAttributeName()
+ + QUOTES + COMMA + SPACE + testAttr.getAttributeName() + CLOSE_PARENTHESIS)));
+ }
+
+ /**
+ * Test for getter method of class.
+ */
+ @Test
+ public void getGetterForClassTest() {
+ JavaAttributeInfo testAttr = getTestAttribute();
+ String method = getGetterForClass(testAttr, GENERATE_SERVICE_AND_MANAGER);
+ assertThat(true, is(method.contains(PUBLIC + SPACE + STRING_DATA_TYPE + SPACE + GET_METHOD_PREFIX)));
+ }
+
+ /**
+ * Test for getter of interface.
+ */
+ @Test
+ public void getGetterForInterfaceTest() {
+ String method = getGetterForInterface(CLASS_NAME, STRING_DATA_TYPE, false, GENERATE_SERVICE_AND_MANAGER);
+ assertThat(true, is(method.contains(STRING_DATA_TYPE + SPACE + GET_METHOD_PREFIX)));
+ }
+
+ /**
+ * Test case for setter method of class.
+ */
+ @Test
+ public void getSetterForClassTest() {
+ JavaAttributeInfo testAttr = getTestAttribute();
+ String method = getSetterForClass(testAttr, CLASS_NAME, GENERATE_SERVICE_AND_MANAGER);
+ assertThat(true, is(
+ method.contains(PUBLIC + SPACE + VOID + SPACE +
+ SET_METHOD_PREFIX + getCapitalCase(CLASS_NAME) + OPEN_PARENTHESIS +
+ STRING_DATA_TYPE + SPACE + ATTRIBUTE_NAME)));
+ }
+
+ /**
+ * Test for setter method of interface.
+ */
+ @Test
+ public void getSetterForInterfaceTest() {
+ String method = getSetterForInterface(CLASS_NAME, STRING_DATA_TYPE, CLASS_NAME, false,
+ GENERATE_SERVICE_AND_MANAGER);
+ assertThat(true, is(method.contains(VOID + SPACE +
+ SET_METHOD_PREFIX + "Testname")));
+ }
+
+ /**
+ * Test case for of method.
+ */
+ @Test
+ public void getOfMethodest() {
+ JavaAttributeInfo testAttr = getTestAttribute();
+ String method = getOfMethod(CLASS_NAME, testAttr);
+ assertThat(true, is(method.contains(PUBLIC + SPACE + STATIC + SPACE + CLASS_NAME + SPACE + OF + OPEN_PARENTHESIS
+ + STRING_DATA_TYPE + SPACE + VALUE + CLOSE_PARENTHESIS)));
+ }
+
+ /**
+ * Test case for setter in type def class.
+ */
+ @Test
+ public void getSetterForTypeDefClassTest() {
+ JavaAttributeInfo testAttr = getTestAttribute();
+ String method = getSetterForTypeDefClass(testAttr);
+ assertThat(true, is(method.contains(PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX)));
+ }
+
+ /**
+ * Test case for over ride string.
+ */
+ @Test
+ public void getOverRideStringTest() {
+ String method = getOverRideString();
+ assertThat(true, is(method.contains(OVERRIDE)));
+ }
+
+ /**
+ * Returns java attribute.
+ *
+ * @return java attribute
+ */
+ private JavaAttributeInfo getTestAttribute() {
+ JavaAttributeInfo testAttr = new JavaAttributeInfo(getTestYangType(), ATTRIBUTE_NAME, false, false);
+ testAttr.setAttributeName(ATTRIBUTE_NAME);
+ testAttr.setAttributeType(getTestYangType());
+ testAttr.setImportInfo(getTestJavaQualifiedTypeInfo());
+ return testAttr;
+ }
+
+ /**
+ * Returns java qualified info.
+ *
+ * @return java qualified info
+ */
+ private JavaQualifiedTypeInfo getTestJavaQualifiedTypeInfo() {
+ JavaQualifiedTypeInfo info = new JavaQualifiedTypeInfo();
+ info.setPkgInfo(JAVA_LANG);
+ info.setClassInfo(STRING_DATA_TYPE);
+ return info;
+ }
+
+ /**
+ * Returns stub YANG type.
+ *
+ * @return test YANG type
+ */
+ private YangType<?> getTestYangType() {
+ YangType<?> attrType = new YangType<>();
+ attrType.setDataTypeName(STRING_DATA_TYPE);
+ attrType.setDataType(STRING);
+ return attrType;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/NotificationTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/NotificationTranslatorTest.java
new file mode 100644
index 0000000..f4d8bf8
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/NotificationTranslatorTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Unit tests for union translator.
+ */
+public final class NotificationTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks union translation should not result in any exception.
+ */
+ @Test
+ public void processUnionTranslator()
+ throws IOException, ParserException {
+
+ String userDir = System.getProperty("user.dir");
+ YangNode node = manager.getDataModel("src/test/resources/NotificationTest.yang");
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(userDir + "/target/NotificationTest/");
+
+ generateJavaCode(node, yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/NotificationTest/");
+ }
+
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java
new file mode 100644
index 0000000..9b8077c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Unit tests for rpc translator.
+ */
+public final class RpcTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks rpc translation should not result in any exception.
+ */
+ @Test
+ public void processRpcTranslator()
+ throws IOException, ParserException {
+
+ String userDir = System.getProperty("user.dir");
+ YangNode node = manager.getDataModel("src/test/resources/RpcTranslator.yang");
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(userDir + "/target/RpcTestGenFile/");
+
+ generateJavaCode(node, yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/RpcTestGenFile/");
+ }
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java
new file mode 100644
index 0000000..9dcdfdf
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/translator/tojava/utils/UnionTranslatorTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Unit tests for union translator.
+ */
+public final class UnionTranslatorTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks union translation should not result in any exception.
+ */
+ @Test
+ public void processUnionTranslator()
+ throws IOException, ParserException {
+
+ String userDir = System.getProperty("user.dir");
+ YangNode node = manager.getDataModel("src/test/resources/UnionTranslator.yang");
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/UnionTestGenFile/");
+
+ generateJavaCode(node, yangPluginConfig);
+
+ deleteDirectory(userDir + "/target/UnionTestGenFile/");
+ }
+
+ // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/UtilConstantsTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/UtilConstantsTest.java
new file mode 100644
index 0000000..a63d432
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/UtilConstantsTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.utils;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test case for testing the util constants.
+ */
+public final class UtilConstantsTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * A private constructor is tested.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {UtilConstants.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/CopyrightHeaderTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/CopyrightHeaderTest.java
new file mode 100644
index 0000000..40ac92c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/CopyrightHeaderTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.utils.io.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Calendar;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.apache.commons.io.FileUtils.contentEquals;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.utils.io.impl.CopyrightHeader.getCopyrightHeader;
+
+/**
+ * Unit Tests for the CopyrightHeader contents.
+ */
+public final class CopyrightHeaderTest {
+
+ private static final String COPYRIGHTS_FIRST_LINE = "/*\n * Copyright " + Calendar.getInstance().get(Calendar.YEAR)
+ + "-present Open Networking Laboratory\n";
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * Unit test for testing private constructor.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {CopyrightHeader.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * This test case checks the received copyright header contents.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void testGetCopyrightHeader() throws IOException {
+
+ String path = "src/test/resources/CopyrightHeader.txt";
+
+ File testRsc = new File(path);
+ FileInputStream in = new FileInputStream(testRsc);
+
+ File testFile = new File("target/TestHeader.txt");
+ FileOutputStream out = new FileOutputStream(testFile);
+
+ out.write(COPYRIGHTS_FIRST_LINE.getBytes());
+ int c = 0;
+ while ((c = in.read()) != -1) {
+ out.write(c);
+ }
+
+ String licenseHeader = getCopyrightHeader();
+ File test = new File("target/TestCopyrightHeader.txt");
+
+ FileWriter writer = new FileWriter(test);
+ writer.write(licenseHeader);
+ writer.close();
+ out.close();
+ out.flush();
+ in.close();
+
+ assertThat(true, is(contentEquals(test, testFile)));
+ test.delete();
+ testFile.delete();
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
new file mode 100644
index 0000000..5fd728b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.utils.io.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
+import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
+import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents;
+import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
+import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.doesPackageExist;
+import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle;
+
+/**
+ * Tests the file handle utilities.
+ */
+public final class FileSystemUtilTest {
+
+ private static final String BASE_DIR_PKG = "target.UnitTestCase.";
+ private static final String BASE_PKG = "target/UnitTestCase";
+ private static final String TEST_DATA_1 = "This is to append a text to the file first1\n";
+ private static final String TEST_DATA_2 = "This is next second line\n";
+ private static final String TEST_DATA_3 = "This is next third line in the file";
+ private static final String TEST_FILE = "testFile";
+ private static final String SOURCE_TEST_FILE = "sourceTestFile";
+ private static final String DIR_PATH = "exist1.exist2.exist3";
+ private static final String PKG_INFO = "package-info.java";
+
+ /**
+ * A private constructor is tested.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors()
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {FileSystemUtil.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * This test case checks the contents to be written in the file.
+ *
+ * @throws IOException when fails to create a test file
+ */
+ @Test
+ public void updateFileHandleTest() throws IOException {
+
+ File dir = new File(BASE_PKG + SLASH + TEST_FILE);
+ dir.mkdirs();
+ File createFile = new File(dir + TEST_FILE);
+ createFile.createNewFile();
+ File createSourceFile = new File(dir + SOURCE_TEST_FILE);
+ createSourceFile.createNewFile();
+ updateFileHandle(createFile, TEST_DATA_1, false);
+ updateFileHandle(createFile, TEST_DATA_2, false);
+ updateFileHandle(createFile, TEST_DATA_3, false);
+ appendFileContents(createFile, createSourceFile);
+ updateFileHandle(createFile, null, true);
+ deleteDirectory(dir);
+ }
+
+ /**
+ * This test case checks whether the package is existing.
+ *
+ * @throws IOException when failed to create a test file
+ */
+ @Test
+ public void packageExistTest() throws IOException {
+
+ String strPath = BASE_DIR_PKG + DIR_PATH;
+ File createDir = new File(strPath.replace(PERIOD, SLASH));
+ createDir.mkdirs();
+ File createFile = new File(createDir + SLASH + PKG_INFO);
+ createFile.createNewFile();
+ assertThat(true, is(doesPackageExist(strPath)));
+ createPackage(getStubNode());
+ createDir.delete();
+ deleteDirectory(createDir);
+ }
+
+ /**
+ * Returns stub YANG node.
+ *
+ * @return stub node
+ */
+ private YangNode getStubNode() {
+ YangJavaModule module = new YangJavaModule();
+ module.setName(TEST_DATA_1);
+ JavaFileInfo javafileInfo = new JavaFileInfo();
+ javafileInfo.setJavaName(TEST_DATA_1);
+ javafileInfo.setBaseCodeGenPath("");
+ javafileInfo.setPackageFilePath(BASE_PKG);
+ javafileInfo.setPluginConfig(getStubPluginConfig());
+ module.setJavaFileInfo(javafileInfo);
+ return module;
+ }
+
+ /**
+ * Returns stub pluginConfig.
+ *
+ * @return stub pluginConfig
+ */
+ private YangPluginConfig getStubPluginConfig() {
+ YangPluginConfig pluginConfig = new YangPluginConfig();
+ pluginConfig.setConflictResolver(null);
+ return pluginConfig;
+ }
+
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
new file mode 100644
index 0000000..2e9f436
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/JavaDocGenTest.java
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.utils.io.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_CLASS;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_INTERFACE;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.IMPL_CLASS;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INTERFACE;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_DEF_SETTER_METHOD;
+
+/**
+ * Tests the java doc that is generated.
+ */
+public final class JavaDocGenTest {
+
+ private static final String TEST_NAME = "testName";
+ private static final String END_STRING = " */\n";
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * This test case checks the content received for the builder class java doc.
+ */
+ @Test
+ public void builderClassGenerationTest() {
+ String builderClassJavaDoc = getJavaDoc(BUILDER_CLASS, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true, is(builderClassJavaDoc.contains("Represents the builder implementation of")
+ && builderClassJavaDoc.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the builder interface ge java doc.
+ */
+ @Test
+ public void builderInterfaceGenerationTest() {
+ String builderInterfaceJavaDoc = getJavaDoc(BUILDER_INTERFACE, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true,
+ is(builderInterfaceJavaDoc.contains("Builder for")
+ && builderInterfaceJavaDoc.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the build java doc.
+ */
+ @Test
+ public void buildGenerationTest() {
+ String buildDoc = getJavaDoc(BUILD_METHOD, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true, is(buildDoc.contains("Builds object of") && buildDoc.contains(END_STRING)));
+ }
+
+ /**
+ * A private constructor is tested.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors()
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {JavaDocGen.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * This test case checks the content received for the constructor java doc.
+ */
+ @Test
+ public void constructorGenerationTest() {
+ String constructorDoc = getJavaDoc(CONSTRUCTOR, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true,
+ is(constructorDoc.contains("Creates an instance of ")
+ && constructorDoc.contains("builder object of")
+ && constructorDoc.contains("@param") && constructorDoc.contains("*/\n")));
+ }
+
+ /**
+ * This test case checks the content received for the default constructor java doc.
+ */
+ @Test
+ public void defaultConstructorGenerationTest() {
+ String defaultConstructorDoc = getJavaDoc(DEFAULT_CONSTRUCTOR, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true, is(defaultConstructorDoc.contains("Creates an instance of ")
+ && defaultConstructorDoc.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the getter java doc.
+ */
+ @Test
+ public void getterGenerationTest() {
+ String getterJavaDoc = getJavaDoc(GETTER_METHOD, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true,
+ is(getterJavaDoc.contains("Returns the attribute") && getterJavaDoc.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the impl class java doc.
+ */
+ @Test
+ public void implClassGenerationTest() {
+ String implClassJavaDoc = getJavaDoc(IMPL_CLASS, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true,
+ is(implClassJavaDoc.contains("Represents the implementation of")
+ && implClassJavaDoc.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the interface java doc.
+ */
+ @Test
+ public void interfaceGenerationTest() {
+ String interfaceJavaDoc = getJavaDoc(INTERFACE, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true,
+ is(interfaceJavaDoc.contains("Abstraction of an entity which represents the functionality of")
+ && interfaceJavaDoc.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the package info java doc.
+ */
+ @Test
+ public void packageInfoGenerationTest() {
+ String packageInfo = getJavaDoc(PACKAGE_INFO, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true,
+ is(packageInfo.contains("Implementation of YANG node") && packageInfo.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the package info java doc.
+ */
+ @Test
+ public void packageInfoGenerationForChildNodeTest() {
+ String packageInfo = getJavaDoc(PACKAGE_INFO, TEST_NAME, true, getStubPluginConfig());
+ assertThat(true, is(packageInfo.contains("Implementation of YANG node testName's children nodes")
+ && packageInfo.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the setter java doc.
+ */
+ @Test
+ public void setterGenerationTest() {
+ String setterJavaDoc = getJavaDoc(SETTER_METHOD, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true,
+ is(setterJavaDoc.contains("Returns the builder object of") && setterJavaDoc.contains(END_STRING)));
+ }
+
+ /**
+ * This test case checks the content received for the typedef setter java doc.
+ */
+ @Test
+ public void typeDefSetterGenerationTest() {
+ String typeDefSetter = getJavaDoc(TYPE_DEF_SETTER_METHOD, TEST_NAME, false, getStubPluginConfig());
+ assertThat(true, is(typeDefSetter.contains("Sets the value of") && typeDefSetter.contains(END_STRING)));
+ }
+
+ /**
+ * Returns stub pluginConfig.
+ *
+ * @return stub pluginConfig
+ */
+ private YangPluginConfig getStubPluginConfig() {
+ YangPluginConfig pluginConfig = new YangPluginConfig();
+ pluginConfig.setConflictResolver(null);
+ return pluginConfig;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangFileScannerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangFileScannerTest.java
new file mode 100644
index 0000000..566d24b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangFileScannerTest.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.utils.io.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static java.io.File.separator;
+
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.utils.io.impl.YangFileScanner.getJavaFiles;
+import static org.onosproject.yangutils.utils.io.impl.YangFileScanner.getYangFiles;
+
+/**
+ * Test the file scanner service.
+ */
+public final class YangFileScannerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ String baseDir = "target/UnitTestCase";
+
+ /**
+ * A private constructor is tested.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {YangFileScanner.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * This test case checks for a .java file inside the specified dir.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void checkJavaFileInsideDirTest() throws IOException {
+
+ String dir = baseDir + separator + "scanner2";
+ File path = createDirectory(dir);
+ createFile(path, "testScanner.java");
+ List<String> dirContents = getJavaFiles(path.toString());
+ List<String> expectedContents = new LinkedList<>();
+ expectedContents.add(path.getCanonicalPath() + separator + "testScanner.java");
+ assertThat(true, is(dirContents.equals(expectedContents)));
+ deleteDirectory(path);
+ }
+
+ /**
+ * Method used for creating multiple directories inside the target file.
+ *
+ * @param path where directories should be created
+ * @return the directory path that is created
+ */
+ private File createDirectory(String path) {
+
+ File myDir = new File(path);
+ myDir.mkdirs();
+ return myDir;
+ }
+
+ /**
+ * Method used for creating file inside the specified directory.
+ *
+ * @param myDir the path where file has to be created inside
+ * @param fileName the name of the file to be created
+ */
+ private void createFile(File myDir, String fileName) throws IOException {
+
+ File file = null;
+ file = new File(myDir + separator + fileName);
+ file.createNewFile();
+ }
+
+ /**
+ * This testcase checks for a java file inside an empty directory.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void emptyDirJavaScannerTest() throws IOException {
+
+ String emptyDir = baseDir + separator + "scanner1";
+ File path = createDirectory(emptyDir);
+ List<String> emptyDirContents = getJavaFiles(path.toString());
+ List<String> expectedContents = new LinkedList<>();
+ assertThat(true, is(emptyDirContents.equals(expectedContents)));
+ deleteDirectory(path);
+ }
+
+ /**
+ * This testcase checks for a yang file inside an empty directory.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void emptyDirYangScannerTest() throws IOException {
+
+ String emptyYangDir = baseDir + separator + "scanner1";
+ File path = createDirectory(emptyYangDir);
+ List<String> emptyDirContents = getYangFiles(path.toString());
+ List<String> expectedContents = new LinkedList<>();
+ assertThat(true, is(emptyDirContents.equals(expectedContents)));
+ deleteDirectory(path);
+ }
+
+ /**
+ * This test case checks with the sub directories in the given path for java files.
+ *
+ * @throws IOException when fails to do IO operations
+ */
+ @Test
+ public void emptySubDirScannerTest() throws IOException {
+
+ String dir = baseDir + separator + "scanner3";
+ File path = createDirectory(dir);
+ String subDir = path.toString() + separator + "subDir1";
+ createDirectory(subDir);
+ createFile(path, "invalidFile.txt");
+ List<String> emptySubDirContents = getJavaFiles(path.toString());
+ List<String> expectedContents = new LinkedList<>();
+ assertThat(true, is(emptySubDirContents.equals(expectedContents)));
+ deleteDirectory(path);
+ }
+
+}
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
new file mode 100644
index 0000000..c10ed03
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/YangIoUtilsTest.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.utils.io.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.project.MavenProject;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
+import org.onosproject.yangutils.utils.UtilConstants;
+import org.sonatype.plexus.build.incremental.BuildContext;
+import org.sonatype.plexus.build.incremental.DefaultBuildContext;
+
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addToCompilationRoot;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
+
+/**
+ * Unit tests for YANG IO utils.
+ */
+public final class YangIoUtilsTest {
+
+ private static final String BASE_DIR = "target/UnitTestCase";
+ private static final String CREATE_PATH = BASE_DIR + File.separator + "dir1/dir2/dir3/dir4/";
+ private static final String CHECK_STRING = "one, two, three, four, five, six";
+ private static final String TRIM_STRING = "one, two, three, four, five, ";
+ private static final String CHECK1 = "check1";
+ private static final String PKG_INFO = "package-info.java";
+ private static final String PATH = "src/main/yangmodel/";
+ private static final String MSG = "Exception occured while creating package info file.";
+
+ /**
+ * Expected exceptions.
+ */
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * This test case checks whether the package-info file is created.
+ *
+ * @throws IOException when fails to do IO operations for test case
+ */
+ @Test
+ public void addPackageInfoTest() throws IOException {
+
+ File dirPath = new File(CREATE_PATH);
+ dirPath.mkdirs();
+ addPackageInfo(dirPath, CHECK1, CREATE_PATH, false, getStubPluginConfig());
+ File filePath = new File(dirPath + File.separator + PKG_INFO);
+ assertThat(filePath.isFile(), is(true));
+ FileUtils.deleteDirectory(dirPath);
+ }
+
+ /**
+ * This test case checks with an additional info in the path.
+ *
+ * @throws IOException when fails to do IO operations for test case
+ */
+ @Test
+ public void addPackageInfoWithPathTest() throws IOException {
+
+ File dirPath = new File(CREATE_PATH);
+ dirPath.mkdirs();
+ addPackageInfo(dirPath, CHECK1, PATH + CREATE_PATH, false, getStubPluginConfig());
+ File filePath = new File(dirPath + File.separator + PKG_INFO);
+ assertThat(filePath.isFile(), is(true));
+ FileUtils.deleteDirectory(dirPath);
+ }
+
+ /**
+ * This test case checks with a child node.
+ *
+ * @throws IOException when fails to do IO operations for test case
+ */
+ @Test
+ public void addPackageInfoWithChildNode() throws IOException {
+
+ File dirPath = new File(CREATE_PATH);
+ dirPath.mkdirs();
+ addPackageInfo(dirPath, CHECK1, PATH + CREATE_PATH, true, getStubPluginConfig());
+ File filePath = new File(dirPath + File.separator + PKG_INFO);
+ assertThat(filePath.isFile(), is(true));
+ FileUtils.deleteDirectory(dirPath);
+ }
+
+ /**
+ * This test case checks whether the package-info file is created when invalid path is given.
+ *
+ * @throws IOException when fails to do IO operations for test case
+ */
+ @Test
+ public void addPackageInfoWithEmptyPathTest() throws IOException {
+
+ File dirPath = new File("invalid/check");
+ thrown.expect(IOException.class);
+ thrown.expectMessage(MSG);
+ addPackageInfo(dirPath, CHECK1, CREATE_PATH, false, getStubPluginConfig());
+ File filePath1 = new File(dirPath + File.separator + PKG_INFO);
+ assertThat(filePath1.isFile(), is(false));
+ FileUtils.deleteDirectory(dirPath);
+ }
+
+ /**
+ * A private constructor is tested.
+ *
+ * @throws SecurityException if any security violation is observed
+ * @throws NoSuchMethodException if when the method is not found
+ * @throws IllegalArgumentException if there is illegal argument found
+ * @throws InstantiationException if instantiation is provoked for the private constructor
+ * @throws IllegalAccessException if instance is provoked or a method is provoked
+ * @throws InvocationTargetException when an exception occurs by the method or constructor
+ */
+ @Test
+ public void callPrivateConstructors()
+ throws SecurityException, NoSuchMethodException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException {
+
+ Class<?>[] classesToConstruct = {YangIoUtils.class };
+ for (Class<?> clazz : classesToConstruct) {
+ Constructor<?> constructor = clazz.getDeclaredConstructor();
+ constructor.setAccessible(true);
+ assertThat(null, not(constructor.newInstance()));
+ }
+ }
+
+ /**
+ * This test case checks if the directory is cleaned.
+ *
+ * @throws IOException when fails to do IO operations for test case
+ */
+ @Test
+ public void cleanGeneratedDirTest() throws IOException {
+
+ File baseDirPath = new File(BASE_DIR);
+ File createNewDir = new File(BASE_DIR + File.separator + UtilConstants.YANG_GEN_DIR);
+ createNewDir.mkdirs();
+ File createFile = new File(createNewDir + File.separator + "check1.java");
+ createFile.createNewFile();
+ deleteDirectory(baseDirPath.getAbsolutePath());
+ FileUtils.deleteDirectory(createNewDir);
+ FileUtils.deleteDirectory(baseDirPath);
+ }
+
+ /**
+ * This test case checks the cleaning method when an invalid path is provided.
+ *
+ * @throws IOException when fails to do IO operations for test case
+ */
+ @Test
+ public void cleanWithInvalidDirTest() throws IOException {
+
+ File baseDirPath = new File(BASE_DIR + "invalid");
+ deleteDirectory(baseDirPath.getAbsolutePath());
+ }
+
+ /**
+ * This test case tests whether the directories are getting created.
+ */
+ @Test
+ public void createDirectoryTest() throws IOException {
+
+ File dirPath = createDirectories(CREATE_PATH);
+ assertThat(dirPath.isDirectory(), is(true));
+ FileUtils.deleteDirectory(dirPath);
+ }
+
+ /**
+ * This test case checks whether the source is getting added.
+ */
+ @Test
+ public void testForAddSource() throws IOException {
+
+ MavenProject project = new MavenProject();
+ BuildContext context = new DefaultBuildContext();
+ File sourceDir = new File(BASE_DIR + File.separator + "yang");
+ sourceDir.mkdirs();
+ addToCompilationRoot(sourceDir.toString(), project, context);
+ FileUtils.deleteDirectory(sourceDir);
+ }
+
+ /**
+ * Unit test case for trim at last method.
+ */
+ @Test
+ public void testForTrimAtLast() {
+
+ String test = trimAtLast(CHECK_STRING, "six");
+ assertThat(test.contains(TRIM_STRING), is(true));
+ }
+
+ /**
+ * Returns stub pluginConfig.
+ *
+ * @return stub pluginConfig
+ */
+ private YangPluginConfig getStubPluginConfig() {
+ YangPluginConfig pluginConfig = new YangPluginConfig();
+ pluginConfig.setConflictResolver(null);
+ return pluginConfig;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/AnyxmlStatement.yang b/utils/yangutils/plugin/src/test/resources/AnyxmlStatement.yang
new file mode 100644
index 0000000..4b1e421
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/AnyxmlStatement.yang
@@ -0,0 +1,16 @@
+module event {
+
+ namespace "http://example.com/event";
+ prefix "ev";
+
+ notification event {
+ leaf event-class {
+ type string;
+ }
+ anyxml reporting-entity;
+ leaf severity {
+ type string;
+ }
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/BelongsToDualPrefix.yang b/utils/yangutils/plugin/src/test/resources/BelongsToDualPrefix.yang
new file mode 100644
index 0000000..37973da
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BelongsToDualPrefix.yang
@@ -0,0 +1,8 @@
+submodule Test {
+yang-version 1;
+belongs-to ONOS {
+prefix On1;
+prefix On2;
+}
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/BelongsToWithPrefix.yang b/utils/yangutils/plugin/src/test/resources/BelongsToWithPrefix.yang
new file mode 100644
index 0000000..75a13ca
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BelongsToWithPrefix.yang
@@ -0,0 +1,6 @@
+submodule Test {
+yang-version 1;
+belongs-to ONOS {
+prefix On1;
+}
+}
diff --git a/utils/yangutils/plugin/src/test/resources/BelongsToWithoutPrefix.yang b/utils/yangutils/plugin/src/test/resources/BelongsToWithoutPrefix.yang
new file mode 100644
index 0000000..eaf9885
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BelongsToWithoutPrefix.yang
@@ -0,0 +1,6 @@
+submodule Test {
+yang-version 1;
+belongs-to ONOS {
+}
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/BitTypeStatement.yang b/utils/yangutils/plugin/src/test/resources/BitTypeStatement.yang
new file mode 100644
index 0000000..9d13495
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BitTypeStatement.yang
@@ -0,0 +1,12 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf mybits {
+ type bits {
+ bit disable-nagle;
+ bit auto-sense-speed;
+ bit Ten-Mb-only;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/BitTypedefStatement.yang b/utils/yangutils/plugin/src/test/resources/BitTypedefStatement.yang
new file mode 100644
index 0000000..d3dc26a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BitTypedefStatement.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef type15 {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Mb-only {
+ position 2;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/BitUnionStatement.yang b/utils/yangutils/plugin/src/test/resources/BitUnionStatement.yang
new file mode 100644
index 0000000..dd62eae
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BitUnionStatement.yang
@@ -0,0 +1,20 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf type15 {
+ type union {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Mb-only {
+ position 2;
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/BitWithDuplicateName.yang b/utils/yangutils/plugin/src/test/resources/BitWithDuplicateName.yang
new file mode 100644
index 0000000..ed5cc32
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BitWithDuplicateName.yang
@@ -0,0 +1,12 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf mybits {
+ type bits {
+ bit disable-nagle;
+ bit disable-nagle;
+ bit Ten-Mb-only;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/CaseChoiceHierarchy.yang b/utils/yangutils/plugin/src/test/resources/CaseChoiceHierarchy.yang
new file mode 100644
index 0000000..28d110e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/CaseChoiceHierarchy.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type empty;
+ }
+ }
+ case late-night {
+ choice dinner {
+ case late-night {
+ leaf beer {
+ type empty;
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/CaseStatement.yang b/utils/yangutils/plugin/src/test/resources/CaseStatement.yang
new file mode 100644
index 0000000..bb3f6c9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/CaseStatement.yang
@@ -0,0 +1,26 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type empty;
+ }
+ leaf beer {
+ type empty;
+ }
+ }
+ case late-night {
+ leaf chocolate {
+ type enumeration {
+ enum dark;
+ enum milk;
+ enum first-available;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/CaseStatementSameEntryDifferentChoice.yang b/utils/yangutils/plugin/src/test/resources/CaseStatementSameEntryDifferentChoice.yang
new file mode 100644
index 0000000..b42cdf9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/CaseStatementSameEntryDifferentChoice.yang
@@ -0,0 +1,28 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type empty;
+ }
+ leaf beer {
+ type empty;
+ }
+ }
+ }
+ choice lunch {
+ case sports-arena {
+ leaf chocolate {
+ type enumeration {
+ enum dark;
+ enum milk;
+ enum first-available;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ChoiceCaseTranslator.yang b/utils/yangutils/plugin/src/test/resources/ChoiceCaseTranslator.yang
new file mode 100644
index 0000000..e8127ea
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ChoiceCaseTranslator.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type string;
+ }
+ leaf beer {
+ type string;
+ }
+ }
+ case late-night {
+ leaf chocolate {
+ type string;
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ChoiceStatementDuplicateEntry.yang b/utils/yangutils/plugin/src/test/resources/ChoiceStatementDuplicateEntry.yang
new file mode 100644
index 0000000..d2a6371
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ChoiceStatementDuplicateEntry.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack;
+ choice lunch;
+ choice snack;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ChoiceStatementSameEntryDifferentContainer.yang b/utils/yangutils/plugin/src/test/resources/ChoiceStatementSameEntryDifferentContainer.yang
new file mode 100644
index 0000000..39ba626
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ChoiceStatementSameEntryDifferentContainer.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food1 {
+ choice snack;
+ choice lunch;
+ }
+ container food2 {
+ choice snack;
+ choice lunch;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ChoiceStatementWithStmtend.yang b/utils/yangutils/plugin/src/test/resources/ChoiceStatementWithStmtend.yang
new file mode 100644
index 0000000..4b85f59
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ChoiceStatementWithStmtend.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ChoiceStatementWithoutBody.yang b/utils/yangutils/plugin/src/test/resources/ChoiceStatementWithoutBody.yang
new file mode 100644
index 0000000..2de7787
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ChoiceStatementWithoutBody.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ChoiceSubStatementDefault.yang b/utils/yangutils/plugin/src/test/resources/ChoiceSubStatementDefault.yang
new file mode 100644
index 0000000..b9fd60d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ChoiceSubStatementDefault.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type string;
+ }
+ leaf beer {
+ type string;
+ }
+ }
+ case late-night {
+ leaf chocolate {
+ type string;
+ }
+ }
+ default "hello";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigDefaultValue.yang b/utils/yangutils/plugin/src/test/resources/ConfigDefaultValue.yang
new file mode 100644
index 0000000..7e19946
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigDefaultValue.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigEmptyValue.yang b/utils/yangutils/plugin/src/test/resources/ConfigEmptyValue.yang
new file mode 100644
index 0000000..0d62956
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigEmptyValue.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ config ;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalse.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalse.yang
new file mode 100644
index 0000000..79dc5ac
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalse.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config false;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseNoKey.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseNoKey.yang
new file mode 100644
index 0000000..66f141e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseNoKey.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ config false;
+ leaf invalid-interval {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildLeaf.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildLeaf.yang
new file mode 100644
index 0000000..ecc0806
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildLeaf.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ config false;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ config true;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildLeafList.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildLeafList.yang
new file mode 100644
index 0000000..e3c7836
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildLeafList.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ config false;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ config true;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildList.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildList.yang
new file mode 100644
index 0000000..ffc6f60
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentContainerChildList.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ config false;
+ list valid {
+ key "invalid-interval";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildContainer.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildContainer.yang
new file mode 100644
index 0000000..3158dd4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildContainer.yang
@@ -0,0 +1,24 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ config false;
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ container valid {
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildLeaf.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildLeaf.yang
new file mode 100644
index 0000000..65171dd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildLeaf.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ config false;
+ leaf invalid-interval {
+ type "uint16";
+ config true;
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildLeafList.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildLeafList.yang
new file mode 100644
index 0000000..33132cd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseParentListChildLeafList.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ config false;
+ leaf-list invalid-interval {
+ type "uint16";
+ config true;
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseValidKeyValidLeaf.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseValidKeyValidLeaf.yang
new file mode 100644
index 0000000..368a4b5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseValidKeyValidLeaf.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ config false;
+ leaf invalid-interval {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigFalseValidKeyValidLeafList.yang b/utils/yangutils/plugin/src/test/resources/ConfigFalseValidKeyValidLeafList.yang
new file mode 100644
index 0000000..4196be4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigFalseValidKeyValidLeafList.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf-list invalid-interval {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigInvalidValue.yang b/utils/yangutils/plugin/src/test/resources/ConfigInvalidValue.yang
new file mode 100644
index 0000000..b2e7659
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigInvalidValue.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ config invalid;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigTrue.yang b/utils/yangutils/plugin/src/test/resources/ConfigTrue.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigTrue.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigTrueNoKey.yang b/utils/yangutils/plugin/src/test/resources/ConfigTrueNoKey.yang
new file mode 100644
index 0000000..7a0a538
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigTrueNoKey.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ config true;
+ leaf invalid-interval {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigTrueNoleafNoLeafList.yang b/utils/yangutils/plugin/src/test/resources/ConfigTrueNoleafNoLeafList.yang
new file mode 100644
index 0000000..c553e60
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigTrueNoleafNoLeafList.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ config true;
+ container container1 {
+ leaf leaf1 {
+ type "string";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigTrueValidKeyValidLeaf.yang b/utils/yangutils/plugin/src/test/resources/ConfigTrueValidKeyValidLeaf.yang
new file mode 100644
index 0000000..fe8efe3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigTrueValidKeyValidLeaf.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigTrueValidKeyValidLeafList.yang b/utils/yangutils/plugin/src/test/resources/ConfigTrueValidKeyValidLeafList.yang
new file mode 100644
index 0000000..4196be4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigTrueValidKeyValidLeafList.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf-list invalid-interval {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ConfigWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/ConfigWithoutStatementEnd.yang
new file mode 100644
index 0000000..0ae02af
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ConfigWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ config false
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContactDualEntryTest.yang b/utils/yangutils/plugin/src/test/resources/ContactDualEntryTest.yang
new file mode 100644
index 0000000..2dca10e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContactDualEntryTest.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+contact "WG List";
+contact "Invalid";
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/ContactIncorrectOrder.yang b/utils/yangutils/plugin/src/test/resources/ContactIncorrectOrder.yang
new file mode 100644
index 0000000..237d003
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContactIncorrectOrder.yang
@@ -0,0 +1,7 @@
+module Test {
+yang-version 1;
+contact "Test";
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ContactValidEntry.yang b/utils/yangutils/plugin/src/test/resources/ContactValidEntry.yang
new file mode 100644
index 0000000..f88e147
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContactValidEntry.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+contact "WG List: <mailto:spring@ietf.org>
+Editor: Stephane Litkowski
+ <mailto:stephane.litkowski@orange.com>";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ContactWithEmptyString.yang b/utils/yangutils/plugin/src/test/resources/ContactWithEmptyString.yang
new file mode 100644
index 0000000..34c6008
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContactWithEmptyString.yang
@@ -0,0 +1,7 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+contact;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ContactWithoutQuotes.yang b/utils/yangutils/plugin/src/test/resources/ContactWithoutQuotes.yang
new file mode 100644
index 0000000..20ab72b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContactWithoutQuotes.yang
@@ -0,0 +1,8 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+contact WG;
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerDuplicateContainer.yang b/utils/yangutils/plugin/src/test/resources/ContainerDuplicateContainer.yang
new file mode 100644
index 0000000..4928463
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerDuplicateContainer.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/ContainerInvalidIdentifier.yang
new file mode 100644
index 0000000..eee1acd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerInvalidIdentifier.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container 1valid {
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerRootNode.yang b/utils/yangutils/plugin/src/test/resources/ContainerRootNode.yang
new file mode 100644
index 0000000..441d717
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerRootNode.yang
@@ -0,0 +1,9 @@
+container valid {
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementCardinality.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementCardinality.yang
new file mode 100644
index 0000000..731e389
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ reference "RFC 6020";
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementConfig.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementConfig.yang
new file mode 100644
index 0000000..736dcbc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementConfig.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementContainer.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementContainer.yang
new file mode 100644
index 0000000..1f9f810
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementContainer.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementDescription.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementDescription.yang
new file mode 100644
index 0000000..dc75d00
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementDescription.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ description "container description";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementLeaf.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementLeaf.yang
new file mode 100644
index 0000000..c9a64e3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementLeaf.yang
@@ -0,0 +1,17 @@
+
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementLeafList.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementLeafList.yang
new file mode 100644
index 0000000..a1877b6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementLeafList.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ min-elements 1;
+ max-elements unbounded;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementList.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementList.yang
new file mode 100644
index 0000000..19810c7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementList.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementPresence.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementPresence.yang
new file mode 100644
index 0000000..d3a30dc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementPresence.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ presence "invalid";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementReference.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementReference.yang
new file mode 100644
index 0000000..33f37fd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementReference.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ reference "container reference";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatementStatus.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementStatus.yang
new file mode 100644
index 0000000..fdf907d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatementStatus.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ config true;
+ status obsolete;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerSubStatements.yang b/utils/yangutils/plugin/src/test/resources/ContainerSubStatements.yang
new file mode 100644
index 0000000..2611f97
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerSubStatements.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ presence "ospf logs";
+ config true;
+ description "container description";
+ status current;
+ reference "container reference";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ContainerWithDuplicateLeaf.yang b/utils/yangutils/plugin/src/test/resources/ContainerWithDuplicateLeaf.yang
new file mode 100644
index 0000000..3adaccd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ContainerWithDuplicateLeaf.yang
@@ -0,0 +1,34 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf valid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf valid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/CopyrightHeader.txt b/utils/yangutils/plugin/src/test/resources/CopyrightHeader.txt
new file mode 100644
index 0000000..2cbed45
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/CopyrightHeader.txt
@@ -0,0 +1,14 @@
+ *
+ * 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.
+ */
+
diff --git a/utils/yangutils/plugin/src/test/resources/DerivedTypeStatement.yang b/utils/yangutils/plugin/src/test/resources/DerivedTypeStatement.yang
new file mode 100644
index 0000000..afbfd1d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DerivedTypeStatement.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ leaf invalid-interval {
+ type P:hello;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/DescriptionEmptyStatement.yang b/utils/yangutils/plugin/src/test/resources/DescriptionEmptyStatement.yang
new file mode 100644
index 0000000..f6c1c3d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DescriptionEmptyStatement.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ description "";
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/DescriptionStringConcat.yang b/utils/yangutils/plugin/src/test/resources/DescriptionStringConcat.yang
new file mode 100644
index 0000000..8bf0519
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DescriptionStringConcat.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ description "Interval before a " + "route is declared invalid";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/DescriptionValidStatement.yang b/utils/yangutils/plugin/src/test/resources/DescriptionValidStatement.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DescriptionValidStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/DescriptionWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/DescriptionWithoutStatementEnd.yang
new file mode 100644
index 0000000..ebd8c24
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DescriptionWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ description "Interval before a " + "route is declared invalid"
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/DuplicateCaseInChoice.yang b/utils/yangutils/plugin/src/test/resources/DuplicateCaseInChoice.yang
new file mode 100644
index 0000000..a7b6b50
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DuplicateCaseInChoice.yang
@@ -0,0 +1,26 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type empty;
+ }
+ leaf beer {
+ type empty;
+ }
+ }
+ case sports-arena {
+ leaf chocolate {
+ type enumeration {
+ enum dark;
+ enum milk;
+ enum first-available;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/DuplicateContainerAndList.yang b/utils/yangutils/plugin/src/test/resources/DuplicateContainerAndList.yang
new file mode 100644
index 0000000..74c7721
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DuplicateContainerAndList.yang
@@ -0,0 +1,29 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ list valid {
+ key "process-id";
+ container interface {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ leaf process-id {
+ type "string";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInContainer.yang b/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInContainer.yang
new file mode 100644
index 0000000..f130797
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInContainer.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ grouping endpoint {
+ leaf address {
+ type ip-address;
+ }
+ leaf port {
+ type port-number;
+ }
+ }
+ grouping endpoint {
+ leaf address {
+ type ip-address;
+ }
+ leaf port {
+ type port-number;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInList.yang b/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInList.yang
new file mode 100644
index 0000000..a9d1b3b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInList.yang
@@ -0,0 +1,36 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ list valid {
+ key address;
+ grouping endpoint {
+ description "grouping under test";
+ status current;
+ reference "RFC 6020";
+ leaf address {
+ type ip-address;
+ }
+ leaf port {
+ type port-number;
+ }
+ }
+ leaf address {
+ type ip;
+ }
+ grouping endpoint {
+ description "grouping under test";
+ status current;
+ reference "RFC 6020";
+ leaf address {
+ type ip-address;
+ }
+ leaf port {
+ type port-number;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInModule.yang b/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInModule.yang
new file mode 100644
index 0000000..ec01781
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DuplicateGroupingInModule.yang
@@ -0,0 +1,24 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping endpoint {
+ leaf address {
+ type P:ip-address;
+ }
+ leaf port {
+ type P:port-number;
+ }
+ }
+ grouping endpoint {
+ leaf address {
+ type P:pip-address;
+ }
+ leaf port {
+ type P:port-number;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/DuplicateLeafInChoice.yang b/utils/yangutils/plugin/src/test/resources/DuplicateLeafInChoice.yang
new file mode 100644
index 0000000..f951c7f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DuplicateLeafInChoice.yang
@@ -0,0 +1,21 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type empty;
+ }
+ leaf beer {
+ type empty;
+ }
+ }
+ case late-night {
+ leaf pretzel {
+ type empty;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/DuplicateLeafInHierarchy.yang b/utils/yangutils/plugin/src/test/resources/DuplicateLeafInHierarchy.yang
new file mode 100644
index 0000000..e23f04c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/DuplicateLeafInHierarchy.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ case sports-arena {
+ leaf pretzel {
+ type empty;
+ }
+ }
+ case late-night {
+ choice lunch {
+ case late {
+ leaf pretzel {
+ type empty;
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/EnumBoundaryValue.yang b/utils/yangutils/plugin/src/test/resources/EnumBoundaryValue.yang
new file mode 100644
index 0000000..ac87ef0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/EnumBoundaryValue.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf ifType {
+ type enumeration {
+ enum "unbounded";
+ enum ZERO;
+ enum two;
+ enum four;
+ enum seven {
+ value 21474836472147483647;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/EnumMaxNextValue.yang b/utils/yangutils/plugin/src/test/resources/EnumMaxNextValue.yang
new file mode 100644
index 0000000..4e4a373
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/EnumMaxNextValue.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf ifType {
+ type enumeration {
+ enum "unbounded";
+ enum ZERO;
+ enum two;
+ enum four;
+ enum seven {
+ value 2147483647;
+ }
+ enum five;
+
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/EnumSorted.yang b/utils/yangutils/plugin/src/test/resources/EnumSorted.yang
new file mode 100644
index 0000000..3760e83
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/EnumSorted.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf ifType {
+ type enumeration {
+ enum four{
+ value 7;
+ }
+ enum seven {
+ value 2147483647;
+ }
+ enum five {
+ value 5;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/EnumTranslator.yang b/utils/yangutils/plugin/src/test/resources/EnumTranslator.yang
new file mode 100644
index 0000000..1957c1f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/EnumTranslator.yang
@@ -0,0 +1,17 @@
+module Sfc {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf test{
+ type string;
+ }
+ leaf myenum {
+ type enumeration {
+ enum zero;
+ enum one;
+ enum seven {
+ value 7;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/EnumTypeStatement.yang b/utils/yangutils/plugin/src/test/resources/EnumTypeStatement.yang
new file mode 100644
index 0000000..1d64805
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/EnumTypeStatement.yang
@@ -0,0 +1,12 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf speed {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum auto;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/EnumWithDuplicateName.yang b/utils/yangutils/plugin/src/test/resources/EnumWithDuplicateName.yang
new file mode 100644
index 0000000..47c3a85
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/EnumWithDuplicateName.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf speed {
+ type enumeration {
+ enum 10m;
+ enum 100m;
+ enum 10m {
+ value 11;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/GroupingAttributes.yang b/utils/yangutils/plugin/src/test/resources/GroupingAttributes.yang
new file mode 100644
index 0000000..f04641f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/GroupingAttributes.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ list valid {
+ key address;
+ leaf address {
+ type P:ip;
+ }
+ grouping endpoint {
+ description "grouping under test";
+ status current;
+ reference "RFC 6020";
+ leaf address {
+ type P:ip-address;
+ }
+ leaf port {
+ type P:port-number;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/GroupingInContainer.yang b/utils/yangutils/plugin/src/test/resources/GroupingInContainer.yang
new file mode 100644
index 0000000..dfa8259
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/GroupingInContainer.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ container valid {
+ grouping endpoint {
+ leaf address {
+ type P:ip-address;
+ }
+ leaf port {
+ type P:port-number;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/GroupingInList.yang b/utils/yangutils/plugin/src/test/resources/GroupingInList.yang
new file mode 100644
index 0000000..c5966fc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/GroupingInList.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ list valid {
+ key address;
+ leaf address {
+ type P:ip;
+ }
+ grouping endpoint {
+ leaf address {
+ type P:ip-address;
+ }
+ leaf port {
+ type P:port-number;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/GroupingInModule.yang b/utils/yangutils/plugin/src/test/resources/GroupingInModule.yang
new file mode 100644
index 0000000..77fef1f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/GroupingInModule.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping endpoint {
+ leaf address {
+ type P:ip-address;
+ }
+ leaf port {
+ type P:port-number;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IdentityrefInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/IdentityrefInvalidIdentifier.yang
new file mode 100644
index 0000000..99a8129
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IdentityrefInvalidIdentifier.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping currentcheck {
+ leaf invalid-interval {
+ type identityref {
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ImportInvalidOrder.yang b/utils/yangutils/plugin/src/test/resources/ImportInvalidOrder.yang
new file mode 100644
index 0000000..6bfc685
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ImportInvalidOrder.yang
@@ -0,0 +1,10 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+revision-date 2015-02-03;
+prefix On1;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ImportMultipleInstance.yang b/utils/yangutils/plugin/src/test/resources/ImportMultipleInstance.yang
new file mode 100644
index 0000000..175f2ff
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ImportMultipleInstance.yang
@@ -0,0 +1,14 @@
+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;
+}
+import itut {
+prefix On3;
+revision-date 2016-02-03;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ImportValidEntry.yang b/utils/yangutils/plugin/src/test/resources/ImportValidEntry.yang
new file mode 100644
index 0000000..b725d39
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ImportValidEntry.yang
@@ -0,0 +1,10 @@
+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;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ImportWithDualPrefix.yang b/utils/yangutils/plugin/src/test/resources/ImportWithDualPrefix.yang
new file mode 100644
index 0000000..8b40bb0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ImportWithDualPrefix.yang
@@ -0,0 +1,11 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On1;
+prefix On2;
+revision-date 2015-02-03;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ImportWithoutPrefix.yang b/utils/yangutils/plugin/src/test/resources/ImportWithoutPrefix.yang
new file mode 100644
index 0000000..ee68e59
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ImportWithoutPrefix.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+revision-date 2015-02-03;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ImportWithoutRevision.yang b/utils/yangutils/plugin/src/test/resources/ImportWithoutRevision.yang
new file mode 100644
index 0000000..af47b7a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ImportWithoutRevision.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/InValidIdentifierXML.yang b/utils/yangutils/plugin/src/test/resources/InValidIdentifierXML.yang
new file mode 100644
index 0000000..c6a5a42
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/InValidIdentifierXML.yang
@@ -0,0 +1,5 @@
+module xMlTest {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IncludeImportAnyOrder.yang b/utils/yangutils/plugin/src/test/resources/IncludeImportAnyOrder.yang
new file mode 100644
index 0000000..05339a6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IncludeImportAnyOrder.yang
@@ -0,0 +1,16 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+include itut {
+revision-date 2016-02-03;
+}
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IncludeInvalidDateSyntax.yang b/utils/yangutils/plugin/src/test/resources/IncludeInvalidDateSyntax.yang
new file mode 100644
index 0000000..3716209
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IncludeInvalidDateSyntax.yang
@@ -0,0 +1,16 @@
+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 16-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IncludeInvalidSyntax.yang b/utils/yangutils/plugin/src/test/resources/IncludeInvalidSyntax.yang
new file mode 100644
index 0000000..91ae17b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IncludeInvalidSyntax.yang
@@ -0,0 +1,16 @@
+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";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IncludeMultiInstance.yang b/utils/yangutils/plugin/src/test/resources/IncludeMultiInstance.yang
new file mode 100644
index 0000000..81a527a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IncludeMultiInstance.yang
@@ -0,0 +1,16 @@
+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";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IncludeWithDate.yang b/utils/yangutils/plugin/src/test/resources/IncludeWithDate.yang
new file mode 100644
index 0000000..9701a2d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IncludeWithDate.yang
@@ -0,0 +1,13 @@
+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;
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IncludeWithEmptyBody.yang b/utils/yangutils/plugin/src/test/resources/IncludeWithEmptyBody.yang
new file mode 100644
index 0000000..471fdb3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IncludeWithEmptyBody.yang
@@ -0,0 +1,12 @@
+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 {
+}
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IncludeWithStmtend.yang b/utils/yangutils/plugin/src/test/resources/IncludeWithStmtend.yang
new file mode 100644
index 0000000..e40813b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IncludeWithStmtend.yang
@@ -0,0 +1,11 @@
+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;
+contact "Test";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/InputStatementWithDataDefinition.yang b/utils/yangutils/plugin/src/test/resources/InputStatementWithDataDefinition.yang
new file mode 100644
index 0000000..0adf3d3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/InputStatementWithDataDefinition.yang
@@ -0,0 +1,28 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ 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;
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/InputStatementWithTypedef.yang b/utils/yangutils/plugin/src/test/resources/InputStatementWithTypedef.yang
new file mode 100644
index 0000000..25ca73d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/InputStatementWithTypedef.yang
@@ -0,0 +1,17 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ rpc activate-software-image {
+ description "description";
+ input {
+ leaf image-name {
+ type string;
+ }
+ typedef my-type {
+ status deprecated;
+ type int32;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/InstanceIdentifierInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/InstanceIdentifierInvalidIdentifier.yang
new file mode 100644
index 0000000..0bbe2f1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/InstanceIdentifierInvalidIdentifier.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container currentcheck {
+ leaf invalid-interval {
+ type instance-identifier;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/IntegerTypeStatement.yang b/utils/yangutils/plugin/src/test/resources/IntegerTypeStatement.yang
new file mode 100644
index 0000000..ca2be38
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/IntegerTypeStatement.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/InvalidLeafIdentifier.yang b/utils/yangutils/plugin/src/test/resources/InvalidLeafIdentifier.yang
new file mode 100644
index 0000000..6faf092
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/InvalidLeafIdentifier.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/InvalidLeafListIdentifier.yang b/utils/yangutils/plugin/src/test/resources/InvalidLeafListIdentifier.yang
new file mode 100644
index 0000000..6359d2a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/InvalidLeafListIdentifier.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf-list invalid {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/InvalidPatternSubStatements.yang b/utils/yangutils/plugin/src/test/resources/InvalidPatternSubStatements.yang
new file mode 100644
index 0000000..76ff75e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/InvalidPatternSubStatements.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type string {
+ pattern "[a-zA-Z]\" {
+ description "pattern description";
+ reference "pattern reference";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/KeyLeafListTypeEmpty.yang b/utils/yangutils/plugin/src/test/resources/KeyLeafListTypeEmpty.yang
new file mode 100644
index 0000000..44c1617
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/KeyLeafListTypeEmpty.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf-list invalid-interval {
+ type "empty";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/KeyLeafTypeEmpty.yang b/utils/yangutils/plugin/src/test/resources/KeyLeafTypeEmpty.yang
new file mode 100644
index 0000000..859520c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/KeyLeafTypeEmpty.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "empty";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/KeyWithUsesInList.yang b/utils/yangutils/plugin/src/test/resources/KeyWithUsesInList.yang
new file mode 100644
index 0000000..d076d0a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/KeyWithUsesInList.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping network {
+ leaf invalid-interval {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ list valid {
+ key "invalid-interval";
+ leaf invalid {
+ type "string";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ uses "network";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/KeyWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/KeyWithoutStatementEnd.yang
new file mode 100644
index 0000000..f56101a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/KeyWithoutStatementEnd.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid"
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafConfigInvalidCardinality.yang b/utils/yangutils/plugin/src/test/resources/LeafConfigInvalidCardinality.yang
new file mode 100644
index 0000000..d403a56
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafConfigInvalidCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ config false;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/LeafInvalidIdentifier.yang
new file mode 100644
index 0000000..dbfff13
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafInvalidIdentifier.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf 1invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafInvalidStatement.yang b/utils/yangutils/plugin/src/test/resources/LeafInvalidStatement.yang
new file mode 100644
index 0000000..4d4f6f6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafInvalidStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leafs invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListConfigInvalidCardinality.yang b/utils/yangutils/plugin/src/test/resources/LeafListConfigInvalidCardinality.yang
new file mode 100644
index 0000000..361a852
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListConfigInvalidCardinality.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ config false;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/LeafListInvalidIdentifier.yang
new file mode 100644
index 0000000..77c24d2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListInvalidIdentifier.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list 1invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListInvalidStatement.yang b/utils/yangutils/plugin/src/test/resources/LeafListInvalidStatement.yang
new file mode 100644
index 0000000..13e4b5f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListInvalidStatement.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaflist invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatementConfig.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementConfig.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementConfig.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatementDescription.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementDescription.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementDescription.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatementMaxElements.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementMaxElements.yang
new file mode 100644
index 0000000..5ab2d0f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementMaxElements.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ max-elements 3;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatementMinElements.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementMinElements.yang
new file mode 100644
index 0000000..fd71281
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementMinElements.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ min-elements 3;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatementReference.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementReference.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementReference.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatementStatus.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementStatus.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementStatus.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatementType.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementType.yang
new file mode 100644
index 0000000..0e5ab56
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementType.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatementUnits.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementUnits.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatementUnits.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListSubStatements.yang b/utils/yangutils/plugin/src/test/resources/LeafListSubStatements.yang
new file mode 100644
index 0000000..29dfdb2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListSubStatements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ max-elements 3;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListUnitsInvalidCardinality.yang b/utils/yangutils/plugin/src/test/resources/LeafListUnitsInvalidCardinality.yang
new file mode 100644
index 0000000..996e49e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListUnitsInvalidCardinality.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ units "minutes";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafListWithoutLeftBrace.yang b/utils/yangutils/plugin/src/test/resources/LeafListWithoutLeftBrace.yang
new file mode 100644
index 0000000..1196422
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafListWithoutLeftBrace.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafMandatoryInvalidCardinality.yang b/utils/yangutils/plugin/src/test/resources/LeafMandatoryInvalidCardinality.yang
new file mode 100644
index 0000000..c275dd7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafMandatoryInvalidCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ mandatory false;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafSubStatementDefault.yang b/utils/yangutils/plugin/src/test/resources/LeafSubStatementDefault.yang
new file mode 100644
index 0000000..a78131d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafSubStatementDefault.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ default "1";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LeafSubStatements.yang b/utils/yangutils/plugin/src/test/resources/LeafSubStatements.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafSubStatements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafWithoutLeftBrace.yang b/utils/yangutils/plugin/src/test/resources/LeafWithoutLeftBrace.yang
new file mode 100644
index 0000000..c2aa979
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafWithoutLeftBrace.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/LeafrefInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/LeafrefInvalidIdentifier.yang
new file mode 100644
index 0000000..4737b6c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LeafrefInvalidIdentifier.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type leafref;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthRestrictionInRefType.yang b/utils/yangutils/plugin/src/test/resources/LengthRestrictionInRefType.yang
new file mode 100644
index 0000000..54684f4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthRestrictionInRefType.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ length "0..100";
+ }
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedef.yang b/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedef.yang
new file mode 100644
index 0000000..17baeec
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedef.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type string {
+ length "0..100";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedefAndTypeInValid.yang b/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedefAndTypeInValid.yang
new file mode 100644
index 0000000..65ed7de
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedefAndTypeInValid.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ length "min..20 | 200..max";
+ }
+ }
+ typedef hello {
+ type string {
+ length "0..100 | 101..200 | 201..300";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedefAndTypeValid.yang b/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedefAndTypeValid.yang
new file mode 100644
index 0000000..eca2691
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthRestrictionInTypedefAndTypeValid.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ length "min..20 | 201..max";
+ }
+ }
+ typedef hello {
+ type string {
+ length "0..100 | 101..200 | 201..300";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthStatementInsideLeafList.yang b/utils/yangutils/plugin/src/test/resources/LengthStatementInsideLeafList.yang
new file mode 100644
index 0000000..06d08db
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthStatementInsideLeafList.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type string {
+ length "1..100";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthStatementInsideTypeDef.yang b/utils/yangutils/plugin/src/test/resources/LengthStatementInsideTypeDef.yang
new file mode 100644
index 0000000..c1195dc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthStatementInsideTypeDef.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef invalid-interval {
+ type string {
+ length "1..100";
+ }
+ }
+ leaf xyz {
+ type invalid-interval {
+ length "2..100";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthStatementWithSpace.yang b/utils/yangutils/plugin/src/test/resources/LengthStatementWithSpace.yang
new file mode 100644
index 0000000..e8612d1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthStatementWithSpace.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type string {
+ length " 0 .. 100 ";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthSubStatements.yang b/utils/yangutils/plugin/src/test/resources/LengthSubStatements.yang
new file mode 100644
index 0000000..f61f979
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthSubStatements.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type string {
+ length "0..100" {
+ description "length description";
+ reference "length reference";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthWithInvalidIntegerPattern.yang b/utils/yangutils/plugin/src/test/resources/LengthWithInvalidIntegerPattern.yang
new file mode 100644
index 0000000..f5c8a69
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthWithInvalidIntegerPattern.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type string {
+ length "a..z";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthWithInvalidInterval.yang b/utils/yangutils/plugin/src/test/resources/LengthWithInvalidInterval.yang
new file mode 100644
index 0000000..7b4ae18
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthWithInvalidInterval.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type string {
+ length "0..18446744073709551617";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthWithInvalidType.yang b/utils/yangutils/plugin/src/test/resources/LengthWithInvalidType.yang
new file mode 100644
index 0000000..74b183c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthWithInvalidType.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type int8 {
+ length "1..100";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthWithMinMax.yang b/utils/yangutils/plugin/src/test/resources/LengthWithMinMax.yang
new file mode 100644
index 0000000..5884266
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthWithMinMax.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type string {
+ length "min..max";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/LengthWithOneInterval.yang b/utils/yangutils/plugin/src/test/resources/LengthWithOneInterval.yang
new file mode 100644
index 0000000..b160f02
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/LengthWithOneInterval.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type string {
+ length "1";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ListAsRootNode.yang b/utils/yangutils/plugin/src/test/resources/ListAsRootNode.yang
new file mode 100644
index 0000000..289525f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListAsRootNode.yang
@@ -0,0 +1,9 @@
+list valid {
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListDuplicateContainer.yang b/utils/yangutils/plugin/src/test/resources/ListDuplicateContainer.yang
new file mode 100644
index 0000000..8c152b2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListDuplicateContainer.yang
@@ -0,0 +1,27 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list ospf {
+ key "process-id";
+ container interface {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ leaf process-id {
+ type "string";
+ }
+ container interface {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ListInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/ListInvalidIdentifier.yang
new file mode 100644
index 0000000..c5f6a3a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListInvalidIdentifier.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list 1valid {
+ key "invalid-interval";
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListStatementWithoutChild.yang b/utils/yangutils/plugin/src/test/resources/ListStatementWithoutChild.yang
new file mode 100644
index 0000000..5c006d7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListStatementWithoutChild.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementConfig.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementConfig.yang
new file mode 100644
index 0000000..55432fb
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementConfig.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementContainer.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementContainer.yang
new file mode 100644
index 0000000..4ce6da4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementContainer.yang
@@ -0,0 +1,19 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list ospf {
+ key "process-id";
+ container interface {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ leaf process-id {
+ type "string";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementDescription.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementDescription.yang
new file mode 100644
index 0000000..a8df3d7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementDescription.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ description "list description";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementKey.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementKey.yang
new file mode 100644
index 0000000..791013d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementKey.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementLeaf.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementLeaf.yang
new file mode 100644
index 0000000..59b92cc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementLeaf.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementLeafList.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementLeafList.yang
new file mode 100644
index 0000000..5235295
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementLeafList.yang
@@ -0,0 +1,17 @@
+
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementList.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementList.yang
new file mode 100644
index 0000000..2021469
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementList.yang
@@ -0,0 +1,20 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list ospf {
+ key "process-id";
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ leaf process-id {
+ type "string";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementMaxElements.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementMaxElements.yang
new file mode 100644
index 0000000..de6139e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementMaxElements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ max-elements 3;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementMinElements.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementMinElements.yang
new file mode 100644
index 0000000..d6071e8
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementMinElements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ min-elements 3;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementReference.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementReference.yang
new file mode 100644
index 0000000..8adfa04
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementReference.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ reference "list reference";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementStatus.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementStatus.yang
new file mode 100644
index 0000000..b88ac74
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementStatus.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ status current;
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatements.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatements.yang
new file mode 100644
index 0000000..109fc17
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatements.yang
@@ -0,0 +1,20 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list ospf {
+ key "invalid-interval";
+ config true;
+ max-elements 10;
+ min-elements 3;
+ description "list description";
+ status current;
+ reference "list reference";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ListSubStatementsCardinality.yang b/utils/yangutils/plugin/src/test/resources/ListSubStatementsCardinality.yang
new file mode 100644
index 0000000..9c4077c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListSubStatementsCardinality.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ reference "RFC 6020";
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ListWithDuplicateLeaf.yang b/utils/yangutils/plugin/src/test/resources/ListWithDuplicateLeaf.yang
new file mode 100644
index 0000000..55a78f6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ListWithDuplicateLeaf.yang
@@ -0,0 +1,26 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MandatoryDefaultValue.yang b/utils/yangutils/plugin/src/test/resources/MandatoryDefaultValue.yang
new file mode 100644
index 0000000..c71d5ea
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MandatoryDefaultValue.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/MandatoryEmptyStatement.yang b/utils/yangutils/plugin/src/test/resources/MandatoryEmptyStatement.yang
new file mode 100644
index 0000000..e2af869
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MandatoryEmptyStatement.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ mandatory ;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/MandatoryFalse.yang b/utils/yangutils/plugin/src/test/resources/MandatoryFalse.yang
new file mode 100644
index 0000000..3ae4601
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MandatoryFalse.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ mandatory false;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/MandatoryTrue.yang b/utils/yangutils/plugin/src/test/resources/MandatoryTrue.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MandatoryTrue.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/MandatoryWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/MandatoryWithoutStatementEnd.yang
new file mode 100644
index 0000000..055f556
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MandatoryWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ mandatory false
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/MaxElementsCardinality.yang b/utils/yangutils/plugin/src/test/resources/MaxElementsCardinality.yang
new file mode 100644
index 0000000..bff2fd7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MaxElementsCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ max-elements 4;
+ max-elements 6;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MaxElementsDefaultValue.yang b/utils/yangutils/plugin/src/test/resources/MaxElementsDefaultValue.yang
new file mode 100644
index 0000000..a591146
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MaxElementsDefaultValue.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MaxElementsInvalidStatement.yang b/utils/yangutils/plugin/src/test/resources/MaxElementsInvalidStatement.yang
new file mode 100644
index 0000000..67cb358
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MaxElementsInvalidStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ max-element 3;
+ description "Interval before a route is declared invalid;
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MaxElementsMaxValue.yang b/utils/yangutils/plugin/src/test/resources/MaxElementsMaxValue.yang
new file mode 100644
index 0000000..7bdfbb0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MaxElementsMaxValue.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ max-elements 77777777777777777777777;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MaxElementsUnbounded.yang b/utils/yangutils/plugin/src/test/resources/MaxElementsUnbounded.yang
new file mode 100644
index 0000000..afaca4f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MaxElementsUnbounded.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ max-elements unbounded;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MaxElementsWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/MaxElementsWithoutStatementEnd.yang
new file mode 100644
index 0000000..5973dd0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MaxElementsWithoutStatementEnd.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ max-elements 3
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MinElementsDefaultValue.yang b/utils/yangutils/plugin/src/test/resources/MinElementsDefaultValue.yang
new file mode 100644
index 0000000..a591146
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MinElementsDefaultValue.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MinElementsInvalidCardinality.yang b/utils/yangutils/plugin/src/test/resources/MinElementsInvalidCardinality.yang
new file mode 100644
index 0000000..18f6019
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MinElementsInvalidCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ min-elements 4;
+ min-elements 6;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MinElementsInvalidKeyword.yang b/utils/yangutils/plugin/src/test/resources/MinElementsInvalidKeyword.yang
new file mode 100644
index 0000000..e634509
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MinElementsInvalidKeyword.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ min-element 3;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/MinElementsInvalidValue.yang b/utils/yangutils/plugin/src/test/resources/MinElementsInvalidValue.yang
new file mode 100644
index 0000000..a381184
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MinElementsInvalidValue.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ min-elements asd;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/MinElementsMaxValue.yang b/utils/yangutils/plugin/src/test/resources/MinElementsMaxValue.yang
new file mode 100644
index 0000000..785482b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MinElementsMaxValue.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ min-elements 77777777777777777777777;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MinElementsWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/MinElementsWithoutStatementEnd.yang
new file mode 100644
index 0000000..699a8b8
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MinElementsWithoutStatementEnd.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ min-elements 3
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleDuplicateContainer.yang b/utils/yangutils/plugin/src/test/resources/ModuleDuplicateContainer.yang
new file mode 100644
index 0000000..bc58896
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleDuplicateContainer.yang
@@ -0,0 +1,29 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ container invalid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleInvalidIdentifierLength.yang b/utils/yangutils/plugin/src/test/resources/ModuleInvalidIdentifierLength.yang
new file mode 100644
index 0000000..fac16bc
--- /dev/null
+++ b/utils/yangutils/plugin/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/plugin/src/test/resources/ModuleSubStatementConfig.yang b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementConfig.yang
new file mode 100644
index 0000000..49deb3e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementConfig.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ config invalid;
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleSubStatementContainer.yang b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementContainer.yang
new file mode 100644
index 0000000..35a91ad
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementContainer.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleSubStatementDescription.yang b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementDescription.yang
new file mode 100644
index 0000000..02643b1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementDescription.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ description "Interval before a route is declared invalid";
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleSubStatementList.yang b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementList.yang
new file mode 100644
index 0000000..1bb3bf5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementList.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleSubStatementMandatory.yang b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementMandatory.yang
new file mode 100644
index 0000000..8f6e1a1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementMandatory.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ mandatory false;
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleSubStatementReference.yang b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementReference.yang
new file mode 100644
index 0000000..20b2fb6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementReference.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ reference "RFC 6020";
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleSubStatementStatus.yang b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementStatus.yang
new file mode 100644
index 0000000..3739096
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementStatus.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ status current;
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleSubStatementUnits.yang b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementUnits.yang
new file mode 100644
index 0000000..d9381ec
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleSubStatementUnits.yang
@@ -0,0 +1,7 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ type "uint16";
+ units "seconds";
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleValidEntry.yang b/utils/yangutils/plugin/src/test/resources/ModuleValidEntry.yang
new file mode 100644
index 0000000..439ded8
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleValidEntry.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleWithDuplicateLeaf.yang b/utils/yangutils/plugin/src/test/resources/ModuleWithDuplicateLeaf.yang
new file mode 100644
index 0000000..2c3ecbc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleWithDuplicateLeaf.yang
@@ -0,0 +1,32 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf valid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ModuleWithInvalidIdentifier.yang b/utils/yangutils/plugin/src/test/resources/ModuleWithInvalidIdentifier.yang
new file mode 100644
index 0000000..d89340a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ModuleWithInvalidIdentifier.yang
@@ -0,0 +1,5 @@
+module Test:Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MultipleKeyValues.yang b/utils/yangutils/plugin/src/test/resources/MultipleKeyValues.yang
new file mode 100644
index 0000000..a9d25a2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MultipleKeyValues.yang
@@ -0,0 +1,20 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "ospf isis";
+ leaf ospf {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ leaf isis {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestriction.yang b/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestriction.yang
new file mode 100644
index 0000000..d971643
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestriction.yang
@@ -0,0 +1,19 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-z]";
+ pattern "[A-Z]";
+ length "min..20 | 201..max";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ pattern "[\n]";
+ length "0..100 | 101..200 | 201..300";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestrictionInValid.yang b/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestrictionInValid.yang
new file mode 100644
index 0000000..7ba3ef9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestrictionInValid.yang
@@ -0,0 +1,19 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-z]";
+ pattern "[A-Z]";
+ length "min..20 | 100..max";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ pattern "[\n]";
+ length "0..100 | 101..200 | 201..300";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestrictionValid.yang b/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestrictionValid.yang
new file mode 100644
index 0000000..161b558
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MultiplePatternAndLengthRestrictionValid.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-z]";
+ pattern "[A-Z]";
+ length "min..20 | 100..max";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ pattern "[\n]";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MultiplePatternRestrictionInRefTypeAndTypedef.yang b/utils/yangutils/plugin/src/test/resources/MultiplePatternRestrictionInRefTypeAndTypedef.yang
new file mode 100644
index 0000000..eaa28c5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MultiplePatternRestrictionInRefTypeAndTypedef.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-z]";
+ pattern "[A-Z]";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ pattern "[\n]";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/MultiplePatternStatement.yang b/utils/yangutils/plugin/src/test/resources/MultiplePatternStatement.yang
new file mode 100644
index 0000000..7a47bfc
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/MultiplePatternStatement.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type string {
+ pattern "[a-zA-Z]";
+ pattern "[a-z]";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/NamespaceDualEntry.yang b/utils/yangutils/plugin/src/test/resources/NamespaceDualEntry.yang
new file mode 100644
index 0000000..09c9b54
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NamespaceDualEntry.yang
@@ -0,0 +1,6 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+namespace urn:ietf:params:xml:ns:yang:ietf-segment-routing;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/NamespaceInDoubleQuotes.yang b/utils/yangutils/plugin/src/test/resources/NamespaceInDoubleQuotes.yang
new file mode 100644
index 0000000..aec0042
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NamespaceInDoubleQuotes.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace "urn:ietf:params:xml:ns:yang:ietf-ospf";
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/NamespaceNoEntryTest.yang b/utils/yangutils/plugin/src/test/resources/NamespaceNoEntryTest.yang
new file mode 100644
index 0000000..ac30ae4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NamespaceNoEntryTest.yang
@@ -0,0 +1,4 @@
+module Test {
+yang-version 1;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/NamespaceWithConcatenationTest.yang b/utils/yangutils/plugin/src/test/resources/NamespaceWithConcatenationTest.yang
new file mode 100644
index 0000000..c9ac4b0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NamespaceWithConcatenationTest.yang
@@ -0,0 +1,6 @@
+module Test {
+yang-version 1;
+namespace "urn:ietf:params:xml:ns:"
+ + "yang:ietf-segment-routing";
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/NamespaceWithInvalidSpaces.yang b/utils/yangutils/plugin/src/test/resources/NamespaceWithInvalidSpaces.yang
new file mode 100644
index 0000000..f8f91c5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NamespaceWithInvalidSpaces.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace "urn:ietf:params:xml :ns:yang:ietf-ospf";
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/NamespaceWithoutQuotes.yang b/utils/yangutils/plugin/src/test/resources/NamespaceWithoutQuotes.yang
new file mode 100644
index 0000000..439ded8
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NamespaceWithoutQuotes.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementContainer.yang b/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementContainer.yang
new file mode 100644
index 0000000..1aded2d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementContainer.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container hello {
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementLeaf.yang b/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementLeaf.yang
new file mode 100644
index 0000000..35a91ad
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementLeaf.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementLeafList.yang b/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementLeafList.yang
new file mode 100644
index 0000000..79687c2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementLeafList.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementList.yang b/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementList.yang
new file mode 100644
index 0000000..f10c686
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NoConfigContainerSubStatementList.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container hello {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementContainer.yang b/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementContainer.yang
new file mode 100644
index 0000000..19b4291
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementContainer.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list list1 {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ container container1 {
+ leaf leaf1 {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementLeaf.yang b/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementLeaf.yang
new file mode 100644
index 0000000..1bb3bf5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementLeaf.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementLeafList.yang b/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementLeafList.yang
new file mode 100644
index 0000000..e70155e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementLeafList.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementList.yang b/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementList.yang
new file mode 100644
index 0000000..4de40cb
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NoConfigListSubStatementList.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ list list1 {
+ key "leaf1";
+ leaf leaf1 {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/NotificationTest.yang b/utils/yangutils/plugin/src/test/resources/NotificationTest.yang
new file mode 100644
index 0000000..f199dbd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/NotificationTest.yang
@@ -0,0 +1,13 @@
+module NotificationTest {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ notification test {
+ leaf type {
+ type string;
+ }
+ leaf severity {
+ type string;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/OrderedByStatement.yang b/utils/yangutils/plugin/src/test/resources/OrderedByStatement.yang
new file mode 100644
index 0000000..f6b4336
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/OrderedByStatement.yang
@@ -0,0 +1,10 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+ leaf-list cipher {
+ type string;
+ ordered-by user;
+ description "A list of ciphers";
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/OrganizationDualEntry.yang b/utils/yangutils/plugin/src/test/resources/OrganizationDualEntry.yang
new file mode 100644
index 0000000..64bf23d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/OrganizationDualEntry.yang
@@ -0,0 +1,18 @@
+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 "IETF SPRING Working Group";
+organization "ITUT SPRING Working Group";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/OrganizationInvalidOrder.yang b/utils/yangutils/plugin/src/test/resources/OrganizationInvalidOrder.yang
new file mode 100644
index 0000000..333f2e5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/OrganizationInvalidOrder.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+organization "ONOS";
+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";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/OrganizationMissingValue.yang b/utils/yangutils/plugin/src/test/resources/OrganizationMissingValue.yang
new file mode 100644
index 0000000..e9e3f46
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/OrganizationMissingValue.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 ;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/OrganizationValidEntry.yang b/utils/yangutils/plugin/src/test/resources/OrganizationValidEntry.yang
new file mode 100644
index 0000000..25ae1ec
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/OrganizationValidEntry.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 "IETF SPRING Working Group";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/OutputStatementWithDataDefinition.yang b/utils/yangutils/plugin/src/test/resources/OutputStatementWithDataDefinition.yang
new file mode 100644
index 0000000..527b399
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/OutputStatementWithDataDefinition.yang
@@ -0,0 +1,28 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ rpc activate-software-image {
+ description "description";
+ output {
+ 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;
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/OutputStatementWithTypedef.yang b/utils/yangutils/plugin/src/test/resources/OutputStatementWithTypedef.yang
new file mode 100644
index 0000000..6027c2d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/OutputStatementWithTypedef.yang
@@ -0,0 +1,17 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ rpc activate-software-image {
+ description "description";
+ output {
+ leaf image-name {
+ type string;
+ }
+ typedef my-type {
+ status deprecated;
+ type int32;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PatternRestrictionInRefType.yang b/utils/yangutils/plugin/src/test/resources/PatternRestrictionInRefType.yang
new file mode 100644
index 0000000..189177d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PatternRestrictionInRefType.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-zA-Z]";
+ }
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PatternRestrictionInRefTypeAndTypedef.yang b/utils/yangutils/plugin/src/test/resources/PatternRestrictionInRefTypeAndTypedef.yang
new file mode 100644
index 0000000..e01b224
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PatternRestrictionInRefTypeAndTypedef.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ pattern "[a-zA-Z]";
+ }
+ }
+ typedef hello {
+ type string {
+ pattern "[0-9]";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PatternRestrictionInTypedef.yang b/utils/yangutils/plugin/src/test/resources/PatternRestrictionInTypedef.yang
new file mode 100644
index 0000000..7875504
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PatternRestrictionInTypedef.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type string {
+ pattern "[a-zA-Z]";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PatternStatementInsideLeafList.yang b/utils/yangutils/plugin/src/test/resources/PatternStatementInsideLeafList.yang
new file mode 100644
index 0000000..d21c0f6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PatternStatementInsideLeafList.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type string {
+ pattern "[a-zA-Z]";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PatternStatementInsideTypeDef.yang b/utils/yangutils/plugin/src/test/resources/PatternStatementInsideTypeDef.yang
new file mode 100644
index 0000000..edb625e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PatternStatementInsideTypeDef.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef invalid-interval {
+ type string {
+ pattern "[a-zA-Z]";
+ }
+ }
+ leaf xyz {
+ type invalid-interval {
+ pattern "[a-z]";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PatternStatementWithPlus.yang b/utils/yangutils/plugin/src/test/resources/PatternStatementWithPlus.yang
new file mode 100644
index 0000000..417e1d1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PatternStatementWithPlus.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type string {
+ pattern "-[0-9]+|[0-9]+";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PatternSubStatements.yang b/utils/yangutils/plugin/src/test/resources/PatternSubStatements.yang
new file mode 100644
index 0000000..3e792c6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PatternSubStatements.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type string {
+ pattern "[a-zA-Z]" {
+ description "pattern description";
+ reference "pattern reference";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PositionDuplication.yang b/utils/yangutils/plugin/src/test/resources/PositionDuplication.yang
new file mode 100644
index 0000000..81eeb16
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PositionDuplication.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 1;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PositionImplicitAndExplicit.yang b/utils/yangutils/plugin/src/test/resources/PositionImplicitAndExplicit.yang
new file mode 100644
index 0000000..bef9712
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PositionImplicitAndExplicit.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf mybits {
+ type bits {
+ bit disable-nagle;
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Ten-Mb-only;
+ }
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/PositionImplicitAndExplicitDuplication.yang b/utils/yangutils/plugin/src/test/resources/PositionImplicitAndExplicitDuplication.yang
new file mode 100644
index 0000000..30b81ab
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PositionImplicitAndExplicitDuplication.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf mybits {
+ type bits {
+ bit disable-nagle;
+ bit auto-sense-speed {
+ position 0;
+ }
+ bit Ten-Mb-only;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PositionNegativeValue.yang b/utils/yangutils/plugin/src/test/resources/PositionNegativeValue.yang
new file mode 100644
index 0000000..60330e0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PositionNegativeValue.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf mybits {
+ type bits {
+ bit disable-nagle;
+ bit auto-sense-speed {
+ position -2;
+ }
+ bit Ten-Mb-only;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PositionStatement.yang b/utils/yangutils/plugin/src/test/resources/PositionStatement.yang
new file mode 100644
index 0000000..afa0a4c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PositionStatement.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/plugin/src/test/resources/PositionWithDoubleQuotes.yang b/utils/yangutils/plugin/src/test/resources/PositionWithDoubleQuotes.yang
new file mode 100644
index 0000000..0c9d358
--- /dev/null
+++ b/utils/yangutils/plugin/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/plugin/src/test/resources/PrefixDualEntry.yang b/utils/yangutils/plugin/src/test/resources/PrefixDualEntry.yang
new file mode 100644
index 0000000..e999774
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PrefixDualEntry.yang
@@ -0,0 +1,18 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+prefix On3;
+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/plugin/src/test/resources/PrefixInvalidValue.yang b/utils/yangutils/plugin/src/test/resources/PrefixInvalidValue.yang
new file mode 100644
index 0000000..40f7617
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PrefixInvalidValue.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/plugin/src/test/resources/PrefixMissingValue.yang b/utils/yangutils/plugin/src/test/resources/PrefixMissingValue.yang
new file mode 100644
index 0000000..4d92ee1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PrefixMissingValue.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix ;
+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/plugin/src/test/resources/PrefixOrder.yang b/utils/yangutils/plugin/src/test/resources/PrefixOrder.yang
new file mode 100644
index 0000000..d14e8b1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PrefixOrder.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+prefix test;
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/PrefixValidEntry.yang b/utils/yangutils/plugin/src/test/resources/PrefixValidEntry.yang
new file mode 100644
index 0000000..826dee4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PrefixValidEntry.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/plugin/src/test/resources/PrefixWithDoubleQuotes.yang b/utils/yangutils/plugin/src/test/resources/PrefixWithDoubleQuotes.yang
new file mode 100644
index 0000000..e9590f1
--- /dev/null
+++ b/utils/yangutils/plugin/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/plugin/src/test/resources/PresenceDefaultValue.yang b/utils/yangutils/plugin/src/test/resources/PresenceDefaultValue.yang
new file mode 100644
index 0000000..6418e20
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PresenceDefaultValue.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf ospf {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/PresenceWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/PresenceWithoutStatementEnd.yang
new file mode 100644
index 0000000..1427c5f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/PresenceWithoutStatementEnd.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ presence "invalid"
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraBrace.yang b/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraBrace.yang
new file mode 100644
index 0000000..ca3f0d0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraBrace.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ list sports-arena {
+ }
+ }
+ }
+ }
+}
+}
+}
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraBraceInBetween.yang b/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraBraceInBetween.yang
new file mode 100644
index 0000000..580d270
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraBraceInBetween.yang
@@ -0,0 +1,35 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping Percentage {
+ leaf hello{
+ type string;
+ }
+ leaf invalid1{
+ type string;
+ }
+ }
+ leaf invalid2{
+ type string;
+ }
+ }
+ container ospf {
+ list valid {
+ key "invalid";
+ leaf invalid{
+ type string;
+ }
+ uses Ant:FirstClass;
+ grouping FirstClass {
+ uses P:PassingClass;
+ }
+ }
+ grouping PassingClass {
+ uses Ant:Percentage;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraLeaf.yang b/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraLeaf.yang
new file mode 100644
index 0000000..5624b7a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ProcessFileWithExtraLeaf.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ list sports-arena {
+ }
+ }
+ }
+}
+leaf invalid {
+
diff --git a/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefType.yang b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefType.yang
new file mode 100644
index 0000000..da396fa
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefType.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ range "1..4 | 10..20";
+ }
+ }
+ typedef hello {
+ type int32;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang
new file mode 100644
index 0000000..f45f1ee
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefTypeAndTypedefInValid.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ range "min..4 | min..max";
+ }
+ }
+ typedef hello {
+ type int32 {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefTypeAndTypedefValid.yang b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefTypeAndTypedefValid.yang
new file mode 100644
index 0000000..b0af767
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInRefTypeAndTypedefValid.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ range "min..4 | 10..max";
+ }
+ }
+ typedef hello {
+ type int32 {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeRestrictionInString.yang b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInString.yang
new file mode 100644
index 0000000..f167230
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInString.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type string {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeRestrictionInStringInRefType.yang b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInStringInRefType.yang
new file mode 100644
index 0000000..c08635f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInStringInRefType.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello {
+ range "1..4 | 10..20";
+ }
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeRestrictionInTypedef.yang b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInTypedef.yang
new file mode 100644
index 0000000..0f53d1f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeRestrictionInTypedef.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type int32 {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeStatementInsideLeafList.yang b/utils/yangutils/plugin/src/test/resources/RangeStatementInsideLeafList.yang
new file mode 100644
index 0000000..9f5808d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeStatementInsideLeafList.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type int32 {
+ range "1..4 | 10..20";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeStatementWithSpace.yang b/utils/yangutils/plugin/src/test/resources/RangeStatementWithSpace.yang
new file mode 100644
index 0000000..a41d68a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeStatementWithSpace.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type int32 {
+ range " 1 .. 4 | 10 .. 20 ";
+ }
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/RangeSubStatements.yang b/utils/yangutils/plugin/src/test/resources/RangeSubStatements.yang
new file mode 100644
index 0000000..4b57bd0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeSubStatements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type int32 {
+ range "1..4 | 10..20" {
+ description "range description";
+ reference "range reference";
+ }
+ }
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/RangeWithInvalidIntegerPattern.yang b/utils/yangutils/plugin/src/test/resources/RangeWithInvalidIntegerPattern.yang
new file mode 100644
index 0000000..60c7992
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeWithInvalidIntegerPattern.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type int32 {
+ range "a..z";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeWithMinMax.yang b/utils/yangutils/plugin/src/test/resources/RangeWithMinMax.yang
new file mode 100644
index 0000000..373d45e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeWithMinMax.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type int32 {
+ range "min..max";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RangeWithOneInterval.yang b/utils/yangutils/plugin/src/test/resources/RangeWithOneInterval.yang
new file mode 100644
index 0000000..85d0288
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RangeWithOneInterval.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type int32 {
+ range "1";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ReferenceEmptyStatement.yang b/utils/yangutils/plugin/src/test/resources/ReferenceEmptyStatement.yang
new file mode 100644
index 0000000..ff3525a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ReferenceEmptyStatement.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ reference "";
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ReferenceStatement.yang b/utils/yangutils/plugin/src/test/resources/ReferenceStatement.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ReferenceStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/ReferenceWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/ReferenceWithoutStatementEnd.yang
new file mode 100644
index 0000000..f2fcf43
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ReferenceWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ reference "RFC 6020"
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/RevisionAbsence.yang b/utils/yangutils/plugin/src/test/resources/RevisionAbsence.yang
new file mode 100644
index 0000000..eb1d1d9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionAbsence.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RevisionDateInQuotesAtImport.yang b/utils/yangutils/plugin/src/test/resources/RevisionDateInQuotesAtImport.yang
new file mode 100644
index 0000000..5f8bcb8
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionDateInQuotesAtImport.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+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/plugin/src/test/resources/RevisionDateInQuotesAtInclude.yang b/utils/yangutils/plugin/src/test/resources/RevisionDateInQuotesAtInclude.yang
new file mode 100644
index 0000000..de405a3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionDateInQuotesAtInclude.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+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/plugin/src/test/resources/RevisionDateInvalid.yang b/utils/yangutils/plugin/src/test/resources/RevisionDateInvalid.yang
new file mode 100644
index 0000000..c219d11
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionDateInvalid.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+import ietf {
+prefix On2;
+revision-date 2015-02-30;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RevisionDateInvalidFormat.yang b/utils/yangutils/plugin/src/test/resources/RevisionDateInvalidFormat.yang
new file mode 100644
index 0000000..8a6c717
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionDateInvalidFormat.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+import ietf {
+prefix On2;
+revision-date 15-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/plugin/src/test/resources/RevisionDateInvalidSyntaxAtImport.yang b/utils/yangutils/plugin/src/test/resources/RevisionDateInvalidSyntaxAtImport.yang
new file mode 100644
index 0000000..df726bf
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionDateInvalidSyntaxAtImport.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+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/plugin/src/test/resources/RevisionDateInvalidSyntaxAtInclude.yang b/utils/yangutils/plugin/src/test/resources/RevisionDateInvalidSyntaxAtInclude.yang
new file mode 100644
index 0000000..ea5631e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionDateInvalidSyntaxAtInclude.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+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/plugin/src/test/resources/RevisionDateValidEntry.yang b/utils/yangutils/plugin/src/test/resources/RevisionDateValidEntry.yang
new file mode 100644
index 0000000..dbf4d3a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionDateValidEntry.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+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/plugin/src/test/resources/RevisionInValidOrder.yang b/utils/yangutils/plugin/src/test/resources/RevisionInValidOrder.yang
new file mode 100644
index 0000000..c60d434
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionInValidOrder.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+revision 2016-02-03;
+include itut {
+revision-date 2016-02-03;
+}
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RevisionInValidSyntax.yang b/utils/yangutils/plugin/src/test/resources/RevisionInValidSyntax.yang
new file mode 100644
index 0000000..1795b3e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionInValidSyntax.yang
@@ -0,0 +1,8 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+contact "Test";
+organization "ONOS";
+revision;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RevisionNoOptionalParameter.yang b/utils/yangutils/plugin/src/test/resources/RevisionNoOptionalParameter.yang
new file mode 100644
index 0000000..664204e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionNoOptionalParameter.yang
@@ -0,0 +1,8 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+contact "Test";
+organization "ONOS";
+revision 2016-02-03;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/RevisionSubStatementReference.yang b/utils/yangutils/plugin/src/test/resources/RevisionSubStatementReference.yang
new file mode 100644
index 0000000..d1ada14
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionSubStatementReference.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ description "module description";
+ revision 2007-06-09 {
+ reference "revision reference";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/RevisionSubStatementRevision.yang b/utils/yangutils/plugin/src/test/resources/RevisionSubStatementRevision.yang
new file mode 100644
index 0000000..3d1daa2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RevisionSubStatementRevision.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ description "module description";
+ revision 2007-06-09 {
+ description "revision description";
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/RpcTranslator.yang b/utils/yangutils/plugin/src/test/resources/RpcTranslator.yang
new file mode 100644
index 0000000..2f0616e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/RpcTranslator.yang
@@ -0,0 +1,25 @@
+module Sfc {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf test{
+ type string;
+ }
+ container my-container{
+ leaf my-val{
+ type string;
+ }
+ }
+ rpc SFP {
+ input {
+ leaf port {
+ type string;
+ }
+ }
+ output {
+ leaf path {
+ type string;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
new file mode 100644
index 0000000..812a528
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type hello;
+ }
+ }
+ typedef hello {
+ type string;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
new file mode 100644
index 0000000..10ccab6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type hello;
+ }
+ }
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
new file mode 100644
index 0000000..eddb649
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef hello {
+ type string;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type hello;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefNotFound.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefNotFound.yang
new file mode 100644
index 0000000..523f0b4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingTypedefNotFound.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type Ant:hello;
+ }
+ }
+ }
+ container isis {
+ typedef hello {
+ type string;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingHierarchicalRefUnresolved.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingHierarchicalRefUnresolved.yang
new file mode 100644
index 0000000..cd71621
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingHierarchicalRefUnresolved.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping create {
+ uses P:valid;
+ }
+ container test{
+ uses create;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang
new file mode 100644
index 0000000..b6e3b45
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingWithSelfAndExternalPrefixMix.yang
@@ -0,0 +1,28 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping Percentage {
+ leaf hello{
+ type string;
+ }
+ }
+ container ospf {
+ list valid {
+ key "invalid";
+ leaf invalid{
+ type string;
+ }
+ uses Ant:FirstClass;
+ grouping FirstClass {
+ uses P:PassingClass;
+ }
+ }
+ grouping PassingClass {
+ uses Ant:Percentage;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang
new file mode 100644
index 0000000..956ba50
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithGroupingWithSelfModulePrefix.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping Percentage {
+ leaf hello{
+ type string;
+ }
+ }
+ container ospf {
+ list valid {
+ key "invalid";
+ leaf invalid{
+ type string;
+ }
+ uses Ant:FirstClass;
+ grouping FirstClass {
+ uses PassingClass;
+ }
+ }
+ grouping PassingClass {
+ uses Ant:Percentage;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang
new file mode 100644
index 0000000..d622196
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef Percentage {
+ type Ant:INT;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type Ant:FirstClass;
+ }
+ typedef FirstClass {
+ type Ant:PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Percentage;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
new file mode 100644
index 0000000..a3e4379
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ typedef Percentage {
+ type P:Per;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type FirstClass;
+ }
+ typedef FirstClass {
+ type PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Percentage;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang
new file mode 100644
index 0000000..958dc23
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef Percentage {
+ type int32;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type FirstClass;
+ }
+ typedef FirstClass {
+ type PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Percentage;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
new file mode 100644
index 0000000..d5f346e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ typedef Percentage {
+ type int32;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type Ant:FirstClass;
+ }
+ typedef FirstClass {
+ type P:PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Ant:Percentage;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang
new file mode 100644
index 0000000..4f292b8
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang
@@ -0,0 +1,22 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef Percentage {
+ type int32;
+ }
+ container ospf {
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type Ant:FirstClass;
+ }
+ typedef FirstClass {
+ type PassingClass;
+ }
+ }
+ typedef PassingClass {
+ type Ant:Percentage;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang
new file mode 100644
index 0000000..d449adf
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingHavingSameUsesManyTimes.yang
@@ -0,0 +1,25 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ grouping endpoint {
+ leaf zip-code {
+ type string;
+ }
+ uses failure;
+ container hold {
+ leaf newone {
+ type string;
+ }
+
+ }
+ uses failure;
+ }
+ grouping failure {
+ leaf test {
+ type string;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingInRpcAndUsesInOutput.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingInRpcAndUsesInOutput.yang
new file mode 100644
index 0000000..3589a9f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingInRpcAndUsesInOutput.yang
@@ -0,0 +1,34 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ rpc rock-the-house {
+ description "description";
+ status current;
+ reference "reference";
+ grouping hello {
+ list valid {
+ key invalid-interval;
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+ input {
+ leaf zip-code {
+ type string;
+ }
+ uses hello;
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ uses hello;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang
new file mode 100644
index 0000000..3e0ba3d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingReferencingItselfFailureScenerio.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ grouping endpoint {
+ leaf zip-code {
+ type string;
+ }
+ uses endpoint;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingWithMultipleUses.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingWithMultipleUses.yang
new file mode 100644
index 0000000..906890f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionGroupingWithMultipleUses.yang
@@ -0,0 +1,63 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ grouping endpoint {
+ leaf zip-code {
+ type string;
+ }
+ uses first;
+ container design {
+ uses second;
+ container correct {
+ leaf newone {
+ type string;
+ }
+ uses third;
+ }
+ }
+ uses fourth;
+ uses fifth;
+ }
+ uses endpoint;
+ grouping first {
+ list valid {
+ key invalid-interval;
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+ grouping second {
+ leaf ink {
+ type int32;
+ }
+ }
+ grouping third {
+ container value {
+ leaf zip-code {
+ type string;
+ }
+ }
+ }
+ grouping fourth {
+ typedef my-type {
+ status deprecated;
+ type int32;
+ }
+ leaf correct {
+ type my-type;
+ }
+ }
+ grouping fifth {
+ leaf abc {
+ type string;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionNestedGroupingWithUnresolvedUses.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionNestedGroupingWithUnresolvedUses.yang
new file mode 100644
index 0000000..b2ab735
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionNestedGroupingWithUnresolvedUses.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container test {
+ leaf leaf2 {
+ type string;
+ }
+ grouping treat {
+ grouping create {
+ grouping mass {
+ }
+ }
+ }
+ }
+ uses Ant:treat;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode.yang
new file mode 100644
index 0000000..91dc763
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionRpcWithOneTypedefAndTwoGroupingUnderDifferentNode.yang
@@ -0,0 +1,38 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ rpc rock-the-house {
+ description "description";
+ status current;
+ reference "reference";
+ input {
+ leaf zip-code {
+ type string;
+ }
+ grouping creative {
+ leaf carry {
+ type string;
+ }
+ }
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ grouping creative {
+ list valid {
+ key invalid-interval;
+ leaf invalid-interval {
+ type "uint16";
+ }
+ }
+ }
+ typedef my-type {
+ status deprecated;
+ type int32;
+ }
+ uses creative;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
new file mode 100644
index 0000000..da6795b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevelForBinary.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevelForBinary.yang
new file mode 100644
index 0000000..d6ff30e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevelForBinary.yang
@@ -0,0 +1,17 @@
+module ospf {
+ namespace "urn:cisco:params:xml:ns:yang:ospf";
+ // replace with IANA namespace when assigned
+ prefix ospf;
+ revision 2020-10-20 {
+ description
+ "Initial revision.";
+ }
+
+ typedef type14 {
+ type binary;
+ }
+
+ leaf typedef14 {
+ type type14;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang
new file mode 100644
index 0000000..33f90c9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type Ant:hello;
+ }
+ typedef hi {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang
new file mode 100644
index 0000000..f6e9197
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevel.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ uses hello;
+ grouping hello {
+ leaf hello{
+ type string;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang
new file mode 100644
index 0000000..13cc4a5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SelfResolutionWhenUsesAndGroupingAtRootLevelGroupingWithChild.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ uses treat;
+ grouping treat {
+ leaf treat{
+ type string;
+ }
+ container test{
+ leaf leaf2{
+ type string;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ShortCaseListenerWithContainer.yang b/utils/yangutils/plugin/src/test/resources/ShortCaseListenerWithContainer.yang
new file mode 100644
index 0000000..3322a66
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ShortCaseListenerWithContainer.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ container sports-arena {
+ leaf pretzel {
+ type empty;
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ShortCaseListenerWithList.yang b/utils/yangutils/plugin/src/test/resources/ShortCaseListenerWithList.yang
new file mode 100644
index 0000000..6eeec79
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ShortCaseListenerWithList.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container food {
+ choice snack {
+ list sports-arena {
+ key "pretzel";
+ leaf pretzel {
+ type int32;
+ }
+ }
+ }
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/StatusDefaultValue.yang b/utils/yangutils/plugin/src/test/resources/StatusDefaultValue.yang
new file mode 100644
index 0000000..0cc9e36
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/StatusDefaultValue.yang
@@ -0,0 +1,12 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/StatusInvalidValue.yang b/utils/yangutils/plugin/src/test/resources/StatusInvalidValue.yang
new file mode 100644
index 0000000..253b785
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/StatusInvalidValue.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ status invalid;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/StatusStatementCurrent.yang b/utils/yangutils/plugin/src/test/resources/StatusStatementCurrent.yang
new file mode 100644
index 0000000..dd9a36d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/StatusStatementCurrent.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/StatusStatementDeprecated.yang b/utils/yangutils/plugin/src/test/resources/StatusStatementDeprecated.yang
new file mode 100644
index 0000000..9a257b1
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/StatusStatementDeprecated.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ status deprecated;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/StatusStatementObsolete.yang b/utils/yangutils/plugin/src/test/resources/StatusStatementObsolete.yang
new file mode 100644
index 0000000..19325ed
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/StatusStatementObsolete.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ status obsolete;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/StatusWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/StatusWithoutStatementEnd.yang
new file mode 100644
index 0000000..27a8cfa
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/StatusWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ status current
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SubModuleInvalidName.yang b/utils/yangutils/plugin/src/test/resources/SubModuleInvalidName.yang
new file mode 100644
index 0000000..7da9397
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SubModuleInvalidName.yang
@@ -0,0 +1,18 @@
+submodule Test:Test {
+belongs-to ONOS {
+prefix On1;
+}
+yang-version 1;
+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/plugin/src/test/resources/SubModuleOrder.yang b/utils/yangutils/plugin/src/test/resources/SubModuleOrder.yang
new file mode 100644
index 0000000..9779bbb
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SubModuleOrder.yang
@@ -0,0 +1,18 @@
+submodule Test {
+belongs-to ONOS {
+prefix On1;
+}
+yang-version 1;
+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/plugin/src/test/resources/SubModuleValidEntry.yang b/utils/yangutils/plugin/src/test/resources/SubModuleValidEntry.yang
new file mode 100644
index 0000000..00ecdca
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SubModuleValidEntry.yang
@@ -0,0 +1,18 @@
+submodule Test {
+yang-version 1;
+belongs-to ONOS {
+prefix On1;
+}
+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/plugin/src/test/resources/SubModuleWithNamespace.yang b/utils/yangutils/plugin/src/test/resources/SubModuleWithNamespace.yang
new file mode 100644
index 0000000..d7a38f7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SubModuleWithNamespace.yang
@@ -0,0 +1,19 @@
+submodule Test {
+belongs-to ONOS {
+prefix On1;
+}
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+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/plugin/src/test/resources/SubModuleWithoutBelongsTo.yang b/utils/yangutils/plugin/src/test/resources/SubModuleWithoutBelongsTo.yang
new file mode 100644
index 0000000..4a25209
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SubModuleWithoutBelongsTo.yang
@@ -0,0 +1,3 @@
+submodule Test {
+yang-version 1;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/SubModuleWithoutVersion.yang b/utils/yangutils/plugin/src/test/resources/SubModuleWithoutVersion.yang
new file mode 100644
index 0000000..f44df8b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/SubModuleWithoutVersion.yang
@@ -0,0 +1,17 @@
+submodule Test {
+belongs-to ONOS {
+prefix On1;
+}
+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/plugin/src/test/resources/UnionTranslator.yang b/utils/yangutils/plugin/src/test/resources/UnionTranslator.yang
new file mode 100644
index 0000000..f1de318
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnionTranslator.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type union {
+ type int32;
+ type int8;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/UnionWhenTypeInLeaf.yang b/utils/yangutils/plugin/src/test/resources/UnionWhenTypeInLeaf.yang
new file mode 100644
index 0000000..65c0369
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnionWhenTypeInLeaf.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type union {
+ type int32;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/UnionWhenTypeInLeafList.yang b/utils/yangutils/plugin/src/test/resources/UnionWhenTypeInLeafList.yang
new file mode 100644
index 0000000..df2b428
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnionWhenTypeInLeafList.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf-list invalid-interval {
+ type union {
+ type int32;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/UnionWithEmptyType.yang b/utils/yangutils/plugin/src/test/resources/UnionWithEmptyType.yang
new file mode 100644
index 0000000..81e8795
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnionWithEmptyType.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type union {
+ type empty;
+ type enumeration {
+ enum "unbounded";
+ }
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/UnitsDefaultValue.yang b/utils/yangutils/plugin/src/test/resources/UnitsDefaultValue.yang
new file mode 100644
index 0000000..c71d5ea
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnitsDefaultValue.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/UnitsStatement.yang b/utils/yangutils/plugin/src/test/resources/UnitsStatement.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnitsStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/test/resources/UnitsStatementCardinality.yang b/utils/yangutils/plugin/src/test/resources/UnitsStatementCardinality.yang
new file mode 100644
index 0000000..50a2ba0
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnitsStatementCardinality.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ units "minutes";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/UnitsStatementOrder.yang b/utils/yangutils/plugin/src/test/resources/UnitsStatementOrder.yang
new file mode 100644
index 0000000..e41e201
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnitsStatementOrder.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ units "seconds";
+ type "uint16";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/UnitsWithoutStatementEnd.yang b/utils/yangutils/plugin/src/test/resources/UnitsWithoutStatementEnd.yang
new file mode 100644
index 0000000..889d7b7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UnitsWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds"
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/UsesInContainer.yang b/utils/yangutils/plugin/src/test/resources/UsesInContainer.yang
new file mode 100644
index 0000000..df52fd6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UsesInContainer.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping endpoint {
+ }
+ container valid {
+ uses endpoint {
+ description "grouping under test";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/UsesInList.yang b/utils/yangutils/plugin/src/test/resources/UsesInList.yang
new file mode 100644
index 0000000..6ac7795
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UsesInList.yang
@@ -0,0 +1,21 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import ietf-yang-types {
+ prefix "P";
+ }
+ grouping endpoint {
+ }
+ list valid {
+ key address;
+ leaf address {
+ type P:ip;
+ }
+ uses endpoint {
+ description "grouping under test";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/UsesInModule.yang b/utils/yangutils/plugin/src/test/resources/UsesInModule.yang
new file mode 100644
index 0000000..02b9f09
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/UsesInModule.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping endpoint {
+ }
+ uses endpoint;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValidAugmentStatement.yang b/utils/yangutils/plugin/src/test/resources/ValidAugmentStatement.yang
new file mode 100644
index 0000000..f6c247e
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValidAugmentStatement.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://example.com/schema/ds0;
+ prefix On;
+
+ import interface-module {
+ prefix "if";
+ }
+ import ietf-yang-types {
+ prefix "P";
+ }
+ augment "/if:interfaces/if:ifEntry" {
+ leaf ds0ChannelNumber {
+ type P:ChannelNumber;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValidLengthStatement.yang b/utils/yangutils/plugin/src/test/resources/ValidLengthStatement.yang
new file mode 100644
index 0000000..57cb809
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValidLengthStatement.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type string {
+ length "0..100";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValidNotificationStatement.yang b/utils/yangutils/plugin/src/test/resources/ValidNotificationStatement.yang
new file mode 100644
index 0000000..1e0f144
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValidNotificationStatement.yang
@@ -0,0 +1,26 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ import ietf-yang-types {
+ prefix "P";
+ }
+ notification link-failure {
+ description "A link failure has been detected";
+ status deprecated;
+ reference "reference";
+ typedef my-type {
+ status deprecated;
+ type int32;
+ }
+ leaf if-name {
+ type string;
+ }
+ leaf if-admin-status {
+ type P:admin-status;
+ }
+ leaf if-oper-status {
+ type P:oper-status;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValidPatternStatement.yang b/utils/yangutils/plugin/src/test/resources/ValidPatternStatement.yang
new file mode 100644
index 0000000..556db31
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValidPatternStatement.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type string {
+ pattern "[a-zA-Z]";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValidRangeStatement.yang b/utils/yangutils/plugin/src/test/resources/ValidRangeStatement.yang
new file mode 100644
index 0000000..4243040
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValidRangeStatement.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type int32 {
+ range "1..4 | 10..20";
+ }
+ }
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/ValidRpcStatement.yang b/utils/yangutils/plugin/src/test/resources/ValidRpcStatement.yang
new file mode 100644
index 0000000..f188227
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValidRpcStatement.yang
@@ -0,0 +1,24 @@
+module rock {
+ namespace "http://example.net/rock";
+ prefix "rock";
+
+ rpc rock-the-house {
+ description "description";
+ status current;
+ reference "reference";
+ typedef my-type {
+ status deprecated;
+ type int32;
+ }
+ input {
+ leaf zip-code {
+ type string;
+ }
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValidSameGroupingEntryInModuleAndContainer.yang b/utils/yangutils/plugin/src/test/resources/ValidSameGroupingEntryInModuleAndContainer.yang
new file mode 100644
index 0000000..2580cdd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValidSameGroupingEntryInModuleAndContainer.yang
@@ -0,0 +1,23 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping endpoint {
+ leaf address {
+ type ip-address;
+ }
+ leaf port {
+ type port-number;
+ }
+ }
+ container valid {
+ grouping endpoint {
+ leaf address {
+ type ip-address;
+ }
+ leaf port {
+ type port-number;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValidVersionWithDoubleQuotes.yang b/utils/yangutils/plugin/src/test/resources/ValidVersionWithDoubleQuotes.yang
new file mode 100644
index 0000000..a2c718a
--- /dev/null
+++ b/utils/yangutils/plugin/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;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValueAndAutoStatement.yang b/utils/yangutils/plugin/src/test/resources/ValueAndAutoStatement.yang
new file mode 100644
index 0000000..89ba403
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValueAndAutoStatement.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf speed {
+ type enumeration {
+ enum 10m {
+ value 10;
+ }
+ enum 100m;
+ enum auto {
+ value 1000;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValueDuplication.yang b/utils/yangutils/plugin/src/test/resources/ValueDuplication.yang
new file mode 100644
index 0000000..339a737
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValueDuplication.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf speed {
+ type enumeration {
+ enum 10m {
+ value 10;
+ }
+ enum 100m {
+ value 100;
+ }
+ enum auto {
+ value 10;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValueExplicitAndAutoDuplication.yang b/utils/yangutils/plugin/src/test/resources/ValueExplicitAndAutoDuplication.yang
new file mode 100644
index 0000000..3e58155
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValueExplicitAndAutoDuplication.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf speed {
+ type enumeration {
+ enum 10m {
+ value 10;
+ }
+ enum 100m;
+ enum auto {
+ value 11;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValueStatement.yang b/utils/yangutils/plugin/src/test/resources/ValueStatement.yang
new file mode 100644
index 0000000..f461359
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValueStatement.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf speed {
+ type enumeration {
+ enum 10m {
+ value 10;
+ }
+ enum 100m {
+ value 100;
+ }
+ enum auto {
+ value 1000;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValueStatementWithNegativeValue.yang b/utils/yangutils/plugin/src/test/resources/ValueStatementWithNegativeValue.yang
new file mode 100644
index 0000000..a3f236b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValueStatementWithNegativeValue.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf speed {
+ type enumeration {
+ enum 10m {
+ value -2;
+ }
+ enum 100m {
+ value "-1";
+ }
+ enum auto {
+ value 0;
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/ValueStatementWithQuotes.yang b/utils/yangutils/plugin/src/test/resources/ValueStatementWithQuotes.yang
new file mode 100644
index 0000000..e166ca4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ValueStatementWithQuotes.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf speed {
+ type enumeration {
+ enum 10m {
+ value "10";
+ }
+ enum 100m {
+ value "100";
+ }
+ enum auto {
+ value "1000";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/VersionDualEntry.yang b/utils/yangutils/plugin/src/test/resources/VersionDualEntry.yang
new file mode 100644
index 0000000..f8eaddd
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/VersionDualEntry.yang
@@ -0,0 +1,6 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+yang-version 1;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/VersionInvalidSyntax.yang b/utils/yangutils/plugin/src/test/resources/VersionInvalidSyntax.yang
new file mode 100644
index 0000000..26cb0b2
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/VersionInvalidSyntax.yang
@@ -0,0 +1,5 @@
+module Test {
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+yang-version ;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/VersionInvalidValue.yang b/utils/yangutils/plugin/src/test/resources/VersionInvalidValue.yang
new file mode 100644
index 0000000..e8e6107
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/VersionInvalidValue.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 2;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/VersionNotPresent.yang b/utils/yangutils/plugin/src/test/resources/VersionNotPresent.yang
new file mode 100644
index 0000000..eed9953
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/VersionNotPresent.yang
@@ -0,0 +1,4 @@
+module Test {
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/VersionOrder.yang b/utils/yangutils/plugin/src/test/resources/VersionOrder.yang
new file mode 100644
index 0000000..92463e9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/VersionOrder.yang
@@ -0,0 +1,5 @@
+module Test {
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+yang-version 1;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/VersionValidEntry.yang b/utils/yangutils/plugin/src/test/resources/VersionValidEntry.yang
new file mode 100644
index 0000000..439ded8
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/VersionValidEntry.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/YangFileWithSyntaxError.yang b/utils/yangutils/plugin/src/test/resources/YangFileWithSyntaxError.yang
new file mode 100644
index 0000000..413a181
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/YangFileWithSyntaxError.yang
@@ -0,0 +1,6 @@
+module Antlrtest {
+yang-version 1
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix Ant;
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/YangFileWithoutSyntaxError.yang b/utils/yangutils/plugin/src/test/resources/YangFileWithoutSyntaxError.yang
new file mode 100644
index 0000000..4f4839f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/YangFileWithoutSyntaxError.yang
@@ -0,0 +1,6 @@
+module Antlrtest {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix Ant;
+}
+
diff --git a/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-inet-types.yang b/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-inet-types.yang
new file mode 100644
index 0000000..db6df27
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-inet-types.yang
@@ -0,0 +1,12 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+ typedef uri {
+ type string;
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-network-topology.yang b/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-network-topology.yang
new file mode 100644
index 0000000..4f426e4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-network-topology.yang
@@ -0,0 +1,34 @@
+ module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ prefix lnk;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ typedef tp-id {
+ type inet:uri;
+ description
+ "An identifier for termination points on a node.
+ The identifier SHOULD be chosen such that the same TP in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in
+ separate datastores. An implementation MAY choose to capture
+ semantics in the identifier, for example to indicate the type
+ of TP and/or the type of node and topology that the TP is a
+ part of.";
+ }
+
+ grouping tp-ref {
+ description
+ "References a termination point in a specific node.";
+ leaf tp-ref {
+ type tp-id;
+ description
+ "A type for an absolute reference to a termination point.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-te-topology.yang b/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-te-topology.yang
new file mode 100644
index 0000000..c1d9324
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/file1UsesFile2TypeDefFile3Type/ietf-te-topology.yang
@@ -0,0 +1,17 @@
+ module ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ // replace with IANA namespace when assigned
+
+ prefix "tet";
+
+ import ietf-network-topology {
+ prefix "nt";
+ }
+
+ container underlay-trail-src {
+ uses nt:tp-ref;
+ description
+ "Source TE link of the underlay trail.";
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/groupingNodeSameAsModule/portpair.yang b/utils/yangutils/plugin/src/test/resources/groupingNodeSameAsModule/portpair.yang
new file mode 100644
index 0000000..3497f04
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/groupingNodeSameAsModule/portpair.yang
@@ -0,0 +1,29 @@
+module port-pair {
+
+ yang-version 1;
+
+ namespace "sfc.portpair";
+
+ prefix "port-pair";
+
+ grouping port-pair {
+ container port-pair {
+
+ leaf name {
+ type string;
+ }
+
+
+ leaf description {
+ type string;
+ }
+
+ }
+ }
+
+ rpc get-port-pair {
+ output {
+ uses port-pair;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-inet-types.yang b/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-inet-types.yang
new file mode 100644
index 0000000..38f209f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-inet-types.yang
@@ -0,0 +1,15 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+
+
+ typedef uri {
+ type string;
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-network-topology.yang b/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-network-topology.yang
new file mode 100644
index 0000000..6e9dfb7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-network-topology.yang
@@ -0,0 +1,17 @@
+ module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ prefix nt;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+ import ietf-network {
+ prefix nd;
+ }
+ leaf source-node {
+ type nd:node-id;
+ description
+ "Source node identifier, must be in same topology.";
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-network.yang b/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-network.yang
new file mode 100644
index 0000000..1f15b40
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/hierarchicalinterfiletype/ietf-network.yang
@@ -0,0 +1,16 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/hierarchicalintrawithinterfiletype/ietf-inet-types.yang b/utils/yangutils/plugin/src/test/resources/hierarchicalintrawithinterfiletype/ietf-inet-types.yang
new file mode 100644
index 0000000..48d13c6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/hierarchicalintrawithinterfiletype/ietf-inet-types.yang
@@ -0,0 +1,13 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+ typedef uri {
+ type string;
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/hierarchicalintrawithinterfiletype/ietf-network.yang b/utils/yangutils/plugin/src/test/resources/hierarchicalintrawithinterfiletype/ietf-network.yang
new file mode 100644
index 0000000..e35d0f5
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/hierarchicalintrawithinterfiletype/ietf-network.yang
@@ -0,0 +1,22 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+ leaf node-ref {
+ type node-id;
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-inet-types.yang b/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-inet-types.yang
new file mode 100644
index 0000000..851a4d7
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-inet-types.yang
@@ -0,0 +1,454 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types for Internet addresses and related things.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - ip-address-no-zone
+ - ipv4-address-no-zone
+ - ipv6-address-no-zone";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef ip-version {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "An unknown or unspecified version of the Internet
+ protocol.";
+ }
+ enum "ipv4" {
+ value 1;
+ description
+ "The IPv4 protocol as defined in RFC 791.";
+ }
+ enum "ipv6" {
+ value 2;
+ description
+ "The IPv6 protocol as defined in RFC 2460.";
+ }
+ }
+ description
+ "This value represents the version of the IP protocol.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetVersion textual convention of the SMIv2.";
+ reference
+ "RFC 791: Internet Protocol
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef dscp {
+ type uint8 {
+ range "0..63";
+ }
+ description
+ "The dscp type represents a Differentiated Services Code Point
+ that may be used for marking packets in a traffic stream.
+ In the value set and its semantics, this type is equivalent
+ to the Dscp textual convention of the SMIv2.";
+ reference
+ "RFC 3289: Management Information Base for the Differentiated
+ Services Architecture
+ RFC 2474: Definition of the Differentiated Services Field
+ (DS Field) in the IPv4 and IPv6 Headers
+ RFC 2780: IANA Allocation Guidelines For Values In
+ the Internet Protocol and Related Headers";
+
+ }
+
+ typedef ipv6-flow-label {
+ type uint32 {
+ range "0..1048575";
+ }
+ description
+ "The ipv6-flow-label type represents the flow identifier or Flow
+ Label in an IPv6 packet header that may be used to
+ discriminate traffic flows.
+
+ In the value set and its semantics, this type is equivalent
+ to the IPv6FlowLabel textual convention of the SMIv2.";
+ reference
+ "RFC 3595: Textual Conventions for IPv6 Flow Label
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
+
+ }
+
+ typedef port-number {
+ type uint16 {
+ range "0..65535";
+ }
+ description
+ "The port-number type represents a 16-bit port number of an
+ Internet transport-layer protocol such as UDP, TCP, DCCP, or
+ SCTP. Port numbers are assigned by IANA. A current list of
+ all assignments is available from <http://www.iana.org/>.
+
+ Note that the port number value zero is reserved by IANA. In
+ situations where the value zero does not make sense, it can
+ be excluded by subtyping the port-number type.
+ In the value set and its semantics, this type is equivalent
+ to the InetPortNumber textual convention of the SMIv2.";
+ reference
+ "RFC 768: User Datagram Protocol
+ RFC 793: Transmission Control Protocol
+ RFC 4960: Stream Control Transmission Protocol
+ RFC 4340: Datagram Congestion Control Protocol (DCCP)
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef as-number {
+ type uint32;
+ description
+ "The as-number type represents autonomous system numbers
+ which identify an Autonomous System (AS). An AS is a set
+ of routers under a single technical administration, using
+ an interior gateway protocol and common metrics to route
+ packets within the AS, and using an exterior gateway
+ protocol to route packets to other ASes. IANA maintains
+ the AS number space and has delegated large parts to the
+ regional registries.
+
+ Autonomous system numbers were originally limited to 16
+ bits. BGP extensions have enlarged the autonomous system
+ number space to 32 bits. This type therefore uses an uint32
+ base type without a range restriction in order to support
+ a larger autonomous system number space.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetAutonomousSystemNumber textual convention of
+ the SMIv2.";
+ reference
+ "RFC 1930: Guidelines for creation, selection, and registration
+ of an Autonomous System (AS)
+ RFC 4271: A Border Gateway Protocol 4 (BGP-4)
+ RFC 4001: Textual Conventions for Internet Network Addresses
+ RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
+ Number Space";
+
+ }
+
+ typedef ip-address {
+ type union {
+ type ipv4-address;
+ type ipv6-address;
+ }
+ description
+ "The ip-address type represents an IP address and is IP
+ version neutral. The format of the textual representation
+ implies the IP version. This type supports scoped addresses
+ by allowing zone identifiers in the address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?';
+ }
+ description
+ "The ipv4-address type represents an IPv4 address in
+ dotted-quad notation. The IPv4 address may include a zone
+ index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+ The canonical format for the zone index is the numerical
+ format";
+ }
+
+ typedef ipv6-address {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\p{N}\p{L}]+)?';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(%.+)?';
+ }
+ description
+ "The ipv6-address type represents an IPv6 address in full,
+ mixed, shortened, and shortened-mixed notation. The IPv6
+ address may include a zone index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+
+
+ The canonical format of IPv6 addresses uses the textual
+ representation defined in Section 4 of RFC 5952. The
+ canonical format for the zone index is the numerical
+ format as described in Section 11.2 of RFC 4007.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-address-no-zone {
+ type union {
+ type ipv4-address-no-zone;
+ type ipv6-address-no-zone;
+ }
+ description
+ "The ip-address-no-zone type represents an IP address and is
+ IP version neutral. The format of the textual representation
+ implies the IP version. This type does not support scoped
+ addresses since it does not allow zone identifiers in the
+ address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address-no-zone {
+ type ipv4-address {
+ pattern '[0-9\.]*';
+ }
+ description
+ "An IPv4 address without a zone index. This type, derived from
+ ipv4-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ }
+
+ typedef ipv6-address-no-zone {
+ type ipv6-address {
+ pattern '[0-9a-fA-F:\.]*';
+ }
+ description
+ "An IPv6 address without a zone index. This type, derived from
+ ipv6-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-prefix {
+ type union {
+ type ipv4-prefix;
+ type ipv6-prefix;
+ }
+ description
+ "The ip-prefix type represents an IP prefix and is IP
+ version neutral. The format of the textual representations
+ implies the IP version.";
+ }
+
+ typedef ipv4-prefix {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))';
+ }
+ description
+ "The ipv4-prefix type represents an IPv4 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 32.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The canonical format of an IPv4 prefix has all bits of
+ the IPv4 address set to zero that are not part of the
+ IPv4 prefix.";
+ }
+
+ typedef ipv6-prefix {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(/.+)';
+ }
+ description
+ "The ipv6-prefix type represents an IPv6 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 128.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The IPv6 address should have all bits that do not belong
+ to the prefix set to zero.
+
+ The canonical format of an IPv6 prefix has all bits of
+ the IPv6 address set to zero that are not part of the
+ IPv6 prefix. Furthermore, the IPv6 address is represented
+ as defined in Section 4 of RFC 5952.";
+ reference
+ "RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef domain-name {
+ type string {
+ length "1..253";
+ pattern
+ '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)|\.';
+ }
+ description
+ "The domain-name type represents a DNS domain name. The
+ name SHOULD be fully qualified whenever possible.
+
+ Internet domain names are only loosely specified. Section
+ 3.5 of RFC 1034 recommends a syntax (modified in Section
+ 2.1 of RFC 1123). The pattern above is intended to allow
+ for current practice in domain name use, and some possible
+ future expansion. It is designed to hold various types of
+ domain names, including names used for A or AAAA records
+ (host names) and other records, such as SRV records. Note
+ that Internet host names have a stricter syntax (described
+ in RFC 952) than the DNS recommendations in RFCs 1034 and
+ 1123, and that systems that want to store host names in
+ schema nodes using the domain-name type are recommended to
+ adhere to this stricter standard to ensure interoperability.
+
+ The encoding of DNS names in the DNS protocol is limited
+ to 255 characters. Since the encoding consists of labels
+ prefixed by a length bytes and there is a trailing NULL
+ byte, only 253 characters can appear in the textual dotted
+ notation.
+
+ The description clause of schema nodes using the domain-name
+ type MUST describe when and how these names are resolved to
+ IP addresses. Note that the resolution of a domain-name value
+ may require to query multiple DNS records (e.g., A for IPv4
+ and AAAA for IPv6). The order of the resolution process and
+ which DNS record takes precedence can either be defined
+ explicitly or may depend on the configuration of the
+ resolver.
+
+ Domain-name values use the US-ASCII encoding. Their canonical
+ format uses lowercase US-ASCII characters. Internationalized
+ domain names MUST be A-labels as per RFC 5890.";
+ reference
+ "RFC 952: DoD Internet Host Table Specification
+ RFC 1034: Domain Names - Concepts and Facilities
+ RFC 1123: Requirements for Internet Hosts -- Application
+ and Support
+ RFC 2782: A DNS RR for specifying the location of services
+ (DNS SRV)
+ RFC 5890: Internationalized Domain Names in Applications
+ (IDNA): Definitions and Document Framework";
+
+ }
+
+ typedef host {
+ type union {
+ type ip-address;
+ type domain-name;
+ }
+ description
+ "The host type represents either an IP address or a DNS
+ domain name.";
+ }
+
+ typedef uri {
+ type string;
+ description
+ "The uri type represents a Uniform Resource Identifier
+ (URI) as defined by STD 66.
+
+ Objects using the uri type MUST be in US-ASCII encoding,
+ and MUST be normalized as described by RFC 3986 Sections
+ 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
+ percent-encoding is removed, and all case-insensitive
+ characters are set to lowercase except for hexadecimal
+ digits, which are normalized to uppercase as described in
+ Section 6.2.2.1.
+
+ The purpose of this normalization is to help provide
+ unique URIs. Note that this normalization is not
+ sufficient to provide uniqueness. Two URIs that are
+ textually distinct after this normalization may still be
+ equivalent.
+
+ Objects using the uri type may restrict the schemes that
+ they permit. For example, 'data:' and 'urn:' schemes
+ might not be appropriate.
+
+ A zero-length URI is not a valid URI. This can be used to
+ express 'URI absent' where required.
+
+ In the value set and its semantics, this type is equivalent
+ to the Uri SMIv2 textual convention defined in RFC 5017.";
+ reference
+ "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
+ RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
+ Group: Uniform Resource Identifiers (URIs), URLs,
+ and Uniform Resource Names (URNs): Clarifications
+ and Recommendations
+ RFC 5017: MIB Textual Conventions for Uniform Resource
+ Identifiers (URIs)";
+
+ }
+ } // module ietf-inet-types
diff --git a/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-common-types.yang b/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-common-types.yang
new file mode 100644
index 0000000..7cde2ec
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-common-types.yang
@@ -0,0 +1,141 @@
+ module ietf-sd-onos-common-types {
+ namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-common-types";
+ prefix types ;
+ /*
+ import ietf-inet-types{
+ prefix inet;
+ }
+ import ietf-yang-types {
+ prefix yang-types;
+ }
+ */
+ organization "";
+ contact "";
+
+ description
+ "Defines common basic types of L3VPN.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ typedef admin-status {
+ type enumeration {
+ enum admin-up {
+ value 0 ;
+ description "admin up, the operate-status is depend on the real
+ running status ." ;
+ }
+ enum admin-down {
+ value 1 ;
+ description "admin down,the operate-status is forced to down no
+ matter what the real status is" ;
+ }
+ enum config-up {
+ value 2 ;
+ description "the operate-status is forced to up no matter what
+ the real status is." ;
+ }
+ }
+ default admin-up;
+ description
+ "The administration status of the service.";
+ }
+
+ typedef notification-status {
+ type enumeration {
+ enum up {
+ value 0 ;
+ description "up." ;
+ }
+ enum down {
+ value 1 ;
+ description "down." ;
+ }
+ }
+ default up;
+ description
+ "The notification status of the service.";
+ }
+
+ typedef notification-type {
+ type enumeration {
+ enum ne{
+ value 0 ;
+ description "ncd change." ;
+ }
+ enum link{
+ value 1 ;
+ description "link change." ;
+ }
+ enum ltp{
+ value 2 ;
+ description "ltp change." ;
+ }
+ }
+ default ltp;
+ description
+ "The notification-type of the service.";
+ }
+
+ typedef operate-status {
+ type enumeration {
+ enum operate-up {
+ value 0 ;
+ description "operate up." ;
+ }
+ enum operate-down {
+ value 1 ;
+ description "operate down." ;
+ }
+ }
+ default operate-up;
+ description
+ "The operation status of the service.";
+ }
+
+ grouping command-result {
+ description
+ "Reusable container of the result of the command.";
+ container command-result {
+ description
+ "The result of the command.";
+ leaf result {
+ type int8;
+ description
+ "1 : success, 2 : failed, 3 : partly failed" ;
+ }
+ container success-resources {
+ description
+ "The resources those are available." ;
+ list success-resource-list {
+ description
+ "The resource list shows those are available." ;
+ leaf resource-id {
+ type string;
+ description
+ "The available resource id." ;
+ }
+ }
+ }
+ container failed-resources {
+ description
+ "The resources those are failed." ;
+ list failed-resource-list {
+ description
+ "The resources list shows those are failed." ;
+ leaf resource-id {
+ type string;
+ description
+ "The failed resources ids." ;
+ }
+ leaf error-code {
+ type string;
+ description
+ "The error code." ;
+ }
+ }
+ }
+ }
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-l3vpn.yang b/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-l3vpn.yang
new file mode 100644
index 0000000..7b55f71
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-l3vpn.yang
@@ -0,0 +1,316 @@
+ module ietf-sd-onos-service-l3vpn {
+ namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-l3vpn";
+ prefix l3vpn ;
+ /*
+ import ietf-inet-types{
+ prefix inet;
+ }
+ import ietf-yang-types {
+ prefix yang-types;
+ }
+ */
+ import ietf-sd-onos-service-types {
+ prefix service-types;
+ }
+ import ietf-sd-onos-common-types {
+ prefix types;
+ }
+ organization "";
+ contact "";
+
+ description
+ "L3vpn configuration model in ONOS.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ grouping l3vpn {
+ description
+ "The configuration module of l3 vpn.";
+ leaf name {
+ type string ;
+ mandatory true;
+ description "name of snc eline." ;
+ }
+ leaf id {
+ type uint32 ;
+ mandatory true;
+ description "ID of snc eline." ;
+ }
+ leaf user-label {
+ type string ;
+ description "user label of snc eline." ;
+ }
+ leaf parent-ncd-id {
+ type string ;
+ description "parent ncd id." ;
+ }
+
+ leaf admin-status {
+ type types:admin-status;
+ description "administration status." ;
+ }
+ leaf operate-status {
+ type types:operate-status;
+ description "operation status." ;
+ }
+
+ uses service-type-grouping;
+ container acess-information {
+ description "access information of the l3 vpn." ;
+
+ uses service-types:l3-ac; }
+
+ container protect-policy{
+ description "L3VPN Service protect policy." ;
+ uses service-types:protect-policy;
+ }
+ container tunnel-service {
+ description "tunnel service." ;
+ uses service-types:tunnel-service;
+ }
+
+ }
+
+ grouping service-type-grouping {
+ description "Basic service type" ;
+ leaf service-topology {
+ type enumeration {
+ enum full-mesh {
+ value 1 ;
+ description "full-mesh." ;
+ }
+ enum hub-spoke {
+ value 2 ;
+ description "hub-spoke." ;
+ }
+ }
+ default full-mesh;
+ description "service topology type." ;
+ }
+ }
+
+ container service {
+ description
+ "Root level of L3vpn service module.";
+ container l3vpn-cfg {
+ description
+ "L3vpn configuration model in ONOS.";
+ list vpn-cfg {
+ key name;
+ description
+ "vpn configuration parameter list.";
+ uses l3vpn;
+ }
+ }
+ container service-paths {
+ description
+ "The service path of the l3 vpn.";
+ }
+ }
+
+
+
+ rpc create-l3vpn-instance {
+ description "Create l3vpn instance." ;
+ input {
+ container l3vpn-instance {
+ description "Create l3vpn instance." ;
+ uses l3vpn;
+ }
+ }
+ }
+
+ rpc delete-l3vpn-instance {
+ description "Delete l3vpn instance." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "vpn id." ;
+ }
+ }
+ }
+
+ rpc close-l3vpn {
+ description "Close l3vpn." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "vpn id." ;
+ }
+ container ac-status {
+ description "Access status of the vpn." ;
+ list acs{
+ key "id";
+ description "Access information." ;
+ leaf id {
+ type string;
+ description "Access id." ;
+ }
+ leaf admin-status {
+ type types:admin-status;
+ description "Administration status." ;
+ }
+ }
+ }
+ }
+ }
+
+ rpc modify-l3vpn-instance-basic {
+ description "Modify l3vpn instance basic information." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "vpn id." ;
+ }
+ leaf user-label {
+ type string ;
+ description "user label." ;
+ }
+ }
+ }
+
+ rpc modify-l3vpn-instance-ac-qos {
+ description "Modify l3vpn instance ac qos information." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "L3vpn ID." ;
+ }
+ container ac-qos {
+ description "ac qos information." ;
+ list acs{
+ key "id";
+ description "acs list." ;
+ leaf id {
+ type string;
+ description "acs ID." ;
+ }
+ container qos-policy {
+ description "qos policy." ;
+ container qos-if-cars {
+ description "cars qos policy." ;
+ uses service-types:qos-if-car;
+
+ }
+ }
+ }
+ }
+ }
+ }
+ rpc modify-l3vpn-instance-connection {
+ description "Modify a l3vpn connection." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "L3vpn ID." ;
+ }
+ container ac-connection {
+ description "ac connection." ;
+ list acs{
+ key "id";
+ description "acs ID." ;
+ leaf id {
+ type string ;
+ description "acs ID." ;
+ }
+ container connection {
+ description "CE to PE connection." ;
+ uses service-types:connection;
+ }
+ }
+ }
+ }
+ }
+ rpc inquire-l3vpn-instance-work-path {
+ description "Inquire a L3VPN instance work path." ;
+ input {
+ leaf service-id {
+ type string;
+ description "service ID." ;
+ }
+ leaf ingress-ne-id {
+ type string ;
+ description "ingress network element ID." ;
+ }
+ leaf destination-ne-id {
+ type string ;
+ description "destination network element ID." ;
+ }
+ leaf ingress-ac-id {
+ type string ;
+ description "ingress ac ID." ;
+ }
+ leaf destination-ac-id {
+ type string ;
+ description "destination ac ID." ;
+ }
+ leaf path-layer {
+ type string ;
+ description "path layer." ;
+ }
+ leaf path-role {
+ type string ;
+ description "path role." ;
+ }
+ }
+ output {
+ container service-path {
+ description "service path." ;
+ leaf service-id {
+ type string;
+ description "service ID." ;
+ }
+ leaf ingress-ne-id {
+ type string ;
+ description "ingress network element ID." ;
+ }
+ leaf destination-ne-id {
+ type string ;
+ description "destination network element ID." ;
+ }
+ leaf ingress-ac-id {
+ type string ;
+ description "ingress access circuit ID." ;
+ }
+ leaf destination-ac-id {
+ type string ;
+ description "destination access circuit ID." ;
+ }
+ leaf path-layer {
+ type string ;
+ description "path layer." ;
+ }
+ leaf path-role {
+ type string ;
+ description "path role." ;
+ }
+ list path-list {
+ key "ne-id";
+ description "path list." ;
+ leaf ne-id {
+ type string;
+ description "network element ID." ;
+ }
+ leaf ingress-ltp-id {
+ type string;
+ description "LTP ID." ;
+ }
+ leaf backward-peer-id {
+ type string;
+ description "backward peer ID." ;
+ }
+ leaf egress-ltp-id {
+ type string;
+ description "egress ltp ID." ;
+ }
+ leaf forward-peer-id {
+ type string;
+ description "forward peer ID." ;
+ }
+ }
+ }
+ }
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-types.yang b/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-types.yang
new file mode 100644
index 0000000..7fd7700
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/ietfyang/l3vpnservice/ietf-sd-onos-service-types.yang
@@ -0,0 +1,816 @@
+ module ietf-sd-onos-service-types {
+ namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-types";
+ prefix service-types ;
+
+ import ietf-inet-types {prefix inet; }
+ import ietf-sd-onos-common-types {prefix types;}
+
+ organization "";
+ contact "";
+
+ description
+ "Defines basic service types for L3VPN service.";
+
+ revision "2015-12-16" {
+ reference "";
+ }
+
+ typedef exp {
+ type enumeration {
+ enum BE {
+ value 0 ;
+ description "BE." ;
+ }
+ enum AF1 {
+ value 1 ;
+ description "AF1." ;
+ }
+ enum AF2 {
+ value 2 ;
+ description "AF2." ;
+ }
+ enum AF3 {
+ value 3 ;
+ description "AF3." ;
+ }
+ enum AF4 {
+ value 4 ;
+ description "AF4." ;
+ }
+ enum EF {
+ value 5 ;
+ description "EF." ;
+ }
+ enum CS6 {
+ value 6 ;
+ description "CS6." ;
+ }
+ enum CS7 {
+ value 7 ;
+ description "CS7." ;
+ }
+ }
+ default CS7;
+ description
+ "exp parameter.";
+ }
+
+ typedef pw-role{
+ type enumeration {
+ enum normal{
+ value 0 ;
+ description "normal." ;
+ }
+ enum master {
+ value 1 ;
+ description "master." ;
+ }
+ enum slave {
+ value 2 ;
+ description "slave." ;
+ }
+ enum DNI-PW {
+ value 3 ;
+ description "DNI PW." ;
+ }
+ }
+ default normal;
+ description
+ "The role of the PW.";
+ }
+
+ grouping qos-if-car {
+ description "qos parameter." ;
+ list qos-if-car {
+ key "direction";
+ description "cars qos policy." ;
+ leaf direction {
+ type enumeration {
+ enum inbound{
+ value 0 ;
+ description "inbound." ;
+ }
+ enum outbound {
+ value 1 ;
+ description "outbound." ;
+ }
+ }
+ description "qos for interface car" ;
+ }
+
+ leaf cir {
+ type int32;
+ description "forward CIR. unit:Kbps" ;
+ }
+ leaf pir {
+ type int32;
+ description "forward PIR. unit:Kbps" ;
+ }
+ leaf cbs {
+ type int32;
+ description "forward CBS. unit:Kbps" ;
+ }
+ leaf pbs {
+ type int32;
+ description "forward PBS. unit:Kbps" ;
+ }
+ }
+ }
+
+ grouping protect-policy {
+ description "The protect policy of the VPN" ;
+ leaf protect-type {
+ type enumeration {
+ enum unprotected {
+ value 0 ;
+ description "unprotected." ;
+ }
+ enum protected {
+ value 1 ;
+ description "protection." ;
+ }
+ }
+ default unprotected ;
+ description "protection type" ;
+ }
+
+ leaf revertive-type {
+ type enumeration {
+ enum no-revertive {
+ value 0 ;
+ description "unprotected." ;
+ }
+ enum revertive {
+ value 1 ;
+ description "protection." ;
+ }
+ }
+ description "revertive mode" ;
+ }
+ leaf wtr {
+ type uint32;
+ default 300;
+ description "WTR.unit:s" ;
+ }
+ }
+ grouping oam-policy {
+ description "The oam policy of the vpn service." ;
+ leaf detect-type {
+ type enumeration {
+ enum undetect {
+ value 0 ;
+ description "unprotected." ;
+ }
+ enum APS {
+ value 1 ;
+ description "protection." ;
+ }
+ enum BFD {
+ value 2 ;
+ description "unprotected." ;
+ }
+ }
+ description "detect type" ;
+ }
+ container bfd-detect-para {
+ description "bfd detect parameters." ;
+ leaf ingress-discriminator {
+ type int32;
+ description "ingress-discriminator" ;
+ }
+ leaf egress-discriminator {
+ type int32;
+ description "egress-discriminator" ;
+ }
+ leaf tx-interval {
+ type int32;
+ description "tx-interval" ;
+ }
+ leaf rx-interval {
+ type int32;
+ description "rx-interval" ;
+ }
+ leaf detect-interval {
+ type int32;
+ description "detect-interval" ;
+ }
+ }
+ }
+ grouping ac {
+ description "Access information." ;
+ leaf id{
+ type string;
+ mandatory true;
+ description "ac id." ;
+ }
+ leaf name{
+ type string;
+ config false;
+ description "ac name." ;
+ }
+
+ leaf ne-id {
+ type string ;
+ mandatory true;
+ description "ne id." ;
+ }
+
+ leaf ltp-id {
+ type string ;
+ mandatory true;
+ description "ltp id." ;
+ }
+ leaf admin-status {
+ type types:admin-status;
+ description "Administration status." ;
+ }
+ leaf operate-status {
+ type types:operate-status;
+ description "Operation status." ;
+ }
+ container l2-access {
+ description "link layer access information of ac." ;
+ uses l2-access;
+ }
+
+ leaf role {
+ type enumeration {
+ enum master {
+ value 0 ;
+ description "master." ;
+ }
+ enum slave {
+ value 1 ;
+ description "slave." ;
+ }
+ enum hub {
+ value 2 ;
+ description "slave." ;
+ }
+ enum spoke {
+ value 3 ;
+ description "slave." ;
+ }
+ }
+ default master;
+ description "role of snc lsp." ;
+ }
+ container qos-policy {
+ description "The qos policy of the vpn service." ;
+ container qos-if-cars {
+ description "qos policy if car." ;
+ list qos-if-car {
+ //key "direction";
+ uses qos-if-car;
+ description "List of qos parameters." ;
+ }
+ }
+ }
+ }
+ grouping l3-ac {
+ description "Access information of l3vpn." ;
+ list access-circuit {
+ key "id";
+ description "list of access circuit." ;
+ uses ac;
+ container connection {
+ description "connection information of ac." ;
+ uses connection;
+ }
+ }
+ }
+ grouping l2-access {
+ description "Access information of l2vpn." ;
+ leaf access-type{
+ type enumeration {
+ enum Port {
+ value 0 ;
+ description "master." ;
+ }
+ enum Dot1Q {
+ value 1 ;
+ description "slave." ;
+ }
+ enum QinQ {
+ value 2 ;
+ description "master." ;
+ }
+ }
+ mandatory true;
+ description "The access type of the vpn service." ;
+ }
+ leaf dot1q-vlan-bitmap {
+ type string;
+ mandatory true;
+ description "Dot1Q Vlan Bitmap." ;
+ }
+
+ leaf qinq-svlan-bitmap {
+ type string;
+ mandatory true;
+ description "QinQ svlan Bitmap." ;
+ }
+
+ leaf qinq-cvlan-bitmap {
+ type string;
+ mandatory true;
+ description "QinQ cvlan Bitmap." ;
+ }
+ leaf access-action {
+ type enumeration {
+ enum Keep {
+ value 0 ;
+ description "keep." ;
+ }
+ enum Push {
+ value 1 ;
+ description "push." ;
+ }
+ enum Pop {
+ value 2 ;
+ description "pop." ;
+ }
+ enum Swap {
+ value 3 ;
+ description "swap." ;
+ }
+ }
+ mandatory true;
+ description "access type." ;
+ }
+
+ leaf action-vlan-id {
+ type int32 {
+ range "1..4094";
+ }
+ description "action vlan id." ;
+ }
+ }
+ grouping connection {
+ description "Describe the connection of the vpn service." ;
+ leaf ip-address {
+ type inet:ip-address ;
+ description "ip address of access circuit's connection." ;
+ }
+ leaf mask-length {
+ type int32 {
+ range "1..32";
+ }
+ description "mask length of ip address." ;
+ }
+ leaf protocols {
+ type enumeration {
+ enum static {
+ value 0 ;
+ description "static." ;
+ }
+ enum ospf {
+ value 1 ;
+ description "ospf." ;
+ }
+ enum isis {
+ value 2 ;
+ description "bgp" ;
+ }
+ enum bgp {
+ value 3 ;
+ description "bgp" ;
+ }
+ }
+ description "protocols between PE and CE." ;
+ }
+ container static-routes {
+ description "Defines the static routes." ;
+ list static-route {
+ key "ip-prefix mask-length";
+ description "List of static route." ;
+ leaf ip-prefix {
+ type inet:ipv4-address;
+ description "ip prefix" ;
+ }
+ leaf mask-length {
+ type uint32 {
+ range "1..32";
+ }
+ description "mast length" ;
+ }
+ leaf next-hop {
+ type inet:ipv4-address ;
+ description "next hop" ;
+ }
+ leaf preference {
+ type uint32 {
+ range "1..65535";
+ }
+ description "preference of the route." ;
+ }
+ }
+ }
+ }
+
+ grouping pw{
+ description "PW definition ";
+ leaf id {
+ type string ;
+ description "ID of pw." ;
+ }
+ uses encaplate-type-grouping;
+
+ leaf ingress-ne-id {
+ type string ;
+ description "ingress ne id." ;
+ }
+
+ leaf egress-ne-id {
+ type string ;
+ description "egress ne id." ;
+ }
+
+ leaf ctrl-word-support {
+ type enumeration {
+ enum not-support {
+ value 0 ;
+ description "pw doesn't support control word" ;
+ }
+ enum support {
+ value 1 ;
+ description "pw supports control word" ;
+ }
+ }
+ default support;
+ description "ctrl word support. 0 : not support, 1 : support" ;
+ }
+
+ leaf sn-support {
+ type enumeration {
+ enum not-support {
+ value 0 ;
+ description "pw doesn't support control word" ;
+ }
+ enum support {
+ value 1 ;
+ description "pw supports control word" ;
+ }
+ }
+ default not-support;
+ description "serial number support. 0 : not support, 1 : support" ;
+ }
+
+ leaf vccv-type {
+ type enumeration {
+ enum not-support {
+ value 0 ;
+ description "pw doesn't support vccv" ;
+ }
+ enum CWD {
+ value 1 ;
+ description "pw supports vccv" ;
+ }
+ enum Label-alert {
+ value 2 ;
+ description "pw supports vccv" ;
+ }
+ enum TTL {
+ value 3 ;
+ description "pw supports vccv" ;
+ }
+ enum CWD&Label-alert {
+ value 4 ;
+ description "pw supports vccv" ;
+ }
+ enum CWD&TTL {
+ value 5 ;
+ description "pw supports vccv" ;
+ }
+ enum Label-alert&TTL {
+ value 6 ;
+ description "pw supports vccv" ;
+ }
+ enum CWD&Label-alert&TTL {
+ value 7 ;
+ description "pw supports vccv" ;
+ }
+ }
+ default not-support;
+ description "vccv type" ;
+ }
+
+ leaf conn-ack-type {
+ type enumeration {
+ enum not-support {
+ value 0 ;
+ description "pw doesn't support connection ack" ;
+ }
+ enum support {
+ value 1 ;
+ description "pw supports connection ack" ;
+ }
+ }
+ default not-support;
+ description "Connectivity test type" ;
+ }
+ container tunnels {
+ description "Define tunnels." ;
+ list tunnel{
+ key "tunnel-id";
+ description "The list of tunnel id." ;
+ uses tunnel;
+ }
+ }
+ }
+ grouping tunnel {
+ description "Reusable entity of tunnel." ;
+ leaf tunnel-id {
+ type string ;
+ description "ID of tunnel." ;
+ }
+ }
+ grouping encaplate-type-grouping {
+ description "encaplate type" ;
+ leaf encaplate-type {
+ type enumeration {
+ enum NONE {
+ value 0 ;
+ description "none." ;
+ }
+ enum fr-dlci-martini {
+ value 1 ;
+ description "fr-dlci-martini." ;
+ }
+ enum atm-aal5-sdu {
+ value 2 ;
+ description "atm-aal5-sdu." ;
+ }
+ enum atm-transparent {
+ value 3 ;
+ description "atm-transparent." ;
+ }
+ enum ethernet-vlan {
+ value 4 ;
+ description "ethernet-vlan." ;
+ }
+ enum ethernet {
+ value 5 ;
+ description "ethernet ." ;
+ }
+ enum hdlc {
+ value 6 ;
+ description " hdlc." ;
+ }
+ enum ppp {
+ value 7 ;
+ description "ppp." ;
+ }
+ enum cep-mpls {
+ value 8 ;
+ description " cep-mpls." ;
+ }
+ enum atm-ntol {
+ value 9 ;
+ description "atm-ntol." ;
+ }
+ enum atm-nto1-vpc {
+ value 10 ;
+ description "atm-nto1-vpc." ;
+ }
+ enum ip-layer2 {
+ value 11 ;
+ description " ip-layer2." ;
+ }
+ enum atm-1to1-vcc {
+ value 12 ;
+ description "atm-1to1-vcc." ;
+ }
+ enum atm-1to1-vpc {
+ value 13 ;
+ description "atm-1to1-vpc." ;
+ }
+ enum atm-aal5-pdu {
+ value 14 ;
+ description "atm-aal5-pdu." ;
+ }
+ enum fr-port {
+ value 15 ;
+ description "fr-port." ;
+ }
+ enum cep-packet {
+ value 16 ;
+ description "cep-packet." ;
+ }
+ enum e1 {
+ value 17 ;
+ description "e1." ;
+ }
+ enum t1 {
+ value 18 ;
+ description "t1." ;
+ }
+ enum e3 {
+ value 19 ;
+ description "e3." ;
+ }
+ enum t3 {
+ value 20 ;
+ description " t3." ;
+ }
+ enum cesopsn-basic {
+ value 21 ;
+ description "cesopsn-basic." ;
+ }
+ enum tdmoip-aal1 {
+ value 22 ;
+ description "tdmoip-aal1." ;
+ }
+ enum cesopsn-tdm {
+ value 23 ;
+ description "cesopsn-tdm." ;
+ }
+ enum tdmoip-aal2 {
+ value 24 ;
+ description "tdmoip-aal2." ;
+ }
+ enum fr-dlci {
+ value 25 ;
+ description "fr-dlci." ;
+ }
+ }
+ description "encaplate type." ;
+ }
+ }
+
+ grouping pw-trail{
+ description "pw trail information." ;
+ leaf id {
+ type string ;
+ description "ID of pw-trail." ;
+ }
+
+ leaf role {
+ type pw-role;
+ description "role of pw-trail." ;
+ }
+ container pw-lists {
+ description "List of pw information." ;
+ list pw-list {
+ key id;
+ description "List of pw information." ;
+ uses pw ;
+ }
+ }
+ }
+ grouping tunnel-service {
+ description "Reusable entity of tunnel service." ;
+ leaf signaling-type {
+ type enumeration {
+ enum RSVP-TE {
+ value 0 ;
+ description "RSVP-TE" ;
+ }
+ enum LDP {
+ value 1 ;
+ description "LDP" ;
+ }
+ enum GRE {
+ value 2 ;
+ description "GRE" ;
+ }
+ enum SR-BE {
+ value 3 ;
+ description "SR-BE" ;
+ }
+ enum SR-TE {
+ value 4 ;
+ description "SR-TE" ;
+ }
+ }
+ default RSVP-TE;
+ description "signaling type." ;
+ }
+ leaf tunnel-mode {
+ type enumeration {
+ enum Nto1 {
+ value 0 ;
+ description "multi service one tunnel" ;
+ }
+ enum 1to1 {
+ value 1 ;
+ description "oner service one tunnel" ;
+ }
+ }
+ default Nto1;
+ description "service to tunnel mode." ;
+ }
+ container protect-policy {
+ description "Protect policy." ;
+ uses protect-policy;
+ }
+ container oam-policy {
+ description "oam policy." ;
+ uses oam-policy;
+ }
+ leaf latency {
+ type int32;
+ description "tunnel latency requirement." ;
+ }
+ }
+ grouping service-path {
+ description "Service path of l3vpn." ;
+ list service-path{
+ key "service-id source-ne-id source-ac-id destination-ne-id destination-ac-id";
+ description
+ "The list of service path.";
+ leaf service-id {
+ type string ;
+ description "l2vpn or l3vpn service id." ;
+ }
+ leaf source-ne-id {
+ type string ;
+ description "source ne id." ;
+ }
+
+ leaf source-ac-id {
+ type string ;
+ description "source ltp id." ;
+ }
+ leaf destination-ne-id {
+ type string ;
+ description "destination ne id." ;
+ }
+
+ leaf destination-ac-id {
+ type string ;
+ description "destination ltp id." ;
+ }
+ container path-lists{
+ description "The path list of service path." ;
+ list path-list {
+ key "path-layer path-role";
+ description "The path list of service path." ;
+ leaf path-layer {
+ type enumeration {
+ enum PW {
+ value 0 ;
+ description "pw path." ;
+ }
+ enum BGP-LSP {
+ value 1 ;
+ description "BGP-LSP Path." ;
+ }
+ enum LSP {
+ value 2 ;
+ description "LSP Path." ;
+ }
+ }
+ description "path type. 0 : PW, 1 : BGP-LSP, 2 : PW" ;
+ }
+ leaf path-role {
+ type enumeration {
+ enum Primary {
+ value 0 ;
+ description "master path." ;
+ }
+ enum Backup {
+ value 1 ;
+ description "backup path." ;
+ }
+ enum Active {
+ value 2 ;
+ description "active path." ;
+ }
+ }
+ description "path role.. 0 : master, 1 : backup, 2 :
+ Bypass." ;
+ }
+ container paths {
+ description "path definition." ;
+ list path {
+ key "ne-id";
+ description "Network element id list." ;
+ leaf ne-id {
+ type string;
+ description "Network element id." ;
+ }
+ leaf ingress-ltp-id {
+ type string;
+ description "ingress ltd id." ;
+ }
+ leaf backward-peer-id {
+ type string;
+ description "backward peer id." ;
+ }
+ leaf egress-ltp-id {
+ type string;
+ description "egress ltd id." ;
+ }
+ leaf forward-peer-id {
+ type string;
+ description "forward peer id." ;
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/multi/onlab-test1-1.7.0-SNAPSHOT.jar b/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/multi/onlab-test1-1.7.0-SNAPSHOT.jar
new file mode 100644
index 0000000..7e8459b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/multi/onlab-test1-1.7.0-SNAPSHOT.jar
Binary files differ
diff --git a/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/multi/onlab-test2-1.7.0-SNAPSHOT.jar b/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/multi/onlab-test2-1.7.0-SNAPSHOT.jar
new file mode 100644
index 0000000..22cbdb9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/multi/onlab-test2-1.7.0-SNAPSHOT.jar
Binary files differ
diff --git a/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/single/onlab-test1-1.7.0-SNAPSHOT.jar b/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/single/onlab-test1-1.7.0-SNAPSHOT.jar
new file mode 100644
index 0000000..7e8459b
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interJarFileLinking/jarFiles/single/onlab-test1-1.7.0-SNAPSHOT.jar
Binary files differ
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-inet-types.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-inet-types.yang
new file mode 100644
index 0000000..2b7ed38
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-inet-types.yang
@@ -0,0 +1,454 @@
+ module ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-inet-types";
+
+ prefix inet;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types for Internet addresses and related things.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - ip-address-no-zone
+ - ipv4-address-no-zone
+ - ipv6-address-no-zone";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef ip-version {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "An unknown or unspecified version of the Internet
+ protocol.";
+ }
+ enum "ipv4" {
+ value 1;
+ description
+ "The IPv4 protocol as defined in RFC 791.";
+ }
+ enum "ipv6" {
+ value 2;
+ description
+ "The IPv6 protocol as defined in RFC 2460.";
+ }
+ }
+ description
+ "This value represents the version of the IP protocol.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetVersion textual convention of the SMIv2.";
+ reference
+ "RFC 791: Internet Protocol
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef dscp {
+ type uint8 {
+ range "0..63";
+ }
+ description
+ "The dscp type represents a Differentiated Services Code Point
+ that may be used for marking packets in a traffic stream.
+ In the value set and its semantics, this type is equivalent
+ to the Dscp textual convention of the SMIv2.";
+ reference
+ "RFC 3289: Management Information Base for the Differentiated
+ Services Architecture
+ RFC 2474: Definition of the Differentiated Services Field
+ (DS Field) in the IPv4 and IPv6 Headers
+ RFC 2780: IANA Allocation Guidelines For Values In
+ the Internet Protocol and Related Headers";
+
+ }
+
+ typedef ipv6-flow-label {
+ type uint32 {
+ range "0..1048575";
+ }
+ description
+ "The ipv6-flow-label type represents the flow identifier or Flow
+ Label in an IPv6 packet header that may be used to
+ discriminate traffic flows.
+
+ In the value set and its semantics, this type is equivalent
+ to the IPv6FlowLabel textual convention of the SMIv2.";
+ reference
+ "RFC 3595: Textual Conventions for IPv6 Flow Label
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
+
+ }
+
+ typedef port-number {
+ type uint16 {
+ range "0..65535";
+ }
+ description
+ "The port-number type represents a 16-bit port number of an
+ Internet transport-layer protocol such as UDP, TCP, DCCP, or
+ SCTP. Port numbers are assigned by IANA. A current list of
+ all assignments is available from <http://www.iana.org/>.
+
+ Note that the port number value zero is reserved by IANA. In
+ situations where the value zero does not make sense, it can
+ be excluded by subtyping the port-number type.
+ In the value set and its semantics, this type is equivalent
+ to the InetPortNumber textual convention of the SMIv2.";
+ reference
+ "RFC 768: User Datagram Protocol
+ RFC 793: Transmission Control Protocol
+ RFC 4960: Stream Control Transmission Protocol
+ RFC 4340: Datagram Congestion Control Protocol (DCCP)
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef as-number {
+ type uint32;
+ description
+ "The as-number type represents autonomous system numbers
+ which identify an Autonomous System (AS). An AS is a set
+ of routers under a single technical administration, using
+ an interior gateway protocol and common metrics to route
+ packets within the AS, and using an exterior gateway
+ protocol to route packets to other ASes. IANA maintains
+ the AS number space and has delegated large parts to the
+ regional registries.
+
+ Autonomous system numbers were originally limited to 16
+ bits. BGP extensions have enlarged the autonomous system
+ number space to 32 bits. This type therefore uses an uint32
+ base type without a range restriction in order to support
+ a larger autonomous system number space.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetAutonomousSystemNumber textual convention of
+ the SMIv2.";
+ reference
+ "RFC 1930: Guidelines for creation, selection, and registration
+ of an Autonomous System (AS)
+ RFC 4271: A Border Gateway Protocol 4 (BGP-4)
+ RFC 4001: Textual Conventions for Internet Network Addresses
+ RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
+ Number Space";
+
+ }
+
+ typedef ip-address {
+ type union {
+ type ipv4-address;
+ type ipv6-address;
+ }
+ description
+ "The ip-address type represents an IP address and is IP
+ version neutral. The format of the textual representation
+ implies the IP version. This type supports scoped addresses
+ by allowing zone identifiers in the address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?';
+ }
+ description
+ "The ipv4-address type represents an IPv4 address in
+ dotted-quad notation. The IPv4 address may include a zone
+ index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+ The canonical format for the zone index is the numerical
+ format";
+ }
+
+ typedef ipv6-address {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\p{N}\p{L}]+)?';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(%.+)?';
+ }
+ description
+ "The ipv6-address type represents an IPv6 address in full,
+ mixed, shortened, and shortened-mixed notation. The IPv6
+ address may include a zone index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+
+
+ The canonical format of IPv6 addresses uses the textual
+ representation defined in Section 4 of RFC 5952. The
+ canonical format for the zone index is the numerical
+ format as described in Section 11.2 of RFC 4007.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-address-no-zone {
+ type union {
+ type ipv4-address-no-zone;
+ type ipv6-address-no-zone;
+ }
+ description
+ "The ip-address-no-zone type represents an IP address and is
+ IP version neutral. The format of the textual representation
+ implies the IP version. This type does not support scoped
+ addresses since it does not allow zone identifiers in the
+ address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address-no-zone {
+ type ipv4-address {
+ pattern '[0-9\.]*';
+ }
+ description
+ "An IPv4 address without a zone index. This type, derived from
+ ipv4-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ }
+
+ typedef ipv6-address-no-zone {
+ type ipv6-address {
+ pattern '[0-9a-fA-F:\.]*';
+ }
+ description
+ "An IPv6 address without a zone index. This type, derived from
+ ipv6-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-prefix {
+ type union {
+ type ipv4-prefix;
+ type ipv6-prefix;
+ }
+ description
+ "The ip-prefix type represents an IP prefix and is IP
+ version neutral. The format of the textual representations
+ implies the IP version.";
+ }
+
+ typedef ipv4-prefix {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))';
+ }
+ description
+ "The ipv4-prefix type represents an IPv4 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 32.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The canonical format of an IPv4 prefix has all bits of
+ the IPv4 address set to zero that are not part of the
+ IPv4 prefix.";
+ }
+
+ typedef ipv6-prefix {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(/.+)';
+ }
+ description
+ "The ipv6-prefix type represents an IPv6 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 128.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The IPv6 address should have all bits that do not belong
+ to the prefix set to zero.
+
+ The canonical format of an IPv6 prefix has all bits of
+ the IPv6 address set to zero that are not part of the
+ IPv6 prefix. Furthermore, the IPv6 address is represented
+ as defined in Section 4 of RFC 5952.";
+ reference
+ "RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef domain-name {
+ type string {
+ length "1..253";
+ pattern
+ '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)|\.';
+ }
+ description
+ "The domain-name type represents a DNS domain name. The
+ name SHOULD be fully qualified whenever possible.
+
+ Internet domain names are only loosely specified. Section
+ 3.5 of RFC 1034 recommends a syntax (modified in Section
+ 2.1 of RFC 1123). The pattern above is intended to allow
+ for current practice in domain name use, and some possible
+ future expansion. It is designed to hold various types of
+ domain names, including names used for A or AAAA records
+ (host names) and other records, such as SRV records. Note
+ that Internet host names have a stricter syntax (described
+ in RFC 952) than the DNS recommendations in RFCs 1034 and
+ 1123, and that systems that want to store host names in
+ schema nodes using the domain-name type are recommended to
+ adhere to this stricter standard to ensure interoperability.
+
+ The encoding of DNS names in the DNS protocol is limited
+ to 255 characters. Since the encoding consists of labels
+ prefixed by a length bytes and there is a trailing NULL
+ byte, only 253 characters can appear in the textual dotted
+ notation.
+
+ The description clause of schema nodes using the domain-name
+ type MUST describe when and how these names are resolved to
+ IP addresses. Note that the resolution of a domain-name value
+ may require to query multiple DNS records (e.g., A for IPv4
+ and AAAA for IPv6). The order of the resolution process and
+ which DNS record takes precedence can either be defined
+ explicitly or may depend on the configuration of the
+ resolver.
+
+ Domain-name values use the US-ASCII encoding. Their canonical
+ format uses lowercase US-ASCII characters. Internationalized
+ domain names MUST be A-labels as per RFC 5890.";
+ reference
+ "RFC 952: DoD Internet Host Table Specification
+ RFC 1034: Domain Names - Concepts and Facilities
+ RFC 1123: Requirements for Internet Hosts -- Application
+ and Support
+ RFC 2782: A DNS RR for specifying the location of services
+ (DNS SRV)
+ RFC 5890: Internationalized Domain Names in Applications
+ (IDNA): Definitions and Document Framework";
+
+ }
+
+ typedef host {
+ type union {
+ type ip-address;
+ type domain-name;
+ }
+ description
+ "The host type represents either an IP address or a DNS
+ domain name.";
+ }
+
+ typedef uri {
+ type string;
+ description
+ "The uri type represents a Uniform Resource Identifier
+ (URI) as defined by STD 66.
+
+ Objects using the uri type MUST be in US-ASCII encoding,
+ and MUST be normalized as described by RFC 3986 Sections
+ 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
+ percent-encoding is removed, and all case-insensitive
+ characters are set to lowercase except for hexadecimal
+ digits, which are normalized to uppercase as described in
+ Section 6.2.2.1.
+
+ The purpose of this normalization is to help provide
+ unique URIs. Note that this normalization is not
+ sufficient to provide uniqueness. Two URIs that are
+ textually distinct after this normalization may still be
+ equivalent.
+
+ Objects using the uri type may restrict the schemes that
+ they permit. For example, 'data:' and 'urn:' schemes
+ might not be appropriate.
+
+ A zero-length URI is not a valid URI. This can be used to
+ express 'URI absent' where required.
+
+ In the value set and its semantics, this type is equivalent
+ to the Uri SMIv2 textual convention defined in RFC 5017.";
+ reference
+ "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
+ RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
+ Group: Uniform Resource Identifiers (URIs), URLs,
+ and Uniform Resource Names (URNs): Clarifications
+ and Recommendations
+ RFC 5017: MIB Textual Conventions for Uniform Resource
+ Identifiers (URIs)";
+
+ }
+ } // module ietf-inet-types
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-network-topology.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-network-topology.yang
new file mode 100644
index 0000000..10c8fb9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-network-topology.yang
@@ -0,0 +1,260 @@
+ module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ prefix lnk;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+ import ietf-network {
+ prefix nd;
+ }
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for network topology,
+ augmenting the base network model with links to connect nodes,
+ as well as termination points to terminate links on nodes.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02.";
+ }
+
+ typedef link-id {
+ type inet:uri;
+ description
+ "An identifier for a link in a topology.
+ The identifier SHOULD be chosen such that the same link in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in
+ separate datastores. An implementation MAY choose to capture
+ semantics in the identifier, for example to indicate the type
+ of link and/or the type of topology that the link is a part
+ of.";
+ }
+
+ typedef tp-id {
+ type inet:uri;
+ description
+ "An identifier for termination points on a node.
+ The identifier SHOULD be chosen such that the same TP in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in
+ separate datastores. An implementation MAY choose to capture
+ semantics in the identifier, for example to indicate the type
+ of TP and/or the type of node and topology that the TP is a
+ part of.";
+ }
+ grouping link-ref {
+ description
+ "References a link in a specific network.";
+ leaf link-ref {
+ type link-id;
+ description
+ "A type for an absolute reference a link instance.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ uses nd:network-ref;
+ }
+
+ grouping tp-ref {
+ description
+ "References a termination point in a specific node.";
+ leaf tp-ref {
+ type tp-id;
+ description
+ "A type for an absolute reference to a termination point.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ uses nd:node-ref;
+ }
+
+ augment "/nd:networks/nd:network" {
+ description
+ "Add links to the network model.";
+ list link {
+ key "link-id";
+ description
+ "A Network Link connects a by Local (Source) node and
+ a Remote (Destination) Network Nodes via a set of the
+ nodes' termination points.
+ As it is possible to have several links between the same
+ source and destination nodes, and as a link could
+ potentially be re-homed between termination points, to
+ ensure that we would always know to distinguish between
+ links, every link is identified by a dedicated link
+ identifier.
+ Note that a link models a point-to-point link, not a
+ multipoint link.
+ Layering dependencies on links in underlay topologies are
+ not represented as the layering information of nodes and of
+ termination points is sufficient.";
+ container source {
+ description
+ "This container holds the logical source of a particular
+ link.";
+ leaf source-node {
+ type nd:node-id;
+ mandatory true;
+ description
+ "Source node identifier, must be in same topology.";
+ }
+ leaf source-tp {
+ type tp-id;
+ description
+ "Termination point within source node that terminates
+ the link.";
+ }
+ }
+ container destination {
+ description
+ "This container holds the logical destination of a
+ particular link.";
+ leaf dest-node {
+ type nd:node-id;
+ mandatory true;
+ description
+ "Destination node identifier, must be in the same
+ network.";
+ }
+ leaf dest-tp {
+ type tp-id;
+ description
+ "Termination point within destination node that
+ terminates the link.";
+ }
+ }
+ leaf link-id {
+ type link-id;
+ description
+ "The identifier of a link in the topology.
+ A link is specific to a topology to which it belongs.";
+ }
+ list supporting-link {
+ key "network-ref link-ref";
+ description
+ "Identifies the link, or links, that this link
+ is dependent on.";
+ leaf network-ref {
+ type nd:network-id;
+ description
+ "This leaf identifies in which underlay topology
+ supporting link is present.";
+ }
+ leaf link-ref {
+ type link-id;
+ description
+ "This leaf identifies a link which is a part
+ of this link's underlay. Reference loops, in which
+ a link identifies itself as its underlay, either
+ directly or transitively, are not allowed.";
+ }
+ }
+ }
+ }
+ augment "/nd:networks/nd:network/nd:node" {
+ description
+ "Augment termination points which terminate links.
+ Termination points can ultimately be mapped to interfaces.";
+ list termination-point {
+ key "tp-id";
+ description
+ "A termination point can terminate a link.
+ Depending on the type of topology, a termination point
+ could, for example, refer to a port or an interface.";
+ leaf tp-id {
+ type tp-id;
+ description
+ "Termination point identifier.";
+ }
+ list supporting-termination-point {
+ key "network-ref node-ref tp-ref";
+ description
+ "The leaf list identifies any termination points that
+ the termination point is dependent on, or maps onto.
+ Those termination points will themselves be contained
+ in a supporting node.
+ This dependency information can be inferred from
+ the dependencies between links. For this reason,
+ this item is not separately configurable. Hence no
+ corresponding constraint needs to be articulated.
+ The corresponding information is simply provided by the
+ implementing system.";
+ leaf network-ref {
+ type nd:network-id;
+ description
+ "This leaf identifies in which topology the
+ supporting termination point is present.";
+ }
+ leaf node-ref {
+ type nd:node-id;
+ description
+ "This leaf identifies in which node the supporting
+ termination point is present.";
+ }
+ leaf tp-ref {
+ type tp-id;
+ description
+ "Reference to the underlay node, must be in a
+ different topology";
+ }
+ }
+ }
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-network.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-network.yang
new file mode 100644
index 0000000..9dbe38f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-network.yang
@@ -0,0 +1,200 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for a collection
+ of nodes in a network. Node definitions are further used
+ in network topologies and inventories.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02";
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+
+ typedef network-id {
+ type inet:uri;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type network-id;
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ leaf node-ref {
+ type node-id;
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+ uses network-ref;
+ }
+
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type network-id;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type network-id;
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type node-id;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type network-id;
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type node-id;
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ }
+ container networks-state {
+ config false;
+ description
+ "Serves as top-level container for a list of state information
+ for networks";
+ list network {
+ key "network-ref";
+ description
+ "Data nodes representing operational data and state of
+ networks.
+ An instance is automatically created for every network
+ in the corresponding list under the networks container.";
+ uses network-ref;
+ leaf server-provided {
+ type boolean;
+ description
+ "Indicates whether the information concerning this
+ particular network is populated by the server
+ (server-provided true, the general case for network
+ information discovered from the server),
+ or whether it is configured by a client
+ (server-provided true, possible e.g. for
+ service overlays managed through a controller).";
+ }
+ }
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-schedule.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-schedule.yang
new file mode 100644
index 0000000..b9f7297
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-schedule.yang
@@ -0,0 +1,64 @@
+ module ietf-schedule {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-schedule";
+ // replace with IANA namespace when assigned
+
+ prefix "sch";
+
+ import ietf-yang-types {
+ prefix "yang";
+ }
+
+ organization "TBD";
+ contact "TBD";
+ description
+ "The model allows time scheduling parameters to be specified.";
+
+ revision "2016-03-01" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ /*
+ * Groupings
+ */
+
+ grouping schedules {
+ description
+ "A list of schedules defining when a particular
+ configuration takes effect.";
+ container schedules {
+ description
+ "Container of a schedule list defining when a particular
+ configuration takes effect.";
+ list schedule {
+ key "schedule-id";
+ description "A list of schedule elements.";
+
+ leaf schedule-id {
+ type uint32;
+ description "Identifies the schedule element.";
+ }
+ leaf start {
+ type yang:date-and-time;
+ description "Start time.";
+ }
+ leaf schedule-duration {
+ type string {
+ pattern
+ 'P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?(\d+S)?';
+ }
+ description "Schedule duration in ISO 8601 format.";
+ }
+ leaf repeat-interval {
+ type string {
+ pattern
+ 'R\d*/P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?'
+ + '(\d+S)?';
+ }
+ description "Repeat interval in ISO 8601 format.";
+ }
+ }
+ }
+ } // schedules
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
new file mode 100644
index 0000000..849828f
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
@@ -0,0 +1,1730 @@
+ module ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ // replace with IANA namespace when assigned
+
+ prefix "tet";
+
+ import ietf-inet-types {
+ prefix "inet";
+ }
+
+ import ietf-schedule {
+ prefix "sch";
+ }
+
+ import ietf-te-types {
+ prefix "te-types";
+ }
+
+ import ietf-network {
+ prefix "nw";
+ }
+
+ import ietf-network-topology {
+ prefix "nt";
+ }
+
+ organization
+ "Traffic Engineering Architecture and Signaling (TEAS)
+ Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/teas/>
+ WG List: <mailto:teas@ietf.org>
+
+ WG Chair: Lou Berger
+ <mailto:lberger@labn.net>
+
+ WG Chair: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Xufeng Liu
+ <mailto:xliu@kuatrotech.com>
+
+ Editor: Igor Bryskin
+ <mailto:Igor.Bryskin@huawei.com>
+
+ Editor: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Tarek Saad
+ <mailto:tsaad@cisco.com>
+
+ Editor: Himanshu Shah
+ <mailto:hshah@ciena.com>
+
+ Editor: Oscar Gonzalez De Dios
+ <mailto:oscar.gonzalezdedios@telefonica.com>";
+
+ description "TE topology model";
+
+ revision "2016-03-17" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ /*
+ * Features
+ */
+
+ /*feature configuration-schedule {
+ description
+ "This feature indicates that the system supports
+ configuration scheduling.";
+ }
+
+ feature te-topology-hierarchy {
+ description
+ "This feature indicates that the system allows underlay
+ and/or overlay TE topology hierarchy.";
+ }
+
+ feature te-performance-metric {
+ description
+ "This feature indicates that the system supports
+ TE performance metric defined in
+ RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ }
+
+ feature template {
+ description
+ "This feature indicates that the system supports
+ template configuration.";
+ }*/
+
+ /*
+ * Typedefs
+ */
+ typedef performance-metric-normality {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "Unknown.";
+ }
+ enum "normal" {
+ value 1;
+ description
+ "Normal.";
+ }
+ enum "abnormal" {
+ value 2;
+ description
+ "Abnormal. The anomalous bit is set.";
+ }
+ }
+ description
+ "Indicates whether a performance metric is normal, abnormal, or
+ unknown.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ }
+
+ typedef te-admin-status {
+ type enumeration {
+ enum up {
+ description
+ "Enabled.";
+ }
+ enum down {
+ description
+ "Disabled.";
+ }
+ enum testing {
+ description
+ "In some test mode.";
+ }
+ enum preparing-maintenance {
+ description
+ "Resource is disabled in the control plane to prepare for
+ graceful shutdown for maintenance purposes.";
+ reference
+ "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
+ Traffic Engineering Networks";
+ }
+ enum maintenance {
+ description
+ "Resource is disabled in the data plane for maintenance
+ purposes.";
+ }
+ }
+ description
+ "Defines a type representing the administrative status of
+ a TE resource.";
+ }
+ typedef te-global-id {
+ type uint32;
+ description
+ "An identifier to uniquely identify an operator, which can be
+ either a provider or a client.
+ The definition of this type is taken from RFC6370 and RFC5003.
+ This attribute type is used solely to provide a globally
+ unique context for TE topologies.";
+ }
+
+ typedef te-link-access-type {
+ type enumeration {
+ enum point-to-point {
+ description
+ "The link is point-to-point.";
+ }
+ enum multi-access {
+ description
+ "The link is multi-access, including broacast and NBMA.";
+ }
+ }
+ description
+ "Defines a type representing the access type of a TE link.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.";
+ }
+
+ typedef te-node-id {
+ type inet:ip-address;
+ description
+ "An identifier for a node in a topology.
+ The identifier is represented as an IPv4 or IPv6 address.
+ This attribute is mapped to Router ID in
+ RFC3630, RFC5329, RFC5305, and RFC 6119.";
+ }
+
+ typedef te-oper-status {
+ type enumeration {
+ enum up {
+ description
+ "Operational up.";
+ }
+ enum down {
+ description
+ "Operational down.";
+ }
+ enum testing {
+ description
+ "In some test mode.";
+ }
+ enum unknown {
+ description
+ "Status cannot be determined for some reason.";
+ }
+ enum preparing-maintenance {
+ description
+ "Resource is disabled in the control plane to prepare for
+ graceful shutdown for maintenance purposes.";
+ reference
+ "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
+ Traffic Engineering Networks";
+ }
+ enum maintenance {
+ description
+ "Resource is disabled in the data plane for maintenance
+ purposes.";
+ }
+ }
+ description
+ "Defines a type representing the operational status of
+ a TE resource.";
+ }
+
+ typedef te-recovery-status {
+ type enumeration {
+ enum normal {
+ description
+ "Both the recovery and working spans are fully
+ allocated and active, data traffic is being
+ transported over (or selected from) the working
+ span, and no trigger events are reported.";
+ }
+ enum recovery-started {
+ description
+ "The recovery action has been started, but not completed.";
+ }
+ enum recovery-succeeded {
+ description
+ "The recovery action has succeeded. The working span has
+ reported a failure/degrade condition and the user traffic
+ is being transported (or selected) on the recovery span.";
+ }
+ enum recovery-failed {
+ description
+ "The recovery action has failed.";
+ }
+ enum reversion-started {
+ description
+ "The reversion has started.";
+ }
+ enum reversion-failed {
+ description
+ "The reversion has failed.";
+ }
+ enum recovery-unavailable {
+ description
+ "The recovery is unavailable -- either as a result of an
+ operator Lockout command or a failure condition detected
+ on the recovery span.";
+ }
+ enum recovery-admin {
+ description
+ "The operator has issued a command switching the user
+ traffic to the recovery span.";
+ }
+ enum wait-to-restore {
+ description
+ "The recovery domain is recovering from a failuer/degrade
+ condition on the working span that is being controlled by
+ the Wait-to-Restore (WTR) timer.";
+ }
+ }
+ description
+ "Defines the status of a recovery action.";
+ reference
+ "RFC4427: Recovery (Protection and Restoration) Terminology
+ for Generalized Multi-Protocol Label Switching (GMPLS).
+ RFC6378: MPLS Transport Profile (MPLS-TP) Linear Protection";
+ }
+
+ typedef te-template-name {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ description
+ "A type for the name of a TE node template or TE link
+ template.";
+ }
+
+ typedef te-topology-event-type {
+ type enumeration {
+ enum "add" {
+ value 0;
+ description
+ "A TE node or te-link has been added.";
+ }
+ enum "remove" {
+ value 1;
+ description
+ "A TE node or te-link has been removed.";
+ }
+ enum "update" {
+ value 2;
+ description
+ "A TE node or te-link has been updated.";
+ }
+ }
+ description "TE Event type for notifications";
+ } // te-topology-event-type
+ typedef te-topology-id {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ description
+ "An identifier for a topology.";
+ }
+
+ typedef te-tp-id {
+ type union {
+ type uint32; // Unnumbered
+ type inet:ip-address; // IPv4 or IPv6 address
+ }
+ description
+ "An identifier for a TE link endpoint on a node.
+ This attribute is mapped to local or remote link identifier in
+ RFC3630 and RFC5305.";
+ }
+
+ /*
+ * Identities
+ */
+
+ /*
+ * Groupings
+ */
+ grouping information-source-attributes {
+ description
+ "The attributes identifying source that has provided the
+ related information, and the source credibility.";
+ leaf information-source {
+ type enumeration {
+ enum "unknown" {
+ description "The source is unknown.";
+ }
+ enum "locally-configured" {
+ description "Configured entity.";
+ }
+ enum "ospfv2" {
+ description "OSPFv2.";
+ }
+ enum "ospfv3" {
+ description "OSPFv3.";
+ }
+ enum "isis" {
+ description "ISIS.";
+ }
+ enum "system-processed" {
+ description "System processed entity.";
+ }
+ enum "other" {
+ description "Other source.";
+ }
+ }
+ description
+ "Indicates the source of the information.";
+ }
+ container information-source-state {
+ description
+ "The container contains state attributes related to
+ the information source.";
+ leaf credibility-preference {
+ type uint16;
+ description
+ "The preference value to calculate the traffic
+ engineering database credibility value used for
+ tie-break selection between different
+ information-source values.
+ Higher value is more preferable.";
+ }
+ container topology {
+ description
+ "When the information is processed by the system,
+ the attributes in this container indicate which topology
+ is used to process to generate the result information.";
+ uses te-topology-ref;
+ } // topology
+ leaf routing-instance {
+ type string;
+ description
+ "When applicable, this is the name of a routing instance
+ from which the information is learned.";
+ } // routing-information
+ }
+ } // information-source-attributes
+
+ grouping performance-metric-attributes {
+ description
+ "Link performance information in real time.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ leaf unidirectional-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ description "Delay or latency in micro seconds.";
+ }
+ leaf unidirectional-min-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ description "Minimum delay or latency in micro seconds.";
+ }
+ leaf unidirectional-max-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ description "Maximum delay or latency in micro seconds.";
+ }
+ leaf unidirectional-delay-variation {
+ type uint32 {
+ range 0..16777215;
+ }
+ description "Delay variation in micro seconds.";
+ }
+ leaf unidirectional-packet-loss {
+ type decimal64 {
+ /*fraction-digits 6;
+ range "0 .. 50.331642";*/
+ }
+ description
+ "Packet loss as a percentage of the total traffic sent
+ over a configurable interval. The finest precision is
+ 0.000003%.";
+ }
+ leaf unidirectional-residual-bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Residual bandwidth that subtracts tunnel
+ reservations from Maximum Bandwidth (or link capacity)
+ [RFC3630] and provides an aggregated remainder across QoS
+ classes.";
+ }
+ leaf unidirectional-available-bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Available bandwidth that is defined to be residual
+ bandwidth minus the measured bandwidth used for the
+ actual forwarding of non-RSVP-TE LSP packets. For a
+ bundled link, available bandwidth is defined to be the
+ sum of the component link available bandwidths.";
+ }
+ leaf unidirectional-utilized-bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Bandwidth utilization that represents the actual
+ utilization of the link (i.e. as measured in the router).
+ For a bundled link, bandwidth utilization is defined to
+ be the sum of the component link bandwidth
+ utilizations.";
+ }
+ } // performance-metric-attributes
+ grouping performance-metric-normality-attributes {
+ description
+ "Link performance metric normality attributes.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ leaf unidirectional-delay {
+ type performance-metric-normality;
+ description "Delay normality.";
+ }
+ leaf unidirectional-min-delay {
+ type performance-metric-normality;
+ description "Minimum delay or latency normality.";
+ }
+ leaf unidirectional-max-delay {
+ type performance-metric-normality;
+ description "Maximum delay or latency normality.";
+ }
+ leaf unidirectional-delay-variation {
+ type performance-metric-normality;
+ description "Delay variation normality.";
+ }
+ leaf unidirectional-packet-loss {
+ type performance-metric-normality;
+ description "Packet loss normality.";
+ }
+ leaf unidirectional-residual-bandwidth {
+ type performance-metric-normality;
+ description "Residual bandwidth normality.";
+ }
+ leaf unidirectional-available-bandwidth {
+ type performance-metric-normality;
+ description "Available bandwidth normality.";
+ }
+ leaf unidirectional-utilized-bandwidth {
+ type performance-metric-normality;
+ description "Bandwidth utilization normality.";
+ }
+ } // performance-metric-normality-attributes
+
+ grouping performance-metric-throttle-container {
+ description
+ "A container controlling performance metric throttle.";
+ container performance-metric-throttle {
+ if-feature te-performance-metric;
+ /*must "suppression-interval >= measure-interval" {
+ error-message
+ "suppression-interval cannot be less then
+ measure-interval.";
+ description
+ "Constraint on suppression-interval and
+ measure-interval.";
+ }*/
+ description
+ "Link performance information in real time.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ leaf unidirectional-delay-offset {
+ type uint32 {
+ range 0..16777215;
+ }
+ description
+ "Offset value to be added to the measured delay value.";
+ }
+ leaf measure-interval {
+ type uint32;
+ default 30;
+ description
+ "Interval in seconds to measure the extended metric
+ values.";
+ }
+ leaf advertisement-interval {
+ type uint32;
+ description
+ "Interval in seconds to advertise the extended metric
+ values.";
+ }
+ leaf suppression-interval {
+ type uint32 {
+ range "1..max";
+ }
+ default 120;
+ description
+ "Interval in seconds to suppress advertising the extended
+ metric values.";
+ }
+ container threshold-out {
+ uses performance-metric-attributes;
+ description
+ "If the measured parameter falls outside an upper bound
+ for all but the min delay metric (or lower bound for
+ min-delay metric only) and the advertised value is not
+ already outside that bound, anomalous announcement will be
+ triggered.";
+ }
+ container threshold-in {
+ uses performance-metric-attributes;
+ description
+ "If the measured parameter falls inside an upper bound
+ for all but the min delay metric (or lower bound for
+ min-delay metric only) and the advertised value is not
+ already inside that bound, normal (anomalous-flag cleared)
+ announcement will be triggered.";
+ }
+ container threshold-accelerated-advertisement {
+ description
+ "When the difference between the last advertised value and
+ current measured value exceed this threshold, anomalous
+ announcement will be triggered.";
+ uses performance-metric-attributes;
+ }
+ }
+ } // performance-metric-throttle-container
+
+ grouping te-link-augment {
+ description
+ "Augmentation for TE link.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-link-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+ uses te-link-config;
+ uses te-link-state-derived;
+ } // state
+ } // te
+ } // te-link-augment
+
+ grouping te-link-config {
+ description
+ "TE link configuration grouping.";
+ choice bundle-stack-level {
+ description
+ "The TE link can be partitioned into bundled
+ links, or component links.";
+ case bundle {
+ container bundled-links {
+ description
+ "A set of bundled links.";
+ reference
+ "RFC4201: Link Bundling in MPLS Traffic Engineering
+ (TE).";
+ list bundled-link {
+ key "sequence";
+ description
+ "Specify a bundled interface that is
+ further partitioned.";
+ leaf sequence {
+ type uint32;
+ description
+ "Identify the sequence in the bundle.";
+ }
+ leaf src-tp-ref {
+ type nt:tp-id;
+ description
+ "Reference to another TE termination point on the
+ same souruce node.";
+ }
+ leaf des-tp-ref {
+ type nt:tp-id;
+ description
+ "Reference to another TE termination point on the
+ same destination node.";
+ }
+ } // list bundled-link
+ }
+ }
+ case component {
+ container component-links {
+ description
+ "A set of component links";
+ list component-link {
+ key "sequence";
+ description
+ "Specify a component interface that is
+ sufficient to unambiguously identify the
+ appropriate resources";
+
+ leaf sequence {
+ type uint32;
+ description
+ "Identify the sequence in the bundle.";
+ }
+ leaf src-interface-ref {
+ type string;
+ description
+ "Reference to component link interface on the
+ source node.";
+ }
+ leaf des-interface-ref {
+ type string;
+ description
+ "Reference to component link interface on the
+ destinatioin node.";
+ }
+ }
+ }
+ }
+ } // bundle-stack-level
+
+ leaf-list te-link-template {
+ if-feature template;
+ type te-template-name;
+ description
+ "The reference to a TE link template.";
+ }
+ uses te-link-config-attributes;
+ } // te-link-config
+
+ grouping te-link-config-attributes {
+ description
+ "Link configuration attributes in a TE topology.";
+ container te-link-attributes {
+ description "Link attributes in a TE topology.";
+ uses sch:schedules;
+ leaf access-type {
+ type te-link-access-type;
+ description
+ "Link access type, which can be point-to-point or
+ multi-access.";
+ }
+ leaf is-abstract {
+ type empty;
+ description "Present if the link is abstract.";
+ }
+ leaf name {
+ type string;
+ description "Link Name.";
+ }
+ container underlay {
+ if-feature te-topology-hierarchy;
+ presence
+ "Indicates the underlay exists for this link.";
+ description "Attributes of the te-link underlay.";
+ reference
+ "RFC4206: Label Switched Paths (LSP) Hierarchy with
+ Generalized Multi-Protocol Label Switching (GMPLS)
+ Traffic Engineering (TE)";
+
+ uses te-link-underlay-attributes;
+ } // underlay
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+
+ uses performance-metric-throttle-container;
+ uses te-link-info-attributes;
+ } // te-link-attributes
+ } // te-link-config-attributes
+
+ grouping te-link-info-attributes {
+ description
+ "Advertised TE information attributes.";
+ leaf link-index {
+ type uint64;
+ description
+ "The link identifier. If OSPF is used, this represents an
+ ospfLsdbID. If IS-IS is used, this represents an isisLSPID.
+ If a locally configured link is used, this object represents
+ a unique value, which is locally defined in a router.";
+ }
+ leaf administrative-group {
+ type te-types:admin-groups;
+ description
+ "Administrative group or color of the link.
+ This attribute covers both administrative group (defined in
+ RFC3630, RFC5329, and RFC5305), and extended administrative
+ group (defined in RFC7308).";
+ }
+ leaf max-link-bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Maximum bandwidth that can be seen on this link in this
+ direction. Units in bytes per second.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC5305: IS-IS Extensions for Traffic Engineering.";
+ }
+ leaf max-resv-link-bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Maximum amount of bandwidth that can be reserved in this
+ direction in this link. Units in bytes per second.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC5305: IS-IS Extensions for Traffic Engineering.";
+ }
+ list unreserved-bandwidth {
+ key "priority";
+ max-elements "8";
+ description
+ "Unreserved bandwidth for 0-7 priority levels. Units in
+ bytes per second.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC5305: IS-IS Extensions for Traffic Engineering.";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ description "Priority.";
+ }
+ leaf bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Unreserved bandwidth for this level.";
+ }
+ }
+ leaf te-default-metric {
+ type uint32;
+ description
+ "Traffic Engineering Metric.";
+ }
+ container performance-metric {
+ if-feature te-performance-metric;
+ description
+ "Link performance information in real time.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ container measurement {
+ description
+ "Measured performance metric values. Static configuration
+ and manual overrides of these measurements are also
+ allowed.";
+ uses performance-metric-attributes;
+ }
+ container normality
+ {
+ description
+ "Performance metric normality values.";
+ uses performance-metric-normality-attributes;
+ }
+ }
+ leaf link-protection-type {
+ type enumeration {
+ enum "unprotected" {
+ description "Unprotected.";
+ }
+ enum "extra-traffic" {
+ description "Extra traffic.";
+ }
+ enum "shared" {
+ description "Shared.";
+ }
+ enum "1-for-1" {
+ description "One for one protection.";
+ }
+ enum "1-plus-1" {
+ description "One plus one protection.";
+ }
+ enum "enhanced" {
+ description "Enhanced protection.";
+ }
+ }
+ description
+ "Link Protection Type desired for this link.";
+ reference
+ "RFC4202: Routing Extensions in Support of
+ Generalized Multi-Protocol Label Switching (GMPLS).";
+ }
+ list interface-switching-capability {
+ key "switching-capability";
+ description
+ "List of Interface Switching Capabilities Descriptors (ISCD)
+ for this link.";
+ reference
+ "RFC3471: Generalized Multi-Protocol Label Switching (GMPLS)
+ Signaling Functional Description.
+ RFC4203: OSPF Extensions in Support of Generalized
+ Multi-Protocol Label Switching (GMPLS).";
+ leaf switching-capability {
+ type string;
+ description
+ "Switching Capability for this interface.";
+ }
+ leaf encoding {
+ type string;
+ description
+ "Encoding supported by this interface.";
+ }
+ list max-lsp-bandwidth {
+ key "priority";
+ max-elements "8";
+ description
+ "Maximum LSP Bandwidth at priorities 0-7.";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ description "Priority.";
+ }
+ leaf bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Max LSP Bandwidth for this level";
+ }
+ }
+ container time-division-multiplex-capable {
+ when "../switching-capability = 'TDM'" {
+ description "Valid only for TDM";
+ }
+ description
+ "Interface has time-division multiplex capabilities.";
+
+ leaf minimum-lsp-bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Minimum LSP Bandwidth. Units in bytes per second.";
+ }
+ leaf indication {
+ type enumeration {
+ enum "standard" {
+ description
+ "Indicates support of standard SONET/SDH.";
+ }
+ enum "arbitrary" {
+ description
+ "Indicates support of arbitrary SONET/SDH.";
+ }
+ }
+ description
+ "Indication whether the interface supports Standard or
+ Arbitrary SONET/SDH";
+ }
+ }
+ list interface-adjustment-capability {
+ key "upper-sc";
+ description
+ "List of Interface Adjustment Capability Descriptors (IACD)
+ for this link.";
+ reference
+ "RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
+ for Multi-Layer and Multi-Region Networks (MLN/MRN).";
+ leaf upper-sc {
+ type string;
+ description
+ "Switching Capability for this interface.";
+ }
+ leaf upper-encoding {
+ type string;
+ description
+ "Encoding supported by this interface.";
+ }
+ list max-lsp-bandwidth {
+ key "priority";
+ max-elements "8";
+ description
+ "Maximum LSP Bandwidth at priorities 0-7.";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ description "Priority.";
+ }
+ leaf bandwidth {
+ type decimal64 {
+ /*fraction-digits 2;*/
+ }
+ description
+ "Max LSP Bandwidth for this level.";
+ }
+ }
+ } // interface-adjustment-capability
+ } // interface-switching-capability
+ container te-srlgs {
+ description
+ "A list of SLRGs.";
+ leaf-list values {
+ type te-types:srlg;
+ description "SRLG value.";
+ reference
+ "RFC4202: Routing Extensions in Support of
+ Generalized Multi-Protocol Label Switching (GMPLS).";
+ }
+ }
+ } // te-link-info-attributes
+
+ grouping te-link-state-derived {
+ description
+ "Link state attributes in a TE topology.";
+ leaf oper-status {
+ type te-oper-status;
+ description
+ "The current operational state of the link.";
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ description
+ "A list of information sources learned but not used.";
+ uses information-source-attributes;
+ uses te-link-info-attributes;
+ }
+ container recovery {
+ description
+ "Status of the recovery process.";
+ leaf restoration-status {
+ type te-recovery-status;
+ description
+ "Restoration status.";
+ }
+ leaf protection-status {
+ type te-recovery-status;
+ description
+ "Protection status.";
+ }
+ }
+ container underlay {
+ if-feature te-topology-hierarchy;
+ description "State attributes for te-link underlay.";
+ uses te-link-state-underlay-attributes;
+ }
+ } // te-link-state-derived
+ grouping te-link-state-underlay-attributes {
+ description "State attributes for te-link underlay.";
+ leaf dynamic {
+ type boolean;
+ description
+ "true if the underlay is dynamically created.";
+ }
+ leaf committed {
+ type boolean;
+ description
+ "true if the underlay is committed.";
+ }
+ } // te-link-state-underlay-attributes
+
+ grouping te-link-underlay-attributes {
+ description "Attributes for te-link underlay.";
+ reference
+ "RFC4206: Label Switched Paths (LSP) Hierarchy with
+ Generalized Multi-Protocol Label Switching (GMPLS)
+ Traffic Engineering (TE)";
+ container underlay-primary-path {
+ description
+ "The service path on the underlay topology that
+ supports this link.";
+ uses te-topology-ref;
+ list path-element {
+ key "path-element-id";
+ description
+ "A list of path elements describing the service path.";
+ leaf path-element-id {
+ type uint32;
+ description "To identify the element in a path.";
+ }
+ uses te-path-element;
+ }
+ } // underlay-primary-path
+ list underlay-backup-path {
+ key "index";
+ description
+ "A list of backup service paths on the underlay topology that
+ protect the underlay primary path. If the primary path is
+ not protected, the list contains zero elements. If the
+ primary path is protected, the list contains one or more
+ elements.";
+ leaf index {
+ type uint32;
+ description
+ "A sequence number to identify a backup path.";
+ }
+ uses te-topology-ref;
+ list path-element {
+ key "path-element-id";
+ description
+ "A list of path elements describing the backup service
+ path";
+ leaf path-element-id {
+ type uint32;
+ description "To identify the element in a path.";
+ }
+ uses te-path-element;
+ }
+ } // underlay-backup-path
+ leaf underlay-protection-type {
+ type uint16;
+ description
+ "Underlay protection type desired for this link";
+ }
+ container underlay-trail-src {
+ uses nt:tp-ref;
+ description
+ "Source TE link of the underlay trail.";
+ }
+ container underlay-trail-des {
+ uses nt:tp-ref;
+ description
+ "Destination TE link of the underlay trail.";
+ }
+ } // te-link-underlay-attributes
+
+ grouping te-node-augment {
+ description
+ "Augmentation for TE node.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ leaf te-node-id {
+ type te-node-id;
+ mandatory true;
+ description
+ "The identifier of a node in the TE topology.
+ A node is specific to a topology to which it belongs.";
+ }
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-node-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+
+ uses te-node-config;
+ uses te-node-state-derived;
+ } // state
+
+ list tunnel-termination-point {
+ key "tunnel-tp-id";
+ description
+ "A termination point can terminate a tunnel.";
+ leaf tunnel-tp-id {
+ type binary;
+ description
+ "Tunnel termination point identifier.";
+ }
+ container config {
+ description
+ "Configuration data.";
+ uses te-node-tunnel-termination-capability;
+ }
+
+ container state {
+ config false;
+ description
+ "Operational state data.";
+
+ uses te-node-tunnel-termination-capability;
+ leaf switching-capability {
+ type string;
+ mandatory true;
+ description
+ "Switching Capability.";
+ }
+ leaf encoding {
+ type string;
+ mandatory true;
+ description
+ "Encoding type.";
+ }
+ } // state
+
+ } // tunnel-termination-point
+ } // te
+ } // te-node-augment
+
+ grouping te-node-config {
+ description "TE node configuration grouping.";
+
+ leaf-list te-node-template {
+ if-feature template;
+ type te-template-name;
+ description
+ "The reference to a TE node template.";
+ }
+ uses te-node-config-attributes;
+ } // te-node-config
+
+ grouping te-node-config-attributes {
+ description "Configuration node attributes in a TE topology.";
+ container te-node-attributes {
+ description "Containing node attributes in a TE topology.";
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+ uses te-node-connectivity-matrix;
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes
+
+ grouping te-node-config-attributes-notification {
+ description
+ "Configuration node attributes for template in a TE topology.";
+ container te-node-attributes {
+ description "Containing node attributes in a TE topology.";
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+ uses te-node-connectivity-matrix-abs;
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes-notification
+
+ grouping te-node-config-attributes-template {
+ description
+ "Configuration node attributes for template in a TE topology.";
+ container te-node-attributes {
+ description "Containing node attributes in a TE topology.";
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes-template
+
+ grouping te-node-connectivity-matrix {
+ description "Connectivity matrix on a TE node.";
+ list connectivity-matrix {
+ key "id";
+ description
+ "Represents node's switching limitations, i.e. limitations
+ in interconnecting network TE links across the node.";
+ reference
+ "RFC7579: General Network Element Constraint Encoding
+ for GMPLS-Controlled Networks.";
+ leaf id {
+ type uint32;
+ description "Identifies the connectivity-matrix entry.";
+ }
+ container from {
+ leaf tp-ref {
+ type nt:tp-id;
+ description
+ "Relative reference to source termination point.";
+ }
+ description
+ "Reference to source NTP.";
+ }
+ container to {
+ leaf tp-ref {
+ type nt:tp-id;
+ description
+ "Relative reference to destination termination point.";
+ }
+ description
+ "Reference to destination NTP.";
+ }
+ leaf is-allowed {
+ type boolean;
+ description
+ "true - switching is allowed,
+ false - switching is disallowed.";
+ }
+ }
+ } // te-node-connectivity-matrix
+
+ grouping te-node-connectivity-matrix-abs {
+ description
+ "Connectivity matrix on a TE node, using absolute
+ paths to reference termination points.";
+ list connectivity-matrix {
+ key "id";
+ description
+ "Represents node's switching limitations, i.e. limitations
+ in interconnecting network TE links across the node.";
+ reference
+ "RFC7579: General Network Element Constraint Encoding
+ for GMPLS-Controlled Networks.";
+ leaf id {
+ type uint32;
+ description "Identifies the connectivity-matrix entry.";
+ }
+ container from {
+ uses nt:tp-ref;
+ description
+ "Reference to source NTP.";
+ }
+ container to {
+ uses nt:tp-ref;
+ description
+ "Reference to destination NTP.";
+ }
+ leaf is-allowed {
+ type boolean;
+ description
+ "true - switching is allowed,
+ false - switching is disallowed.";
+ }
+ }
+ } // te-node-connectivity-matrix-abs
+
+ grouping te-node-info-attributes {
+ description
+ "Advertised TE information attributes.";
+ leaf domain-id {
+ type uint32;
+ description
+ "Identifies the domain that this node belongs.
+ This attribute is used to support inter-domain links.";
+ reference
+ "RFC5152: A Per-Domain Path Computation Method for
+ Establishing Inter-Domain Traffic Engineering (TE)
+ Label Switched Paths (LSPs).
+ RFC5392: OSPF Extensions in Support of Inter-Autonomous
+ System (AS) MPLS and GMPLS Traffic Engineering.
+ RFC5316: ISIS Extensions in Support of Inter-Autonomous
+ System (AS) MPLS and GMPLS Traffic Engineering.";
+ }
+ leaf is-abstract {
+ type empty;
+ description
+ "Present if the node is abstract, not present if the node
+ is actual.";
+ }
+ leaf name {
+ type inet:domain-name;
+ description "Node name.";
+ }
+ leaf-list signaling-address {
+ type inet:ip-address;
+ description "Node signaling address.";
+ }
+ container underlay-topology {
+ if-feature te-topology-hierarchy;
+ description
+ "When an abstract node encapsulates a topology,
+ the attributes in this container point to said topology.";
+ uses te-topology-ref;
+ }
+ } // te-node-info-attributes
+
+ grouping te-node-state-derived {
+ description "Node state attributes in a TE topology.";
+ leaf oper-status {
+ type te-oper-status;
+ description
+ "The current operational state of the node.";
+ }
+ leaf is-multi-access-dr {
+ type empty;
+ description
+ "The presence of this attribute indicates that this TE node
+ is a pseudonode elected as a designated router.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC1195: Use of OSI IS-IS for Routing in TCP/IP and Dual
+ Environments.";
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ description
+ "A list of information sources learned but not used.";
+ uses information-source-attributes;
+ uses te-node-connectivity-matrix;
+ uses te-node-info-attributes;
+ }
+ } // te-node-state-derived
+
+ grouping te-node-state-derived-notification {
+ description "Node state attributes in a TE topology.";
+ leaf oper-status {
+ type te-oper-status;
+ description
+ "The current operational state of the node.";
+ }
+ leaf is-multi-access-dr {
+ type empty;
+ description
+ "The presence of this attribute indicates that this TE node
+ is a pseudonode elected as a designated router.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.
+ RFC1195: Use of OSI IS-IS for Routing in TCP/IP and Dual
+ Environments.";
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ description
+ "A list of information sources learned but not used.";
+ uses information-source-attributes;
+ uses te-node-connectivity-matrix-abs;
+ uses te-node-info-attributes;
+ }
+ } // te-node-state-derived-notification
+
+ grouping te-node-tunnel-termination-capability {
+ description
+ "Termination capability of a tunnel termination point on a
+ TE node.";
+
+ list termination-capability {
+ key "link-tp";
+ description
+ "The termination capabilities between
+ tunnel-termination-point and link termination-point.
+ The capability information can be used to compute
+ the tunnel path.";
+ leaf link-tp {
+ type nt:tp-id;
+ description
+ "Link termination point.";
+ }
+ } // termination-capability
+ } // te-node-tunnel-termination-capability
+
+ grouping te-path-element {
+ description
+ "A group of attributes defining an element in a TE path
+ such as TE node, TE link, TE atomic resource or label.";
+ uses te-types:explicit-route-subobject;
+ } // te-path-element
+
+ grouping te-termination-point-augment {
+ description
+ "Augmentation for TE termination point.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ leaf te-tp-id {
+ type te-tp-id;
+ mandatory true;
+ description
+ "An identifier to uniquely identify a TE termination
+ point.";
+ }
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-termination-point-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+ uses te-termination-point-config;
+ } // state
+ } // te
+ } // te-termination-point-augment
+
+ grouping te-termination-point-config {
+ description
+ "TE termination point configuration grouping.";
+ uses sch:schedules;
+ } // te-termination-point-config
+
+ grouping te-topologies-augment {
+ description
+ "Augmentation for TE topologies.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ container templates {
+ description
+ "Configuration parameters for templates used for TE
+ topology.";
+
+ list node-template {
+ if-feature template;
+ key "name";
+ leaf name {
+ type te-template-name;
+ description
+ "The name to identify a TE node template.";
+ }
+ description
+ "The list of TE node templates used to define sharable
+ and reusable TE node attributes.";
+ uses template-attributes;
+ uses te-node-config-attributes-template;
+ } // node-template
+
+ list link-template {
+ if-feature template;
+ key "name";
+ leaf name {
+ type te-template-name;
+ description
+ "The name to identify a TE link template.";
+ }
+ description
+ "The list of TE link templates used to define sharable
+ and reusable TE link attributes.";
+ uses template-attributes;
+ uses te-link-config-attributes;
+ } // link-template
+ } // templates
+ } // te
+ } // te-topologies-augment
+
+ grouping te-topology-augment {
+ description
+ "Augmentation for TE topology.";
+
+ container te {
+ presence "TE support.";
+ description
+ "Indicates TE support.";
+
+ leaf provider-id {
+ type te-global-id;
+ mandatory true;
+ description
+ "An identifier to uniquely identify a provider.";
+ }
+ leaf client-id {
+ type te-global-id;
+ mandatory true;
+ description
+ "An identifier to uniquely identify a client.";
+ }
+ leaf te-topology-id {
+ type te-topology-id;
+ mandatory true;
+ description
+ "It is presumed that a datastore will contain many
+ topologies. To distinguish between topologies it is
+ vital to have UNIQUE topology identifiers.";
+ }
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-topology-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+ uses te-topology-config;
+ } // state
+ } // te
+ } // te-topology-augment
+
+ grouping te-topology-config {
+ description
+ "TE topology configuration grouping.";
+ uses sch:schedules;
+ leaf preference {
+ type uint8 {
+ range "1..255";
+ }
+ description
+ "Specifies a preference for this topology. A lower number
+ indicates a higher preference.";
+ }
+ } // te-topology-config
+
+ grouping te-topology-ref {
+ description
+ "References a TE topology.";
+ leaf provider-id-ref {
+ type te-global-id;
+ description
+ "A reference to a provider-id.";
+ }
+ leaf client-id-ref {
+ type te-global-id;
+ description
+ "A reference to a client-id.";
+ }
+ leaf te-topology-id-ref {
+ type tet:te-topology-id;
+ description
+ "A reference to a te-topology-id.";
+ }
+ leaf network-id-ref {
+ type nw:network-id;
+ description
+ "A reference to a network-id in base ietf-network module.";
+ }
+ } // te-topology-ref
+
+ grouping te-topology-type {
+ description
+ "Identifies the TE topology type.";
+ container te-topology {
+ presence "Indicates TE topology.";
+ description
+ "Its presence identifies the TE topology type.";
+ }
+ } // te-topology-type
+
+ grouping template-attributes {
+ description
+ "Common attributes for all templates.";
+
+ leaf priority {
+ type uint16;
+ description
+ "The preference value to resolve conflicts between different
+ templates. When two or more templates specify values for
+ one configuration attribute, the value from the template
+ with the highest priority is used.";
+ }
+ leaf reference-change-policy {
+ type enumeration {
+ enum no-action {
+ description
+ "When an attribute changes in this template, the
+ configuration node referring to this template does
+ not take any action.";
+ }
+ enum not-allowed {
+ description
+ "When any configuration object has a reference to this
+ template, changing this template is not allowed.";
+ }
+ enum cascade {
+ description
+ "When an attribute changes in this template, the
+ configuration object referring to this template applies
+ the new attribute value to the corresponding
+ configuration.";
+ }
+ }
+ description
+ "This attribute specifies the action taken to a configuration
+ node that has a reference to this template.";
+ }
+ } // template-attributes
+
+ /*
+ * Configuration data nodes
+ */
+ augment "/nw:networks/nw:network/nw:network-types" {
+ description
+ "Introduce new network type for TE topology.";
+ uses te-topology-type;
+ }
+
+ augment "/nw:networks" {
+ description
+ "Augmentation parameters for TE topologies.";
+ uses te-topologies-augment;
+ }
+
+ augment "/nw:networks/nw:network" {
+ when "nw:network-types/te-topology" {
+ description
+ "Augmentation parameters apply only for networks with
+ TE topology type.";
+ }
+ description
+ "Configuration parameters for TE topology.";
+ uses te-topology-augment;
+ }
+
+ augment "/nw:networks/nw:network/nw:node" {
+ when "../nw:network-types/te-topology" {
+ description
+ "Augmentation parameters apply only for networks with
+ TE topology type.";
+ }
+ description
+ "Configuration parameters for TE at node level.";
+ uses te-node-augment;
+ }
+
+ augment "/nw:networks/nw:network/nt:link" {
+ when "../nw:network-types/te-topology" {
+ description
+ "Augmentation parameters apply only for networks with
+ TE topology type.";
+ }
+ description
+ "Configuration parameters for TE at link level";
+ uses te-link-augment;
+ }
+
+ augment "/nw:networks/nw:network/nw:node/"
+ + "nt:termination-point" {
+ when "../../nw:network-types/te-topology" {
+ description
+ "Augmentation parameters apply only for networks with
+ TE topology type.";
+ }
+ description
+ "Configuration parameters for TE at termination point level";
+ uses te-termination-point-augment;
+ }
+
+ /*
+ * Operational state data nodes
+ */
+
+ /*
+ * Notifications
+ */
+ notification te-node-event {
+ description "Notification event for TE node.";
+ leaf event-type {
+ type te-topology-event-type;
+ description "Event type.";
+ }
+ uses nw:node-ref;
+ uses te-topology-type;
+ uses tet:te-node-config-attributes-notification;
+ uses tet:te-node-state-derived-notification;
+ }
+
+ notification te-link-event {
+ description "Notification event for TE link.";
+ leaf event-type {
+ type te-topology-event-type;
+ description "Event type";
+ }
+ uses nt:link-ref;
+ uses te-topology-type;
+ uses tet:te-link-config-attributes;
+ uses tet:te-link-state-derived;
+ }
+
+ augment "/te-link-event/te-link-attributes/underlay" {
+ description "Add state attributes to te-link underlay.";
+ uses te-link-state-underlay-attributes;
+ }
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-types.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-types.yang
new file mode 100644
index 0000000..0962720
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-types.yang
@@ -0,0 +1,853 @@
+ module ietf-te-types {
+
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-types";
+
+ /* Replace with IANA when assigned */
+ prefix "te-types";
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ organization
+ "IETF Traffic Engineering Architecture and Signaling (TEAS)
+ Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/teas/>
+ WG List: <mailto:teas@ietf.org>
+
+ WG Chair: Lou Berger
+ <mailto:lberger@labn.net>
+
+ WG Chair: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Tarek Saad
+ <mailto:tsaad@cisco.com>
+
+ Editor: Rakesh Gandhi
+ <mailto:rgandhi@cisco.com>
+
+ Editor: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Himanshu Shah
+ <mailto:hshah@ciena.com>
+
+ Editor: Xufeng Liu
+ <mailto:xufeng.liu@ericsson.com>
+
+ Editor: Xia Chen
+ <mailto:jescia.chenxia@huawei.com>
+
+ Editor: Raqib Jones
+ <mailto:raqib@Brocade.com>
+
+ Editor: Bin Wen
+ <mailto:Bin_Wen@cable.comcast.com>";
+
+ description
+ "This module contains a collection of generally
+ useful TE specific YANG data type defintions.";
+
+ revision 2016-03-20 {
+ description "Latest revision of TE generic types";
+ reference "RFC3209";
+ }
+
+ /*identity tunnel-type {
+ description
+ "Base identity from which specific tunnel types are
+ derived.";
+ }
+
+ identity tunnel-p2p {
+ base tunnel-type;
+ description
+ "TE point-to-point tunnel type.";
+ }
+
+ identity tunnel-p2mp {
+ base tunnel-type;
+ description
+ "TE point-to-multipoint tunnel type.";
+ }
+
+ identity state-type {
+ description
+ "Base identity for TE states";
+ }
+
+ identity state-up {
+ base state-type;
+ description
+ "State up";
+ }
+
+ identity state-down {
+ base state-type;
+ description
+ "State down";
+ }
+
+ identity lsp-prot-type {
+ description
+ "Base identity from which LSP protection types are
+ derived.";
+ }
+
+ identity lsp-prot-unprotected {
+ description
+ "LSP protection 'Unprotected'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-reroute-extra {
+ description
+ "LSP protection '(Full) Rerouting'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-reroute {
+ description
+ "LSP protection 'Rerouting without Extra-Traffic'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-1-for-n {
+ description
+ "LSP protection '1:N Protection with Extra-Traffic'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-unidir-1-to-1 {
+ description
+ "LSP protection '1+1 Unidirectional Protection'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-bidir-1-to-1 {
+ description
+ "LSP protection '1+1 Bidirectional Protection'";
+ reference "RFC4872";
+ }
+
+ identity switching-capabilities {
+ description
+ "Base identity for interface switching capabilities";
+ }
+
+ identity switching-psc1 {
+ base switching-capabilities;
+ description
+ "Packet-Switch Capable-1 (PSC-1)";
+ }
+
+ identity switching-evpl {
+ base switching-capabilities;
+ description
+ "Ethernet Virtual Private Line (EVPL)";
+ }
+
+ identity switching-l2sc {
+ base switching-capabilities;
+ description
+ "Layer-2 Switch Capable (L2SC)";
+ }
+
+ identity switching-tdm {
+ base switching-capabilities;
+ description
+ "Time-Division-Multiplex Capable (TDM)";
+ }
+
+ identity switching-otn {
+ base switching-capabilities;
+ description
+ "OTN-TDM capable";
+ }
+
+ identity switching-dcsc {
+ base switching-capabilities;
+ description
+ "Data Channel Switching Capable (DCSC)";
+ }
+ identity switching-lsc {
+ base switching-capabilities;
+ description
+ "Lambda-Switch Capable (LSC)";
+ }
+
+ identity switching-fsc {
+ base switching-capabilities;
+ description
+ "Fiber-Switch Capable (FSC)";
+ }
+
+ identity lsp-encoding-types {
+ description
+ "Base identity for encoding types";
+ }
+
+ identity lsp-encoding-packet {
+ base lsp-encoding-types;
+ description
+ "Packet LSP encoding";
+ }
+
+ identity lsp-encoding-ethernet {
+ base lsp-encoding-types;
+ description
+ "Ethernet LSP encoding";
+ }
+
+ identity lsp-encoding-pdh {
+ base lsp-encoding-types;
+ description
+ "ANSI/ETSI LSP encoding";
+ }
+
+ identity lsp-encoding-sdh {
+ base lsp-encoding-types;
+ description
+ "SDH ITU-T G.707 / SONET ANSI T1.105 LSP encoding";
+ }
+
+ identity lsp-encoding-digital-wrapper {
+ base lsp-encoding-types;
+ description
+ "Digital Wrapper LSP encoding";
+ }
+
+ identity lsp-encoding-lambda {
+ base lsp-encoding-types;
+ description
+ "Lambda (photonic) LSP encoding";
+ }
+
+ identity lsp-encoding-fiber {
+ base lsp-encoding-types;
+ description
+ "Fiber LSP encoding";
+ }
+
+ identity lsp-encoding-fiber-channel {
+ base lsp-encoding-types;
+ description
+ "FiberChannel LSP encoding";
+ }
+
+ identity lsp-encoding-oduk {
+ base lsp-encoding-types;
+ description
+ "G.709 ODUk (Digital Path)LSP encoding";
+ }
+
+ identity lsp-encoding-optical-channel {
+ base lsp-encoding-types;
+ description
+ "Line (e.g., 8B/10B) LSP encoding";
+ }
+
+ identity lsp-encoding-line {
+ base lsp-encoding-types;
+ description
+ "Line (e.g., 8B/10B) LSP encoding";
+ }*/
+
+ /* TE basic features */
+ /*feature p2mp-te {
+ description
+ "Indicates support for P2MP-TE";
+ }
+
+ feature frr-te {
+ description
+ "Indicates support for TE FastReroute (FRR)";
+ }
+
+ feature extended-admin-groups {
+ description
+ "Indicates support for TE link extended admin
+ groups.";
+ }
+
+ feature named-path-affinities {
+ description
+ "Indicates support for named path affinities";
+ }
+
+ feature named-extended-admin-groups {
+ description
+ "Indicates support for named extended admin groups";
+ }
+
+ feature named-srlg-groups {
+ description
+ "Indicates support for named SRLG groups";
+ }
+
+ feature named-path-constraints {
+ description
+ "Indicates support for named path constraints";
+ }*/
+
+ grouping explicit-route-subobject {
+ description
+ "The explicit route subobject grouping";
+ choice type {
+ description
+ "The explicit route subobject type";
+ case ipv4-address {
+ description
+ "IPv4 address explicit route subobject";
+ leaf v4-address {
+ type inet:ipv4-address;
+ description
+ "An IPv4 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits beyond
+ the prefix are ignored on receipt and
+ SHOULD be set to zero on transmission.";
+ }
+ leaf v4-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v4-loose {
+ type boolean;
+ description
+ "Describes whether the object is loose
+ if set, or otherwise strict";
+ }
+ }
+ case ipv6-address {
+ description
+ "IPv6 address Explicit Route Object";
+ leaf v6-address {
+ type inet:ipv6-address;
+ description
+ "An IPv6 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits
+ beyond the prefix are ignored on
+ receipt and SHOULD be set to zero
+ on transmission.";
+ }
+ leaf v6-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v6-loose {
+ type boolean;
+ description
+ "Describes whether the object is loose
+ if set, or otherwise strict";
+ }
+ }
+ case as-number {
+ leaf as-number {
+ type uint16;
+ description "AS number";
+ }
+ description
+ "Autonomous System explicit route subobject";
+ }
+ case unnumbered-link {
+ leaf router-id {
+ type inet:ip-address;
+ description
+ "A router-id address";
+ }
+ leaf interface-id {
+ type uint32;
+ description "The interface identifier";
+ }
+ description
+ "Unnumbered link explicit route subobject";
+ reference
+ "RFC3477: Signalling Unnumbered Links in
+ RSVP-TE";
+ }
+ case label {
+ leaf value {
+ type uint32;
+ description "the label value";
+ }
+ description
+ "The Label ERO subobject";
+ }
+ /* AS domain sequence..? */
+ }
+ }
+
+ grouping record-route-subobject {
+ description
+ "The record route subobject grouping";
+ choice type {
+ description
+ "The record route subobject type";
+ case ipv4-address {
+ leaf v4-address {
+ type inet:ipv4-address;
+ description
+ "An IPv4 address. This address is
+ treated as a prefix based on the prefix
+ length value below. Bits beyond the
+ prefix are ignored on receipt and
+ SHOULD be set to zero on transmission.";
+ }
+ leaf v4-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v4-flags {
+ type uint8;
+ description
+ "IPv4 address sub-object flags";
+ reference "RFC3209";
+ }
+ }
+ case ipv6-address {
+ leaf v6-address {
+ type inet:ipv6-address;
+ description
+ "An IPv6 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits
+ beyond the prefix are ignored on
+ receipt and SHOULD be set to zero
+ on transmission.";
+ }
+ leaf v6-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v6-flags {
+ type uint8;
+ description
+ "IPv6 address sub-object flags";
+ reference "RFC3209";
+ }
+ }
+ case label {
+ leaf value {
+ type uint32;
+ description "the label value";
+ }
+ leaf flags {
+ type uint8;
+ description
+ "Label sub-object flags";
+ reference "RFC3209";
+ }
+ description
+ "The Label ERO subobject";
+ }
+ }
+ }
+
+ /*identity route-usage-type {
+ description
+ "Base identity for route usage";
+ }
+
+ identity route-include-ero {
+ base route-usage-type;
+ description
+ "Include ERO from route";
+ }
+
+ identity route-exclude-ero {
+ base route-usage-type;
+ description
+ "Exclude ERO from route";
+ }
+
+ identity route-exclude-srlg {
+ base route-usage-type;
+ description
+ "Exclude SRLG from route";
+ }
+
+ identity path-metric-type {
+ description
+ "Base identity for path metric type";
+ }
+
+ identity path-metric-te {
+ base path-metric-type;
+ description
+ "TE path metric";
+ }
+
+ identity path-metric-igp {
+ base path-metric-type;
+ description
+ "IGP path metric";
+ }
+
+ identity path-tiebreaker-type {
+ description
+ "Base identity for path tie-breaker type";
+ }
+
+ identity path-tiebreaker-minfill {
+ base path-tiebreaker-type;
+ description
+ "Min-Fill LSP path placement";
+ }
+
+ identity path-tiebreaker-maxfill {
+ base path-tiebreaker-type;
+ description
+ "Max-Fill LSP path placement";
+ }
+
+ identity path-tiebreaker-randoom {
+ base path-tiebreaker-type;
+ description
+ "Random LSP path placement";
+ }
+
+ identity bidir-provisioning-mode {
+ description
+ "Base identity for bidirectional provisioning
+ mode.";
+ }
+
+ identity bidir-provisioning-single-sided {
+ base bidir-provisioning-mode;
+ description
+ "Single-sided bidirectional provioning mode";
+ }
+
+ identity bidir-provisioning-double-sided {
+ base bidir-provisioning-mode;
+ description
+ "Double-sided bidirectional provioning mode";
+ }
+
+ identity bidir-association-type {
+ description
+ "Base identity for bidirectional association type";
+ }
+
+ identity bidir-assoc-corouted {
+ base bidir-association-type;
+ description
+ "Co-routed bidirectional association type";
+ }
+
+ identity bidir-assoc-non-corouted {
+ base bidir-association-type;
+ description
+ "Non co-routed bidirectional association type";
+ }
+
+ identity resource-affinities-type {
+ description
+ "Base identity for resource affinities";
+ }
+
+ identity resource-aff-include-all {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel all of which must be present for a link
+ to be acceptable";
+ }
+
+ identity resource-aff-include-any {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel any of which must be present for a link
+ to be acceptable";
+ }
+
+ identity resource-aff-exclude-any {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel any of which renders a link unacceptable";
+ }*/
+
+ typedef admin-group {
+ type binary {
+// length 32;
+ }
+ description
+ "Administrative group/Resource class/Color.";
+ }
+
+ typedef extended-admin-group {
+ type binary;
+ description
+ "Extended administrative group/Resource class/Color.";
+ }
+
+ typedef admin-groups {
+ type union {
+ type admin-group;
+ type extended-admin-group;
+ }
+ description "TE administrative group derived type";
+ }
+
+ typedef srlg {
+ type uint32;
+ description "SRLG type";
+ }
+
+ /*identity path-computation-srlg-type {
+ description
+ "Base identity for SRLG path computation";
+ }
+
+ identity srlg-ignore {
+ base path-computation-srlg-type;
+ description
+ "Ignores SRLGs in path computation";
+ }
+
+ identity srlg-strict {
+ base path-computation-srlg-type;
+ description
+ "Include strict SRLG check in path computation";
+ }
+
+ identity srlg-preferred {
+ base path-computation-srlg-type;
+ description
+ "Include preferred SRLG check in path computation";
+ }
+
+ identity srlg-weighted {
+ base path-computation-srlg-type;
+ description
+ "Include weighted SRLG check in path computation";
+ }*/
+
+ typedef te-metric {
+ type uint32;
+ description
+ "TE link metric";
+ }
+
+ typedef topology-id {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ description
+ "An identifier for a topology.";
+ }
+
+ /**
+ * TE tunnel generic groupings
+ **/
+
+ /* Tunnel path selection parameters */
+ grouping tunnel-path-selection {
+ description
+ "Tunnel path selection properties grouping";
+ container path-selection {
+ description
+ "Tunnel path selection properties container";
+ leaf topology {
+ type te-types:topology-id;
+ description
+ "The tunnel path is computed using the specific
+ topology identified by this identifier";
+ }
+ leaf cost-limit {
+ type uint32 {
+ range "1..4294967295";
+ }
+ description
+ "The tunnel path cost limit.";
+ }
+ leaf hop-limit {
+ type uint8 {
+ range "1..255";
+ }
+ description
+ "The tunnel path hop limit.";
+ }
+ leaf metric-type {
+ type string;
+ description
+ "The tunnel path metric type.";
+ }
+ leaf tiebreaker-type {
+ type string;
+ description
+ "The tunnel path computation tie breakers.";
+ }
+ leaf ignore-overload {
+ type boolean;
+ description
+ "The tunnel path can traverse overloaded node.";
+ }
+ uses tunnel-path-affinities;
+ uses tunnel-path-srlgs;
+ }
+ }
+
+ grouping tunnel-path-affinities {
+ description
+ "Path affinities grouping";
+ container tunnel-path-affinities {
+ if-feature named-path-affinities;
+ description
+ "Path affinities container";
+ choice style {
+ description
+ "Path affinities representation style";
+ case values {
+ leaf value {
+ type uint32 {
+ range "0..4294967295";
+ }
+ description
+ "Affinity value";
+ }
+ leaf mask {
+ type uint32 {
+ range "0..4294967295";
+ }
+ description
+ "Affinity mask";
+ }
+ }
+ case named {
+ list constraints {
+ key "usage";
+ leaf usage {
+ type string;
+ description "Affinities usage";
+ }
+ container constraint {
+ description
+ "Container for named affinities";
+ list affinity-names {
+ key "name";
+ leaf name {
+ type string;
+ description
+ "Affinity name";
+ }
+ description
+ "List of named affinities";
+ }
+ }
+ description
+ "List of named affinity constraints";
+ }
+ }
+ }
+ }
+ }
+
+ grouping tunnel-path-srlgs {
+ description
+ "Path SRLG properties grouping";
+ container tunnel-path-srlgs {
+ description
+ "Path SRLG properties container";
+ choice style {
+ description
+ "Type of SRLG representation";
+ case values {
+ leaf usage {
+ type string;
+ description "SRLG usage";
+ }
+ leaf-list values {
+ type te-types:srlg;
+ description "SRLG value";
+ }
+ }
+ case named {
+ list constraints {
+ key "usage";
+ leaf usage {
+ type string;
+ description "SRLG usage";
+ }
+ container constraint {
+ description
+ "Container for named SRLG list";
+ list srlg-names {
+ key "name";
+ leaf name {
+ type string;
+ description
+ "The SRLG name";
+ }
+ description
+ "List named SRLGs";
+ }
+ }
+ description
+ "List of named SRLG constraints";
+ }
+ }
+ }
+ }
+ }
+
+ grouping tunnel-bidir-assoc-properties {
+ description
+ "TE tunnel associated bidirectional properties
+ grouping";
+ container bidirectional {
+ description
+ "TE tunnel associated bidirectional attributes.";
+ container association {
+ description
+ "Tunnel bidirectional association properties";
+ leaf id {
+ type uint16;
+ description
+ "The TE tunnel association identifier.";
+ }
+ leaf source {
+ type inet:ip-address;
+ description
+ "The TE tunnel association source.";
+ }
+ leaf global-source {
+ type inet:ip-address;
+ description
+ "The TE tunnel association global
+ source.";
+ }
+ leaf type {
+ type string;
+ description
+ "The TE tunnel association type.";
+ }
+ leaf provisioing {
+ type string;
+ description
+ "Describes the provisioning model of the
+ associated bidirectional LSP";
+ reference
+ "draft-ietf-teas-mpls-tp-rsvpte-ext-
+ associated-lsp, section-3.2";
+ }
+ }
+ }
+ }
+ /*** End of TE tunnel groupings ***/
+
+ /**
+ * TE interface generic groupings
+ **/
+ }
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-yang-types.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-yang-types.yang
new file mode 100644
index 0000000..9a543fa
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-yang-types.yang
@@ -0,0 +1,490 @@
+ module ietf-yang-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:ietf-yang-types";
+
+ prefix yang;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - yang-identifier
+ - hex-string
+ - uuid
+ - dotted-quad";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef counter32 {
+ type uint32;
+ description
+ "The counter32 type represents a non-negative integer
+ that monotonically increases until it reaches a
+ maximum value of 2^32-1 (4294967295 decimal), when it
+ wraps around and starts increasing again from zero.
+
+ Counters have no defined 'initial' value, and thus, a
+ single value of a counter has (in general) no information
+ content. Discontinuities in the monotonically increasing
+ value normally occur at re-initialization of the
+ management system, and at other times as specified in the
+ description of a schema node using this type. If such
+ other times can occur, for example, the creation of
+ a schema node of type counter32 at times other than
+ re-initialization, then a corresponding schema node
+ should be defined, with an appropriate type, to indicate
+ the last discontinuity.
+
+ The counter32 type should not be used for configuration
+ schema nodes. A default statement SHOULD NOT be used in
+ combination with the type counter32.
+
+ In the value set and its semantics, this type is equivalent
+ to the Counter32 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef zero-based-counter32 {
+ type counter32;
+ default "0";
+ description
+ "The zero-based-counter32 type represents a counter32
+ that has the defined 'initial' value zero.
+
+ A schema node of this type will be set to zero (0) on creation
+ and will thereafter increase monotonically until it reaches
+ a maximum value of 2^32-1 (4294967295 decimal), when it
+ wraps around and starts increasing again from zero.
+
+ Provided that an application discovers a new schema node
+ of this type within the minimum time to wrap, it can use the
+ 'initial' value as a delta. It is important for a management
+ station to be aware of this minimum time and the actual time
+ between polls, and to discard data if the actual time is too
+ long or there is no defined minimum time.
+
+ In the value set and its semantics, this type is equivalent
+ to the ZeroBasedCounter32 textual convention of the SMIv2.";
+ reference
+ "RFC 4502: Remote Network Monitoring Management Information
+ Base Version 2";
+
+ }
+
+ typedef counter64 {
+ type uint64;
+ description
+ "The counter64 type represents a non-negative integer
+ that monotonically increases until it reaches a
+ maximum value of 2^64-1 (18446744073709551615 decimal),
+ when it wraps around and starts increasing again from zero.
+
+ Counters have no defined 'initial' value, and thus, a
+ single value of a counter has (in general) no information
+ content. Discontinuities in the monotonically increasing
+ value normally occur at re-initialization of the
+ management system, and at other times as specified in the
+ description of a schema node using this type. If such
+ other times can occur, for example, the creation of
+ a schema node of type counter64 at times other than
+ re-initialization, then a corresponding schema node
+ should be defined, with an appropriate type, to indicate
+ the last discontinuity.
+
+ The counter64 type should not be used for configuration
+ schema nodes. A default statement SHOULD NOT be used in
+ combination with the type counter64.
+
+ In the value set and its semantics, this type is equivalent
+ to the Counter64 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef zero-based-counter64 {
+ type counter64;
+ default "0";
+ description
+ "The zero-based-counter64 type represents a counter64 that
+ has the defined 'initial' value zero.
+
+
+
+
+ A schema node of this type will be set to zero (0) on creation
+ and will thereafter increase monotonically until it reaches
+ a maximum value of 2^64-1 (18446744073709551615 decimal),
+ when it wraps around and starts increasing again from zero.
+
+ Provided that an application discovers a new schema node
+ of this type within the minimum time to wrap, it can use the
+ 'initial' value as a delta. It is important for a management
+ station to be aware of this minimum time and the actual time
+ between polls, and to discard data if the actual time is too
+ long or there is no defined minimum time.
+
+ In the value set and its semantics, this type is equivalent
+ to the ZeroBasedCounter64 textual convention of the SMIv2.";
+ reference
+ "RFC 2856: Textual Conventions for Additional High Capacity
+ Data Types";
+
+ }
+
+ typedef gauge32 {
+ type uint32;
+ description
+ "The gauge32 type represents a non-negative integer, which
+ may increase or decrease, but shall never exceed a maximum
+ value, nor fall below a minimum value. The maximum value
+ cannot be greater than 2^32-1 (4294967295 decimal), and
+ the minimum value cannot be smaller than 0. The value of
+ a gauge32 has its maximum value whenever the information
+ being modeled is greater than or equal to its maximum
+ value, and has its minimum value whenever the information
+ being modeled is smaller than or equal to its minimum value.
+ If the information being modeled subsequently decreases
+ below (increases above) the maximum (minimum) value, the
+ gauge32 also decreases (increases).
+
+ In the value set and its semantics, this type is equivalent
+ to the Gauge32 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef gauge64 {
+ type uint64;
+ description
+ "The gauge64 type represents a non-negative integer, which
+ may increase or decrease, but shall never exceed a maximum
+ value, nor fall below a minimum value. The maximum value
+ cannot be greater than 2^64-1 (18446744073709551615), and
+ the minimum value cannot be smaller than 0. The value of
+ a gauge64 has its maximum value whenever the information
+ being modeled is greater than or equal to its maximum
+ value, and has its minimum value whenever the information
+ being modeled is smaller than or equal to its minimum value.
+ If the information being modeled subsequently decreases
+ below (increases above) the maximum (minimum) value, the
+ gauge64 also decreases (increases).
+
+ In the value set and its semantics, this type is equivalent
+ to the CounterBasedGauge64 SMIv2 textual convention defined
+ in RFC 2856";
+ reference
+ "RFC 2856: Textual Conventions for Additional High Capacity
+ Data Types";
+
+ }
+
+ typedef object-identifier {
+ type string {
+ pattern
+ '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))(\.(0|([1-9]\d*)))*';
+ }
+ description
+ "The object-identifier type represents administratively
+ assigned names in a registration-hierarchical-name tree.
+
+ Values of this type are denoted as a sequence of numerical
+ non-negative sub-identifier values. Each sub-identifier
+ value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
+ are separated by single dots and without any intermediate
+ whitespace.
+
+ The ASN.1 standard restricts the value space of the first
+ sub-identifier to 0, 1, or 2. Furthermore, the value space
+ of the second sub-identifier is restricted to the range
+ 0 to 39 if the first sub-identifier is 0 or 1. Finally,
+ the ASN.1 standard requires that an object identifier
+ has always at least two sub-identifiers. The pattern
+ captures these restrictions.
+
+ Although the number of sub-identifiers is not limited,
+ module designers should realize that there may be
+ implementations that stick with the SMIv2 limit of 128
+ sub-identifiers.
+
+ This type is a superset of the SMIv2 OBJECT IDENTIFIER type
+ since it is not restricted to 128 sub-identifiers. Hence,
+ this type SHOULD NOT be used to represent the SMIv2 OBJECT
+ IDENTIFIER type; the object-identifier-128 type SHOULD be
+ used instead.";
+ reference
+ "ISO9834-1: Information technology -- Open Systems
+ Interconnection -- Procedures for the operation of OSI
+ Registration Authorities: General procedures and top
+ arcs of the ASN.1 Object Identifier tree";
+
+ }
+
+ typedef object-identifier-128 {
+ type object-identifier {
+ pattern '\d*(\.\d*){1,127}';
+ }
+ description
+ "This type represents object-identifiers restricted to 128
+ sub-identifiers.
+
+ In the value set and its semantics, this type is equivalent
+ to the OBJECT IDENTIFIER type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef yang-identifier {
+ type string {
+ length "1..max";
+ pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
+ pattern
+ '.|..|[^xX].*|.[^mM].*|..[^lL].*';
+ }
+ description
+ "A YANG identifier string as defined by the 'identifier'
+ rule in Section 12 of RFC 6020. An identifier must
+ start with an alphabetic character or an underscore
+ followed by an arbitrary sequence of alphabetic or
+ numeric characters, underscores, hyphens, or dots.
+
+ A YANG identifier MUST NOT start with any possible
+ combination of the lowercase or uppercase character
+ sequence 'xml'.";
+ reference
+ "RFC 6020: YANG - A Data Modeling Language for the Network
+ Configuration Protocol (NETCONF)";
+
+ }
+
+ typedef date-and-time {
+ type string {
+ pattern
+ '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]\d{2}:\d{2})';
+ }
+ description
+ "The date-and-time type is a profile of the ISO 8601
+ standard for representation of dates and times using the
+ Gregorian calendar. The profile is defined by the
+ date-time production in Section 5.6 of RFC 3339.
+
+ The date-and-time type is compatible with the dateTime XML
+ schema type with the following notable exceptions:
+
+ (a) The date-and-time type does not allow negative years.
+
+ (b) The date-and-time time-offset -00:00 indicates an unknown
+ time zone (see RFC 3339) while -00:00 and +00:00 and Z
+ all represent the same time zone in dateTime.
+
+ (c) The canonical format (see below) of data-and-time values
+ differs from the canonical format used by the dateTime XML
+ schema type, which requires all times to be in UTC using
+ the time-offset 'Z'.
+
+ This type is not equivalent to the DateAndTime textual
+ convention of the SMIv2 since RFC 3339 uses a different
+ separator between full-date and full-time and provides
+ higher resolution of time-secfrac.
+
+ The canonical format for date-and-time values with a known time
+ zone uses a numeric time zone offset that is calculated using
+ the device's configured known offset to UTC time. A change of
+ the device's offset to UTC time will cause date-and-time values
+ to change accordingly. Such changes might happen periodically
+ in case a server follows automatically daylight saving time
+ (DST) time zone offset changes. The canonical format for
+ date-and-time values with an unknown time zone (usually
+ referring to the notion of local time) uses the time-offset
+ -00:00.";
+ reference
+ "RFC 3339: Date and Time on the Internet: Timestamps
+ RFC 2579: Textual Conventions for SMIv2
+ XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
+
+ }
+
+ typedef timeticks {
+ type uint32;
+ description
+ "The timeticks type represents a non-negative integer that
+ represents the time, modulo 2^32 (4294967296 decimal), in
+ hundredths of a second between two epochs. When a schema
+ node is defined that uses this type, the description of
+ the schema node identifies both of the reference epochs.
+
+ In the value set and its semantics, this type is equivalent
+ to the TimeTicks type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef timestamp {
+ type timeticks;
+ description
+ "The timestamp type represents the value of an associated
+ timeticks schema node at which a specific occurrence
+ happened. The specific occurrence must be defined in the
+ description of any schema node defined using this type. When
+ the specific occurrence occurred prior to the last time the
+ associated timeticks attribute was zero, then the timestamp
+ value is zero. Note that this requires all timestamp values
+ to be reset to zero when the value of the associated timeticks
+ attribute reaches 497+ days and wraps around to zero.
+
+ The associated timeticks schema node must be specified
+ in the description of any schema node using this type.
+
+ In the value set and its semantics, this type is equivalent
+ to the TimeStamp textual convention of the SMIv2.";
+ reference
+ "RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef phys-address {
+ type string {
+ pattern
+ '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+ }
+ description
+ "Represents media- or physical-level addresses represented
+ as a sequence octets, each octet represented by two hexadecimal
+ numbers. Octets are separated by colons. The canonical
+ representation uses lowercase characters.
+
+ In the value set and its semantics, this type is equivalent
+ to the PhysAddress textual convention of the SMIv2.";
+ reference
+ "RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef mac-address {
+ type string {
+ pattern
+ '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
+ }
+ description
+ "The mac-address type represents an IEEE 802 MAC address.
+ The canonical representation uses lowercase characters.
+
+ In the value set and its semantics, this type is equivalent
+ to the MacAddress textual convention of the SMIv2.";
+ reference
+ "IEEE 802: IEEE Standard for Local and Metropolitan Area
+ Networks: Overview and Architecture
+ RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef xpath1.0 {
+ type string;
+ description
+ "This type represents an XPATH 1.0 expression.
+
+ When a schema node is defined that uses this type, the
+ description of the schema node MUST specify the XPath
+ context in which the XPath expression is evaluated.";
+ reference
+ "XPATH: XML Path Language (XPath) Version 1.0";
+
+ }
+
+ typedef hex-string {
+ type string {
+ pattern
+ '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+ }
+ description
+ "A hexadecimal string with octets represented as hex digits
+ separated by colons. The canonical representation uses
+ lowercase characters.";
+ }
+
+ typedef uuid {
+ type string {
+ pattern
+ '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
+ }
+ description
+ "A Universally Unique IDentifier in the string representation
+ defined in RFC 4122. The canonical representation uses
+ lowercase characters.
+
+ The following is an example of a UUID in string representation:
+ f81d4fae-7dec-11d0-a765-00a0c91e6bf6
+ ";
+ reference
+ "RFC 4122: A Universally Unique IDentifier (UUID) URN
+ Namespace";
+
+ }
+
+ typedef dotted-quad {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
+ }
+ description
+ "An unsigned 32-bit number expressed in the dotted-quad
+ notation, i.e., four octets written as decimal numbers
+ and separated with the '.' (full stop) character.";
+ }
+ } // module ietf-yang-types
+
diff --git a/utils/yangutils/plugin/src/test/resources/interfiletype/module1.yang b/utils/yangutils/plugin/src/test/resources/interfiletype/module1.yang
new file mode 100644
index 0000000..3c60bd6
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfiletype/module1.yang
@@ -0,0 +1,14 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ }
+ leaf invalid-interval {
+ type p:hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfiletype/module2.yang b/utils/yangutils/plugin/src/test/resources/interfiletype/module2.yang
new file mode 100644
index 0000000..6784c45
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfiletype/module2.yang
@@ -0,0 +1,8 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant2;
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfiletypewithinclude/module1.yang b/utils/yangutils/plugin/src/test/resources/interfiletypewithinclude/module1.yang
new file mode 100644
index 0000000..d1d4db3
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfiletypewithinclude/module1.yang
@@ -0,0 +1,9 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ include module2;
+ leaf invalid-interval {
+ type hello;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfiletypewithinclude/module2.yang b/utils/yangutils/plugin/src/test/resources/interfiletypewithinclude/module2.yang
new file mode 100644
index 0000000..8e47100
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfiletypewithinclude/module2.yang
@@ -0,0 +1,9 @@
+submodule module2 {
+ yang-version 1;
+ belongs-to module1 {
+ prefix "module1";
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfiletypewithrevision/module1.yang b/utils/yangutils/plugin/src/test/resources/interfiletypewithrevision/module1.yang
new file mode 100644
index 0000000..180511d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfiletypewithrevision/module1.yang
@@ -0,0 +1,15 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ revision-date 2007-06-09;
+ }
+ leaf invalid-interval {
+ type p:hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfiletypewithrevision/module2.yang b/utils/yangutils/plugin/src/test/resources/interfiletypewithrevision/module2.yang
new file mode 100644
index 0000000..fd99872
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfiletypewithrevision/module2.yang
@@ -0,0 +1,11 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant2;
+ revision 2007-06-09 {
+ description "Initial revision.";
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfiletypewithrevisioninname/module1.yang b/utils/yangutils/plugin/src/test/resources/interfiletypewithrevisioninname/module1.yang
new file mode 100644
index 0000000..180511d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfiletypewithrevisioninname/module1.yang
@@ -0,0 +1,15 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ revision-date 2007-06-09;
+ }
+ leaf invalid-interval {
+ type p:hello;
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfiletypewithrevisioninname/module2@2007-06-09.yang b/utils/yangutils/plugin/src/test/resources/interfiletypewithrevisioninname/module2@2007-06-09.yang
new file mode 100644
index 0000000..fd99872
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfiletypewithrevisioninname/module2@2007-06-09.yang
@@ -0,0 +1,11 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant2;
+ revision 2007-06-09 {
+ description "Initial revision.";
+ }
+ typedef hello {
+ type string;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfileuses/module1.yang b/utils/yangutils/plugin/src/test/resources/interfileuses/module1.yang
new file mode 100644
index 0000000..69df326
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileuses/module1.yang
@@ -0,0 +1,9 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ import module2 {
+ prefix p;
+ }
+ uses p:hello;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfileuses/module2.yang b/utils/yangutils/plugin/src/test/resources/interfileuses/module2.yang
new file mode 100644
index 0000000..5bb3616
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileuses/module2.yang
@@ -0,0 +1,10 @@
+module module2 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ grouping hello {
+ leaf hello {
+ type string;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfileuseswithinclude/module1.yang b/utils/yangutils/plugin/src/test/resources/interfileuseswithinclude/module1.yang
new file mode 100644
index 0000000..41899d9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileuseswithinclude/module1.yang
@@ -0,0 +1,7 @@
+module module1 {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ include module2;
+ uses hello;
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfileuseswithinclude/module2.yang b/utils/yangutils/plugin/src/test/resources/interfileuseswithinclude/module2.yang
new file mode 100644
index 0000000..1b423d9
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfileuseswithinclude/module2.yang
@@ -0,0 +1,11 @@
+submodule module2 {
+ yang-version 1;
+ belongs-to module1 {
+ prefix "module1";
+ }
+ grouping hello {
+ leaf hello {
+ type string;
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfilewithusesreferringtype/ietf-network.yang b/utils/yangutils/plugin/src/test/resources/interfilewithusesreferringtype/ietf-network.yang
new file mode 100644
index 0000000..3d96560
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfilewithusesreferringtype/ietf-network.yang
@@ -0,0 +1,14 @@
+ module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+
+ container networks {
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/interfilewithusesreferringtype/ietf-te-topology.yang b/utils/yangutils/plugin/src/test/resources/interfilewithusesreferringtype/ietf-te-topology.yang
new file mode 100644
index 0000000..2434403
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/interfilewithusesreferringtype/ietf-te-topology.yang
@@ -0,0 +1,51 @@
+ module ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+ // replace with IANA namespace when assigned
+
+ prefix "tet";
+
+ import ietf-network {
+ prefix "nw";
+ }
+
+ grouping te-topologies-augment {
+ description
+ "Augmentation for TE topologies.";
+ leaf reference-change-policy {
+ type enumeration {
+ enum no-action {
+ description
+ "When an attribute changes in this template, the
+ configuration node referring to this template does
+ not take any action.";
+ }
+ enum not-allowed {
+ description
+ "When any configuration object has a reference to this
+ template, changing this template is not allowed.";
+ }
+ enum cascade {
+ description
+ "When an attribute changes in this template, the
+ configuration object referring to this template applies
+ the new attribute value to the corresponding
+ configuration.";
+ }
+ }
+ description
+ "This attribute specifies the action taken to a configuration
+ node that has a reference to this template.";
+ }
+ } // te-topologies-augment
+
+
+
+ augment "/nw:networks" {
+ description
+ "Augmentation parameters for TE topologies.";
+ uses te-topologies-augment;
+ }
+
+
+}
diff --git a/utils/yangutils/plugin/src/test/resources/processTypeDef.yang b/utils/yangutils/plugin/src/test/resources/processTypeDef.yang
new file mode 100644
index 0000000..2875752
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/processTypeDef.yang
@@ -0,0 +1,11 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ typedef hello {
+ type String;
+ }
+ leaf invalid-interval {
+ type hello;
+ }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/usesInContainer/GroupingError.yang b/utils/yangutils/plugin/src/test/resources/usesInContainer/GroupingError.yang
new file mode 100644
index 0000000..8c7c01d
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/usesInContainer/GroupingError.yang
@@ -0,0 +1,64 @@
+
+module ietf-sd-onos-service-types {
+
+ namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-types";
+ prefix service-types ;
+
+ grouping qos-if-car {
+ description "qos parameter." ;
+ list qos-if-car {
+ key "direction";
+ description "cars qos policy." ;
+ leaf direction {
+ type enumeration {
+ enum inbound{
+ value 0 ;
+ description "inbound." ;
+ }
+ enum outbound {
+ value 1 ;
+ description "outbound." ;
+ }
+ }
+ description "qos for interface car" ;
+ }
+}
+}
+
+ container qos-policy {
+ description "The qos policy of the vpn service." ;
+ container qos-if-cars {
+ description "qos policy if car." ;
+ list qos-if-car {
+ key "direction";
+ uses qos-if-car;
+ description "List of qos parameters." ;
+ }
+ }
+ }
+
+ rpc close-l3vpn {
+ description "Close l3vpn." ;
+ input {
+ leaf l3vpn-id {
+ type string;
+ description "vpn id." ;
+ }
+ container ac-status {
+ description "Access status of the vpn." ;
+ list acs{
+ key "id";
+ description "Access information." ;
+ leaf id {
+ type string;
+ description "Access id." ;
+ }
+ leaf admin-status {
+ type string;
+ description "Administration status." ;
+ }
+ }
+ }
+ }
+ }
+}