BigtableTableAdminGrpcClient implements BigtableTableAdminClient { private String generateConsistencyToken(BigtableTableName tableName) { GenerateConsistencyTokenRequest request = GenerateConsistencyTokenRequest.newBuilder().setName(tableName.toString()).build(); return createUnaryListener(request, generateConsistencyTokenRpc, request.getName()) .getBlockingResult() .getConsistencyToken(); } BigtableTableAdminGrpcClient(
      Channel channel,
      ScheduledExecutorService retryExecutorService,
      BigtableOptions bigtableOptions); @Override ListTablesResponse listTables(ListTablesRequest request); @Override ListenableFuture<ListTablesResponse> listTablesAsync(ListTablesRequest request); @Override Table getTable(GetTableRequest request); @Override ListenableFuture<Table> getTableAsync(GetTableRequest request); @Override Table createTable(CreateTableRequest request); @Override ListenableFuture<Table> createTableAsync(CreateTableRequest request); @Override Table modifyColumnFamily(ModifyColumnFamiliesRequest request); @Override ListenableFuture<Table> modifyColumnFamilyAsync(ModifyColumnFamiliesRequest request); @Override void deleteTable(DeleteTableRequest request); @Override ListenableFuture<Empty> deleteTableAsync(DeleteTableRequest request); @Override void dropRowRange(DropRowRangeRequest request); @Override ListenableFuture<Empty> dropRowRangeAsync(DropRowRangeRequest request); @Override void waitForReplication(BigtableTableName tableName, long timeout); @Override Policy getIamPolicy(GetIamPolicyRequest request); @Override Policy setIamPolicy(SetIamPolicyRequest request); @Override TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request); @Override ListenableFuture<Operation> snapshotTableAsync(SnapshotTableRequest request); @Override ListenableFuture<Snapshot> getSnapshotAsync(GetSnapshotRequest request); @Override ListenableFuture<ListSnapshotsResponse> listSnapshotsAsync(ListSnapshotsRequest request); @Override ListenableFuture<Empty> deleteSnapshotAsync(DeleteSnapshotRequest request); @Override ListenableFuture<Operation> createTableFromSnapshotAsync(
      CreateTableFromSnapshotRequest request);  }
@Test public void testGenerateConsistencyToken() throws TimeoutException, InterruptedException { GenerateConsistencyTokenRequest request = GenerateConsistencyTokenRequest.newBuilder().setName(TABLE_NAME).build(); final AtomicInteger counter = new AtomicInteger(0); Answer<Void> answer = new Answer<Void>() { @Override public Void answer(final InvocationOnMock invocation) throws Throwable { Listener listener = invocation.getArgument(0, Listener.class); if (counter.incrementAndGet() == 1) { listener.onMessage(GenerateConsistencyTokenResponse.getDefaultInstance()); } else { listener.onMessage(CheckConsistencyResponse.newBuilder().setConsistent(true).build()); } listener.onClose(Status.OK, null); return null; } }; doAnswer(answer).when(mockClientCall).start(any(Listener.class), any(Metadata.class)); defaultClient.waitForReplication(INSTANCE_NAME.toTableName("TABLE_NAME"), 6000); verify(mockClientCall, times(2)).start(any(Listener.class), any(Metadata.class)); verify(mockClientCall, times(1)) .sendMessage(ArgumentMatchers.isA(GenerateConsistencyTokenRequest.class)); verify(mockClientCall, times(1)) .sendMessage(ArgumentMatchers.isA(CheckConsistencyRequest.class)); verify(mockClientCall, times(2)).halfClose(); }