[ONOS-4910, ONOS-4921] Framework: utils validation and defect fix

Change-Id: I821920fa8c88e64406b702c2b8736bdeaf231474
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
index 303a3e6..baab6c7 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
@@ -145,9 +145,9 @@
         assertThat(decimal64.getFractionDigit(), is(18));
 
         decimal64.setValue(new BigDecimal(-9.223372036854775808));
-        decimal64.validateValue();
+        decimal64.validateDecimal64();
         decimal64.setValue(new BigDecimal(9.223372036854775807));
-        decimal64.validateValue();
+        decimal64.validateDecimal64();
     }
 
     /**
@@ -181,7 +181,7 @@
 
         decimal64.setValue(new BigDecimal(-92233720368547758.08));
         // validation should fail
-        decimal64.validateValue();
+        decimal64.validateDecimal64();
     }
 
     /**
@@ -271,7 +271,7 @@
     @Test
     public void processDecimal64InvalidRange() throws IOException, ParserException, DataModelException {
         thrown.expect(ParserException.class);
-        thrown.expectMessage("YANG file error : decimal64 validation failed.");
+        thrown.expectMessage("YANG file error : range validation failed.");
 
         manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidRangeStmnt.yang");
     }
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListenerTest.java
index 2aab556..81e973f 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DefaultListenerTest.java
@@ -19,13 +19,21 @@
 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.YangDerivedInfo;
 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.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.DataTypeException;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangInt64;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
 
@@ -36,6 +44,8 @@
  * Test cases for testing default listener functionality.
  */
 public class DefaultListenerTest {
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
 
     private final YangUtilsParserManager manager = new YangUtilsParserManager();
 
@@ -43,9 +53,9 @@
      * Checks if default value is set correctly.
      */
     @Test
-    public void processLeafSubStatementDefault() throws IOException, ParserException {
+    public void processDefaultValueInLeafSubStatement() throws IOException, ParserException {
 
-        YangNode node = manager.getDataModel("src/test/resources/LeafSubStatementDefault.yang");
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueInLeafSubStatement.yang");
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
 
@@ -60,16 +70,28 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getName(), is("invalid-interval"));
-        assertThat(leafInfo.getDefaultValueInString(), is("\"1\""));
+        assertThat(leafInfo.getDefaultValueInString(), is("1"));
     }
 
     /**
-     * Checks if default value is set correctly.
+     * Validates default invalid value in leaf.
      */
     @Test
-    public void processChoiceSubStatementDefault() throws IOException, ParserException {
+    public void processDefaultInalueInLeafSubStatement() throws IOException, ParserException {
 
-        YangNode node = manager.getDataModel("src/test/resources/ChoiceSubStatementDefault.yang");
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"x\" is not a valid uint16.");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueInLeafSubStatement.yang");
+    }
+
+    /**
+     * Validates default case value in choice statement.
+     */
+    @Test
+    public void processDefaultCaseInChoiceSubStatement() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultCaseInChoiceSubStatement.yang");
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
 
@@ -85,6 +107,408 @@
 
         YangChoice yangChoice = (YangChoice) yangContainer.getChild();
         assertThat(yangChoice.getName(), is("snack"));
-        assertThat(yangChoice.getDefaultValueInString(), is("\"hello\""));
+        assertThat(yangChoice.getDefaultValueInString(), is("sports-arena"));
+    }
+
+    /**
+     * Validates default invalide case in choice statement.
+     */
+    @Test
+    public void processDefaultInvalidCaseInChoiceSubStatement() throws IOException, ParserException {
+
+        thrown.expect(ParserException.class);
+        thrown.expectMessage("Internal parser error detected: Invalid content in choice \"snack\" after processing.");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueInChoiceSubStmt.yang");
+    }
+
+    /**
+     * Validates default value in typedef.
+     */
+    @Test
+    public void processDefaultInTypedef() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueInTypeDef.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 typedef
+        YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
+        assertThat(typedef.getName(), is("topInt"));
+        assertThat(typedef.getDefaultValueInString(), is("10"));
+
+        YangType type = typedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.INT64));
+        assertThat(type.getDataTypeName(), is("int64"));
+
+        // check leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+        assertThat(leafInfo.getName(), is("myValue"));
+
+        // Check leaf reffered typedef
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("topInt"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+        YangType<YangDerivedInfo> typeDerived = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+        YangDerivedInfo derivedInfo = (YangDerivedInfo) typeDerived.getDataTypeExtendedInfo();
+        YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(prevTypedef.getName(), is("topInt"));
+        assertThat(prevTypedef.getDefaultValueInString(), is("10"));
+        YangType topType = prevTypedef.getTypeList().iterator().next();
+        assertThat(topType.getDataType(), is(YangDataTypes.INT64));
+        assertThat(topType.getDataTypeName(), is("int64"));
+        YangType<YangInt64> typeInt64 = (YangType<YangInt64>) topType;
+        YangInt64 int64Obj = typeInt64.getDataTypeExtendedInfo();
+    }
+
+    /**
+     * Validates invalid default value in typedef.
+     */
+    @Test
+    public void processInvalidDefaultValueInTypdeDef() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"x\" is not a valid int64.");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueInTypeDef.yang");
+    }
+
+    /**
+     * Validates default value decimal64 in leaf.
+     */
+    @Test
+    public void processDefaultValueDecimal64InLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueDecimal64InLeaf.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 leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check the default value
+        // This default value is verified by YangType.isValidValue() called from LeafListener.processLeafExit()
+        assertThat(leafInfo.getName(), is("mydecimal"));
+        assertThat(leafInfo.getDefaultValueInString(), is("5"));
+    }
+
+    /**
+     * Validates default invalid value decimal64 in leaf.
+     */
+    @Test
+    public void processDefaultInvalidValueDecimal64InLeaf() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"x\" is not a valid decimal64.");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueDecimal64InLeaf.yang");
+    }
+
+    /**
+     * Validates default value string in leaf.
+     */
+    @Test
+    public void processDefaultValueStringInLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueStringInLeaf.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 leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check the default value
+        // This default value is verified by YangType.isValidValue() called from LeafListener.processLeafExit()
+        assertThat(leafInfo.getName(), is("MyString"));
+        assertThat(leafInfo.getDefaultValueInString(), is("2bB"));
+    }
+
+    /**
+     * Validates default invalid value string in leaf.
+     */
+    @Test
+    public void processDefaultInvalidValueStringInLeaf() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"2bB2bB\" is not a valid string");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueStringInLeaf.yang");
+    }
+
+    /**
+     * Validates default value boolean in leaf.
+     */
+    @Test
+    public void processDefaultValueBooleanInLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueBooleanInLeaf.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 leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check the default value
+        // This default value is verified by YangType.isValidValue() called from LeafListener.processLeafExit()
+        assertThat(leafInfo.getName(), is("myboolean"));
+        assertThat(leafInfo.getDefaultValueInString(), is("true"));
+    }
+
+    /**
+     * Validates default invalid value boolean in leaf.
+     */
+    @Test
+    public void processDefaultInvalidValueBooleanInLeaf() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"yes\" is not a valid boolean");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueBooleanInLeaf.yang");
+    }
+
+    /**
+     * Validates default value enumeration in leaf.
+     */
+    @Test
+    public void processDefaultValueEnumberationInLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueEnumerationInLeaf.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 leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check the default value
+        // This default value is verified by YangType.isValidValue() called from LeafListener.processLeafExit()
+        assertThat(leafInfo.getName(), is("myenum"));
+        assertThat(leafInfo.getDefaultValueInString(), is("one"));
+    }
+
+    /**
+     * Validates default invalid value enumeration in leaf.
+     */
+    @Test
+    public void processDefaultInvalidValueEnumberationInLeaf() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"xyz\" is not a valid union");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueEnumerationInLeaf.yang");
+    }
+
+    /**
+     * Validates default value bits in leaf.
+     */
+    @Test
+    public void processDefaultValueBitsInLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueBitsInLeaf.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 leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check the default value
+        // This default value is verified by YangType.isValidValue() called from LeafListener.processLeafExit()
+        assertThat(leafInfo.getName(), is("mybits"));
+        assertThat(leafInfo.getDefaultValueInString(), is("auto-sense-speed"));
+    }
+
+    /**
+     * Validates default invalid value bits in leaf.
+     */
+    @Test
+    public void processDefaultInvalidValueBitsInLeaf() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"xyz\" is not a valid bits");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueBitsInLeaf.yang");
+    }
+
+    /**
+     * Validates default value binary in leaf.
+     */
+    @Test
+    public void processDefaultValueBinaryInLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueBinaryInLeaf.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 leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check the default value
+        // This default value is verified by YangType.isValidValue() called from LeafListener.processLeafExit()
+        assertThat(leafInfo.getName(), is("message"));
+        assertThat(leafInfo.getDefaultValueInString(), is("10010010"));
+    }
+
+    /**
+     * Validates default invalid value binary in leaf.
+     */
+    @Test
+    public void processDefaultInvlaidValueBinaryInLeaf() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"000\" is not a valid binary");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueBinaryInLeaf.yang");
+    }
+
+    /**
+     * Validates default value empty in leaf.
+     */
+    @Test
+    public void processDefaultValueEmptyInLeaf() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"something\" is not a allowed for a data type empty");
+
+        manager.getDataModel("src/test/resources/default/DefaultValueEmptyInLeaf.yang");
+    }
+
+    /**
+     * Validates default value union in leaf.
+     */
+    @Test
+    public void processDefaultValueUnionInLeaf() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueUnionInLeaf.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 leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check the default value
+        // This default value is verified by YangType.isValidValue() called from LeafListener.processLeafExit()
+        assertThat(leafInfo.getName(), is("message"));
+        assertThat(leafInfo.getDefaultValueInString(), is("unbounded"));
+    }
+
+    /**
+     * Validates default invalid value union in leaf.
+     */
+    @Test
+    public void processDefaultInvalidValueUnionInLeaf() throws IOException, ParserException {
+        thrown.expect(DataTypeException.class);
+        thrown.expectMessage("YANG file error : Input value \"xyz\" is not a valid union");
+
+        manager.getDataModel("src/test/resources/default/DefaultInvalidValueUnionInLeaf.yang");
+    }
+
+    /**
+     * Validates default value in multiple typedef.
+     */
+    @Test
+    public void processDefaultInMultiTypedef() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/default/DefaultValueInMultiTypeDef.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 typedef
+        YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
+        assertThat(typedef.getName(), is("topInt"));
+        assertThat(typedef.getDefaultValueInString(), is("10"));
+
+        YangType type = typedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.INT64));
+        assertThat(type.getDataTypeName(), is("int64"));
+
+        // check leaf
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+        assertThat(leafInfo.getName(), is("lowInt"));
+
+        // check leaf type
+        assertThat(leafInfo.getName(), is("lowInt"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("midInt"));
+        YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+        assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+        YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+        // check previous typedef
+        YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(prevTypedef.getName(), is("midInt"));
+        type = prevTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+        derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+        // check top typedef
+        YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(topTypedef.getName(), is("topInt"));
+        assertThat(topTypedef.getDefaultValueInString(), is("10"));
+        YangType topType = topTypedef.getTypeList().iterator().next();
+        assertThat(topType.getDataType(), is(YangDataTypes.INT64));
+        assertThat(topType.getDataTypeName(), is("int64"));
+        YangType<YangInt64> typeInt64 = (YangType<YangInt64>) topType;
+        YangInt64 int64Obj = typeInt64.getDataTypeExtendedInfo();
     }
 }
