### Question:
HdfsSnapshotLocationManager implements SourceLocationManager { static List<Path> calculateSubPaths( List<Partition> sourcePartitions, String sourceDataLocation, String copyBaseLocation) { List<Path> paths = new ArrayList<>(sourcePartitions.size()); for (Partition partition : sourcePartitions) { String partitionLocation = partition.getSd().getLocation(); String partitionBranch = partitionLocation.replace(sourceDataLocation, ""); while (partitionBranch.startsWith("/")) { partitionBranch = partitionBranch.substring(1); } Path copyPartitionPath = new Path(copyBaseLocation, partitionBranch); paths.add(copyPartitionPath); LOG.debug("Added sub-path {}.", copyPartitionPath.toString()); } return paths; } HdfsSnapshotLocationManager(
      HiveConf sourceHiveConf,
      String eventId,
      Table sourceTable,
      boolean snapshotsDisabled,
      SourceCatalogListener sourceCatalogListener);   HdfsSnapshotLocationManager(
      HiveConf sourceHiveConf,
      String eventId,
      Table sourceTable,
      boolean snapshotsDisabled,
      String tableBasePath,
      SourceCatalogListener sourceCatalogListener);   HdfsSnapshotLocationManager(
      HiveConf sourceHiveConf,
      String eventId,
      Table sourceTable,
      List<Partition> sourcePartitions,
      boolean snapshotsDisabled,
      String tableBasePath,
      SourceCatalogListener sourceCatalogListener);   HdfsSnapshotLocationManager(
      HiveConf sourceHiveConf,
      String eventId,
      Table sourceTable,
      List<Partition> sourcePartitions,
      boolean snapshotsDisabled,
      String tableBasePath,
      FileSystemFactory fileSystemFactory,
      SourceCatalogListener sourceCatalogListener); @Override Path getTableLocation(); @Override void cleanUpLocations(); @Override List<Path> getPartitionLocations(); @Override Path getPartitionSubPath(Path partitionLocation);  }### Answer:
@Test public void calculateSubPaths() { StorageDescriptor sd = new StorageDescriptor(); sd.setLocation("/a/partition1"); partition1.setSd(sd); List<Path> subPaths = HdfsSnapshotLocationManager.calculateSubPaths(Collections.singletonList(partition1), "/a", "/b"); assertThat(subPaths.get(0).toString(), is("/b/partition1")); }
@Test public void calculateSubPathsFullUri() { StorageDescriptor sd = new StorageDescriptor(); sd.setLocation("/a/partition1"); partition1.setSd(sd); List<Path> subPaths = HdfsSnapshotLocationManager.calculateSubPaths(Collections.singletonList(partition1), "/a", "hdfs: assertThat(subPaths.get(0).toString(), is("hdfs: }
@Test public void calculateSubPathsUriEncodedPathAndPartition() { StorageDescriptor sd = new StorageDescriptor(); sd.setLocation("hdfs: partition1.setSd(sd); List<Path> subPaths = HdfsSnapshotLocationManager.calculateSubPaths(Collections.singletonList(partition1), "hdfs: assertThat(subPaths.get(0).toString(), is("/b%25c/partition1=url%25encoded.%3A")); }
@Test public void calculateSubPathsTrailingSlash() { StorageDescriptor sd = new StorageDescriptor(); sd.setLocation("/a/partition1"); partition1.setSd(sd); List<Path> subPaths = HdfsSnapshotLocationManager.calculateSubPaths(Collections.singletonList(partition1), "/a/", "/b"); assertThat(subPaths.get(0).toString(), is("/b/partition1")); }