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.api.schema.UnkeyedListNode;
import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
public abstract class AbstractPrettyTreeTest {
protected static final QName ROOT_QNAME = QName.create(
*
* @return A test node
*/
- protected static NormalizedNode createContainerNode() {
- return ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
- .withChild(createMapNode())
- .withChild(createChoiceNode())
- .withChild(createContainerFromAnotherNamespace())
- .withChild(createLeafNode())
- .withChild(createLeafSetNode())
- .withChild(createUserLeafSetNode())
- .withChild(createUserMapNode())
- .withChild(createUnkeyedListNode())
- .withChild(createAnyDataNode())
- .build();
+ protected static ContainerNode createContainerNode() {
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
+ .withChild(createMapNode())
+ .withChild(createChoiceNode())
+ .withChild(createContainerFromAnotherNamespace())
+ .withChild(createLeafNode())
+ .withChild(createLeafSetNode())
+ .withChild(createUserLeafSetNode())
+ .withChild(createUserMapNode())
+ .withChild(createUnkeyedListNode())
+ .withChild(createAnyDataNode())
+ .build();
}
protected static MapNode createMapNode() {
}
protected static ContainerNode createContainerFromAnotherNamespace() {
- return ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(ANOTHER_QNAME))
- .withChild(mapNodeBuilder(LIST_ANOTHER_NAMESPACE_QNAME)
- .withChild(mapEntry(LIST_ANOTHER_NAMESPACE_QNAME,
- LEAF_ANOTHER_NAMESPACE_QNAME,
- "Leaf from another namespace value"))
- .build())
- .build();
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(ANOTHER_QNAME))
+ .withChild(mapNodeBuilder(LIST_ANOTHER_NAMESPACE_QNAME)
+ .withChild(mapEntry(LIST_ANOTHER_NAMESPACE_QNAME, LEAF_ANOTHER_NAMESPACE_QNAME,
+ "Leaf from another namespace value"))
+ .build())
+ .build();
}
protected static LeafNode<String> createLeafNode() {
- return Builders.<String>leafBuilder()
- .withNodeIdentifier(NodeIdentifier.create(LEAF_QNAME))
- .withValue("Leaf value")
- .build();
+ return ImmutableNodes.leafNode(LEAF_QNAME, "Leaf value");
}
protected static LeafSetNode<String> createLeafSetNode() {
final String value = "Leaf set value";
- final LeafSetEntryNode<String> leafSetValue = Builders.<String>leafSetEntryBuilder()
+ return Builders.<String>leafSetBuilder()
+ .withNodeIdentifier(NodeIdentifier.create(LEAF_SET_QNAME))
+ .withValue(List.of(Builders.<String>leafSetEntryBuilder()
.withNodeIdentifier(new NodeWithValue<>(LEAF_SET_QNAME, value))
.withValue(value)
- .build();
- return Builders.<String>leafSetBuilder()
- .withNodeIdentifier(NodeIdentifier.create(LEAF_SET_QNAME))
- .withValue(List.of(leafSetValue))
- .build();
+ .build()))
+ .build();
}
protected static UserLeafSetNode<String> createUserLeafSetNode() {
import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
+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.impl.ImmutableContainerNodeBuilder;
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.DataTreeModification;
private void firstModification() throws DataValidationFailedException {
/* MERGE */
- SystemMapNode outerListNode = ImmutableNodes.mapNodeBuilder()
- .withNodeIdentifier(NodeIdentifier.create(outerList))
- .withChild(createOuterListEntry("1", "o-1"))
- .withChild(createOuterListEntry("2", "o-2"))
- .withChild(createOuterListEntry("3", "o-3"))
- .build();
- ContainerNode rootContainerNode = createRootContainerBuilder()
- .withChild(createSubRootContainerBuilder().withChild(outerListNode).build())
- .build();
YangInstanceIdentifier path = YangInstanceIdentifier.of(root);
DataTreeModification modification = inMemoryDataTree.takeSnapshot().newModification();
- modification.merge(path, rootContainerNode);
+ modification.merge(path, createRootContainerBuilder()
+ .withChild(createSubRootContainerBuilder()
+ .withChild(ImmutableNodes.mapNodeBuilder()
+ .withNodeIdentifier(NodeIdentifier.create(outerList))
+ .withChild(createOuterListEntry("1", "o-1"))
+ .withChild(createOuterListEntry("2", "o-2"))
+ .withChild(createOuterListEntry("3", "o-3"))
+ .build())
+ .build())
+ .build());
/* WRITE INNER LIST WITH ENTRIES*/
- SystemMapNode innerListNode = createInnerListBuilder()
- .withChild(createInnerListEntry("a", "i-a"))
- .withChild(createInnerListEntry("b", "i-b"))
- .build();
path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2"))
.node(innerList);
- modification.write(path, innerListNode);
+ modification.write(path, createInnerListBuilder()
+ .withChild(createInnerListEntry("a", "i-a"))
+ .withChild(createInnerListEntry("b", "i-b"))
+ .build());
/* COMMIT */
modification.ready();
private void secondModification(final int testScenarioNumber) throws DataValidationFailedException {
/* MERGE */
- SystemMapNode outerListNode = ImmutableNodes.mapNodeBuilder()
- .withNodeIdentifier(NodeIdentifier.create(outerList))
- .withChild(createOuterListEntry("3", "o-3"))
- .withChild(createOuterListEntry("4", "o-4"))
- .withChild(createOuterListEntry("5", "o-5"))
- .build();
-
ContainerNode rootContainerNode = createRootContainerBuilder()
- .withChild(createSubRootContainerBuilder().withChild(outerListNode).build())
+ .withChild(createSubRootContainerBuilder()
+ .withChild(ImmutableNodes.mapNodeBuilder()
+ .withNodeIdentifier(NodeIdentifier.create(outerList))
+ .withChild(createOuterListEntry("3", "o-3"))
+ .withChild(createOuterListEntry("4", "o-4"))
+ .withChild(createOuterListEntry("5", "o-5"))
+ .build())
+ .build())
.build();
YangInstanceIdentifier path = YangInstanceIdentifier.of(root);
DataTreeModification modification = inMemoryDataTree.takeSnapshot().newModification();
modification.merge(path, rootContainerNode);
- if (testScenarioNumber == 1) {
- /* WRITE EMPTY INNER LIST */
- writeEmptyInnerList(modification, "2");
- } else if (testScenarioNumber == 2) {
- /* WRITE INNER LIST ENTRY */
- MapEntryNode innerListEntryA = createInnerListEntry("a", "i-a-2");
- path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2"))
+ switch (testScenarioNumber) {
+ case 1:
+ /* WRITE EMPTY INNER LIST */
+ writeEmptyInnerList(modification, "2");
+ break;
+ case 2: {
+ /* WRITE INNER LIST ENTRY */
+ MapEntryNode innerListEntryA = createInnerListEntry("a", "i-a-2");
+ path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2"))
.node(innerList).node(createInnerListEntryPath("a"));
- modification.write(path, innerListEntryA);
- } else if (testScenarioNumber == 3) {
- /* WRITE INNER LIST WITH ENTRIES */
- SystemMapNode innerListNode = createInnerListBuilder().withChild(createInnerListEntry("a", "i-a-3"))
- .withChild(createInnerListEntry("c", "i-c")).build();
- path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2"))
+ modification.write(path, innerListEntryA);
+ break;
+ }
+ case 3: {
+ /* WRITE INNER LIST WITH ENTRIES */
+ path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2"))
.node(innerList);
- modification.write(path, innerListNode);
+ modification.write(path, createInnerListBuilder()
+ .withChild(createInnerListEntry("a", "i-a-3"))
+ .withChild(createInnerListEntry("c", "i-c"))
+ .build());
+ break;
+ }
+ default:
+ break;
}
/* COMMIT */
}
private DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createRootContainerBuilder() {
- return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(root));
+ return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(root));
}
private DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createSubRootContainerBuilder() {
- return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(subRoot));
+ return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(subRoot));
}
private CollectionNodeBuilder<MapEntryNode, SystemMapNode> createInnerListBuilder() {
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
+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.impl.ImmutableLeafSetEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
private static final YangInstanceIdentifier MIN_MAX_LEAF_LIST_PATH = YangInstanceIdentifier
.builder(MASTER_CONTAINER_PATH).node(MIN_MAX_LEAF_LIST_QNAME).build();
- private final MapEntryNode fooEntryNodeWithValue = ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(
- NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo"))
- .withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "footest")).build();
- private final MapEntryNode bazEntryNodeWithValue = ImmutableMapEntryNodeBuilder.create().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 fooEntryNodeWithValue = Builders.mapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo"))
+ .withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "footest"))
+ .build();
+ private final MapEntryNode bazEntryNodeWithValue = Builders.mapEntryBuilder()
+ .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,
final NodeWithValue<?> barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar");
final NodeWithValue<?> gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo");
- final LeafSetEntryNode<Object> barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create()
+ final LeafSetEntryNode<Object> barLeafSetEntry = Builders.leafSetEntryBuilder()
.withNodeIdentifier(barPath)
.withValue("bar").build();
- final LeafSetEntryNode<Object> gooLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create()
+ final LeafSetEntryNode<Object> gooLeafSetEntry = Builders.leafSetEntryBuilder()
.withNodeIdentifier(gooPath)
.withValue("goo").build();
- final LeafSetNode<Object> fooLeafSetNode = ImmutableLeafSetNodeBuilder.create()
+ final LeafSetNode<Object> fooLeafSetNode = Builders.leafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME))
.withChildValue("foo")
.build();
import org.junit.Before;
import org.junit.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.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
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.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.tree.api.ConflictingModificationAppliedException;
import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
}
private static ContainerNode createFooTestContainerNode() {
- return ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
- .withChild(
- mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(FOO_NODE).build()).build();
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(FOO_NODE).build())
+ .build();
}
private static ContainerNode createBarTestContainerNode() {
- return ImmutableContainerNodeBuilder
- .create()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
- .withChild(
- mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(BAR_NODE).build()).build();
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(BAR_NODE).build())
+ .build();
}
private static <T> T assertPresentAndType(final Optional<?> potential, final Class<T> type) {
package org.opendaylight.yangtools.yang.data.tree.impl;
import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
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.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.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
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.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
.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,
+ private static final MapEntryNode INNER_FOO_ENTRY_NODE = mapEntry(TestModel.INNER_LIST_QNAME,
TestModel.NAME_QNAME, "foo");
- private static final MapEntryNode INNER_BAR_ENTRY_NODE = ImmutableNodes
- .mapEntryBuilder(QName.create(TestModel.TEST_QNAME, "inner-list2"), TestModel.NAME_QNAME, "foo")
- .withChild(ImmutableNodes.leafNode(TestModel.VALUE_QNAME, "value")).build();
+ private static final MapEntryNode INNER_BAR_ENTRY_NODE =
+ mapEntryBuilder(QName.create(TestModel.TEST_QNAME, "inner-list2"), TestModel.NAME_QNAME, "foo")
+ .withChild(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();
private static ContainerNode createFooTestContainerNode() {
- return ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
- .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(FOO_NODE).build()).build();
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(FOO_NODE).build()).build();
}
private static ContainerNode createBarTestContainerNode() {
- return ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
- .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(BAR_NODE).build()).build();
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME).withChild(BAR_NODE).build()).build();
}
@Test(expected = SchemaValidationFailedException.class)
final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT);
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
- final YangInstanceIdentifier ii = OUTER_LIST_1_PATH.node(
- new YangInstanceIdentifier.NodeIdentifier(TestModel.INNER_LIST_QNAME)).node(
- INNER_FOO_ENTRY_NODE.getIdentifier());
+ final YangInstanceIdentifier ii = OUTER_LIST_1_PATH.node(new NodeIdentifier(TestModel.INNER_LIST_QNAME))
+ .node(INNER_FOO_ENTRY_NODE.getIdentifier());
modificationTree.write(ii, INNER_FOO_ENTRY_NODE);
inMemoryDataTree.validate(modificationTree);
public void testOnPathCaseLeafFail() throws DataValidationFailedException {
final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT);
- final YangInstanceIdentifier.NodeIdentifier choice1Id = new YangInstanceIdentifier.NodeIdentifier(QName.create(
- TestModel.TEST_QNAME, "choice1"));
- final YangInstanceIdentifier.NodeIdentifier case2ContId = new YangInstanceIdentifier.NodeIdentifier(
- QName.create(TestModel.TEST_QNAME, "case2-cont"));
+ final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
+ final NodeIdentifier case2ContId = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "case2-cont"));
final YangInstanceIdentifier ii = TestModel.TEST_PATH.node(choice1Id).node(case2ContId);
final ContainerNode case2Cont = Builders.containerBuilder().withNodeIdentifier(case2ContId)
.withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value")).build();
public void testOnDataCaseLeafFail() throws DataValidationFailedException {
final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
DataTreeConfiguration.DEFAULT_CONFIGURATION, SCHEMA_CONTEXT);
- final YangInstanceIdentifier.NodeIdentifier choice1Id = new YangInstanceIdentifier.NodeIdentifier(QName.create(
- TestModel.TEST_QNAME, "choice1"));
+ final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
final YangInstanceIdentifier ii = TestModel.TEST_PATH.node(choice1Id);
final ChoiceNode choice1 = Builders.choiceBuilder().withNodeIdentifier(choice1Id)
.withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value")).build();
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
+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.impl.ImmutableContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
public void setUp() throws Exception {
dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
- final ContainerNode testContainer = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
- .withChild(ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
- .build())
- .build();
+ final ContainerNode testContainer = Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
+ .build())
+ .build();
final InMemoryDataTreeModification modification = (InMemoryDataTreeModification) dataTree.takeSnapshot()
.newModification();
.setRootPath(TestModel.INNER_CONTAINER_PATH)
.setUniqueIndexes(true).build(), SCHEMA_CONTEXT);
- final LeafNode<String> leaf = ImmutableLeafNodeBuilder.<String>create()
- .withNodeIdentifier(new NodeIdentifier(TestModel.VALUE_QNAME))
- .withValue("testing-value")
- .build();
+ final LeafNode<String> leaf = ImmutableNodes.leafNode(TestModel.VALUE_QNAME, "testing-value");
final DataTreeModification modification = innerDataTree.takeSnapshot().newModification();
modification.write(TestModel.VALUE_PATH, leaf);
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.AfterClass;
import org.opendaylight.yangtools.yang.data.api.YangNetconfError;
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.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.NormalizedNodeContainer;
-import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
+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.impl.ImmutableLeafSetEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
final NodeWithValue<Object> barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar");
final NodeWithValue<Object> gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo");
- final LeafSetEntryNode<Object> barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(barPath)
- .withValue("bar").build();
- final LeafSetEntryNode<Object> gooLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(gooPath)
- .withValue("goo").build();
-
- final LeafSetNode<Object> fooLeafSetNode = ImmutableLeafSetNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME))
- .withChildValue("foo").build();
-
- modificationTree.write(MIN_MAX_LEAF_LIST_PATH, fooLeafSetNode);
- modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), barLeafSetEntry);
- modificationTree.merge(MIN_MAX_LEAF_LIST_PATH.node(gooPath), gooLeafSetEntry);
+ modificationTree.write(MIN_MAX_LEAF_LIST_PATH, Builders.leafSetBuilder()
+ .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME))
+ .withChildValue("foo")
+ .build());
+ modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), Builders.leafSetEntryBuilder()
+ .withNodeIdentifier(barPath)
+ .withValue("bar")
+ .build());
+ modificationTree.merge(MIN_MAX_LEAF_LIST_PATH.node(gooPath), Builders.leafSetEntryBuilder()
+ .withNodeIdentifier(gooPath)
+ .withValue("goo")
+ .build());
modificationTree.delete(MIN_MAX_LEAF_LIST_PATH.node(gooPath));
modificationTree.ready();
final NodeWithValue<Object> gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo");
final NodeWithValue<Object> fuuPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "fuu");
- final LeafSetEntryNode<Object> barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(barPath)
- .withValue("bar").build();
- final LeafSetEntryNode<Object> gooLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(gooPath)
- .withValue("goo").build();
- final LeafSetEntryNode<Object> fuuLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(fuuPath)
- .withValue("fuu").build();
-
- final LeafSetNode<Object> fooLeafSetNode = ImmutableLeafSetNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME))
- .withChildValue("foo").build();
-
- modificationTree.write(MIN_MAX_LEAF_LIST_PATH, fooLeafSetNode);
- modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), barLeafSetEntry);
- modificationTree.merge(MIN_MAX_LEAF_LIST_PATH.node(gooPath), gooLeafSetEntry);
- modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(fuuPath), fuuLeafSetEntry);
+ modificationTree.write(MIN_MAX_LEAF_LIST_PATH, Builders.leafSetBuilder()
+ .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME))
+ .withChildValue("foo")
+ .build());
+ modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), Builders.leafSetEntryBuilder()
+ .withNodeIdentifier(barPath)
+ .withValue("bar")
+ .build());
+ modificationTree.merge(MIN_MAX_LEAF_LIST_PATH.node(gooPath), Builders.leafSetEntryBuilder()
+ .withNodeIdentifier(gooPath)
+ .withValue("goo")
+ .build());
+ modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(fuuPath), Builders.leafSetEntryBuilder()
+ .withNodeIdentifier(fuuPath)
+ .withValue("fuu")
+ .build());
final MinMaxElementsValidationFailedException ex = assertThrows(MinMaxElementsValidationFailedException.class,
() -> modificationTree.ready());
public void unkeyedListTestPass() throws DataValidationFailedException {
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
- final UnkeyedListEntryNode foo = ImmutableUnkeyedListEntryNodeBuilder.create()
+ final UnkeyedListNode unkeyedListNode = Builders.unkeyedListBuilder()
+ .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
+ .withValue(List.of(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME))
- .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo")).build();
- final List<UnkeyedListEntryNode> unkeyedEntries = new ArrayList<>();
- unkeyedEntries.add(foo);
- final UnkeyedListNode unkeyedListNode = ImmutableUnkeyedListNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
- .withValue(unkeyedEntries).build();
+ .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo"))
+ .build()))
+ .build();
modificationTree.write(MASTER_CONTAINER_PATH, ImmutableNodes.containerNode(MASTER_CONTAINER_QNAME));
modificationTree.merge(UNKEYED_LIST_PATH, unkeyedListNode);
public void unkeyedListTestFail() {
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
- final UnkeyedListEntryNode foo = ImmutableUnkeyedListEntryNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME))
- .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo")).build();
- final UnkeyedListEntryNode bar = ImmutableUnkeyedListEntryNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME))
- .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "bar")).build();
- final List<UnkeyedListEntryNode> unkeyedEntries = new ArrayList<>();
- unkeyedEntries.add(foo);
- unkeyedEntries.add(bar);
- final UnkeyedListNode unkeyedListNode = ImmutableUnkeyedListNodeBuilder.create()
- .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
- .withValue(unkeyedEntries).build();
-
- modificationTree.write(UNKEYED_LIST_PATH, unkeyedListNode);
+ modificationTree.write(UNKEYED_LIST_PATH, Builders.unkeyedListBuilder()
+ .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
+ .withValue(List.of(
+ Builders.unkeyedListEntryBuilder()
+ .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME))
+ .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "foo"))
+ .build(),
+ Builders.unkeyedListEntryBuilder()
+ .withNodeIdentifier(new NodeIdentifier(UNKEYED_LEAF_QNAME))
+ .withChild(ImmutableNodes.leafNode(UNKEYED_LEAF_QNAME, "bar"))
+ .build()))
+ .build());
final MinMaxElementsValidationFailedException ex = assertThrows(MinMaxElementsValidationFailedException.class,
() -> modificationTree.ready());
assertEquals("(urn:opendaylight:params:xml:ns:yang:list-constraints-validation-test-model?"
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.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.impl.ImmutableContainerNodeBuilder;
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.DataTreeModification;
*
* @return a test document
*/
- public NormalizedNode createDocumentOne() {
- return ImmutableContainerNodeBuilder
- .create()
- .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
- .withChild(createTestContainer()).build();
-
+ public ContainerNode createDocumentOne() {
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
+ .withChild(createTestContainer())
+ .build();
}
private static ContainerNode createTestContainer() {
- return ImmutableContainerNodeBuilder
- .create()
- .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
- .withChild(
- mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
- .withChild(BAR_NODE).build()).build();
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+ .withChild(BAR_NODE).build())
+ .build();
}
@Test
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
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.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
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;
DataTreeConfiguration.DEFAULT_OPERATIONAL));
}
- public NormalizedNode createDocumentOne() {
- return ImmutableContainerNodeBuilder
- .create()
- .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
- .withChild(createTestContainer()).build();
-
+ public static ContainerNode createDocumentOne() {
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(SchemaContext.NAME))
+ .withChild(createTestContainer())
+ .build();
}
@Test
}
private static ContainerNode createTestContainer() {
- return ImmutableContainerNodeBuilder
- .create()
- .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
- .withChild(
- mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
- .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
- .withChild(BAR_NODE).build()).build();
+ return Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+ .withChild(BAR_NODE)
+ .build())
+ .build();
}
private static <T extends TreeNode> T assertPresentAndType(final Optional<? extends TreeNode> potential,
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
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.impl.ImmutableContainerNodeBuilder;
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.DataTreeModification;
.withChild(Builders.augmentationBuilder()
.withNodeIdentifier(new AugmentationIdentifier(Set.of(XYZZY_AUGMENT, XYZZY_AUGMENT_CONT)))
.withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT, "xyzzy"))
- .withChild(ImmutableContainerNodeBuilder.create()
+ .withChild(Builders.containerBuilder()
.withNodeIdentifier(new NodeIdentifier(XYZZY_AUGMENT_CONT))
- .withChild(ImmutableContainerNodeBuilder.create()
+ .withChild(Builders.containerBuilder()
.withNodeIdentifier(new NodeIdentifier(XYZZY_AUGMENT_CONT_INNER))
.withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT_CONT_LEAF, "aug-cont-leaf"))
.build())
.withNodeIdentifier(new NodeIdentifier(BAZ))
.withChild(ImmutableNodes.leafNode(XYZZY_LEAF, "xyzzy"))
.withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT, "xyzzy"))
- .withChild(ImmutableContainerNodeBuilder.create()
+ .withChild(Builders.containerBuilder()
.withNodeIdentifier(NodeIdentifier.create(XYZZY_AUGMENT_CONT))
- .withChild(ImmutableContainerNodeBuilder.create()
+ .withChild(Builders.containerBuilder()
.withNodeIdentifier(NodeIdentifier.create(XYZZY_AUGMENT_CONT_INNER))
.withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT_CONT_LEAF, "aug-cont-leaf"))
.build())
.withChild(Builders.augmentationBuilder()
.withNodeIdentifier(new AugmentationIdentifier(Set.of(XYZZY_AUGMENT, XYZZY_AUGMENT_CONT)))
.withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT, "xyzzy"))
- .withChild(ImmutableContainerNodeBuilder.create()
+ .withChild(Builders.containerBuilder()
.withNodeIdentifier(NodeIdentifier.create(XYZZY_AUGMENT_CONT))
- .withChild(ImmutableContainerNodeBuilder.create()
+ .withChild(Builders.containerBuilder()
.withNodeIdentifier(NodeIdentifier.create(XYZZY_AUGMENT_CONT_INNER))
.withChild(ImmutableNodes.leafNode(XYZZY_AUGMENT_CONT_LEAF, "aug-cont-leaf"))
.build())