use of org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.
the class RpcBrokerTest method testExecuteRpc.
@Test
public void testExecuteRpc() {
new TestKit(node1) {
{
final ContainerNode invokeRpcResult = makeRPCOutput("bar");
final DOMRpcResult rpcResult = new DefaultDOMRpcResult(invokeRpcResult);
when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), Mockito.<NormalizedNode<?, ?>>any())).thenReturn(Futures.<DOMRpcResult, DOMRpcException>immediateCheckedFuture(rpcResult));
final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null);
rpcInvoker1.tell(executeMsg, getRef());
final RpcResponse rpcResponse = expectMsgClass(duration("5 seconds"), RpcResponse.class);
assertEquals(rpcResult.getResult(), rpcResponse.getResultNormalizedNode());
}
};
}
use of org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.
the class DOMRpcServiceTestBugfix560 method test.
@Test
public void test() throws ExecutionException, InterruptedException {
// FIXME: This is made to only make sure instance identifier codec for path is instantiated.
domMountPointService.createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() {
@Override
public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath arg0, final NormalizedNode<?, ?> arg1) {
final DOMRpcResult result = new DefaultDOMRpcResult((NormalizedNode<?, ?>) null);
return Futures.immediateCheckedFuture(result);
}
}).register();
final Optional<MountPoint> mountInstance = bindingMountPointService.getMountPoint(BA_MOUNT_ID);
assertTrue(mountInstance.isPresent());
final Optional<RpcConsumerRegistry> rpcRegistry = mountInstance.get().getService(RpcConsumerRegistry.class);
assertTrue(rpcRegistry.isPresent());
final OpendaylightTestRpcServiceService rpcService = rpcRegistry.get().getRpcService(OpendaylightTestRpcServiceService.class);
assertNotNull(rpcService);
try {
final Future<RpcResult<Void>> result = rpcService.rockTheHouse(new RockTheHouseInputBuilder().build());
assertTrue(result.get().isSuccessful());
} catch (final IllegalStateException ex) {
fail("OpendaylightTestRpcServiceService class doesn't contain rockTheHouse method!");
}
}
use of org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.
the class CrossBrokerRpcTest method bindingRpcInvoker_DomRoutedProviderTest.
@Test
public void bindingRpcInvoker_DomRoutedProviderTest() throws Exception {
KnockKnockOutputBuilder builder = new KnockKnockOutputBuilder();
builder.setAnswer("open");
final KnockKnockOutput output = builder.build();
provisionRegistry.registerRpcImplementation((rpc, input) -> {
ContainerNode result = testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(output);
return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
}, DOMRpcIdentifier.create(KNOCK_KNOCK_PATH, BI_NODE_C_ID));
OpendaylightOfMigrationTestModelService baKnockInvoker = providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
Future<RpcResult<KnockKnockOutput>> baResult = baKnockInvoker.knockKnock((knockKnock(BA_NODE_C_ID).setQuestion("Who's there?").build()));
assertNotNull(baResult);
assertEquals(output, baResult.get().getResult());
}
use of org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.
the class RoutedGetConstantService method invokeRpc.
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final DOMRpcIdentifier rpc, @Nullable final NormalizedNode<?, ?> input) {
LOG.debug("get-contexted-constant invoked, current value: {}", constant);
final LeafNode<Object> value = ImmutableLeafNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONSTANT)).withValue(constant).build();
final ContainerNode result = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(OUTPUT)).withChild(value).build();
return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
}
use of org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult in project controller by opendaylight.
the class SingletonGetConstantService method invokeRpc.
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode<?, ?> input) {
LOG.debug("get-singleton-constant invoked, current value: {}", constant);
final LeafNode<Object> value = ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(CONSTANT)).withValue(constant).build();
final ContainerNode result = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(OUTPUT)).withChild(value).build();
return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
}
Aggregations