[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