@Override
  public LocalResourceId resolve(String other, ResolveOptions resolveOptions) {
    checkState(isDirectory(), "Expected the path is a directory, but had [%s].", pathString);
    checkArgument(
        resolveOptions.equals(StandardResolveOptions.RESOLVE_FILE)
            || resolveOptions.equals(StandardResolveOptions.RESOLVE_DIRECTORY),
        "ResolveOptions: [%s] is not supported.",
        resolveOptions);
    checkArgument(
        !(resolveOptions.equals(StandardResolveOptions.RESOLVE_FILE) && other.endsWith("/")),
        "The resolved file: [%s] should not end with '/'.",
        other);
    if (SystemUtils.IS_OS_WINDOWS) {
      return resolveLocalPathWindowsOS(other, resolveOptions);
    } else {
      return resolveLocalPath(other, resolveOptions);
    }
  }
@Test
  public void testResolveNormalizationInUnix() {
    if (SystemUtils.IS_OS_WINDOWS) {
      // Skip tests
      return;
    }
    // Tests normalization of "." and ".."
    //
    // Normalization is the implementation choice of LocalResourceId,
    // and it is not required by ResourceId.resolve().
    assertEquals(
        toResourceIdentifier("file://home/bb"),
        toResourceIdentifier("file://root/../home/output/../")
            .resolve("aa", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve("..", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve("bb", StandardResolveOptions.RESOLVE_FILE));
    assertEquals(
        toResourceIdentifier("file://root/aa/bb"),
        toResourceIdentifier("file://root/./")
            .resolve("aa", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve(".", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve("bb", StandardResolveOptions.RESOLVE_FILE));
    assertEquals(
        toResourceIdentifier("aa/bb"),
        toResourceIdentifier("a/../")
            .resolve("aa", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve(".", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve("bb", StandardResolveOptions.RESOLVE_FILE));
    assertEquals(
        toResourceIdentifier("/aa/bb"),
        toResourceIdentifier("/a/../")
            .resolve("aa", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve(".", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve("bb", StandardResolveOptions.RESOLVE_FILE));

    // Tests "./", "../", "~/".
    assertEquals(
        toResourceIdentifier("aa/bb"),
        toResourceIdentifier("./")
            .resolve("aa", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve(".", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve("bb", StandardResolveOptions.RESOLVE_FILE));
    assertEquals(
        toResourceIdentifier("../aa/bb"),
        toResourceIdentifier("../")
            .resolve("aa", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve(".", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve("bb", StandardResolveOptions.RESOLVE_FILE));
    assertEquals(
        toResourceIdentifier("~/aa/bb/"),
        toResourceIdentifier("~/")
            .resolve("aa", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve(".", StandardResolveOptions.RESOLVE_DIRECTORY)
            .resolve("bb", StandardResolveOptions.RESOLVE_DIRECTORY));
  }