@Test
  public void testAddPartitionSpec() throws Exception {

    Table table = createTable();
    Partition partition1 = buildPartition(Lists.newArrayList("2013"), getYearPartCol(), 1);
    Partition partition2 = buildPartition(Lists.newArrayList("2014"), getYearPartCol(), 2);
    Partition partition3 = buildPartition(Lists.newArrayList("2012"), getYearPartCol(), 3);
    List<Partition> partitions = Lists.newArrayList(partition1, partition2, partition3);

    String rootPath = table.getSd().getLocation() + "/addpartspectest/";
    PartitionSpecProxy partitionSpec =
        buildPartitionSpec(DB_NAME, TABLE_NAME, rootPath, partitions);
    client.add_partitions_pspec(partitionSpec);

    verifyPartition(table, "year=2013", Lists.newArrayList("2013"), 1);
    verifyPartition(table, "year=2014", Lists.newArrayList("2014"), 2);
    verifyPartition(table, "year=2012", Lists.newArrayList("2012"), 3);
  }
Tests for creating partitions from partition spec.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java