Migrate tests to use node.spi.ImmutableNodes 91/109591/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 3 Jan 2024 14:36:39 +0000 (15:36 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 3 Jan 2024 17:56:11 +0000 (17:56 +0000)
We have a few stragglers, migrate them.

JIRA: YANGTOOLS-1259
Change-Id: Ie21d13359c7ec8d4b10f3ca4193460c478acefc3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
16 files changed:
benchmarks/src/main/java/org/opendaylight/yangtools/yang/data/impl/tree/InMemoryDataTreeBenchmark.java
codec/yang-data-codec-binfmt/src/test/java/org/opendaylight/yangtools/yang/data/codec/binfmt/NormalizedNodeStreamReaderWriterTest.java
codec/yang-data-codec-binfmt/src/test/java/org/opendaylight/yangtools/yang/data/codec/binfmt/TestModel.java
codec/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemaOrderedNormalizedNodeWriterTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedNodeUtilsTest.java
data/yang-data-spi/src/main/java/org/opendaylight/yangtools/yang/data/spi/node/ImmutableNodes.java
data/yang-data-spi/src/test/java/org/opendaylight/yangtools/yang/data/spi/node/impl/BuilderTest.java
data/yang-data-tree-ri/pom.xml
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/AbstractPrettyTreeTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug2690Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/Bug4454Test.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ConcurrentTreeModificationTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ConfigStatementValidationTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ListConstraintsValidation.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/ModificationMetadataTreeTest.java
data/yang-data-tree-ri/src/test/java/org/opendaylight/yangtools/yang/data/tree/impl/StoreTreeNodesTest.java

index f8022ac34d98d46e56b02920134326a1225fa661..9dd4a0b4ba4cc47a558c85938f01f8d6fd939517 100644 (file)
@@ -79,8 +79,11 @@ public class InMemoryDataTreeBenchmark {
             .withNodeIdentifier(BenchmarkModel.INNER_LIST);
 
         for (int i = 0; i < count; ++i) {
-            mapEntryBuilder
-                .withChild(ImmutableNodes.mapEntry(BenchmarkModel.INNER_LIST_QNAME, BenchmarkModel.NAME_QNAME, i));
+            mapEntryBuilder.withChild(ImmutableNodes.newMapEntryBuilder()
+                .withNodeIdentifier(
+                    NodeIdentifierWithPredicates.of(BenchmarkModel.INNER_LIST_QNAME, BenchmarkModel.NAME_QNAME, i))
+                .withChild(ImmutableNodes.leafNode(BenchmarkModel.NAME_QNAME, i))
+                .build());
         }
 
         return mapEntryBuilder.build();
index ae64f2d49140cf3fbadcaf2e60046b7df08d4a95..6f28ff6b5a7594ed59b83c801c49a2d701ac6e6d 100644 (file)
@@ -89,7 +89,11 @@ class NormalizedNodeStreamReaderWriterTest {
             .withChild(ImmutableNodes.leafNode(TestModel.EMPTY_QNAME, Empty.value()))
             .withChild(ImmutableNodes.newUserMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.ORDERED_LIST_QNAME))
-                .withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME, TestModel.ID_QNAME, 11))
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(
+                        NodeIdentifierWithPredicates.of(TestModel.ORDERED_LIST_ENTRY_QNAME, TestModel.ID_QNAME, 11))
+                    .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, 11))
+                    .build())
                 .build())
             .build();
     }
index ef0900095796c9b4c161fc397409ef0b4cefdf3c..e3db488e2b34f1f98359b1e65df6b1b0aa983b5b 100644 (file)
@@ -79,8 +79,14 @@ public final class TestModel {
         .withChild(ImmutableNodes.leafNode(ID_QNAME, TWO_ID))
         .withChild(ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(INNER_LIST_QNAME))
-            .withChild(ImmutableNodes.mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME))
-            .withChild(ImmutableNodes.mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME))
+            .withChild(ImmutableNodes.newMapEntryBuilder()
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME))
+                .withChild(ImmutableNodes.leafNode(NAME_QNAME, TWO_ONE_NAME))
+                .build())
+            .withChild(ImmutableNodes.newMapEntryBuilder()
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME))
+                .withChild(ImmutableNodes.leafNode(NAME_QNAME, TWO_TWO_NAME))
+                .build())
             .build())
         .build();
 
