private Table createTable(String dbName, String tableName, TableType type, String owner, PrincipalType ownerType)
          throws Exception {
    TableBuilder builder = new TableBuilder()
            .setCatName("hive")
            .setDbName(dbName) .setTableName(tableName)
            .setOwner(owner)
            .setOwnerType(ownerType)
            .addCol("id", "int")
            .addCol("name", "string")
            .setType(type.name());

    Table table = builder.build(metaStore.getConf());

    if (type == TableType.MATERIALIZED_VIEW) {
      CreationMetadata cm = new CreationMetadata(
          MetaStoreUtils.getDefaultCatalog(metaStore.getConf()), dbName, tableName, ImmutableSet.of());
      cm.setSourceTables(Collections.emptyList());
      table.setCreationMetadata(cm);
    }

    if (type == TableType.EXTERNAL_TABLE) {
      table.getParameters().put("EXTERNAL", "true");
    } else if (type == TableType.MANAGED_TABLE) {
       // we do not want MANAGED tables to be converted to EXTERNAL
      table.getParameters().put("transactional", "true");
      table.getParameters().put("transactional_properties", "insert_only");
    }
    return table;
  }
API tests for HMS client's getTableMeta method.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestGetTableMeta.java