LeafEffectiveStatement should be a DataTreeEffectiveStatement 88/84988/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 8 Oct 2019 11:21:14 +0000 (13:21 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 8 Oct 2019 20:01:55 +0000 (22:01 +0200)
This is a conflicting model, which should understand it has conflicting
children.

JIRA: YANGTOOLS-857
Change-Id: I1bca05f9a3f053419d518ef2c9966978901b419f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/LeafEffectiveStatement.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT857Test.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/test/resources/bugs/YT857/foo.yang [new file with mode: 0644]

index dc97dd200fbbbf51352a6dbd1f3bc951130b8483..5bd3b93b2087bc9d8280c2611fa8641b91b80c93 100644 (file)
@@ -10,6 +10,6 @@ package org.opendaylight.yangtools.yang.model.api.stmt;
 import com.google.common.annotations.Beta;
 
 @Beta
-public interface LeafEffectiveStatement extends SchemaTreeEffectiveStatement<LeafStatement> {
+public interface LeafEffectiveStatement extends DataTreeEffectiveStatement<LeafStatement> {
 
 }
diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT857Test.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT857Test.java
new file mode 100644 (file)
index 0000000..7bda7a0
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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 static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+public class YT857Test {
+    @Test
+    public void testConflictDetection() throws Exception {
+        try {
+            StmtTestUtils.parseYangSource("/bugs/YT857/foo.yang");
+            fail("Conflict on models should have been detected");
+        } catch (ReactorException e) {
+            final Throwable cause = e.getCause();
+            assertThat(cause, instanceOf(SourceException.class));
+            assertThat(cause.getMessage(),
+                startsWith("Cannot add data tree child with name (foo)one, a conflicting child already exists"));
+        }
+    }
+}
diff --git a/yang/yang-parser-rfc7950/src/test/resources/bugs/YT857/foo.yang b/yang/yang-parser-rfc7950/src/test/resources/bugs/YT857/foo.yang
new file mode 100644 (file)
index 0000000..51d97ed
--- /dev/null
@@ -0,0 +1,28 @@
+module foo {
+    namespace foo;
+    prefix foo;
+
+    grouping flags {
+        leaf one {
+            type boolean;
+        }
+        leaf two {
+            type boolean;
+        }
+    }
+
+    grouping choice-grp {
+        choice flags {
+            case first {
+                uses flags;
+            }
+            case second {
+                uses flags;
+            }
+        }
+    }
+
+    container cont {
+        uses choice-grp;
+    }
+}