@@ -121,8 +127,16 @@ public final class TestModel {
                 .build())
             .withChild(ImmutableNodes.newUserMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ORDERED_LIST_QNAME))
-                .withChild(ImmutableNodes.mapEntry(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "1"))
-                .withChild(ImmutableNodes.mapEntry(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "2"))
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(
+                        NodeIdentifierWithPredicates.of(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "1"))
+                    .withChild(ImmutableNodes.leafNode(ORDERED_LIST_ENTRY_QNAME, "1"))
+                    .build())
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(
+                        NodeIdentifierWithPredicates.of(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "2"))
+                    .withChild(ImmutableNodes.leafNode(ORDERED_LIST_ENTRY_QNAME, "2"))
+                    .build())
                 .build())
             // Create a list of shoes
             .withChild(ImmutableNodes.newSystemLeafSetBuilder()
@@ -151,7 +165,10 @@ public final class TestModel {
                 .build())
             .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(OUTER_LIST_QNAME))
-                .withChild(ImmutableNodes.mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(OUTER_LIST_QNAME, ID_QNAME, ONE_ID))
+                    .withChild(ImmutableNodes.leafNode(ID_QNAME, ONE_ID))
+                    .build())
                 .withChild(BAR_NODE)
                 .build());
     }
index 475facb2a5b878f4409e05c3679691669a341765..56f2308243cf0240fd636975f7386a9b159da341 100644 (file)
@@ -17,6 +17,7 @@ import org.junit.jupiter.params.provider.ArgumentsSource;
 import org.opendaylight.yangtools.yang.common.QName;
 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.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.SchemaOrderedNormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -68,14 +69,10 @@ class SchemaOrderedNormalizedNodeWriterTest {
                             createQName(FOO_NAMESPACE, NAME_NODE), "policy1"))
                         .withChild(ImmutableNodes.newUserMapBuilder()
                             .withNodeIdentifier(getNodeIdentifier(FOO_NAMESPACE, RULE_NODE))
-                            .withChild(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
-                                createQName(FOO_NAMESPACE, NAME_NODE), "rule1"))
-                            .withChild(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
-                                createQName(FOO_NAMESPACE, NAME_NODE), "rule2"))
-                            .withChild(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
-                                createQName(FOO_NAMESPACE, NAME_NODE), "rule3"))
-                            .withChild(ImmutableNodes.mapEntry(createQName(FOO_NAMESPACE, RULE_NODE),
-                                createQName(FOO_NAMESPACE, NAME_NODE), "rule4"))
+                            .withChild(newRule("rule1"))
+                            .withChild(newRule("rule2"))
+                            .withChild(newRule("rule3"))
+                            .withChild(newRule("rule4"))
                             .build())
                         .build())
                     .withChild(ImmutableNodes.newMapEntryBuilder()
@@ -117,6 +114,14 @@ class SchemaOrderedNormalizedNodeWriterTest {
         assertFalse(diff.hasDifferences(), diff.toString());
     }
 
+    private static MapEntryNode newRule(final String ruleName) {
+        final var name = createQName(FOO_NAMESPACE, NAME_NODE);
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(createQName(FOO_NAMESPACE, RULE_NODE), name, ruleName))
+            .withChild(ImmutableNodes.leafNode(name, ruleName))
+            .build();
+    }
+
     @ParameterizedTest(name = "{0}")
     @ArgumentsSource(TestFactories.class)
     void testWriteOrder(final String factoryMode, final XMLOutputFactory factory) throws Exception {
index bc054d4148eadeb164252dbb45492f4f0e844c28..e3c44b0ab9b4936ed125e03d2de765d453ddd07c 100644 (file)
@@ -88,14 +88,23 @@ class NormalizedNodeUtilsTest {
             .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
             .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(LIST_A_QNAME))
-                .withChild(ImmutableNodes.mapEntry(LIST_A_QNAME, LEAF_A_QNAME, FOO))
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_A_QNAME, LEAF_A_QNAME, FOO))
+                    .withChild(ImmutableNodes.leafNode(LEAF_A_QNAME, FOO))
+                    .build())
                 .withChild(ImmutableNodes.newMapEntryBuilder()
                     .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_A_QNAME, LEAF_A_QNAME, BAR))
                     .withChild(ImmutableNodes.leafNode(LEAF_A_QNAME, BAR))
                     .withChild(ImmutableNodes.newSystemMapBuilder()
                         .withNodeIdentifier(new NodeIdentifier(LIST_B_QNAME))
-                        .withChild(ImmutableNodes.mapEntry(LIST_B_QNAME, LEAF_B_QNAME, ONE))
-                        .withChild(ImmutableNodes.mapEntry(LIST_B_QNAME, LEAF_B_QNAME, TWO))
+                        .withChild(ImmutableNodes.newMapEntryBuilder()
+                            .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_B_QNAME, LEAF_B_QNAME, ONE))
+                            .withChild(ImmutableNodes.leafNode(LEAF_B_QNAME, ONE))
+                            .build())
+                        .withChild(ImmutableNodes.newMapEntryBuilder()
+                            .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_B_QNAME, LEAF_B_QNAME, TWO))
+                            .withChild(ImmutableNodes.leafNode(LEAF_B_QNAME, TWO))
+                            .build())
                         .build())
                     .build())
                 .build())
