use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class OrderedListTest method modification2.
public void modification2() throws DataValidationFailedException {
UserMapNode parentOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(parentOrderedList)).withChild(createParentOrderedListEntry("pkval3", "plfval3updated")).withChild(createParentOrderedListEntry("pkval4", "plfval4")).withChild(createParentOrderedListEntry("pkval5", "plfval5")).build();
ContainerNode parentContainerNode = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode).build()).build();
DataTreeModification treeModification = inMemoryDataTree.takeSnapshot().newModification();
YangInstanceIdentifier path1 = YangInstanceIdentifier.of(parentContainer);
treeModification.merge(path1, parentContainerNode);
UserMapNode childOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(childOrderedList)).withChild(createChildOrderedListEntry("chkval1", "chlfval1updated")).withChild(createChildOrderedListEntry("chkval2", "chlfval2updated")).withChild(createChildOrderedListEntry("chkval3", "chlfval3")).build();
YangInstanceIdentifier path2 = YangInstanceIdentifier.of(parentContainer).node(childContainer).node(parentOrderedList).node(createParentOrderedListEntryPath("pkval2")).node(childOrderedList);
treeModification.merge(path2, childOrderedListNode);
treeModification.ready();
inMemoryDataTree.validate(treeModification);
inMemoryDataTree.commit(inMemoryDataTree.prepare(treeModification));
DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
Optional<NormalizedNode> readNode = snapshotAfterCommits.readNode(path1);
assertTrue(readNode.isPresent());
readNode = snapshotAfterCommits.readNode(path2);
assertTrue(readNode.isPresent());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class OrderedListTest method delete1.
public void delete1() throws DataValidationFailedException {
YangInstanceIdentifier path = YangInstanceIdentifier.of(parentContainer).node(childContainer).node(parentOrderedList).node(createParentOrderedListEntryPath("pkval2")).node(childOrderedList).node(createChildOrderedListEntryPath("chkval1"));
DataTreeModification treeModification = inMemoryDataTree.takeSnapshot().newModification();
treeModification.delete(path);
treeModification.ready();
inMemoryDataTree.validate(treeModification);
inMemoryDataTree.commit(inMemoryDataTree.prepare(treeModification));
DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
Optional<NormalizedNode> readNode = snapshotAfterCommits.readNode(path);
assertFalse(readNode.isPresent());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class OrderedListTest method delete2.
public void delete2() throws DataValidationFailedException {
YangInstanceIdentifier path = YangInstanceIdentifier.of(parentContainer).node(childContainer).node(parentOrderedList).node(createParentOrderedListEntryPath("pkval2"));
DataTreeModification treeModification = inMemoryDataTree.takeSnapshot().newModification();
treeModification.delete(path);
treeModification.ready();
inMemoryDataTree.validate(treeModification);
inMemoryDataTree.commit(inMemoryDataTree.prepare(treeModification));
DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
Optional<NormalizedNode> readNode = snapshotAfterCommits.readNode(path);
assertFalse(readNode.isPresent());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class OrderedListTest method modification1.
public void modification1() throws DataValidationFailedException {
UserMapNode parentOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(parentOrderedList)).withChild(createParentOrderedListEntry("pkval1", "plfval1")).withChild(createParentOrderedListEntry("pkval2", "plfval2")).withChild(createParentOrderedListEntry("pkval3", "plfval3")).build();
ContainerNode parentContainerNode = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode).build()).build();
YangInstanceIdentifier path1 = YangInstanceIdentifier.of(parentContainer);
DataTreeModification treeModification = inMemoryDataTree.takeSnapshot().newModification();
treeModification.write(path1, parentContainerNode);
UserMapNode childOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(childOrderedList)).withChild(createChildOrderedListEntry("chkval1", "chlfval1")).withChild(createChildOrderedListEntry("chkval2", "chlfval2")).build();
YangInstanceIdentifier path2 = YangInstanceIdentifier.of(parentContainer).node(childContainer).node(parentOrderedList).node(createParentOrderedListEntryPath("pkval2")).node(childOrderedList);
treeModification.write(path2, childOrderedListNode);
treeModification.ready();
inMemoryDataTree.validate(treeModification);
inMemoryDataTree.commit(inMemoryDataTree.prepare(treeModification));
DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
Optional<NormalizedNode> readNode = snapshotAfterCommits.readNode(path1);
assertTrue(readNode.isPresent());
readNode = snapshotAfterCommits.readNode(path2);
assertTrue(readNode.isPresent());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class StructuralApplyModificationTest method assertNodeExistence.
private void assertNodeExistence(final YangInstanceIdentifier outerListParentPath, final boolean shouldBePresent) {
final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
final Optional<NormalizedNode> readNode = snapshotAfterCommits.readNode(outerListParentPath);
assertEquals(readNode.isPresent(), shouldBePresent);
}
Aggregations