use of com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList in project gax-java by googleapis.
the class BatchingCallSettingsTest method testBuilderFromSettings.
@Test
public void testBuilderFromSettings() {
BatchingCallSettings.Builder<Integer, Integer, LabeledIntList, List<Integer>> builder = BatchingCallSettings.newBuilder(SQUARER_BATCHING_DESC_V2);
RetrySettings retrySettings = RetrySettings.newBuilder().setTotalTimeout(Duration.ofMinutes(1)).build();
builder.setBatchingSettings(BATCHING_SETTINGS).setRetryableCodes(StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNAUTHENTICATED).setRetrySettings(retrySettings);
BatchingCallSettings settings = builder.build();
BatchingCallSettings.Builder newBuilder = settings.toBuilder();
assertThat(newBuilder.getBatchingSettings()).isEqualTo(BATCHING_SETTINGS);
assertThat(newBuilder.getRetryableCodes()).containsExactly(StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNAUTHENTICATED);
assertThat(newBuilder.getRetrySettings()).isEqualTo(retrySettings);
}
use of com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList in project gax-java by googleapis.
the class BatcherImplTest method testCloseAsyncNonblocking.
@Test
public void testCloseAsyncNonblocking() throws ExecutionException, InterruptedException {
final SettableApiFuture<List<Integer>> innerFuture = SettableApiFuture.create();
UnaryCallable<LabeledIntList, List<Integer>> unaryCallable = new UnaryCallable<LabeledIntList, List<Integer>>() {
@Override
public ApiFuture<List<Integer>> futureCall(LabeledIntList request, ApiCallContext context) {
return innerFuture;
}
};
underTest = new BatcherImpl<>(SQUARER_BATCHING_DESC_V2, unaryCallable, labeledIntList, batchingSettings, EXECUTOR);
ApiFuture<Integer> elementFuture = underTest.add(1);
Stopwatch stopwatch = Stopwatch.createStarted();
ApiFuture<Void> closeFuture = underTest.closeAsync();
assertThat(stopwatch.elapsed(TimeUnit.MILLISECONDS)).isAtMost(100);
assertThat(closeFuture.isDone()).isFalse();
assertThat(elementFuture.isDone()).isFalse();
innerFuture.set(ImmutableList.of(1));
closeFuture.get();
}
Aggregations