[ONOS-4762][ONOS-4601]Grammar for meta data + Union defect fix
Change-Id: I8f78127e5b292cca6a79b32d496c2602c9105acd
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
index cb4c42d..ab84306 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
@@ -129,19 +129,6 @@
}
/**
- * 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
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
index a5b2dfb..b156188 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
@@ -91,13 +91,8 @@
/**
* Checks whether exception is thrown when leaf-list keyword is incorrect.
*/
- @Test
+ @Test(expected = ParserException.class)
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");
}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
index 0b4beaa..9bbd0f5 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
@@ -90,19 +90,6 @@
}
/**
- * 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.
*/
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java
index 52e43a9..fef5599 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java
@@ -140,18 +140,4 @@
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/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
index aa0cee2..29e4c63 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
@@ -92,19 +92,6 @@
}
/**
- * 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.
*/
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
index c2f668b..e362eeb 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
@@ -92,19 +92,6 @@
}
/**
- * 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.
*/
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
index e6c840d..6d97bb8 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
@@ -145,19 +145,6 @@
}
/**
- * 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
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnionListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnionListenerTest.java
index 04b3796..1fe7218 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnionListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnionListenerTest.java
@@ -138,4 +138,12 @@
YangNode node = manager.getDataModel("src/test/resources/UnionWithEmptyType.yang");
}
+
+ /**
+ * Checks whether type union has atleast one type statement.
+ */
+ @Test (expected = ParserException.class)
+ public void processUnionWithoutChild() throws IOException, ParserException {
+ manager.getDataModel("src/test/resources/UnionWithoutChild.yang");
+ }
}
diff --git a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
index 6684df5..fe2bed1 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
@@ -71,19 +71,6 @@
}
/**
- * 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
diff --git a/plugin/src/test/resources/LeafInvalidStatement.yang b/plugin/src/test/resources/LeafInvalidStatement.yang
deleted file mode 100644
index 4d4f6f6..0000000
--- a/plugin/src/test/resources/LeafInvalidStatement.yang
+++ /dev/null
@@ -1,14 +0,0 @@
-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/plugin/src/test/resources/MaxElementsInvalidStatement.yang b/plugin/src/test/resources/MaxElementsInvalidStatement.yang
deleted file mode 100644
index 67cb358..0000000
--- a/plugin/src/test/resources/MaxElementsInvalidStatement.yang
+++ /dev/null
@@ -1,14 +0,0 @@
-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/plugin/src/test/resources/MinElementsInvalidKeyword.yang b/plugin/src/test/resources/MinElementsInvalidKeyword.yang
deleted file mode 100644
index e634509..0000000
--- a/plugin/src/test/resources/MinElementsInvalidKeyword.yang
+++ /dev/null
@@ -1,14 +0,0 @@
-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/plugin/src/test/resources/ModuleSubStatementConfig.yang b/plugin/src/test/resources/ModuleSubStatementConfig.yang
deleted file mode 100644
index 49deb3e..0000000
--- a/plugin/src/test/resources/ModuleSubStatementConfig.yang
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test {
- yang-version 1;
- namespace http://huawei.com;
- prefix Ant;
- config invalid;
-}
\ No newline at end of file
diff --git a/plugin/src/test/resources/ModuleSubStatementMandatory.yang b/plugin/src/test/resources/ModuleSubStatementMandatory.yang
deleted file mode 100644
index 8f6e1a1..0000000
--- a/plugin/src/test/resources/ModuleSubStatementMandatory.yang
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test {
- yang-version 1;
- namespace http://huawei.com;
- prefix Ant;
- mandatory false;
-}
\ No newline at end of file
diff --git a/plugin/src/test/resources/ModuleSubStatementStatus.yang b/plugin/src/test/resources/ModuleSubStatementStatus.yang
deleted file mode 100644
index 3739096..0000000
--- a/plugin/src/test/resources/ModuleSubStatementStatus.yang
+++ /dev/null
@@ -1,6 +0,0 @@
-module Test {
- yang-version 1;
- namespace http://huawei.com;
- prefix Ant;
- status current;
-}
\ No newline at end of file
diff --git a/plugin/src/test/resources/ModuleSubStatementUnits.yang b/plugin/src/test/resources/ModuleSubStatementUnits.yang
deleted file mode 100644
index d9381ec..0000000
--- a/plugin/src/test/resources/ModuleSubStatementUnits.yang
+++ /dev/null
@@ -1,7 +0,0 @@
-module Test {
- yang-version 1;
- namespace http://huawei.com;
- prefix Ant;
- type "uint16";
- units "seconds";
-}
\ No newline at end of file
diff --git a/plugin/src/test/resources/UnionWithoutChild.yang b/plugin/src/test/resources/UnionWithoutChild.yang
new file mode 100644
index 0000000..14d3329
--- /dev/null
+++ b/plugin/src/test/resources/UnionWithoutChild.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 union {
+ type "union";
+ }
+ }
+ }
+}
+