index fd84192406c009489b0bbd1fdfab79eba5cd30b0..14a36f53e04c46898ac85c7c44716e1e93c6c8d9 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.spi.node;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QName;
 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.AnydataNode;
 import org.opendaylight.yangtools.yang.data.api.schema.AnyxmlNode;
@@ -71,14 +70,6 @@ public final class ImmutableNodes {
         return leafNode(NodeIdentifier.create(name), value);
     }
 
-    public static @NonNull MapEntryNode mapEntry(final NodeIdentifierWithPredicates name) {
-        return BUILDER_FACTORY.newMapEntryBuilder(name.size()).withNodeIdentifier(name).build();
-    }
-
-    public static @NonNull MapEntryNode mapEntry(final QName listName, final QName keyName, final Object keyValue) {
-        return mapEntry(NodeIdentifierWithPredicates.of(listName, keyName, keyValue));
-    }
-
     public static <T> @NonNull LeafSetEntryNode<T> leafSetEntry(final NodeWithValue<T> name) {
         return ImmutableLeafSetEntryNode.of(name);
     }
index 7de4f229b64ba576d6d6dbf4aa3a370fda40dcc6..724a1e8bf1518e7f1c5161c78d7b3be72ff73453 100644 (file)
@@ -36,12 +36,18 @@ class BuilderTest {
     private static final NodeIdentifier NODE_IDENTIFIER_LIST = NodeIdentifier.create(LIST_MAIN);
     private static final NodeIdentifier NODE_IDENTIFIER_LEAF_LIST = NodeIdentifier.create(LEAF_LIST_MAIN);
     private static final NodeIdentifier NODE_IDENTIFIER_LEAF = NodeIdentifier.create(LIST_MAIN_CHILD_QNAME_1);
-    private static final MapEntryNode LIST_MAIN_CHILD_1 = ImmutableNodes.mapEntry(
-        NodeIdentifierWithPredicates.of(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 1));
-    private static final MapEntryNode LIST_MAIN_CHILD_2 = ImmutableNodes.mapEntry(
-        NodeIdentifierWithPredicates.of(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 2));
-    private static final MapEntryNode LIST_MAIN_CHILD_3 = ImmutableNodes.mapEntry(
-        NodeIdentifierWithPredicates.of(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 3));
+    private static final MapEntryNode LIST_MAIN_CHILD_1 = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 1))
+        .withChild(ImmutableNodes.leafNode(LIST_MAIN_CHILD_QNAME_1, 1))
+        .build();
+    private static final MapEntryNode LIST_MAIN_CHILD_2 = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 2))
+        .withChild(ImmutableNodes.leafNode(LIST_MAIN_CHILD_QNAME_1, 2))
+        .build();
+    private static final MapEntryNode LIST_MAIN_CHILD_3 = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 3))
+        .withChild(ImmutableNodes.leafNode(LIST_MAIN_CHILD_QNAME_1, 3))
+        .build();
     private static final int SIZE = 3;
     private static final NodeWithValue<String> BAR_PATH = new NodeWithValue<>(LEAF_LIST_MAIN, "bar");
     private static final LeafSetEntryNode<String> LEAF_SET_ENTRY_NODE =
