public static ResourceId matchNewDirectory(String singleResourceSpec, String... baseNames) {
    ResourceId currentDir = matchNewResource(singleResourceSpec, true);
    for (String dir : baseNames) {
      currentDir = currentDir.resolve(dir, StandardResolveOptions.RESOLVE_DIRECTORY);
    }
    return currentDir;
  }
@Test
  public void testMatchNewDirectory() {
    List<KV<String, KV<String, String[]>>> testCases =
        ImmutableList.<KV<String, KV<String, String[]>>>builder()
            .add(KV.of("/abc/d/", KV.of("/abc", new String[] {"d"})))
            .add(KV.of("/abc/d/", KV.of("/abc/", new String[] {"d"})))
            .add(KV.of("/abc/d/", KV.of("/abc", new String[] {"d/"})))
            .add(KV.of("/abc/d/e/f/", KV.of("/abc", new String[] {"d", "e", "f"})))
            .add(KV.of("/abc/", KV.of("/abc", new String[] {})))
            .build();
    for (KV<String, KV<String, String[]>> testCase : testCases) {
      ResourceId expected = FileSystems.matchNewResource(testCase.getKey(), true);
      ResourceId actual =
          FileSystems.matchNewDirectory(
              testCase.getValue().getKey(), testCase.getValue().getValue());
      assertEquals(expected, actual);
    }
  }