Search in sources :

Example 1 with KnockKnockOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput in project controller by opendaylight.

the class CrossBrokerRpcTest method knockResult.

private Future<RpcResult<KnockKnockOutput>> knockResult(final boolean success, final String answer) {
    KnockKnockOutput output = // 
    new KnockKnockOutputBuilder().setAnswer(answer).build();
    RpcResult<KnockKnockOutput> result = RpcResultBuilder.<KnockKnockOutput>status(success).withResult(output).build();
    return Futures.immediateFuture(result);
}
Also used : KnockKnockOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput) KnockKnockOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder)

Example 2 with KnockKnockOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput in project mdsal by opendaylight.

the class BindingDOMRpcIntegrationTest method testBindingRpcShortcut.

@Test
public void testBindingRpcShortcut() throws InterruptedException, ExecutionException, TimeoutException {
    final ListenableFuture<RpcResult<KnockKnockOutput>> baKnockResult = knockResult(true, "open");
    knockRpcImpl.registerTo(baRpcProviderService, BA_NODE_ID).setKnockKnockResult(baKnockResult);
    final OpendaylightKnockKnockRpcService baKnockService = baRpcConsumerService.getRpcService(OpendaylightKnockKnockRpcService.class);
    KnockKnockInput baKnockKnockInput = knockKnock(BA_NODE_ID).setQuestion("who's there?").build();
    ListenableFuture<RpcResult<KnockKnockOutput>> future = baKnockService.knockKnock(baKnockKnockInput);
    final RpcResult<KnockKnockOutput> rpcResult = future.get(5, TimeUnit.SECONDS);
    assertEquals(baKnockResult.get().getResult().getClass(), rpcResult.getResult().getClass());
    assertSame(baKnockResult.get().getResult(), rpcResult.getResult());
    assertSame(baKnockKnockInput, knockRpcImpl.getReceivedKnocks().get(BA_NODE_ID).iterator().next());
}
Also used : OpendaylightKnockKnockRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.OpendaylightKnockKnockRpcService) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) KnockKnockOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput) KnockKnockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockInput) Test(org.junit.Test)

Example 3 with KnockKnockOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput in project mdsal by opendaylight.

the class BindingDOMRpcIntegrationTest method knockResult.

private static ListenableFuture<RpcResult<KnockKnockOutput>> knockResult(final boolean success, final String answer) {
    KnockKnockOutput output = new KnockKnockOutputBuilder().setAnswer(answer).build();
    RpcResult<KnockKnockOutput> result = RpcResultBuilder.<KnockKnockOutput>status(success).withResult(output).build();
    return Futures.immediateFuture(result);
}
Also used : KnockKnockOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput) KnockKnockOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutputBuilder)

Example 4 with KnockKnockOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput 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 5 with KnockKnockOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput in project mdsal by opendaylight.

the class BindingDOMRpcIntegrationTest method testDOMRegistrationWithBindingInvocation.

@Test
public void testDOMRegistrationWithBindingInvocation() throws InterruptedException, ExecutionException, TimeoutException {
    KnockKnockOutput baKnockKnockOutput = new KnockKnockOutputBuilder().setAnswer("open").build();
    biRpcProviderService.registerRpcImplementation((rpc, input) -> FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(testContext.getCodec().currentSerializer().toNormalizedNodeRpcData(baKnockKnockOutput))), DOMRpcIdentifier.create(KNOCK_KNOCK_QNAME, testContext.getCodec().currentSerializer().toYangInstanceIdentifier(BA_NODE_ID)));
    final OpendaylightKnockKnockRpcService baKnockService = baRpcConsumerService.getRpcService(OpendaylightKnockKnockRpcService.class);
    Future<RpcResult<KnockKnockOutput>> baResult = baKnockService.knockKnock(knockKnock(BA_NODE_ID).setQuestion("Who's there?").build());
    assertNotNull(baResult);
    assertEquals(baKnockKnockOutput, baResult.get(5, TimeUnit.SECONDS).getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) OpendaylightKnockKnockRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.OpendaylightKnockKnockRpcService) KnockKnockOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput) KnockKnockOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 KnockKnockOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutput)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)2 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)2 KnockKnockOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput)2 KnockKnockOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder)2 KnockKnockOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockOutputBuilder)2 OpendaylightKnockKnockRpcService (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.OpendaylightKnockKnockRpcService)2 DOMRpcResult (org.opendaylight.controller.md.sal.dom.api.DOMRpcResult)1 DefaultDOMRpcResult (org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult)1 OpendaylightOfMigrationTestModelService (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService)1 KnockKnockInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.knock.knock.rev180723.KnockKnockInput)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1