use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.
the class OpendaylightDirectStatisticsServiceImplTest method testGetMeterStatisticsFail.
@Test
public void testGetMeterStatisticsFail() throws Exception {
RpcResult<GetMeterStatisticsOutput> result = emptyService.getMeterStatistics(getMeterStatisticsInput).get();
assertFalse(result.isSuccessful());
for (RpcError error : result.getErrors()) {
assertTrue(error.getMessage().contains(AbstractMeterDirectStatisticsService.class.getSimpleName()));
}
verify(meterDirectStatisticsService, times(0)).handleAndReply(getMeterStatisticsInput);
}
use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.
the class AbstractRequestCallbackTest method provideRpcError.
private RpcError provideRpcError(ListenableFuture futureResult) throws InterruptedException, java.util.concurrent.ExecutionException {
final Object result = futureResult.get();
assertTrue(result instanceof RpcResult);
RpcResult rpcResult = (RpcResult) result;
final Collection errors = rpcResult.getErrors();
assertEquals(1, errors.size());
final Object error = errors.iterator().next();
assertTrue(error instanceof RpcError);
return (RpcError) error;
}
use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.
the class AbstractRequestCallbackTest method testOnFailureWithDeviceRequestFailedException.
@Test
public void testOnFailureWithDeviceRequestFailedException() throws Exception {
ErrorMessage dummyErrorMessage = new ErrorMessageBuilder().build();
abstractRequestCallback.onFailure(new DeviceRequestFailedException(DUMMY_EXCEPTION_DESCRIPTION, dummyErrorMessage));
final ListenableFuture futureResult = dummyRequestContext.getFuture();
RpcError rpcError = provideRpcError(futureResult);
assertEquals("Device reported error type null code null", rpcError.getMessage());
}
use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.
the class AbstractRequestCallbackTest method testOnFailure.
@Test
public void testOnFailure() throws Exception {
abstractRequestCallback.onFailure(new IllegalStateException(DUMMY_MESSAGE_ILLEGAL_STATE_EXCEPTION));
final ListenableFuture futureResult = dummyRequestContext.getFuture();
RpcError rpcError = provideRpcError(futureResult);
assertEquals(DUMMY_MESSAGE_ILLEGAL_STATE_EXCEPTION, rpcError.getMessage());
}
use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.
the class ResponseExpectedRpcListenerTest method testDiscard.
/**
* Test object creation.
*/
@Test
public void testDiscard() {
RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName());
ResponseExpectedRpcListener<OfHeader> listener = new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key);
listener.discard();
RpcError rpcError = AbstractRpcListener.buildRpcError("Failed to send message", "check switch connection", new TimeoutException("Request timed out"));
SettableFuture<RpcResult<?>> result = SettableFuture.create();
result.set(RpcResultBuilder.failed().withRpcError(rpcError).build());
try {
Assert.assertEquals("Wrong result", result.get().getErrors().iterator().next().getMessage(), listener.getResult().get().getErrors().iterator().next().getMessage());
Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult());
Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful());
} catch (InterruptedException | ExecutionException e) {
fail("Problem accessing result");
}
}
Aggregations