diff --git a/plugin/src/test/resources/default/DefaultCaseInChoiceSubStatement.yang b/plugin/src/test/resources/default/DefaultCaseInChoiceSubStatement.yang
new file mode 100644
index 0000000..72b597b
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultCaseInChoiceSubStatement.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 "sports-arena";
+       }
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueBinaryInLeaf.yang b/plugin/src/test/resources/default/DefaultInvalidValueBinaryInLeaf.yang
new file mode 100644
index 0000000..aab417b
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueBinaryInLeaf.yang
@@ -0,0 +1,12 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf message {
+        type binary {
+            length "8";
+        }
+        default "000";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueBitsInLeaf.yang b/plugin/src/test/resources/default/DefaultInvalidValueBitsInLeaf.yang
new file mode 100644
index 0000000..2e84cf3
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueBitsInLeaf.yang
@@ -0,0 +1,20 @@
+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 Mb-only {
+                 position 2;
+             }
+         }
+         default "xyz";
+     }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueBooleanInLeaf.yang b/plugin/src/test/resources/default/DefaultInvalidValueBooleanInLeaf.yang
new file mode 100644
index 0000000..1d98df9
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueBooleanInLeaf.yang
@@ -0,0 +1,10 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf myboolean {
+        type boolean;
+        default "yes";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueDecimal64InLeaf.yang b/plugin/src/test/resources/default/DefaultInvalidValueDecimal64InLeaf.yang
new file mode 100644
index 0000000..305235f
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueDecimal64InLeaf.yang
@@ -0,0 +1,13 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf mydecimal {
+        type decimal64 {
+           fraction-digits 4;
+           range 4..6;
+        } 
+        default "x";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueEnumerationInLeaf.yang b/plugin/src/test/resources/default/DefaultInvalidValueEnumerationInLeaf.yang
new file mode 100644
index 0000000..643dac3
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueEnumerationInLeaf.yang
@@ -0,0 +1,16 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+     leaf myenum {
+         type enumeration {
+             enum zero;
+             enum one;
+             enum seven {
+                 value 7;
+             }
+         }
+         default "xyz";
+     }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueInChoiceSubStmt.yang b/plugin/src/test/resources/default/DefaultInvalidValueInChoiceSubStmt.yang
new file mode 100644
index 0000000..b9fd60d
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueInChoiceSubStmt.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/plugin/src/test/resources/default/DefaultInvalidValueInLeafSubStatement.yang b/plugin/src/test/resources/default/DefaultInvalidValueInLeafSubStatement.yang
new file mode 100644
index 0000000..9b20fa2
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueInLeafSubStatement.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    leaf invalid-interval {
+        type "uint16";
+        units "seconds";
+        default "x";
+        description "Interval before a route is declared invalid";
+        config true;
+        mandatory true;
+        status current;
+        reference "RFC 6020";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueInTypeDef.yang b/plugin/src/test/resources/default/DefaultInvalidValueInTypeDef.yang
new file mode 100644
index 0000000..35f8554
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueInTypeDef.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    typedef topInt {
+       type int64;
+       default "x";
+    }
+
+    leaf myValue {
+        type topInt;
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueStringInLeaf.yang b/plugin/src/test/resources/default/DefaultInvalidValueStringInLeaf.yang
new file mode 100644
index 0000000..28d3d22
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueStringInLeaf.yang
@@ -0,0 +1,13 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf MyString {
+       type string {
+          length "0..4";
+          pattern "[0-9a-fA-F]*";
+       }
+       default "2bB2bB";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultInvalidValueUnionInLeaf.yang b/plugin/src/test/resources/default/DefaultInvalidValueUnionInLeaf.yang
new file mode 100644
index 0000000..2bbb698
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultInvalidValueUnionInLeaf.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf message {
+        type union {
+            type int32;
+            type enumeration {
+                enum "unbounded";
+            }
+        }
+        default "xyz";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueBinaryInLeaf.yang b/plugin/src/test/resources/default/DefaultValueBinaryInLeaf.yang
new file mode 100644
index 0000000..fa6fb05
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueBinaryInLeaf.yang
@@ -0,0 +1,12 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf message {
+        type binary {
+            length "8";
+        }
+        default "10010010";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueBitsInLeaf.yang b/plugin/src/test/resources/default/DefaultValueBitsInLeaf.yang
new file mode 100644
index 0000000..574df85
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueBitsInLeaf.yang
@@ -0,0 +1,20 @@
+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 Mb-only {
+                 position 2;
+             }
+         }
+         default "auto-sense-speed";
+     }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueBooleanInLeaf.yang b/plugin/src/test/resources/default/DefaultValueBooleanInLeaf.yang
new file mode 100644
index 0000000..bb126ff
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueBooleanInLeaf.yang
@@ -0,0 +1,10 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf myboolean {
+        type boolean;
+        default "true";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueDecimal64InLeaf.yang b/plugin/src/test/resources/default/DefaultValueDecimal64InLeaf.yang
new file mode 100644
index 0000000..18e566d
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueDecimal64InLeaf.yang
@@ -0,0 +1,13 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf mydecimal {
+        type decimal64 {
+           fraction-digits 4;
+           range 4..6;
+        } 
+        default "5";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueDerivedInTypedef.yang b/plugin/src/test/resources/default/DefaultValueDerivedInTypedef.yang
new file mode 100644
index 0000000..b787b18
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueDerivedInTypedef.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    typedef topInt {
+       type int64;
+       default "10";
+    }
+
+    leaf myValue {
+        type topInt;
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueEmptyInLeaf.yang b/plugin/src/test/resources/default/DefaultValueEmptyInLeaf.yang
new file mode 100644
index 0000000..8c8bbea
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueEmptyInLeaf.yang
@@ -0,0 +1,10 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf enable-qos {
+        type empty;
+        default "something";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueEnumerationInLeaf.yang b/plugin/src/test/resources/default/DefaultValueEnumerationInLeaf.yang
new file mode 100644
index 0000000..2545976
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueEnumerationInLeaf.yang
@@ -0,0 +1,16 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+     leaf myenum {
+         type enumeration {
+             enum zero;
+             enum one;
+             enum seven {
+                 value 7;
+             }
+         }
+         default "one";
+     }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueInLeafSubStatement.yang b/plugin/src/test/resources/default/DefaultValueInLeafSubStatement.yang
new file mode 100644
index 0000000..a78131d
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueInLeafSubStatement.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/plugin/src/test/resources/default/DefaultValueInMultiTypeDef.yang b/plugin/src/test/resources/default/DefaultValueInMultiTypeDef.yang
new file mode 100644
index 0000000..d25b7c2
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueInMultiTypeDef.yang
@@ -0,0 +1,18 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    typedef topInt {
+       type int64;
+       default "10";
+    }
+
+    typedef midInt {
+       type topInt;
+    }
+
+    leaf lowInt {
+        type midInt;
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueInTypeDef.yang b/plugin/src/test/resources/default/DefaultValueInTypeDef.yang
new file mode 100644
index 0000000..b787b18
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueInTypeDef.yang
@@ -0,0 +1,14 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    typedef topInt {
+       type int64;
+       default "10";
+    }
+
+    leaf myValue {
+        type topInt;
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueStringInLeaf.yang b/plugin/src/test/resources/default/DefaultValueStringInLeaf.yang
new file mode 100644
index 0000000..1bdb1e8
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueStringInLeaf.yang
@@ -0,0 +1,13 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf MyString {
+       type string {
+          length "0..4";
+          pattern "[0-9a-fA-F]*";
+       }
+       default "2bB";
+    }
+}
diff --git a/plugin/src/test/resources/default/DefaultValueUnionInLeaf.yang b/plugin/src/test/resources/default/DefaultValueUnionInLeaf.yang
new file mode 100644
index 0000000..e2b39c9
--- /dev/null
+++ b/plugin/src/test/resources/default/DefaultValueUnionInLeaf.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    leaf message {
+        type union {
+            type int32;
+            type enumeration {
+                enum "unbounded";
+            }
+        }
+        default "unbounded";
+    }
+}