use of com.google.rpc.RetryInfo in project google-cloud-java by GoogleCloudPlatform.
the class SpannerExceptionFactoryTest method abortWithRetryInfo.
@Test
public void abortWithRetryInfo() {
Metadata.Key<RetryInfo> key = ProtoUtils.keyForProto(RetryInfo.getDefaultInstance());
Status status = Status.fromCodeValue(Status.Code.ABORTED.value());
Metadata trailers = new Metadata();
RetryInfo retryInfo = RetryInfo.newBuilder().setRetryDelay(Duration.newBuilder().setNanos(1000000).setSeconds(1L)).build();
trailers.put(key, retryInfo);
SpannerException e = SpannerExceptionFactory.newSpannerException(new StatusRuntimeException(status, trailers));
assertThat(e).isInstanceOf(AbortedException.class);
assertThat(((AbortedException) e).getRetryDelayInMillis()).isEqualTo(1001L);
}
use of com.google.rpc.RetryInfo in project google-cloud-java by GoogleCloudPlatform.
the class TransactionRunnerImplTest method createRetryException.
private StatusRuntimeException createRetryException() {
Metadata.Key<RetryInfo> key = ProtoUtils.keyForProto(RetryInfo.getDefaultInstance());
Status status = Status.fromCodeValue(Status.Code.ABORTED.value());
Metadata trailers = new Metadata();
RetryInfo retryInfo = RetryInfo.newBuilder().setRetryDelay(Duration.newBuilder().setNanos(1000000).setSeconds(1L)).build();
trailers.put(key, retryInfo);
return new StatusRuntimeException(status, trailers);
}
use of com.google.rpc.RetryInfo in project google-cloud-java by GoogleCloudPlatform.
the class SpannerExceptionFactoryTest method abortWithoutDuration.
@Test
public void abortWithoutDuration() {
Metadata.Key<RetryInfo> key = ProtoUtils.keyForProto(RetryInfo.getDefaultInstance());
Status status = Status.fromCodeValue(Status.Code.ABORTED.value());
Metadata trailers = new Metadata();
trailers.put(key, RetryInfo.getDefaultInstance());
SpannerException e = SpannerExceptionFactory.newSpannerException(new StatusRuntimeException(status, trailers));
assertThat(e).isInstanceOf(AbortedException.class);
assertThat(((AbortedException) e).getRetryDelayInMillis()).isEqualTo(-1L);
}
Aggregations