index d472c952d3d0b3b749c10d88375cf0222490a2ac..aebf404fecece5c9b5bffdde1ae2e2686a297aa1 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-model-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-model-spi</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-model-util</artifactId>
index 2e45119ddccd9e08f6573af70b00eb7a802136e4..c7c6a67f35dfd5f22d4d9c8dd48c49540a49ff7e 100644 (file)
@@ -106,19 +106,26 @@ abstract class AbstractPrettyTreeTest {
     protected static MapNode createMapNode() {
         return ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(LIST_A_QNAME))
-            .withChild(ImmutableNodes.mapEntry(LIST_A_QNAME, LEAF_A_QNAME, "foo"))
+            .withChild(createMapEntry(LIST_A_QNAME, LEAF_A_QNAME, "foo"))
             .withChild(createMapEntryNode())
             .build();
     }
 
+    private static MapEntryNode createMapEntry(final QName list, final QName key, final String value) {
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(list, key, value))
+            .withChild(ImmutableNodes.leafNode(key, value))
+            .build();
+    }
+
     protected static MapEntryNode createMapEntryNode() {
         return ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(NodeIdentifierWithPredicates.of(LIST_A_QNAME, LEAF_A_QNAME, "bar"))
             .withChild(ImmutableNodes.leafNode(LEAF_A_QNAME, "bar"))
             .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(LIST_B_QNAME))
-                .withChild(ImmutableNodes.mapEntry(LIST_B_QNAME, LEAF_B_QNAME, "one"))
-                .withChild(ImmutableNodes.mapEntry(LIST_B_QNAME, LEAF_B_QNAME, "two"))
+                .withChild(createMapEntry(LIST_B_QNAME, LEAF_B_QNAME, "one"))
+                .withChild(createMapEntry(LIST_B_QNAME, LEAF_B_QNAME, "two"))
                 .build())
             .build();
     }
@@ -139,7 +146,7 @@ abstract class AbstractPrettyTreeTest {
             .withNodeIdentifier(new NodeIdentifier(ANOTHER_QNAME))
             .withChild(ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(LIST_ANOTHER_NAMESPACE_QNAME))
-                .withChild(ImmutableNodes.mapEntry(LIST_ANOTHER_NAMESPACE_QNAME, LEAF_ANOTHER_NAMESPACE_QNAME,
+                .withChild(createMapEntry(LIST_ANOTHER_NAMESPACE_QNAME, LEAF_ANOTHER_NAMESPACE_QNAME,
                     "Leaf from another namespace value"))
                 .build())
             .build();
@@ -173,7 +180,7 @@ abstract class AbstractPrettyTreeTest {
     }
 
     protected static MapEntryNode createUserMapEntryNode() {
-        return ImmutableNodes.mapEntry(USER_MAP_QNAME, USER_MAP_ENTRY_QNAME, "User map entry value");
+        return createMapEntry(USER_MAP_QNAME, USER_MAP_ENTRY_QNAME, "User map entry value");
     }
 
     protected static UnkeyedListNode createUnkeyedListNode() {
index e77f81ca0e97430e4476356f850e70942217fc1a..8763c549c7566f73e79795a7040a1303f61ba19d 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 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.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
@@ -33,8 +34,14 @@ class Bug2690Test extends AbstractTestModelTest {
 
     @Test
     void testWriteMerge1() throws DataValidationFailedException {
-        final var fooEntryNode = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
-        final var barEntryNode = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2);
+        final var fooEntryNode = ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
+            .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, 1))
+            .build();
+        final var barEntryNode = ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2))
+            .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, 2))
+            .build();
         final var mapNode1 = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
                 .withChild(fooEntryNode).build();
index 1b376b54220fbffbd63f1bd18fa2df3afd7e1bf1..88ba6e7b2f5d10381d4e9e7a1183faae4117dc9d 100644 (file)
@@ -71,12 +71,18 @@ class Bug4454Test {
         .withNodeIdentifier(NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "baz"))
         .withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "baztest"))
         .build();
