[ONOS-6694] Multi augment with same name.
Change-Id: Ib319944816679c5c9a703ff771bdfbd0d6af67ab
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 156194e..97e2a86 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
@@ -435,4 +435,67 @@
YangPluginConfig.compileCode(COMP);
deleteDirectory(DIR);
}
+
+ /**
+ * Checks multiple augment handling which has the same name for open
+ * config YANG files.
+ *
+ * @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 processOpenConfigAugment() throws IOException,
+ ParserException, MojoExecutionException {
+
+ deleteDirectory(DIR);
+ String dir = "src/test/resources/augwithsamename/oc/";
+
+ Set<Path> paths = new HashSet<>();
+ for (String file : getYangFiles(dir)) {
+ 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);
+ }
+
+ /**
+ * Checks multiple augment handling which has the same name.
+ *
+ * @throws IOException if any error occurs during IO on files
+ * @throws ParserException if any error occurs during parsing
+ * @throws MojoExecutionException if any mojo operation fail
+ */
+ @Test
+ public void processSameAugName() throws IOException,
+ ParserException, MojoExecutionException {
+
+ deleteDirectory(DIR);
+ String dir = "src/test/resources/augwithsamename/multiaugwithsamename/";
+
+ Set<Path> paths = new HashSet<>();
+ for (String file : getYangFiles(dir)) {
+ 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/augwithsamename/multiaugwithsamename/module1.yang b/compiler/plugin/maven/src/test/resources/augwithsamename/multiaugwithsamename/module1.yang
new file mode 100644
index 0000000..fedf735
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augwithsamename/multiaugwithsamename/module1.yang
@@ -0,0 +1,14 @@
+module module1 {
+
+ namespace "urn:ietf:params:xml:ns:aug:module:1";
+
+ prefix mod-a;
+
+ container cont{
+ container val {
+ leaf-list create {
+ type string;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/augwithsamename/multiaugwithsamename/module2.yang b/compiler/plugin/maven/src/test/resources/augwithsamename/multiaugwithsamename/module2.yang
new file mode 100644
index 0000000..7ec09aa
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augwithsamename/multiaugwithsamename/module2.yang
@@ -0,0 +1,39 @@
+module module2 {
+
+ namespace "urn:ietf:params:xml:ns:aug:module:2";
+
+ prefix mod-b;
+
+ import module1 {
+ prefix mod-a;
+ }
+
+ augment "/mod-a:cont/mod-a:val" {
+ leaf arg {
+ type string;
+ }
+ }
+
+ augment "/mod-a:cont/mod-a:val" {
+ leaf-list arg-lis {
+ type string;
+ }
+ }
+
+ augment "/mod-a:cont/mod-a:val" {
+ container cont {
+ leaf ll {
+ type binary;
+ }
+ }
+ }
+
+ augment "/mod-a:cont/mod-a:val" {
+ list contlist {
+ key true;
+ leaf true {
+ type boolean;
+ }
+ }
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/augwithsamename/oc/openconfig-if-ip.yang b/compiler/plugin/maven/src/test/resources/augwithsamename/oc/openconfig-if-ip.yang
new file mode 100644
index 0000000..1c7a8ce
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augwithsamename/oc/openconfig-if-ip.yang
@@ -0,0 +1,69 @@
+module openconfig-if-ip {
+
+ yang-version "1";
+
+ namespace "http://openconfig.net/yang/interfaces/ip";
+
+ prefix "oc-ip";
+
+ import openconfig-interfaces {
+ prefix oc-if;
+ }
+
+ grouping ip-vrrp-top {
+ container vrrp {
+ list vrrp-group {
+ key "virtual-router-id";
+ leaf virtual-router-id {
+ type string;
+ }
+ }
+ }
+ }
+
+ grouping ipv4-top {
+ container ipv4 {
+ container addresses {
+ list address {
+ key "ip";
+ leaf ip {
+ type string;
+ }
+ }
+ }
+ }
+ }
+
+ grouping ipv6-top {
+ container ipv6 {
+ container addresses {
+ list address {
+ key "ip";
+ leaf ip {
+ type string;
+ }
+ }
+ }
+ }
+ }
+
+ augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" +
+ "oc-if:subinterface" {
+ uses ipv4-top;
+ }
+
+ augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" +
+ "oc-if:subinterface" {
+ uses ipv6-top;
+ }
+
+ augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" +
+ "oc-if:subinterface/oc-ip:ipv4/oc-ip:addresses/oc-ip:address" {
+ uses ip-vrrp-top;
+ }
+
+ augment "/oc-if:interfaces/oc-if:interface/oc-if:subinterfaces/" +
+ "oc-if:subinterface/oc-ip:ipv6/oc-ip:addresses/oc-ip:address" {
+ uses ip-vrrp-top;
+ }
+}
diff --git a/compiler/plugin/maven/src/test/resources/augwithsamename/oc/openconfig-interfaces.yang b/compiler/plugin/maven/src/test/resources/augwithsamename/oc/openconfig-interfaces.yang
new file mode 100644
index 0000000..2804dc6
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/augwithsamename/oc/openconfig-interfaces.yang
@@ -0,0 +1,42 @@
+module openconfig-interfaces {
+
+ yang-version "1";
+
+ namespace "http://openconfig.net/yang/interfaces";
+
+ prefix "oc-if";
+
+ contact
+ "OpenConfig working group
+ netopenconfig@googlegroups.com";
+
+ grouping subinterfaces-top {
+ container subinterfaces {
+ list subinterface {
+ key "index";
+ leaf index {
+ type int8;
+ }
+ }
+ }
+ }
+
+ grouping interfaces-top {
+ description
+ "Top-level grouping for interface configuration and
+ operational state data";
+
+ container interfaces {
+ list interface {
+ key "name";
+
+ leaf name {
+ type string;
+ }
+ uses subinterfaces-top;
+ }
+ }
+ }
+
+ uses interfaces-top;
+}