use of com.google.api.gax.rpc.UnknownException in project gax-java by googleapis.
the class RetryingTest method testUnknownStatusCode.
@Test
public void testUnknownStatusCode() {
ImmutableSet<StatusCode.Code> retryable = ImmutableSet.of();
Mockito.when(callInt.futureCall((Integer) Mockito.any(), (ApiCallContext) Mockito.any())).thenReturn(ApiFutures.<Integer>immediateFailedFuture(new RuntimeException("unknown")));
UnaryCallSettings<Integer, Integer> callSettings = UnaryCallSettings.<Integer, Integer>newUnaryCallSettingsBuilder().setRetryableCodes(retryable).build();
UnaryCallable<Integer, Integer> callable = HttpJsonCallableFactory.createUnaryCallable(callInt, callSettings, clientContext);
UnknownException exception = assertThrows(UnknownException.class, () -> callable.call(1));
Truth.assertThat(exception).hasMessageThat().isEqualTo("java.lang.RuntimeException: unknown");
}
use of com.google.api.gax.rpc.UnknownException in project java-bigquerystorage by googleapis.
the class StreamWriterTest method testAppendFailRandomException.
@Test
public void testAppendFailRandomException() throws Exception {
StreamWriter writer = getTestStreamWriter();
// Trigger a non-StatusRuntimeException for append operation (although grpc API should not
// return anything other than StatusRuntimeException)
IllegalArgumentException illegalArgumentException = new IllegalArgumentException("Illegal argument");
testBigQueryWrite.addException(illegalArgumentException);
ApiFuture<AppendRowsResponse> appendFuture1 = sendTestMessage(writer, new String[] { "A" });
UnknownException actualError = assertFutureException(UnknownException.class, appendFuture1);
assertEquals(Code.UNKNOWN, actualError.getStatusCode().getCode());
writer.close();
}
Aggregations