-    private final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
-            "foo");
-    private final MapEntryNode barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
-            "bar");
-    private final MapEntryNode bazEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
-            "baz");
+    private final MapEntryNode fooEntryNode = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo"))
+        .withChild(ImmutableNodes.leafNode(MIN_MAX_KEY_LEAF_QNAME, "foo"))
+        .build();
+    private final MapEntryNode barEntryNode = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar"))
+        .withChild(ImmutableNodes.leafNode(MIN_MAX_KEY_LEAF_QNAME, "bar"))
+        .build();
+    private final MapEntryNode bazEntryNode = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "baz"))
+        .withChild(ImmutableNodes.leafNode(MIN_MAX_KEY_LEAF_QNAME, "baz"))
+        .build();
     private final SystemMapNode mapNodeBazFuzWithNodes = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
             .withChild(bazEntryNode).withChild(bazEntryNodeWithValue).withChild(fooEntryNode)
@@ -425,8 +431,11 @@ class Bug4454Test {
 
     @Test
     void minMaxListNoMinMaxDeleteTest() throws DataValidationFailedException {
-        final var fooEntryNoMinMaxNode =
-                ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME, "foo");
+        final var fooEntryNoMinMaxNode = ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(
+                NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME, "foo"))
+            .withChild(ImmutableNodes.leafNode(MIN_MAX_KEY_LEAF_QNAME, "foo"))
+            .build();
         final var mapNode1 = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME_NO_MINMAX))
                 .withChild(fooEntryNoMinMaxNode).build();
index 8c286fa48fb288a030d1f67edc439e1fb838879c..bca2a0a82bc519df9f4494c9773a77520b1a92f0 100644 (file)
@@ -11,8 +11,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
 import java.util.Optional;
 import org.junit.jupiter.api.BeforeEach;
@@ -20,6 +18,7 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 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.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -48,13 +47,21 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
             .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
             .build();
 
-    private static final MapEntryNode FOO_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).build())
-            .build();
-
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).build())
-            .build();
+    private static final MapEntryNode FOO_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+        .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, ONE_ID))
+        .withChild(ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+            .build())
+        .build();
+
+    private static final MapEntryNode BAR_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+            .build())
+        .build();
 
     private DataTree inMemoryDataTree;
 
@@ -68,14 +75,20 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     private static ContainerNode createFooTestContainerNode() {
         return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(FOO_NODE).build())
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+                .withChild(FOO_NODE)
+                .build())
             .build();
     }
 
     private static ContainerNode createBarTestContainerNode() {
         return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(BAR_NODE).build())
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+                .withChild(BAR_NODE)
+                .build())
             .build();
     }
 
@@ -447,7 +460,8 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     void writeWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
@@ -478,7 +492,8 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     void writeMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
@@ -509,7 +524,8 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     void mergeWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
@@ -540,7 +556,8 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     void mergeMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
@@ -571,7 +588,8 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     void deleteWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
@@ -606,7 +624,8 @@ class ConcurrentTreeModificationTest extends AbstractTestModelTest {
     void deleteMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final var initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, emptyContainer(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
index f4a0a16a50979f4993993b9c9b6f3012935fa3f2..80c25795a6d3c08109508850b3afcafaeb1c75c8 100644 (file)
@@ -8,13 +8,12 @@
 package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 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.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -35,33 +34,54 @@ class ConfigStatementValidationTest extends AbstractTestModelTest {
             .builder(TestModel.OUTER_LIST_PATH).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
             .build();
 
-    private static final MapEntryNode INNER_FOO_ENTRY_NODE = ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME,
-            TestModel.NAME_QNAME, "foo");
-
-    private static final MapEntryNode INNER_BAR_ENTRY_NODE =
-            mapEntryBuilder(QName.create(TestModel.TEST_QNAME, "inner-list2"), TestModel.NAME_QNAME, "foo")
-                .withChild(ImmutableNodes.leafNode(TestModel.VALUE_QNAME, "value")).build();
-
-    private static final MapEntryNode FOO_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(INNER_FOO_ENTRY_NODE)
-                    .build())
-            .build();
-
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(INNER_BAR_ENTRY_NODE)
-                    .build())
-            .build();
+    private static final MapEntryNode INNER_FOO_ENTRY_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "foo"))
+        .withChild(ImmutableNodes.leafNode(TestModel.NAME_QNAME, "foo"))
+        .build();
+
+    private static final MapEntryNode INNER_BAR_ENTRY_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(QName.create(TestModel.TEST_QNAME, "inner-list2"),
+            TestModel.NAME_QNAME, "foo"))
+        .withChild(ImmutableNodes.leafNode(TestModel.NAME_QNAME, "foo"))
+        .withChild(ImmutableNodes.leafNode(TestModel.VALUE_QNAME, "value"))
+        .build();
+
+    private static final MapEntryNode FOO_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+        .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, ONE_ID))
+        .withChild(ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+            .withChild(INNER_FOO_ENTRY_NODE)
+            .build())
+        .build();
+
+    private static final MapEntryNode BAR_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+            .withChild(INNER_BAR_ENTRY_NODE)
+            .build())
+        .build();
 
     private static ContainerNode createFooTestContainerNode() {
         return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(FOO_NODE).build()).build();
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+                .withChild(FOO_NODE)
+                .build())
+            .build();
     }
 
     private static ContainerNode createBarTestContainerNode() {
         return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(BAR_NODE).build()).build();
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+                .withChild(BAR_NODE)
+                .build())
+            .build();
     }
 
     @Test
