public boolean createMetadataTable() {
    GCRules.GCRule gcRules = GCRules.GCRULES.maxVersions(1);

    if (tableAdminClient.exists(tableId)) {
      Table table = tableAdminClient.getTable(tableId);
      List<ColumnFamily> currentCFs = table.getColumnFamilies();
      ModifyColumnFamiliesRequest request = ModifyColumnFamiliesRequest.of(tableId);
      boolean needsNewColumnFamily = false;
      for (String targetCF : COLUMN_FAMILIES) {
        boolean exists = false;
        for (ColumnFamily currentCF : currentCFs) {
          if (targetCF.equals(currentCF.getId())) {
            exists = true;
            break;
          }
        }
        if (!exists) {
          needsNewColumnFamily = true;
          request.addFamily(targetCF, gcRules);
        }
      }
      if (needsNewColumnFamily) {
        tableAdminClient.modifyFamilies(request);
      }
      return false;
    }

    CreateTableRequest createTableRequest = CreateTableRequest.of(tableId);
    for (String cf : COLUMN_FAMILIES) {
      createTableRequest.addFamily(cf, gcRules);
    }

    tableAdminClient.createTable(createTableRequest);
    return true;
  }
@Test
  public void testCreateTableAlreadyExists() {
    assertTrue(metadataTableAdminDao.createMetadataTable());
    // Verify column families are correct.
    Table table = tableAdminClient.getTable(tableId);
    assertEquals(COLUMN_FAMILIES.size(), table.getColumnFamilies().size());
    assertThat(
        table.getColumnFamilies().stream().map(ColumnFamily::getId).collect(Collectors.toList()),
        Matchers.containsInAnyOrder(COLUMN_FAMILIES.toArray()));

    assertFalse(metadataTableAdminDao.createMetadataTable());
    // Verify the expected column families are still there.
    table = tableAdminClient.getTable(tableId);
    assertEquals(COLUMN_FAMILIES.size(), table.getColumnFamilies().size());
    assertThat(
        table.getColumnFamilies().stream().map(ColumnFamily::getId).collect(Collectors.toList()),
        Matchers.containsInAnyOrder(COLUMN_FAMILIES.toArray()));
  }