[ONOS-4947][ONOS-4954][ONOS-4952]Defect Fixed: Invalid name in case of qualified info for child nodes
Change-Id: I0b94455333afd9322c1e583a5c3ec311dbe99991
diff --git a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/TypeDefTranslatorTest.java b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/TypeDefTranslatorTest.java
index dc728c4..b674d26 100644
--- a/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/TypeDefTranslatorTest.java
+++ b/plugin/src/test/java/org/onosproject/yangutils/plugin/manager/TypeDefTranslatorTest.java
@@ -41,7 +41,7 @@
@Test
public void processTypeDefTranslator() throws IOException, ParserException, MojoExecutionException {
- String searchDir = "src/test/resources/typedefTranslator";
+ String searchDir = "src/test/resources/typedefTranslator/without";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
utilManager.createYangNodeSet();
@@ -55,4 +55,27 @@
deleteDirectory("target/typedefTranslator/");
}
+ /**
+ * Checks typedef translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTypeDefWithRestrictionsTranslator() throws IOException, ParserException, MojoExecutionException {
+
+ /*FIXME: After typedef with leafref is fixed.
+ String searchDir = "src/test/resources/typedefTranslator/with";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir("target/typedefTranslator/");
+ yangPluginConfig.setManagerCodeGenDir("target/typedefTranslator/");
+ utilManager.translateToJava(yangPluginConfig);
+
+ deleteDirectory("target/typedefTranslator/");
+ */
+ }
}
diff --git a/plugin/src/test/resources/typedefTranslator/Onos_Yang_1.yang b/plugin/src/test/resources/typedefTranslator/wihtout/Onos_Yang_1.yang
similarity index 100%
rename from plugin/src/test/resources/typedefTranslator/Onos_Yang_1.yang
rename to plugin/src/test/resources/typedefTranslator/wihtout/Onos_Yang_1.yang
diff --git a/plugin/src/test/resources/typedefTranslator/with/Onos_Yang_1.yang b/plugin/src/test/resources/typedefTranslator/with/Onos_Yang_1.yang
new file mode 100644
index 0000000..c09e372
--- /dev/null
+++ b/plugin/src/test/resources/typedefTranslator/with/Onos_Yang_1.yang
@@ -0,0 +1,201 @@
+module typedef {
+
+ yang-version "1";
+ namespace "http://rob.sh/yang/test/list";
+ prefix "foo";
+
+ import remote { prefix defn; }
+
+ organization "BugReports Inc";
+ contact "A bug reporter";
+
+ description
+ "A test module";
+ revision 2014-01-01 {
+ description "april-fools";
+ reference "fooled-you";
+ }
+
+ typedef derived-string-type {
+ type string;
+ }
+
+ typedef restricted-integer-type {
+ type uint16 {
+ range 0..64;
+ }
+ }
+
+ typedef bgp-session-direction {
+ type enumeration {
+ enum INBOUND;
+ enum OUTBOUND;
+ }
+ }
+
+ typedef new-string-type {
+ type string;
+ default "defaultValue";
+ }
+
+ typedef restricted-inherit {
+ type string {
+ pattern "^a.*";
+ }
+ }
+
+ typedef restricted-int-inherit {
+ type int8 {
+ range 0..100;
+ }
+ }
+
+ typedef parent-union {
+ type union {
+ type string {
+ pattern "a.*";
+ }
+ type string {
+ pattern "b.*";
+ }
+ }
+ }
+
+ typedef child-union {
+ type union {
+ type parent-union;
+ type string {
+ pattern "z.*";
+ }
+ }
+ }
+
+ typedef union-included {
+ type union {
+ type string {
+ pattern "a.*";
+ }
+ type string {
+ pattern "b.*";
+ }
+ }
+ }
+
+ identity identity_base;
+ identity IDONE {
+ base "identity_base";
+ }
+
+ identity IDTWO {
+ base "identity_base";
+ }
+
+ typedef identity_one {
+ type identityref {
+ base identity_base;
+ }
+ }
+
+ typedef referenced-leaf {
+ type leafref {
+ path "/container/target";
+ require-instance false;
+ }
+ }
+
+ grouping scoped-typedef {
+ typedef scoped-type {
+ type string {
+ pattern "a.*";
+ }
+ }
+
+ leaf scoped-leaf {
+ type scoped-type;
+ }
+ }
+
+ container container {
+ description
+ "A container";
+
+ leaf-list target {
+ type string;
+ description
+ "A target leaf for leafref checks";
+ }
+
+ leaf string {
+ type derived-string-type;
+ }
+
+ leaf integer {
+ type restricted-integer-type;
+ }
+
+ leaf stringdefault {
+ type derived-string-type;
+ default "aDefaultValue";
+ }
+
+ leaf integerdefault {
+ type restricted-integer-type;
+ default 10;
+ }
+
+ leaf new-string {
+ type new-string-type;
+ }
+
+ leaf remote-new-type {
+ type defn:remote-definition;
+ }
+
+ leaf session-dir {
+ type bgp-session-direction;
+ }
+
+ leaf remote-local-type {
+ type defn:remote-local-definition;
+ }
+
+ leaf inheritance {
+ type restricted-inherit {
+ pattern ".*k";
+ }
+ }
+
+ leaf int-inheritance {
+ type restricted-int-inherit {
+ range 2..5;
+ }
+ }
+
+ leaf-list stacked-union {
+ type child-union;
+ }
+
+ leaf include-of-include-definition {
+ type defn:hybrid-definition;
+ }
+
+ leaf identity-one-typedef {
+ type identity_one;
+ }
+
+ leaf union-with-union {
+ type union {
+ type union-included;
+ type string {
+ pattern "q.*";
+ }
+ }
+ }
+
+ leaf reference {
+ type referenced-leaf;
+ }
+
+ uses scoped-typedef;
+ }
+}
diff --git a/plugin/src/test/resources/typedefTranslator/with/remote.yang b/plugin/src/test/resources/typedefTranslator/with/remote.yang
new file mode 100644
index 0000000..409f04f
--- /dev/null
+++ b/plugin/src/test/resources/typedefTranslator/with/remote.yang
@@ -0,0 +1,33 @@
+module remote {
+ yang-version "1";
+ namespace "http://rob.sh/yang/test/typedef/remote";
+ prefix "remote";
+
+ import second-remote { prefix sr; }
+
+ organization "BugReports Inc";
+ contact "A bug reporter";
+
+ description
+ "A test module";
+ revision 2014-01-01 {
+ description "april-fools";
+ reference "fooled-you";
+ }
+
+ typedef remote-definition {
+ type string;
+ }
+
+ typedef remote-local-definition {
+ type local-definition;
+ }
+
+ typedef local-definition {
+ type string;
+ }
+
+ typedef hybrid-definition {
+ type sr:second-remote-definition;
+ }
+}
diff --git a/plugin/src/test/resources/typedefTranslator/with/second-remote.yang b/plugin/src/test/resources/typedefTranslator/with/second-remote.yang
new file mode 100644
index 0000000..c106d89
--- /dev/null
+++ b/plugin/src/test/resources/typedefTranslator/with/second-remote.yang
@@ -0,0 +1,21 @@
+module second-remote {
+ yang-version "1";
+ namespace "http://rob.sh/yang/test/typedef/second-remote";
+ prefix "second-remote";
+
+ organization "BugReports Inc";
+ contact "A bug reporter";
+
+ description
+ "A test module";
+ revision 2014-01-01 {
+ description "april-fools";
+ reference "fooled-you";
+ }
+
+ typedef second-remote-definition {
+ type string {
+ pattern "z.*";
+ }
+ }
+}