Remove DataPostPath
[netconf.git] / restconf / restconf-nb / src / test / java / org / opendaylight / restconf / nb / rfc8040 / databind / XmlChildBodyTest.java
index 9bad88ab6f68dedc9e022af64b8f749da75c9e7a..8ad3757d2e0eb324a8bf9db925826c07e1df6189 100644 (file)
@@ -12,23 +12,22 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import java.util.List;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
-import org.opendaylight.restconf.server.api.DataPostPath;
 import org.opendaylight.restconf.server.api.DatabindContext;
+import org.opendaylight.restconf.server.api.DatabindPath;
+import org.opendaylight.restconf.server.api.XmlChildBody;
 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.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.Inference;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 class XmlChildBodyTest extends AbstractBodyTest {
     private static final QName TOP_LEVEL_LIST = QName.create("foo", "2017-08-09", "top-level-list");
 
-    private static DataPostPath EMPTY_PATH;
-    private static DataPostPath CONT_PATH;
+    private static DatabindPath.Data EMPTY_PATH;
+    private static DatabindPath.Data CONT_PATH;
 
     @BeforeAll
     static void beforeAll() throws Exception {
@@ -37,10 +36,11 @@ class XmlChildBodyTest extends AbstractBodyTest {
         testFiles.addAll(loadFiles("/foo-xml-test/yang"));
         final var modelContext = YangParserTestUtils.parseYangFiles(testFiles);
 
-        CONT_PATH = new DataPostPath(DatabindContext.ofModel(modelContext),
-            Inference.ofDataTreePath(modelContext, CONT_QNAME), YangInstanceIdentifier.of(CONT_QNAME));
-        EMPTY_PATH = new DataPostPath(DatabindContext.ofModel(modelContext),
-            Inference.ofDataTreePath(modelContext), YangInstanceIdentifier.of());
+        final var contPath = YangInstanceIdentifier.of(CONT_QNAME);
+        final var databind = DatabindContext.ofModel(modelContext);
+        final var nodeAndStack = databind.schemaTree().enterPath(contPath).orElseThrow();
+        CONT_PATH = new DatabindPath.Data(databind, nodeAndStack.stack().toInference(), contPath, nodeAndStack.node());
+        EMPTY_PATH = new DatabindPath.Data(DatabindContext.ofModel(modelContext));
     }
 
     @Test
@@ -55,7 +55,7 @@ class XmlChildBodyTest extends AbstractBodyTest {
         final var entryId = NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST,
             QName.create(TOP_LEVEL_LIST, "key-leaf"), "key-value");
         assertEquals(List.of(new NodeIdentifier(TOP_LEVEL_LIST), entryId), payload.prefix());
-        assertEquals(Builders.mapEntryBuilder()
+        assertEquals(ImmutableNodes.newMapEntryBuilder()
             .withNodeIdentifier(entryId)
             .withChild(ImmutableNodes.leafNode(QName.create(TOP_LEVEL_LIST, "key-leaf"), "key-value"))
             .withChild(ImmutableNodes.leafNode(QName.create(TOP_LEVEL_LIST, "ordinary-leaf"), "leaf-value"))
@@ -76,9 +76,9 @@ class XmlChildBodyTest extends AbstractBodyTest {
 
         final var lflst11 = QName.create("augment:module:leaf:list", "2014-01-27", "lflst11");
         assertEquals(List.of(new NodeIdentifier(CONT1_QNAME)), payload.prefix());
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(CONT1_QNAME))
-            .withChild(Builders.leafSetBuilder()
+            .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                 .withNodeIdentifier(new NodeIdentifier(lflst11))
                 .withChildValue("lflst11_1")
                 .withChildValue("lflst11_2")
@@ -100,7 +100,7 @@ class XmlChildBodyTest extends AbstractBodyTest {
 
         final var contAugment = QName.create("augment:module", "2014-01-17", "cont-augment");
         assertEquals(List.of(new NodeIdentifier(contAugment)), payload.prefix());
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(contAugment))
             .withChild(ImmutableNodes.leafNode(QName.create(contAugment, "leaf1"), "stryng"))
             .build(), payload.body());
@@ -117,7 +117,7 @@ class XmlChildBodyTest extends AbstractBodyTest {
             new NodeIdentifier(QName.create(container1, "augment-choice1")),
             new NodeIdentifier(QName.create(container1, "augment-choice2")),
             new NodeIdentifier(container1)), payload.prefix());
-        assertEquals(Builders.containerBuilder()
+        assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(container1))
             .withChild(ImmutableNodes.leafNode(QName.create(container1, "case-choice-case-leaf1"), "stryng"))
             .build(), payload.body());
@@ -136,7 +136,7 @@ class XmlChildBodyTest extends AbstractBodyTest {
 
         final var fooBarContainer = new NodeIdentifier(QName.create("foo:module", "2016-09-29", "foo-bar-container"));
         assertEquals(List.of(fooBarContainer), payload.prefix());
-        assertEquals(Builders.containerBuilder().withNodeIdentifier(fooBarContainer).build(),
+        assertEquals(ImmutableNodes.newContainerBuilder().withNodeIdentifier(fooBarContainer).build(),
             payload.body());
     }
 
@@ -153,7 +153,7 @@ class XmlChildBodyTest extends AbstractBodyTest {
 
         final var fooBarContainer = new NodeIdentifier(QName.create("bar:module", "2016-09-29", "foo-bar-container"));
         assertEquals(List.of(fooBarContainer), payload.prefix());
-        assertEquals(Builders.containerBuilder().withNodeIdentifier(fooBarContainer).build(),
+        assertEquals(ImmutableNodes.newContainerBuilder().withNodeIdentifier(fooBarContainer).build(),
             payload.body());
     }
 }