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 {
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
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"))
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")
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());
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());
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());
}
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());
}
}