Search in sources :

Example 1 with LabeledIntSquarerCallable

use of com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntSquarerCallable in project gax-java by googleapis.

the class BatcherImplTest method testSendOutstanding.

@Test
public void testSendOutstanding() {
    final AtomicInteger callableCounter = new AtomicInteger();
    underTest = new BatcherImpl<>(SQUARER_BATCHING_DESC_V2, new LabeledIntSquarerCallable() {

        @Override
        public ApiFuture<List<Integer>> futureCall(LabeledIntList request, ApiCallContext context) {
            callableCounter.incrementAndGet();
            return super.futureCall(request, context);
        }
    }, labeledIntList, batchingSettings, EXECUTOR);
    // Empty Batcher
    underTest.sendOutstanding();
    assertThat(callableCounter.get()).isEqualTo(0);
    underTest.add(2);
    underTest.add(3);
    underTest.add(4);
    underTest.sendOutstanding();
    assertThat(callableCounter.get()).isEqualTo(1);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LabeledIntSquarerCallable(com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntSquarerCallable) LabeledIntList(com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) LabeledIntList(com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList) ApiCallContext(com.google.api.gax.rpc.ApiCallContext) Test(org.junit.Test)

Aggregations

ApiCallContext (com.google.api.gax.rpc.ApiCallContext)1 LabeledIntList (com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntList)1 LabeledIntSquarerCallable (com.google.api.gax.rpc.testing.FakeBatchableApi.LabeledIntSquarerCallable)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Test (org.junit.Test)1