use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.
the class InvokeRpcMethodTest method testInvokeRpcMethodWithInput.
@Test
@Ignore
public void testInvokeRpcMethodWithInput() {
final DOMRpcResult expResult = mock(DOMRpcResult.class);
final QName path = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)make-toast");
final Module rpcModule = schemaContext.findModules("toaster").iterator().next();
assertNotNull(rpcModule);
final QName rpcQName = QName.create(rpcModule.getQNameModule(), "make-toast");
RpcDefinition rpcDef = null;
ContainerLike rpcInputSchemaNode = null;
for (final RpcDefinition rpc : rpcModule.getRpcs()) {
if (rpcQName.isEqualWithoutRevision(rpc.getQName())) {
rpcInputSchemaNode = rpc.getInput();
rpcDef = rpc;
break;
}
}
assertNotNull(rpcDef);
assertNotNull(rpcInputSchemaNode);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> containerBuilder = SchemaAwareBuilders.containerBuilder(rpcInputSchemaNode);
final NormalizedNodeContext payload = new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpcInputSchemaNode, null, schemaContext), containerBuilder.build());
doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(eq(path), any(NormalizedNode.class));
final NormalizedNodeContext output = this.restconfImpl.invokeRpc("toaster:make-toast", payload, uriInfo);
assertNotNull(output);
assertEquals(null, output.getData());
// additional validation in the fact that the restconfImpl does not
// throw an exception.
}
use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.
the class JSONRestconfServiceImplTest method testInvokeRpcWithNoInput.
@Test
public void testInvokeRpcWithNoInput() throws Exception {
final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode) null);
doReturn(immediateFluentFuture(expResult)).when(brokerFacade).invokeRpc(any(QName.class), any());
final String uriPath = "toaster:cancel-toast";
final Optional<String> output = this.service.invokeRpc(uriPath, Optional.empty());
assertEquals("Output present", false, output.isPresent());
verify(brokerFacade).invokeRpc(eq(CANCEL_TOAST_QNAME), any());
}
use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.
the class ProxyNetconfDataTreeServiceTest method lock.
private void lock() {
final ListenableFuture<DOMRpcResult> lock = proxy.lock();
masterActor.expectMsgClass(NetconfDataTreeServiceRequest.class);
masterActor.reply(new Status.Success(masterActor.ref()));
masterActor.expectMsgClass(LockRequest.class);
masterActor.reply(new InvokeRpcMessageReply(null, Collections.emptyList()));
Futures.whenAllComplete(lock).run(() -> {
assertTrue(lock.isDone());
assertNotNull(Futures.getUnchecked(lock));
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.
the class ActorProxyNetconfServiceFacade method discardChanges.
@Override
public ListenableFuture<DOMRpcResult> discardChanges() {
LOG.debug("{}: Discard changes via actor {}", id, masterActor);
final SettableFuture<DOMRpcResult> discardChangesResult = SettableFuture.create();
final Future<Object> future = Patterns.ask(masterActor, new DiscardChangesRequest(), askTimeout);
future.onComplete(new OnComplete<>() {
@Override
public void onComplete(final Throwable failure, final Object response) {
if (failure != null) {
discardChangesResult.setException(failure);
} else if (response instanceof InvokeRpcMessageReply) {
discardChangesResult.set(mapInvokeRpcMessageReplyToDOMRpcResult((InvokeRpcMessageReply) response));
} else {
discardChangesResult.setException(new ClusteringRpcException("Discard changes operation returned unexpected type"));
LOG.error("{}: Discard changes via actor {} returned unexpected type", id, masterActor);
}
}
}, executionContext);
return discardChangesResult;
}
use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project netconf by opendaylight.
the class ActorProxyNetconfServiceFacade method createResult.
private ListenableFuture<? extends DOMRpcResult> createResult() {
final SettableFuture<DOMRpcResult> settableFuture = SettableFuture.create();
settableFuture.set(new DefaultDOMRpcResult());
return settableFuture;
}
Aggregations