Search in sources :

Example 1 with SendEchoOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutput in project openflowplugin by opendaylight.

the class SalEchoServiceImplTest method testSendEcho.

@Test
public void testSendEcho() throws Exception {
    final EchoOutput echoOut = new EchoOutputBuilder().setData(DUMMY_DATA).build();
    final RpcResult<EchoOutput> replyRpcResult = RpcResultBuilder.success(echoOut).build();
    final ListenableFuture<RpcResult<EchoOutput>> replyFt = Futures.immediateFuture(replyRpcResult);
    Mockito.when(mockedRequestContext.getFuture()).thenReturn(replyFt);
    SendEchoInput sendEchoInput = new SendEchoInputBuilder().setData(DUMMY_DATA).build();
    final Future<RpcResult<SendEchoOutput>> echoOutput = salEchoService.sendEcho(sendEchoInput);
    Assert.assertNotNull(echoOutput);
    Assert.assertTrue(echoOutput.isDone());
    Assert.assertTrue(echoOutput.get().isSuccessful());
    verify(mockedRequestContextStack).createRequestContext();
    verify(mockedOutboundQueue).commitEntry(Matchers.eq(2121L), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
}
Also used : SendEchoOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutput) EchoOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) SendEchoInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) EchoOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder) SendEchoInput(org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoInput) Test(org.junit.Test)

Example 2 with SendEchoOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutput in project openflowplugin by opendaylight.

the class SalEchoServiceImpl method transform.

private Future<RpcResult<SendEchoOutput>> transform(final ListenableFuture<RpcResult<EchoOutput>> rpcResultListenableFuture) {
    return Futures.transform(rpcResultListenableFuture, input -> {
        Preconditions.checkNotNull(input, "echoOutput value is never expected to be NULL");
        final RpcResult<SendEchoOutput> rpcOutput;
        if (input.isSuccessful()) {
            final SendEchoOutput sendEchoOutput = new SendEchoOutputBuilder().setData(input.getResult().getData()).build();
            rpcOutput = RpcResultBuilder.success(sendEchoOutput).build();
        } else {
            rpcOutput = RpcResultBuilder.<SendEchoOutput>failed().withRpcErrors(input.getErrors()).build();
        }
        return rpcOutput;
    }, MoreExecutors.directExecutor());
}
Also used : SendEchoOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutput) SendEchoOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutputBuilder)

Aggregations

SendEchoOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutput)2 Test (org.junit.Test)1 SendEchoInput (org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoInput)1 SendEchoInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoInputBuilder)1 SendEchoOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutputBuilder)1 EchoOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput)1 EchoOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder)1 OfHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1