use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.
the class InMemoryDataTreeBenchmark method write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark.
@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws DataValidationFailedException {
final DataTreeModification modification = begin();
for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
modification.write(OUTER_LIST_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
}
commit(modification);
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.
the class Bug3674Test method testDeleteOfNonExistingNode.
@Test
public void testDeleteOfNonExistingNode() throws DataValidationFailedException {
final DataTreeModification mod = tree.takeSnapshot().newModification();
mod.delete(TestModel.OUTER_LIST_PATH);
mod.ready();
final DataTreeCandidate candidate = tree.prepare(mod);
final DataTreeCandidateNode root = candidate.getRootNode();
assertEquals(ModificationType.UNMODIFIED, root.getModificationType());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.
the class Bug3674Test method setUp.
@Before
public void setUp() throws DataValidationFailedException {
tree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
// Create the top-level container
final DataTreeModification mod = tree.takeSnapshot().newModification();
mod.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
mod.ready();
tree.commit(tree.prepare(mod));
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.
the class Bug4454Test method minMaxListDeleteTest.
@Test
public void minMaxListDeleteTest() throws DataValidationFailedException {
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
NodeIdentifierWithPredicates mapEntryPath2 = NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo");
final YangInstanceIdentifier minMaxLeafFoo = MASTER_CONTAINER_PATH.node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
mapEntryPath2 = NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar");
final YangInstanceIdentifier minMaxLeafBar = MASTER_CONTAINER_PATH.node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
mapEntryPath2 = NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "baz");
final YangInstanceIdentifier minMaxLeafBaz = MASTER_CONTAINER_PATH.node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
modificationTree.write(MIN_MAX_LIST_PATH, mapNodeFooWithNodes);
modificationTree.merge(MIN_MAX_LIST_PATH, mapNodeBar);
modificationTree.merge(MIN_MAX_LIST_PATH, mapNodeBaz);
modificationTree.delete(minMaxLeafFoo);
modificationTree.delete(minMaxLeafBar);
modificationTree.delete(minMaxLeafBaz);
modificationTree.ready();
inMemoryDataTree.validate(modificationTree);
final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
inMemoryDataTree.commit(prepare);
// Empty list should have disappeared, along with the container, as we are not enforcing root
final NormalizedNode data = inMemoryDataTree.takeSnapshot().readNode(YangInstanceIdentifier.empty()).get();
assertTrue(data instanceof ContainerNode);
assertEquals(0, ((ContainerNode) data).size());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.
the class Bug4454Test method minMaxLeafListPass.
@Test
public void minMaxLeafListPass() throws DataValidationFailedException {
final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
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().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.ready();
inMemoryDataTree.validate(modificationTree);
final DataTreeCandidate prepare1 = inMemoryDataTree.prepare(modificationTree);
inMemoryDataTree.commit(prepare1);
DataTreeSnapshot test1 = inMemoryDataTree.takeSnapshot();
DataTreeModification tempMod1 = test1.newModification();
tempMod1.write(MIN_MAX_LEAF_LIST_PATH.node(gooPath), gooLeafSetEntry);
tempMod1.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), barLeafSetEntry);
tempMod1.ready();
inMemoryDataTree.validate(tempMod1);
final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(tempMod1);
inMemoryDataTree.commit(prepare2);
final DataTreeSnapshot snapshotAfterCommit = inMemoryDataTree.takeSnapshot();
final Optional<NormalizedNode> masterContainer = snapshotAfterCommit.readNode(MASTER_CONTAINER_PATH);
assertTrue(masterContainer.isPresent());
final Optional<NormalizedNodeContainer<?>> leafList = ((DistinctNodeContainer) masterContainer.get()).findChildByArg(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME));
assertTrue(leafList.isPresent());
assertEquals(3, leafList.get().size());
}
Aggregations