Search in sources :

Example 21 with DataTreeSnapshot

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());
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) UserMapNode(org.opendaylight.yangtools.yang.data.api.schema.UserMapNode) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 22 with DataTreeSnapshot

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());
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 23 with DataTreeSnapshot

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());
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 24 with DataTreeSnapshot

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());
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) UserMapNode(org.opendaylight.yangtools.yang.data.api.schema.UserMapNode) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 25 with DataTreeSnapshot

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);
}
Also used : DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)

Aggregations

DataTreeSnapshot (org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot)41 DataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)36 Test (org.junit.Test)30 DataTreeCandidate (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate)25 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)18 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)11 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)11 ConflictingModificationAppliedException (org.opendaylight.yangtools.yang.data.tree.api.ConflictingModificationAppliedException)9 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)5 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)4 UserMapNode (org.opendaylight.yangtools.yang.data.api.schema.UserMapNode)4 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 DOMStoreReadTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction)2 QName (org.opendaylight.yangtools.yang.common.QName)2 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)2 NodeWithValue (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue)2 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)2 NormalizedNodeContainer (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer)2 SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)2