use of com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList in project gax-java by googleapis.
the class BatchTest method testBatchElementCounter.
@Test
public void testBatchElementCounter() {
ElementCounter<Batch<LabeledIntList, List<Integer>>> counter = new BatchElementCounter<>(SQUARER_BATCHING_DESC);
LabeledIntList request = new LabeledIntList("lable", 3);
Batch<LabeledIntList, List<Integer>> batch = createBatch(request);
Truth.assertThat(counter.count(batch)).isEqualTo(1);
}
use of com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList in project gax-java by googleapis.
the class BatchTest method testBatchByteCounter.
@Test
public void testBatchByteCounter() {
ElementCounter<Batch<LabeledIntList, List<Integer>>> counter = new BatchByteCounter<>();
LabeledIntList request = new LabeledIntList("lable", 3);
Batch<LabeledIntList, List<Integer>> batch = createBatch(request);
Truth.assertThat(counter.count(batch)).isEqualTo(3);
}
use of com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList in project gax-java by googleapis.
the class BatchTest method testConstructor.
@Test
public void testConstructor() {
LabeledIntList request = new LabeledIntList("lable", 2);
Batch<LabeledIntList, List<Integer>> batch = createBatch(request);
Truth.assertThat(batch.getRequest()).isEqualTo(request);
Truth.assertThat(batch.getCallable()).isSameInstanceAs(batch.getCallable());
Truth.assertThat(batch.getRequestIssuerList().size()).isEqualTo(1);
Truth.assertThat(batch.getByteCount()).isEqualTo(2);
}
use of com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList in project gax-java by googleapis.
the class BatchTest method testMerge.
@Test
public void testMerge() {
LabeledIntList request1 = new LabeledIntList("lable", 1);
Batch<LabeledIntList, List<Integer>> batch1 = createBatch(request1);
LabeledIntList request2 = new LabeledIntList("lable", 2);
Batch<LabeledIntList, List<Integer>> batch2 = createBatch(request2);
batch1.merge(batch2);
Truth.assertThat(batch1.getByteCount()).isEqualTo(3);
}
use of com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList in project gax-java by googleapis.
the class BatcherFactoryTest method testGetPushingBatcher.
@Test
public void testGetPushingBatcher() {
BatchingSettings batchingSettings = BatchingSettings.newBuilder().setDelayThreshold(Duration.ofSeconds(1)).setElementCountThreshold(2L).setRequestByteThreshold(1000L).build();
FlowControlSettings flowControlSettings = FlowControlSettings.newBuilder().setLimitExceededBehavior(LimitExceededBehavior.Ignore).build();
FlowController flowController = new FlowController(flowControlSettings);
BatcherFactory<LabeledIntList, List<Integer>> batcherFactory = new BatcherFactory<>(new SquarerBatchingDescriptor(), batchingSettings, batchingExecutor, flowController);
Truth.assertThat(batcherFactory.getBatchingSettings()).isSameInstanceAs(batchingSettings);
ThresholdBatcher<Batch<LabeledIntList, List<Integer>>> batcherFoo = batcherFactory.getPushingBatcher(new PartitionKey("foo"));
ThresholdBatcher<Batch<LabeledIntList, List<Integer>>> batcherFoo2 = batcherFactory.getPushingBatcher(new PartitionKey("foo"));
ThresholdBatcher<Batch<LabeledIntList, List<Integer>>> batcherBar = batcherFactory.getPushingBatcher(new PartitionKey("bar"));
Truth.assertThat(batcherFoo).isSameInstanceAs(batcherFoo2);
Truth.assertThat(batcherFoo).isNotSameInstanceAs(batcherBar);
}
Aggregations