@Test
  public void testUpdateTableStatsForCreateTableInvokeStatsCalc() throws TException {
    // DO_NOT_UPDATE_STATS in env context is not defined => invoke stats calculation
    Map<String, String> params = new HashMap<>(paramsWithStats);
    Warehouse wh = mock(Warehouse.class);

    Table tbl = new TableBuilder()
            .setDbName(DB_NAME)
            .setTableName(TABLE_NAME)
            .addCol("id", "int")
            .setTableParams(params)
            .build(null);

    MetaStoreServerUtils.updateTableStatsForCreateTable(wh, db, tbl, null,
            MetastoreConf.newMetastoreConf(), new Path("/tmp/0"), false);

    assertTrue(messageWasLogged(MessageFormat.format(
            STATS_CALC_CALL_LOG_MSG_FORMAT, tbl.getCatName(), tbl.getDbName(), tbl.getTableName())));

    // DO_NOT_UPDATE_STATS in env context is set to false => invoke stats calculation
    EnvironmentContext env = new EnvironmentContext();
    env.putToProperties(StatsSetupConst.DO_NOT_UPDATE_STATS, StatsSetupConst.FALSE);

    MetaStoreServerUtils.updateTableStatsForCreateTable(wh, db, tbl, env,
            MetastoreConf.newMetastoreConf(), new Path("/tmp/0"), false);
    assertTrue(messageWasLogged(MessageFormat.format(
            STATS_CALC_CALL_LOG_MSG_FORMAT, tbl.getCatName(), tbl.getDbName(), tbl.getTableName())));
  }
Verify that updateTableStatsForCreateTable() invokes calculation of table statistics when
<ol>
  <li>Stats auto source in envContext is not set</li>
  <li>Stats auto source in envContext is set to true</li>
</ol>
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestMetaStoreServerUtils.java