index c2ee6118fc997f3c759e9f2047c5614ab1c3337c..8e1f7e993cf5015539947e994caf375a34a39c29 100644 (file)
@@ -24,9 +24,11 @@ import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 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.YangNetconfErrorAware;
 import org.opendaylight.yangtools.yang.data.api.schema.DistinctNodeContainer;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -138,8 +140,8 @@ class ListConstraintsValidation {
     @Test
     void minMaxListTestPass() throws DataValidationFailedException {
 
-        final var fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo");
-        final var barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar");
+        final var fooEntryNode = minMaxEntry("foo");
+        final var barEntryNode = minMaxEntry("bar");
         final var mapNode1 = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
                 .withChild(fooEntryNode).build();
@@ -162,20 +164,25 @@ class ListConstraintsValidation {
         assertEquals(2, ((NormalizedNodeContainer<?>) minMaxListRead.orElseThrow()).size());
     }
 
+    private static MapEntryNode minMaxEntry(final String value) {
+        return ImmutableNodes.newMapEntryBuilder()
+            .withNodeIdentifier(NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, value))
+            .withChild(ImmutableNodes.leafNode(MIN_MAX_KEY_LEAF_QNAME, value))
+            .build();
+    }
+
     @Test
     void minMaxListFail() throws DataValidationFailedException {
         assertThrows(DataValidationFailedException.class, () -> {
             var modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
-            final var fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
-                    "foo");
-            final var barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
-                    "bar");
-            final var gooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
-                    "goo");
+            final var fooEntryNode = minMaxEntry("foo");
+            final var barEntryNode = minMaxEntry("bar");
+            final var gooEntryNode = minMaxEntry("goo");
             final var mapNode = ImmutableNodes.newSystemMapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
-                .withChild(fooEntryNode).build();
+                .withChild(fooEntryNode)
+                .build();
 
             final var fooPath = MIN_MAX_LIST_PATH.node(fooEntryNode.name());
             final var barPath = MIN_MAX_LIST_PATH.node(barEntryNode.name());
index 5d7f076cc184db514a54516ea9e9fe5f97a860ab..6e0b41bbd63859b0e8221652e0ca8cfcd19ae023 100644 (file)
@@ -12,14 +12,13 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
 import java.util.Optional;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 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.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
@@ -74,10 +73,21 @@ class ModificationMetadataTreeTest extends AbstractTestModelTest {
             .node(TestModel.VALUE_QNAME)
             .build();
 
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
-        .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
-            .withChild(ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
-            .withChild(ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME,TestModel.NAME_QNAME, TWO_TWO_NAME))
+    private static final MapEntryNode BAR_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+            .withChild(ImmutableNodes.newMapEntryBuilder()
+                .withNodeIdentifier(
+                    NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
+                .withChild(ImmutableNodes.leafNode(TestModel.NAME_QNAME, TWO_ONE_NAME))
+                .build())
+            .withChild(ImmutableNodes.newMapEntryBuilder()
+                .withNodeIdentifier(
+                    NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME,TestModel.NAME_QNAME, TWO_TWO_NAME))
+                .withChild(ImmutableNodes.leafNode(TestModel.NAME_QNAME, TWO_TWO_NAME))
+                .build())
             .build())
         .build();
 
@@ -116,8 +126,13 @@ class ModificationMetadataTreeTest extends AbstractTestModelTest {
     private static ContainerNode createTestContainer() {
         return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
-                .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(
+                        NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+                    .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, ONE_ID))
+                    .build())
                 .withChild(BAR_NODE).build())
             .build();
     }
