@Override
  protected LocalResourceId matchNewResource(String singleResourceSpec, boolean isDirectory) {
    if (isDirectory) {
      if (!singleResourceSpec.endsWith(File.separator)) {
        singleResourceSpec += File.separator;
      }
    } else {
      checkArgument(
          !singleResourceSpec.endsWith(File.separator),
          "Expected file path but received directory path [%s].",
          singleResourceSpec);
    }
    Path path = Paths.get(singleResourceSpec);
    return LocalResourceId.fromPath(path, isDirectory);
  }
@Test
  public void testMatchNewResource() {
    // TODO: Java core test failing on windows, https://github.com/apache/beam/issues/20461
    assumeFalse(SystemUtils.IS_OS_WINDOWS);
    LocalResourceId fileResource =
        localFileSystem.matchNewResource("/some/test/resource/path", false /* isDirectory */);
    LocalResourceId dirResource =
        localFileSystem.matchNewResource("/some/test/resource/path", true /* isDirectory */);
    assertNotEquals(fileResource, dirResource);
    assertThat(
        fileResource
            .getCurrentDirectory()
            .resolve("path", StandardResolveOptions.RESOLVE_DIRECTORY),
        equalTo(dirResource.getCurrentDirectory()));
    assertThat(
        fileResource
            .getCurrentDirectory()
            .resolve("path", StandardResolveOptions.RESOLVE_DIRECTORY),
        equalTo(dirResource.getCurrentDirectory()));
    assertThat(dirResource.toString(), equalTo("/some/test/resource/path/"));

    IllegalArgumentException exception =
        assertThrows(
            IllegalArgumentException.class,
            () -> localFileSystem.matchNewResource("/some/test/resource/path/", false));
    assertTrue(exception.getMessage().startsWith("Expected file path but received directory path"));
  }