use of org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode in project controller by opendaylight.
the class InMemoryDataStoreTest method testMerge.
@Test
public void testMerge() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
assertNotNull(writeTx);
ContainerNode containerNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build()).build();
writeTx.merge(TestModel.TEST_PATH, containerNode);
assertThreePhaseCommit(writeTx.ready());
Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
assertEquals("After commit read: data", containerNode, afterCommitRead.get());
// Merge a new list entry node
writeTx = domStore.newWriteOnlyTransaction();
assertNotNull(writeTx);
containerNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2)).build()).build();
writeTx.merge(TestModel.TEST_PATH, containerNode);
assertThreePhaseCommit(writeTx.ready());
afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
assertEquals("After commit read: data", containerNode, afterCommitRead.get());
}
use of org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode in project controller by opendaylight.
the class InMemoryDataStoreTest method testDelete.
@Test
public void testDelete() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
assertNotNull(writeTx);
// Write /test and commit
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
assertThreePhaseCommit(writeTx.ready());
Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
// Delete /test and verify
writeTx = domStore.newWriteOnlyTransaction();
writeTx.delete(TestModel.TEST_PATH);
assertThreePhaseCommit(writeTx.ready());
afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
assertEquals("After commit read: isPresent", false, afterCommitRead.isPresent());
}
use of org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode in project bgpcep by opendaylight.
the class AbstractRIBSupportTest method createNlriWithDrawnRoute.
protected final ContainerNode createNlriWithDrawnRoute(final DestinationType destUnreach) {
final MpUnreachNlri mpReach = new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(destUnreach).build()).build();
final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> result = this.mappingService.toNormalizedNode(MP_UNREACH_IID, mpReach);
return (ContainerNode) result.getValue();
}
use of org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode in project bgpcep by opendaylight.
the class AbstractRIBSupportTest method createRoutes.
@SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
protected final Collection<MapEntryNode> createRoutes(final DataObject routes) {
Preconditions.checkArgument(routes.getImplementedInterface().equals(this.abstractRIBSupport.routesContainerClass()));
final InstanceIdentifier<DataObject> routesIId = routesIId();
final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNode = this.mappingService.toNormalizedNode(routesIId, routes);
final ContainerNode container = (ContainerNode) normalizedNode.getValue();
final NodeIdentifier routeNid = new NodeIdentifier(getRouteListQname());
return ((MapNode) container.getChild(routeNid).get()).getValue();
}
Aggregations