Remove use of SchemaContext.getQName() 19/90019/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 28 May 2020 04:12:51 +0000 (06:12 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 28 May 2020 04:12:51 +0000 (06:12 +0200)
The idea that SchemaContext has a QName is deprecated, and the methods
using it are themselves unused. Just remove the callers.

Change-Id: I507a96e7b0f2ecfd725e6b86623c80788f25b580
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java

index 8aa2420..d991346 100644 (file)
@@ -5,7 +5,6 @@
  * 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.controller.cluster.datastore.util;
 
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
@@ -34,7 +33,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
@@ -186,32 +184,6 @@ public final class TestModel {
             DATASTORE_TEST_NOTIFICATION_YANG);
     }
 
-    /**
-     * Returns a test document.
-     * <p/>
-     * <p/>
-     * <pre>
-     * test
-     *     outer-list
-     *          id 1
-     *     outer-list
-     *          id 2
-     *          inner-list
-     *                  name "one"
-     *          inner-list
-     *                  name "two"
-     *
-     * </pre>
-     */
-    public static NormalizedNode<?, ?> createDocumentOne(final SchemaContext schemaContext) {
-        return ImmutableContainerNodeBuilder
-                .create()
-                .withNodeIdentifier(
-                        new NodeIdentifier(schemaContext.getQName()))
-                .withChild(createTestContainer()).build();
-
-    }
-
     public static DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
         // Create a list of shoes
         // This is to test leaf list entry
@@ -279,9 +251,10 @@ public final class TestModel {
                 .withValue(ImmutableSet.of("foo", "bar"));
 
         // Create unkeyed list entry
-        UnkeyedListEntryNode unkeyedListEntry =
-                Builders.unkeyedListEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(
-                    UNKEYED_LIST_QNAME)).withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed-entry-name")).build();
+        UnkeyedListEntryNode unkeyedListEntry = Builders.unkeyedListEntryBuilder()
+                .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
+                .withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed-entry-name"))
+                .build();
 
         // Create YangInstanceIdentifier with all path arg types.
         YangInstanceIdentifier instanceID = YangInstanceIdentifier.create(
@@ -299,7 +272,7 @@ public final class TestModel {
         // Create the document
         return ImmutableContainerNodeBuilder
                 .create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
+                .withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
                 .withChild(myBits.build())
                 .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC))
                 .withChild(ImmutableNodes.leafNode(BOOLEAN_LEAF_QNAME, ENABLED))
@@ -310,13 +283,13 @@ public final class TestModel {
                 .withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, instanceID))
                 .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME))
                 .withChild(Builders.unkeyedListBuilder()
-                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME))
+                        .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
                         .withChild(unkeyedListEntry).build())
                 .withChild(Builders.choiceBuilder()
-                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TWO_THREE_QNAME))
+                        .withNodeIdentifier(new NodeIdentifier(TWO_THREE_QNAME))
                         .withChild(ImmutableNodes.leafNode(TWO_QNAME, "two")).build())
                 .withChild(Builders.orderedMapBuilder()
-                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ORDERED_LIST_QNAME))
+                        .withNodeIdentifier(new NodeIdentifier(ORDERED_LIST_QNAME))
                         .withValue(ImmutableList.<MapEntryNode>builder().add(
                                 mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "1").build(),
                                 mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "2").build()).build())
@@ -336,53 +309,44 @@ public final class TestModel {
     }
 
     public static MapEntryNode createAugmentedListEntry(final int id, final String name) {
-
         Set<QName> childAugmentations = new HashSet<>();
         childAugmentations.add(AUG_CONT_QNAME);
 
-        ContainerNode augCont =
-                ImmutableContainerNodeBuilder
-                        .create()
-                        .withNodeIdentifier(
-                                new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME))
-                        .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
-
+        ContainerNode augCont = ImmutableContainerNodeBuilder.create()
+                        .withNodeIdentifier(new NodeIdentifier(AUG_CONT_QNAME))
+                        .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name))
+                        .build();
 
-        final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier =
-                new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
 
+        final AugmentationIdentifier augmentationIdentifier = new AugmentationIdentifier(childAugmentations);
         final AugmentationNode augmentationNode =
                 Builders.augmentationBuilder()
                         .withNodeIdentifier(augmentationIdentifier).withChild(augCont)
                         .build();
 
-        return ImmutableMapEntryNodeBuilder
-                .create()
-                .withNodeIdentifier(
-                        YangInstanceIdentifier.NodeIdentifierWithPredicates.of(
-                                AUGMENTED_LIST_QNAME, ID_QNAME, id))
+        return ImmutableMapEntryNodeBuilder.create()
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(AUGMENTED_LIST_QNAME, ID_QNAME, id))
                 .withChild(ImmutableNodes.leafNode(ID_QNAME, id))
                 .withChild(augmentationNode).build();
     }
 
-
     public static ContainerNode createFamily() {
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode>
+        final DataContainerNodeBuilder<NodeIdentifier, ContainerNode>
             familyContainerBuilder = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
-                        new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME));
+                        new NodeIdentifier(FAMILY_QNAME));
 
         final CollectionNodeBuilder<MapEntryNode, MapNode> childrenBuilder =
                 mapNodeBuilder(CHILDREN_QNAME);
 
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
             firstChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
             secondChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
 
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
             firstGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
                     FIRST_GRAND_CHILD_ID);
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
             secondGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
                     SECOND_GRAND_CHILD_ID);
 
