Reproduce YANGTOOLS-1445 79/103279/1
authorSangwook Ha <sangwook.ha@verizon.com>
Tue, 12 Jul 2022 22:26:01 +0000 (15:26 -0700)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Nov 2022 19:00:19 +0000 (20:00 +0100)
Building effective model fails when unique statement is used in a
grouping used by another grouping.

Add a test case (the third one) to reproduce the issue. There is no
issue when the unique statement is used in a single grouping like the
first two test cases.

JIRA: YANGTOOLS-1445
Change-Id: Idadfb6e8fc0bf724f0ff770d9fe986692e4b30eb
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
(cherry picked from commit 4bfd28bd20bcdb401b8a612ffbd6eadf8ca4b904)

parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1445Test.java [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/list-grouping/foo.yang [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/nested-grouping/foo.yang [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/top-level-grouping/foo.yang [new file with mode: 0644]

diff --git a/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1445Test.java b/parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1445Test.java
new file mode 100644 (file)
index 0000000..8fd380f
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2022 Verizon and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt;
+
+import org.junit.Test;
+
+public class YT1445Test  extends AbstractYangTest {
+    @Test
+    public void testUniqueTopLevelGrouping() {
+        assertEffectiveModel("/bugs/YT1445/top-level-grouping/foo.yang");
+    }
+
+    @Test
+    public void testUniqueInListGrouping() {
+        assertEffectiveModel("/bugs/YT1445/list-grouping/foo.yang");
+    }
+
+    @Test
+    public void testUniqueInGroupingUsedByGrouping() {
+        assertEffectiveModel("/bugs/YT1445/nested-grouping/foo.yang");
+    }
+}
diff --git a/parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/list-grouping/foo.yang b/parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/list-grouping/foo.yang
new file mode 100644 (file)
index 0000000..9aaf209
--- /dev/null
@@ -0,0 +1,23 @@
+module foo {
+  namespace "urn:foo";
+  prefix "foo";
+
+  grouping bar-group {
+    list bar {
+      key bar;
+      unique baz;
+
+      leaf bar {
+        type string;
+      }
+
+      leaf baz {
+        type string;
+      }
+    }
+  }
+
+  container foo {
+    uses bar-group;
+  }
+}
diff --git a/parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/nested-grouping/foo.yang b/parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/nested-grouping/foo.yang
new file mode 100644 (file)
index 0000000..6ee6683
--- /dev/null
@@ -0,0 +1,27 @@
+module foo {
+  namespace "urn:foo";
+  prefix "foo";
+
+  grouping bar-group {
+    list bar {
+      key bar;
+      unique baz;
+
+      leaf bar {
+        type string;
+      }
+
+      leaf baz {
+        type string;
+      }
+    }
+  }
+
+  grouping foo-group {
+    container foo {
+      uses bar-group;
+    }
+  }
+
+  uses foo-group;
+}
diff --git a/parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/top-level-grouping/foo.yang b/parser/yang-parser-rfc7950/src/test/resources/bugs/YT1445/top-level-grouping/foo.yang
new file mode 100644 (file)
index 0000000..d5193ad
--- /dev/null
@@ -0,0 +1,23 @@
+module foo {
+  namespace "urn:foo";
+  prefix "foo";
+
+  grouping foo-group {
+    container foo {
+      list bar {
+        key bar;
+        unique baz;
+
+        leaf bar {
+          type string;
+        }
+
+        leaf baz {
+          type string;
+        }
+      }
+    }
+  }
+
+  uses foo-group;
+}