index b02b262999e70ed362826850c2b6f76d8a394aa6..52c6cec5a536f432d3ab00c18c9d9ffb650ed62b 100644 (file)
@@ -10,16 +10,15 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
 import java.util.Optional;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 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.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNodes;
@@ -28,12 +27,8 @@ import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.Version;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class StoreTreeNodesTest extends AbstractTestModelTest {
-    private static final Logger LOG = LoggerFactory.getLogger(StoreTreeNodesTest.class);
 
+class StoreTreeNodesTest extends AbstractTestModelTest {
     private static final Short ONE_ID = 1;
     private static final Short TWO_ID = 2;
     private static final String TWO_ONE_NAME = "one";
@@ -54,10 +49,21 @@ public class StoreTreeNodesTest extends AbstractTestModelTest {
             .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME)
             .build();
 
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
-        .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
-            .withChild(ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
-            .withChild(ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME))
+    private static final MapEntryNode BAR_NODE = ImmutableNodes.newMapEntryBuilder()
+        .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, TWO_ID))
+        .withChild(ImmutableNodes.newSystemMapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+            .withChild(ImmutableNodes.newMapEntryBuilder()
+                .withNodeIdentifier(
+                    NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
+                .withChild(ImmutableNodes.leafNode(TestModel.NAME_QNAME, TWO_ONE_NAME))
+                .build())
+            .withChild(ImmutableNodes.newMapEntryBuilder()
+                .withNodeIdentifier(
+                    NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME))
+                .withChild(ImmutableNodes.leafNode(TestModel.NAME_QNAME, TWO_TWO_NAME))
+                .build())
             .build())
         .build();
 
@@ -102,12 +108,7 @@ public class StoreTreeNodesTest extends AbstractTestModelTest {
         final var inMemoryDataTreeSnapshot = new InMemoryDataTreeSnapshot(SCHEMA_CONTEXT,
                 TreeNode.of(createDocumentOne(), Version.initial()), rootOper);
         final var rootNode = inMemoryDataTreeSnapshot.getRootNode();
-        TreeNode foundNode = null;
-        try {
-            foundNode = StoreTreeNodes.findNodeChecked(rootNode, OUTER_LIST_1_PATH);
-        } catch (final IllegalArgumentException e) {
-            fail("Illegal argument exception was thrown and should not have been" + e.getMessage());
-        }
+        TreeNode foundNode = StoreTreeNodes.findNodeChecked(rootNode, OUTER_LIST_1_PATH);
         assertNotNull(foundNode);
     }
 
@@ -119,12 +120,8 @@ public class StoreTreeNodesTest extends AbstractTestModelTest {
         final var outerList1InvalidPath = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
                 .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3) //
                 .build();
-        try {
-            StoreTreeNodes.findNodeChecked(rootNode, outerList1InvalidPath);
-            fail("Illegal argument exception should have been thrown");
-        } catch (final IllegalArgumentException e) {
-            LOG.debug("Illegal argument exception was thrown as expected: '{}' - '{}'", e.getClass(), e.getMessage());
-        }
+        assertThrows(IllegalArgumentException.class,
+            () -> StoreTreeNodes.findNodeChecked(rootNode, outerList1InvalidPath));
     }
 
     @Test
@@ -162,8 +159,13 @@ public class StoreTreeNodesTest extends AbstractTestModelTest {
     private static ContainerNode createTestContainer() {
         return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
-                .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+            .withChild(ImmutableNodes.newSystemMapBuilder()
+                .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+                .withChild(ImmutableNodes.newMapEntryBuilder()
+                    .withNodeIdentifier(
+                        NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+                    .withChild(ImmutableNodes.leafNode(TestModel.ID_QNAME, ONE_ID))
+                    .build())
                 .withChild(BAR_NODE)
                 .build())
             .build();