@@ -394,31 +358,27 @@ public final class TestModel {
                         FIRST_GRAND_CHILD_NAME));
 
         secondGrandChildBuilder.withChild(
-                ImmutableNodes
-                        .leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID))
-                .withChild(
-                        ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME,
-                                SECOND_GRAND_CHILD_NAME));
+                ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID))
+                .withChild(ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, SECOND_GRAND_CHILD_NAME));
 
         firstChildBuilder
                 .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID))
                 .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME))
-                .withChild(
-                        mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(
-                                firstGrandChildBuilder.build()).build());
+                .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME)
+                    .withChild(firstGrandChildBuilder.build())
+                    .build());
 
 
         secondChildBuilder
                 .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID))
                 .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME))
-                .withChild(
-                        mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(
-                                firstGrandChildBuilder.build()).build());
+                .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME)
+                    .withChild(firstGrandChildBuilder.build())
+                    .build());
 
         childrenBuilder.withChild(firstChildBuilder.build());
         childrenBuilder.withChild(secondChildBuilder.build());
 
         return familyContainerBuilder.withChild(childrenBuilder.build()).build();
     }
-
 }
index 4c3c5f7..27576ad 100644 (file)
@@ -15,13 +15,16 @@ import java.util.HashSet;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
@@ -33,12 +36,11 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public final class CompositeModel {
+    public static final QName TEST_QNAME = QName.create(
+        "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
 
-    public static final QName TEST_QNAME = QName
-            .create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
-
-    public static final QName AUG_QNAME = QName
-            .create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", "2014-03-13", "name");
+    public static final QName AUG_QNAME = QName.create(
+        "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:aug", "2014-03-13", "name");
 
     public static final QName AUG_CONTAINER = QName.create(AUG_QNAME, "aug-container");
     public static final QName AUG_INNER_CONTAINER = QName.create(AUG_QNAME, "aug-inner-container");
@@ -112,86 +114,56 @@ public final class CompositeModel {
             DATASTORE_TEST_NOTIFICATION_YANG);
     }
 
-    /**
-     * Returns a test document.
-     *
-     * <pre>
-     * test
-     *     outer-list
-     *          id 1
-     *     outer-list
-     *          id 2
-     *          inner-list
-     *                  name "one"
-     *          inner-list
-     *                  name "two"
-     *
-     * </pre>
-     */
-    public static NormalizedNode<?, ?> createDocumentOne(final SchemaContext schemaContext) {
-        return ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName()))
-                .withChild(createTestContainer()).build();
-
-    }
-
     public static ContainerNode createTestContainer() {
-
         final LeafSetEntryNode<Object> nike = ImmutableLeafSetEntryNodeBuilder.create()
-                .withNodeIdentifier(
-                        new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "nike"))
+                .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "nike"))
                 .withValue("nike").build();
         final LeafSetEntryNode<Object> puma = ImmutableLeafSetEntryNodeBuilder.create()
-                .withNodeIdentifier(
-                        new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "puma"))
+                .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "puma"))
                 .withValue("puma").build();
         final LeafSetNode<Object> shoes = ImmutableLeafSetNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "shoe")))
+                .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "shoe")))
                 .withChild(nike).withChild(puma).build();
 
         final LeafSetEntryNode<Object> five = ImmutableLeafSetEntryNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5))
+                .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5))
                 .withValue(5).build();
         final LeafSetEntryNode<Object> fifteen = ImmutableLeafSetEntryNodeBuilder.create()
-                .withNodeIdentifier(
-                        new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15))
+                .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15))
                 .withValue(15).build();
         final LeafSetNode<Object> numbers = ImmutableLeafSetNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "number")))
+                .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "number")))
                 .withChild(five).withChild(fifteen).build();
 
         Set<QName> childAugmentations = new HashSet<>();
         childAugmentations.add(AUG_QNAME);
-        final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier =
-                new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
+        final AugmentationIdentifier augmentationIdentifier = new AugmentationIdentifier(childAugmentations);
         final AugmentationNode augmentationNode = Builders.augmentationBuilder()
                 .withNodeIdentifier(augmentationIdentifier).withChild(ImmutableNodes.leafNode(AUG_QNAME, "First Test"))
                 .build();
         return ImmutableContainerNodeBuilder.create()
-                .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME))
+                .withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
                 .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)).withChild(augmentationNode).withChild(shoes)
                 .withChild(numbers).withChild(mapNodeBuilder(OUTER_LIST_QNAME)
                         .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)).withChild(BAR_NODE).build())
                 .build();
-
     }
 
     public static ContainerNode createFamily() {
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> familyContainerBuilder =
-            ImmutableContainerNodeBuilder.create().withNodeIdentifier(
-                    new YangInstanceIdentifier.NodeIdentifier(FAMILY_QNAME));
+        final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> familyContainerBuilder =
+            ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(FAMILY_QNAME));
 
         final CollectionNodeBuilder<MapEntryNode, MapNode> childrenBuilder = mapNodeBuilder(CHILDREN_QNAME);
 
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
             firstChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
             secondChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
 
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
             firstGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
                     FIRST_GRAND_CHILD_ID);
-        final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode>
+        final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
             secondGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
                     SECOND_GRAND_CHILD_ID);
 
@@ -214,5 +186,4 @@ public final class CompositeModel {
 
         return familyContainerBuilder.withChild(childrenBuilder.build()).build();
     }
-
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.