@Test
public void testWriteToTableValidateConfig() throws Exception {

  // No error.
  CloudBigtableIO.writeToTable(scanConfig).validate(null);
  // Empty project ID.
  try {
    CloudBigtableIO.writeToTable(scanConfig.toBuilder().withProjectId("").build()).validate(null);
    Assert.fail("Expect IllegalArgumentException");
  } catch (IllegalArgumentException e) {
    Assert.assertTrue(e.getMessage().contains("A projectId must be set"));
  }
  // Empty instance ID.
  try {
    CloudBigtableIO.writeToTable(scanConfig.toBuilder().withInstanceId("").build())
        .validate(null);
    Assert.fail("Expect IllegalArgumentException");
  } catch (IllegalArgumentException e) {
    Assert.assertTrue(e.getMessage().contains("A instanceId must be set"));
  }
  // Empty table ID.
  try {
    CloudBigtableIO.writeToTable(scanConfig.toBuilder().withTableId("").build()).validate(null);
    Assert.fail("Expect IllegalArgumentException");
  } catch (IllegalArgumentException e) {
    Assert.assertTrue(e.getMessage().contains("A tableid must be set"));
  }
}