Search in sources :

Example 1 with Mdsal500Service

use of org.opendaylight.yang.gen.v1.rpc.norev.Mdsal500Service in project mdsal by opendaylight.

the class Mdsal500Test method testDOMRegistrationWithBindingInvocation.

@Test
public void testDOMRegistrationWithBindingInvocation() throws InterruptedException, ExecutionException, TimeoutException {
    SwitchOutput baSwitchOutput = new SwitchOutputBuilder().build();
    biRpcProviderService.registerRpcImplementation((rpc, input) -> FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(testContext.getCodec().currentSerializer().toNormalizedNodeRpcData(baSwitchOutput))), DOMRpcIdentifier.create(SWITCH_QNAME));
    final Mdsal500Service baSwitchService = baRpcConsumerService.getRpcService(Mdsal500Service.class);
    Future<RpcResult<SwitchOutput>> baResult = baSwitchService.switch$(switchBuilder(FOO).build());
    assertNotNull(baResult);
    assertEquals(baSwitchOutput, baResult.get(5, TimeUnit.SECONDS).getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) Mdsal500Service(org.opendaylight.yang.gen.v1.rpc.norev.Mdsal500Service) SwitchOutputBuilder(org.opendaylight.yang.gen.v1.rpc.norev.SwitchOutputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) SwitchOutput(org.opendaylight.yang.gen.v1.rpc.norev.SwitchOutput) Test(org.junit.Test)

Example 2 with Mdsal500Service

use of org.opendaylight.yang.gen.v1.rpc.norev.Mdsal500Service in project mdsal by opendaylight.

the class Mdsal500Test method testBindingRpcShortcut.

@Test
public void testBindingRpcShortcut() throws InterruptedException, ExecutionException, TimeoutException {
    final ListenableFuture<RpcResult<SwitchOutput>> baSwitchResult = switchResult(true);
    switchRpcImpl.registerTo(baRpcProviderService).setSwitchResult(baSwitchResult);
    final Mdsal500Service baSwitchService = baRpcConsumerService.getRpcService(Mdsal500Service.class);
    SwitchInput baSwitchInput = switchBuilder(FOO).build();
    ListenableFuture<RpcResult<SwitchOutput>> future = baSwitchService.switch$(baSwitchInput);
    final RpcResult<SwitchOutput> rpcResult = future.get(5, TimeUnit.SECONDS);
    assertEquals(baSwitchResult.get().getResult().getClass(), rpcResult.getResult().getClass());
    assertSame(baSwitchResult.get().getResult(), rpcResult.getResult());
    assertSame(baSwitchInput, switchRpcImpl.getReceivedSwitch().get(FOO).iterator().next());
}
Also used : Mdsal500Service(org.opendaylight.yang.gen.v1.rpc.norev.Mdsal500Service) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) SwitchInput(org.opendaylight.yang.gen.v1.rpc.norev.SwitchInput) SwitchOutput(org.opendaylight.yang.gen.v1.rpc.norev.SwitchOutput) Test(org.junit.Test)

Example 3 with Mdsal500Service

use of org.opendaylight.yang.gen.v1.rpc.norev.Mdsal500Service in project mdsal by opendaylight.

the class Mdsal500Test method testBindingRegistrationWithDOMInvocation.

@Test
public void testBindingRegistrationWithDOMInvocation() throws Exception {
    switchRpcImpl.registerTo(baRpcProviderService).setSwitchResult(switchResult(true));
    final Mdsal500Service baSwitchService = baRpcConsumerService.getRpcService(Mdsal500Service.class);
    assertNotSame(switchRpcImpl, baSwitchService);
    SwitchInput baSwitchInput = switchBuilder(FOO).build();
    ContainerNode biSwitchInput = toDOMSwitchInput(baSwitchInput);
    DOMRpcResult domResult = biRpcService.invokeRpc(SWITCH_QNAME, biSwitchInput).get(5, TimeUnit.SECONDS);
    assertNotNull(domResult);
    assertNotNull(domResult.getResult());
    assertTrue("Binding KnockKnock service was not invoked", switchRpcImpl.getReceivedSwitch().containsKey(FOO));
    assertEquals(baSwitchInput, switchRpcImpl.getReceivedSwitch().get(FOO).iterator().next());
}
Also used : Mdsal500Service(org.opendaylight.yang.gen.v1.rpc.norev.Mdsal500Service) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) SwitchInput(org.opendaylight.yang.gen.v1.rpc.norev.SwitchInput) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)3 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)3 Mdsal500Service (org.opendaylight.yang.gen.v1.rpc.norev.Mdsal500Service)3 SwitchInput (org.opendaylight.yang.gen.v1.rpc.norev.SwitchInput)2 SwitchOutput (org.opendaylight.yang.gen.v1.rpc.norev.SwitchOutput)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 SwitchOutputBuilder (org.opendaylight.yang.gen.v1.rpc.norev.SwitchOutputBuilder)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1