static BigtableWriteOptions translateToBigtableWriteOptions(
      BigtableWriteOptions writeOptions, BigtableOptions options) {
    BigtableWriteOptions.Builder builder = writeOptions.toBuilder();
    // configure timeouts
    if (options.getCallOptionsConfig().getMutateRpcAttemptTimeoutMs().isPresent()) {
      builder.setAttemptTimeout(
          org.joda.time.Duration.millis(
              options.getCallOptionsConfig().getMutateRpcAttemptTimeoutMs().get()));
    }
    if (options.getBulkOptions().isEnableBulkMutationThrottling()) {
      builder.setThrottlingTargetMs(options.getBulkOptions().getBulkMutationRpcTargetMs());
    }
    builder.setOperationTimeout(
        org.joda.time.Duration.millis(options.getCallOptionsConfig().getMutateRpcTimeoutMs()));
    // configure batch size
    builder.setMaxElementsPerBatch(options.getBulkOptions().getBulkMaxRowKeyCount());
    builder.setMaxBytesPerBatch(options.getBulkOptions().getBulkMaxRequestSize());
    builder.setMaxOutstandingElements(
        options.getBulkOptions().getMaxInflightRpcs()
            * (long) options.getBulkOptions().getBulkMaxRowKeyCount());
    builder.setMaxOutstandingBytes(
        options.getBulkOptions().getMaxInflightRpcs()
            * options.getBulkOptions().getBulkMaxRequestSize());

    return builder.build();
  }
@Test
  public void testBigtableOptionsToBigtableWriteOptions() throws Exception {
    BigtableOptions options =
        BigtableOptions.builder()
            .setCallOptionsConfig(
                CallOptionsConfig.builder()
                    .setMutateRpcAttemptTimeoutMs(200)
                    .setMutateRpcTimeoutMs(2000)
                    .build())
            .setRetryOptions(
                RetryOptions.builder()
                    .setInitialBackoffMillis(15)
                    .setBackoffMultiplier(2.5)
                    .build())
            .setBulkOptions(
                BulkOptions.builder()
                    .setBulkMaxRequestSize(20)
                    .setBulkMaxRowKeyCount(100)
                    .setMaxInflightRpcs(5)
                    .build())
            .build();

    BigtableWriteOptions writeOptions =
        BigtableWriteOptions.builder()
            .setTableId(ValueProvider.StaticValueProvider.of("table"))
            .build();

    BigtableWriteOptions fromBigtableOptions =
        BigtableConfigTranslator.translateToBigtableWriteOptions(writeOptions, options);

    assertNotNull(fromBigtableOptions.getAttemptTimeout());
    assertNotNull(fromBigtableOptions.getOperationTimeout());
    assertNotNull(fromBigtableOptions.getMaxBytesPerBatch());
    assertNotNull(fromBigtableOptions.getMaxElementsPerBatch());
    assertNotNull(fromBigtableOptions.getMaxOutstandingElements());
    assertNotNull(fromBigtableOptions.getMaxOutstandingBytes());

    assertEquals(org.joda.time.Duration.millis(200), fromBigtableOptions.getAttemptTimeout());
    assertEquals(org.joda.time.Duration.millis(2000), fromBigtableOptions.getOperationTimeout());
    assertEquals(20, (long) fromBigtableOptions.getMaxBytesPerBatch());
    assertEquals(100, (long) fromBigtableOptions.getMaxElementsPerBatch());
    assertEquals(5 * 100, (long) fromBigtableOptions.getMaxOutstandingElements());
    assertEquals(5 * 20, (long) fromBigtableOptions.getMaxOutstandingBytes());
  }