Search in sources :

Example 1 with DefaultDOMRpcResult

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());
        }
    };
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) ExecuteRpc(org.opendaylight.controller.remote.rpc.messages.ExecuteRpc) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) TestKit(akka.testkit.javadsl.TestKit) RpcResponse(org.opendaylight.controller.remote.rpc.messages.RpcResponse) Test(org.junit.Test)

Example 2 with DefaultDOMRpcResult

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!");
    }
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) DOMRpcService(org.opendaylight.controller.md.sal.dom.api.DOMRpcService) DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) RockTheHouseInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder) DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) DOMRpcException(org.opendaylight.controller.md.sal.dom.api.DOMRpcException) MountPoint(org.opendaylight.controller.md.sal.binding.api.MountPoint) DOMRpcAvailabilityListener(org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener) RpcConsumerRegistry(org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry) OpendaylightTestRpcServiceService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService) SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 3 with DefaultDOMRpcResult

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());
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) KnockKnockOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder) KnockKnockOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput) DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) OpendaylightOfMigrationTestModelService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService) Test(org.junit.Test)

Example 4 with DefaultDOMRpcResult

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));
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Nonnull(javax.annotation.Nonnull)

Example 5 with DefaultDOMRpcResult

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));
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Nonnull(javax.annotation.Nonnull)

Aggregations

DefaultDOMRpcResult (org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult)9 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)8 Test (org.junit.Test)6 DOMRpcResult (org.opendaylight.controller.md.sal.dom.api.DOMRpcResult)6 DOMRpcException (org.opendaylight.controller.md.sal.dom.api.DOMRpcException)4 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)4 Nonnull (javax.annotation.Nonnull)3 ArgumentCaptor (org.mockito.ArgumentCaptor)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)2 TestKit (akka.testkit.javadsl.TestKit)1 MountPoint (org.opendaylight.controller.md.sal.binding.api.MountPoint)1 DOMRpcAvailabilityListener (org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener)1 DOMRpcService (org.opendaylight.controller.md.sal.dom.api.DOMRpcService)1 ExecuteRpc (org.opendaylight.controller.remote.rpc.messages.ExecuteRpc)1 RpcResponse (org.opendaylight.controller.remote.rpc.messages.RpcResponse)1 RpcConsumerRegistry (org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry)1 KnockKnockOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput)1 KnockKnockOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder)1 OpendaylightOfMigrationTestModelService (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService)1