private void testUtil(String isAutoPurge, boolean isExternal, boolean isPartitioned,
      boolean purgeExpected, boolean isTruncateTest, String testTableName) throws Exception {
    try (Statement stmt = con.createStatement()) {
      // create a test table with auto.purge = true
      createTestTable(stmt, isAutoPurge, isExternal, isPartitioned, testTableName);
      int numFilesInTrashBefore = getTrashFileCount();
      String command = getCommand(isTruncateTest, isPartitioned, testTableName);
      stmt.execute(command);
      int numFilesInTrashAfter = getTrashFileCount();
      if (purgeExpected) {
        Assert.assertTrue(
            String.format(
                "Data should have been moved to trash. Number of files in trash: before : %d after %d",
                numFilesInTrashBefore, numFilesInTrashAfter),
            numFilesInTrashBefore < numFilesInTrashAfter);
      } else {
        Assert.assertEquals(
            String.format(
                "Data should not have been moved to trash. Number of files in trash: before : %d after %d",
                numFilesInTrashBefore, numFilesInTrashAfter),
            numFilesInTrashBefore, numFilesInTrashAfter);
      }
    }
  }
Test util method to run the insert overwrite table or truncate table test on a table

@param isAutoPurge - If set, creates a table with auto.purge with the given value
@param isExternal - if set creates a external table for the test
@param isPartitioned - if set creates a partitioned table for the test
@param purgeExpected - if set the assert condition for the test is such that it expectes old
         table data to be moved to trash. If not creates a assert condition to make sure that
         data is not moved to trash
@param isTruncateTest - if set uses truncate table command for the test. Otherwise uses Insert
         overwrite table command for the test
@param testTableName - table name for the test table
@throws Exception
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestAutoPurgeTables.java