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());
}
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());
}
Aggregations