use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class RpcServiceAdapter method transformFuture.
private static ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc, final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeSerializer codec) {
return Futures.transform(domFuture, input -> {
final NormalizedNode<?, ?> domData = input.getResult();
final DataObject bindingResult;
if (domData != null) {
final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output"));
bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData);
} else {
bindingResult = null;
}
// DOMRpcResult does not have a notion of success, hence we have to reverse-engineer it by looking
// at reported errors and checking whether they are just warnings.
final Collection<RpcError> errors = input.getErrors();
return RpcResult.class.cast(RpcResultBuilder.status(errors.stream().noneMatch(error -> error.getSeverity() == ErrorSeverity.ERROR)).withResult(bindingResult).withRpcErrors(errors).build());
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class Bug1418AugmentationTest method complexAugmentationCreatedTest.
@Test
public void complexAugmentationCreatedTest() {
final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, AsyncDataBroker.DataChangeScope.SUBTREE, false);
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY));
assertCommit(writeTx.submit());
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getCreatedData(), COMPLEX_AUGMENT);
assertContains(event.getCreatedData(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY));
assertEmpty(event.getUpdatedData());
assertEmpty(event.getOriginalData());
assertEmpty(event.getRemovedPaths());
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class Bug1418AugmentationTest method leafOnlyAugmentationUpdatedTest.
@Test
public void leafOnlyAugmentationUpdatedTest() {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf changed"));
assertCommit(writeTx.submit());
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getUpdatedData(), SIMPLE_AUGMENT);
assertContains(event.getOriginalData(), SIMPLE_AUGMENT);
assertEmpty(event.getCreatedData());
assertEmpty(event.getRemovedPaths());
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class Bug1418AugmentationTest method leafOnlyAugmentationDeletedTest.
@Test
public void leafOnlyAugmentationDeletedTest() {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT);
assertCommit(writeTx.submit());
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getRemovedPaths(), SIMPLE_AUGMENT);
assertContains(event.getOriginalData(), SIMPLE_AUGMENT);
assertEmpty(event.getCreatedData());
assertEmpty(event.getUpdatedData());
}
use of org.opendaylight.yangtools.yang.binding.DataObject 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