augment linking prefix change defect fix and it's ut
Change-Id: I6cad4b47f374c78ef68414a7481b2b1197bfdd6e
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java
index 83969a2..f80c5d9 100644
--- a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/AugmentTranslatorTest.java
@@ -152,4 +152,37 @@
utilManager.translateToJava(yangPluginConfig);
deleteDirectory(DIR);
}
+
+ /**
+ * Checks the augment statements linking with prefix change from inter to.
+ * inter
+ *
+ * @throws IOException if any error occurs during IO on files
+ * @throws ParserException if any error occurs during parsing
+ * @throws MojoExecutionException if any mojo operation fails
+ */
+ @Test
+ public void processActnAugmentInterTranslator() throws IOException,
+ ParserException,
+ MojoExecutionException {
+
+ deleteDirectory(DIR);
+ String searchDir = "src/test/resources/actnInterAugments";
+
+ Set<Path> paths = new HashSet<>();
+ for (String file : getYangFiles(searchDir)) {
+ paths.add(Paths.get(file));
+ }
+
+ utilManager.createYangFileInfoSet(paths);
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ YangPluginConfig.compileCode(COMP);
+ deleteDirectory(DIR);
+ }
}
diff --git a/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-network-topology@2017-03-01.yang b/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-network-topology@2017-03-01.yang
new file mode 100644
index 0000000..c29a9cd
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-network-topology@2017-03-01.yang
@@ -0,0 +1,23 @@
+module ietf-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
+ prefix lnk;
+
+ import ietf-network {
+ prefix nd;
+ }
+
+ revision 2017-03-01 {
+ reference
+ "draft-ietf-i2rs-yang-network-topo-12";
+ }
+
+ augment "/nd:networks/nd:network" {
+ list link {
+ key "link-id";
+ leaf link-id {
+ type string;
+ }
+ }
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-network@2017-03-01.yang b/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-network@2017-03-01.yang
new file mode 100644
index 0000000..7f4fe71
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-network@2017-03-01.yang
@@ -0,0 +1,17 @@
+module ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-network";
+ prefix nd;
+ revision 2017-03-01 {
+ reference
+ "draft-ietf-i2rs-yang-network-topo-12";
+ }
+ container networks {
+ list network {
+ key "network-id";
+ leaf network-id {
+ type string;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-otn-topology@2017-04-25.yang b/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-otn-topology@2017-04-25.yang
new file mode 100644
index 0000000..19d9841
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-otn-topology@2017-04-25.yang
@@ -0,0 +1,61 @@
+module ietf-otn-topology {
+ yang-version 1;
+
+ namespace "urn:ietf:params:xml:ns:yang:ietf-otn-topology";
+ prefix "otntopo";
+
+ import ietf-network {
+ prefix "nd";
+ }
+
+ import ietf-network-topology {
+ prefix "lnk";
+ }
+
+ import ietf-te-topology {
+ prefix "tet";
+ }
+
+
+ revision 2017-04-25 {
+ description
+ "Revision 0.3";
+ reference
+ "draft-zhang-ccamp-l1-topo-yang-07.txt";
+ }
+
+
+ grouping otn-link-attributes {
+
+ list available-odu-info{
+ key "priority";
+ max-elements "8";
+
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ }
+
+ list odulist {
+ key "odu-type";
+
+ leaf odu-type {
+ type string;
+ }
+
+ leaf number {
+ type uint16;
+ }
+ }
+ }
+
+ leaf distance {
+ type uint32;
+ }
+ }
+
+ augment "/nd:networks/nd:network/lnk:link/tet:te/tet:config" {
+ uses otn-link-attributes;
+ }
+ }
diff --git a/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-te-topology@2017-03-12.yang b/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-te-topology@2017-03-12.yang
new file mode 100644
index 0000000..98054f8
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/actnInterAugments/ietf-te-topology@2017-03-12.yang
@@ -0,0 +1,26 @@
+module ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
+
+ prefix "tet";
+
+ import ietf-network {
+ prefix "nw";
+ }
+
+ import ietf-network-topology {
+ prefix "nt";
+ }
+
+ revision "2017-03-12" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ augment "/nw:networks/nw:network/nt:link" {
+ container te {
+ container config {
+ } // config
+ } // te
+ }
+}