Add ImmutableNode.newXYXBuilder() methods
[yangtools.git] / data / yang-data-tree-ri / src / test / java / org / opendaylight / yangtools / yang / data / tree / impl / MandatoryLeafTest.java
index 3d2c52bcd9ca0d00da246faa1056b58a9b3c96e9..802ced6adcb570797a3705405300fd46daa9f96b 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
 
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
@@ -17,7 +16,7 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.DataValidationFailedException;
@@ -49,14 +48,15 @@ class MandatoryLeafTest {
         final var inMemoryDataTree = initDataTree(true);
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
-        final var container = Builders.containerBuilder()
+        final var container = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(choice1Id)
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                    .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
-                    .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                    .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
+                    .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"),
+                        "leaf-value2"))
                     .build())
                 .build())
             .build();
@@ -74,7 +74,7 @@ class MandatoryLeafTest {
     void testCorrectMandatoryLeafChoiceWrite() throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree(true);
         // Container write
-        final var container = Builders.containerBuilder()
+        final var container = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
             .build();
 
@@ -88,12 +88,12 @@ class MandatoryLeafTest {
 
         // Choice write
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
-        final var choice = Builders.choiceBuilder()
+        final var choice = ImmutableNodes.newChoiceBuilder()
             .withNodeIdentifier(choice1Id)
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value"))
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                 .build())
             .build();
 
@@ -112,13 +112,14 @@ class MandatoryLeafTest {
             final var inMemoryDataTree = initDataTree(true);
             final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
-            final var container = Builders.containerBuilder()
+            final var container = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(choice1Id)
-                    .withChild(Builders.containerBuilder()
+                    .withChild(ImmutableNodes.newContainerBuilder()
                         .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                        .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                        .withChild(ImmutableNodes.leafNode(
+                            QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                         .build())
                     .build())
                 .build();
@@ -145,13 +146,14 @@ class MandatoryLeafTest {
         final var inMemoryDataTree = initDataTree(false);
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
-        final ContainerNode container = Builders.containerBuilder()
+        final ContainerNode container = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
-            .withChild(Builders.choiceBuilder()
+            .withChild(ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(choice1Id)
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                    .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                    .withChild(ImmutableNodes.leafNode(
+                        QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                     .build())
                 .build())
             .build();
@@ -169,7 +171,7 @@ class MandatoryLeafTest {
         assertThrows(IllegalArgumentException.class, () -> {
             final var inMemoryDataTree = initDataTree(true);
             // Container write
-            final var container = Builders.containerBuilder()
+            final var container = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
             final var modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
@@ -182,11 +184,12 @@ class MandatoryLeafTest {
 
             // Choice write
             final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
-            final var choice = Builders.choiceBuilder()
+            final var choice = ImmutableNodes.newChoiceBuilder()
                 .withNodeIdentifier(choice1Id)
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                    .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                    .withChild(ImmutableNodes.leafNode(
+                        QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                     .build())
                 .build();
 
@@ -211,7 +214,7 @@ class MandatoryLeafTest {
     void testDisabledValidationChoiceWrite() throws DataValidationFailedException {
         final var inMemoryDataTree = initDataTree(false);
         // Container write
-        final var container = Builders.containerBuilder()
+        final var container = ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
         final var modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
@@ -224,11 +227,11 @@ class MandatoryLeafTest {
 
         // Choice write
         final var choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
-        final var choice = Builders.choiceBuilder()
+        final var choice = ImmutableNodes.newChoiceBuilder()
             .withNodeIdentifier(choice1Id)
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont")))
-                .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
+                .withChild(ImmutableNodes.leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                 .build())
             .build();