@Test
  public void testAddPartitionSpecInvalidLocation() throws Exception {

    createTable();
    String tableLocation = metaStore.getWarehouseRoot() + "/" + TABLE_NAME;
    Map<String, String> valuesAndLocations = new HashMap<>();
    valuesAndLocations.put("2014", tableLocation + "/year=2014");
    valuesAndLocations.put("2015", tableLocation + "/year=2015");
    valuesAndLocations.put("2016", "invalidhost:80000/wrongfolder");
    valuesAndLocations.put("2017", tableLocation + "/year=2017");
    valuesAndLocations.put("2018", tableLocation + "/year=2018");
    List<Partition> partitions = buildPartitions(DB_NAME, TABLE_NAME, valuesAndLocations);
    PartitionSpecProxy partitionSpecProxy =
        buildPartitionSpec(DB_NAME, TABLE_NAME, null, partitions);

    try {
      client.add_partitions_pspec(partitionSpecProxy);
      Assert.fail("MetaException should have happened.");
    } catch (MetaException e) {
      // Expected exception
    }

    List<Partition> parts = client.listPartitions(DB_NAME, TABLE_NAME, MAX);
    Assert.assertNotNull(parts);
    Assert.assertTrue(parts.isEmpty());
    for (Partition partition : partitions) {
      if (!"invalidhost:80000/wrongfolder".equals(partition.getSd().getLocation())) {
        Assert.assertFalse(metaStore.isPathExists(new Path(partition.getSd().getLocation())));
      }
    }
  }
Tests for creating partitions from partition spec.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestAddPartitionsFromPartSpec.java