Fix case-related augment test 33/74633/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Jun 2018 09:50:05 +0000 (11:50 +0200)
committerStephen Kitt <skitt@redhat.com>
Mon, 30 Jul 2018 09:41:24 +0000 (11:41 +0200)
The test model used in this test is not valid, as it introduces
same container/leaf as both an augmentation of the list and as an
augmentation of that list's choice, leading to the leaf/container
being defined twice in the list's data tree hierarchy.

Change-Id: I582b53ea942f71141e98e14aa0f23878af339b86
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7a0e6a60c9d71a08f0b981e812850675f802a752)

binding/mdsal-binding-dom-codec/src/test/java/org/opendaylight/mdsal/binding/dom/codec/test/CaseSubstitutionTest.java
binding/mdsal-binding-test-model/src/main/yang/opendaylight-mdsal-augment-test.yang
binding/mdsal-binding-test-model/src/main/yang/opendaylight-mdsal-binding-test.yang
binding2/mdsal-binding2-test-model/src/main/yang/opendaylight-mdsal-augment-test.yang
binding2/mdsal-binding2-test-model/src/main/yang/opendaylight-mdsal-binding-test.yang

index 1d1f0caeee06d8bdd632fe4ed08291319d3ba9fd..6c8df5070248e9ccd494911d3e884877c6a09edc 100644 (file)
@@ -21,11 +21,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.te
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ContainerWithUsesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.complex.from.grouping.ListViaUses;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.put.top.input.top.level.list.choice.in.list.ComplexViaUsesWithDifferentNameBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.top.level.list.choice.in.list.ComplexViaUsesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.put.top.input.choice.list.choice.in.choice.list.ComplexViaUsesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.list.choice.in.choice.list.ComplexViaUsesWithDifferentNameBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.ChoiceList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.ChoiceListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.ChoiceListKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -34,8 +36,12 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 public class CaseSubstitutionTest extends AbstractBindingRuntimeTest {
 
     private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
+    private static final ChoiceListKey CHOICE_FOO_KEY = new ChoiceListKey("foo");
+
     private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
             .child(TopLevelList.class, TOP_FOO_KEY).build();
+    private static final InstanceIdentifier<ChoiceList> BA_CHOICE_LIST = InstanceIdentifier.builder(Top.class)
+            .child(ChoiceList.class, CHOICE_FOO_KEY).build();
     private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
             .augmentation(TreeLeafOnlyAugment.class);
     private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
@@ -54,16 +60,16 @@ public class CaseSubstitutionTest extends AbstractBindingRuntimeTest {
 
     @Test
     public void choiceInGroupingSubstituted() {
-        final TopLevelList baRpc = new TopLevelListBuilder()
-            .setKey(TOP_FOO_KEY)
-            .setChoiceInList(new ComplexViaUsesWithDifferentNameBuilder(createComplexData()).build())
+        final ChoiceList baRpc = new ChoiceListBuilder()
+            .setKey(CHOICE_FOO_KEY)
+            .setChoiceInChoiceList(new ComplexViaUsesWithDifferentNameBuilder(createComplexData()).build())
             .build();
-        final TopLevelList baTree = new TopLevelListBuilder()
-            .setKey(TOP_FOO_KEY)
-            .setChoiceInList(new ComplexViaUsesBuilder(createComplexData()).build())
+        final ChoiceList baTree = new ChoiceListBuilder()
+            .setKey(CHOICE_FOO_KEY)
+            .setChoiceInChoiceList(new ComplexViaUsesBuilder(createComplexData()).build())
             .build();
-        final NormalizedNode<?, ?> domTreeEntry = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, baTree).getValue();
-        final NormalizedNode<?, ?> domRpcEntry = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, baRpc).getValue();
+        final NormalizedNode<?, ?> domTreeEntry = registry.toNormalizedNode(BA_CHOICE_LIST, baTree).getValue();
+        final NormalizedNode<?, ?> domRpcEntry = registry.toNormalizedNode(BA_CHOICE_LIST, baRpc).getValue();
         assertEquals(domTreeEntry, domRpcEntry);
     }
 
index faaea8535fd81c9ab5c59a07ded4672a39138f9a..4f452997331824ccd14842da79c805122cb79a8c 100644 (file)
@@ -127,9 +127,6 @@ module opendaylight-mdsal-augment-test {
         case simple-via-uses {
             uses leaf-from-grouping;
         }
-        case complex-via-uses {
-            uses complex-from-grouping;
-        }
         case empty-leaf {
             leaf empty-type {
                 type empty;
@@ -141,11 +138,20 @@ module opendaylight-mdsal-augment-test {
         case simple-via-uses {
             uses leaf-from-grouping;
         }
+    }
+
+    augment "/test:top/test:choice-list/test:choice-in-choice-list" {
         case complex-via-uses-with-different-name {
             uses complex-from-grouping;
         }
     }
 
+    augment "/test:put-top/test:input/test:choice-list/test:choice-in-choice-list" {
+        case complex-via-uses {
+            uses complex-from-grouping;
+        }
+    }
+
     augment "/test:top" {
         ext:augment-identifier top-choice-augment1;
         choice augment-choice1 {
index 0942c6d523f29b909b4ee8f063714faac968eaa0..35c1c17f2f1673df1bda0950d4f094b09990fb29 100644 (file)
@@ -77,6 +77,17 @@ module opendaylight-mdsal-binding-test {
             type string;
             ordered-by user;
         }
+
+        list choice-list {
+            key "name";
+            leaf name {
+                type string;
+            }
+
+            choice choice-in-choice-list {
+
+            }
+        }
     }
 
     grouping choice {
index faaea8535fd81c9ab5c59a07ded4672a39138f9a..661bb8a3bb6cfd63b0edfa43f4e6532b09673bb3 100644 (file)
@@ -127,9 +127,6 @@ module opendaylight-mdsal-augment-test {
         case simple-via-uses {
             uses leaf-from-grouping;
         }
-        case complex-via-uses {
-            uses complex-from-grouping;
-        }
         case empty-leaf {
             leaf empty-type {
                 type empty;
@@ -141,6 +138,15 @@ module opendaylight-mdsal-augment-test {
         case simple-via-uses {
             uses leaf-from-grouping;
         }
+    }
+
+    augment "/test:top/test:choice-list/test:choice-in-choice-list" {
+        case complex-via-uses {
+            uses complex-from-grouping;
+        }
+    }
+
+    augment "/test:put-top/test:input/test:choice-list/test:choice-in-choice-list" {
         case complex-via-uses-with-different-name {
             uses complex-from-grouping;
         }
index 0942c6d523f29b909b4ee8f063714faac968eaa0..35c1c17f2f1673df1bda0950d4f094b09990fb29 100644 (file)
@@ -77,6 +77,17 @@ module opendaylight-mdsal-binding-test {
             type string;
             ordered-by user;
         }
+
+        list choice-list {
+            key "name";
+            leaf name {
+                type string;
+            }
+
+            choice choice-in-choice-list {
+
+            }
+        }
     }
 
     grouping choice {