[ONOS-4910, ONOS-4921] Framework: utils validation and defect fix
Change-Id: I821920fa8c88e64406b702c2b8736bdeaf231474
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";
+ }
+}