@Test
  public void testTruncateTablePartitioned() throws Exception {
    // Partitioned table - delete specific partitions a0, a2
    List<String> partitionsToDelete = new ArrayList<>();
    partitionsToDelete.add("test_part_col=a0");
    partitionsToDelete.add("test_part_col=a2");
    client.truncateTable(partitionedTable.getDbName(), partitionedTable.getTableName(),
        partitionsToDelete);
    Assert.assertTrue("Location should exist",
        metaStore.isPathExists(new Path(testTables[0].getSd().getLocation())));
    List<Partition> partitions =
        client.listPartitions(partitionedTable.getDbName(), partitionedTable.getTableName(),
            (short)-1);
    for(Partition partition : partitions) {
      Path dataFile = new Path(partition.getSd().getLocation() + "/dataFile");
      if (partition.getValues().contains("a0") || partition.getValues().contains("a2")) {
        // a0, a2 should be empty
        Assert.assertFalse("DataFile should be removed", metaStore.isPathExists(dataFile));
      } else {
        // Others (a1) should be kept
        Assert.assertTrue("DataFile should not be removed", metaStore.isPathExists(dataFile));
      }
    }

  }
This test creates and queries a table and then drops it. Good for testing the happy path
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java