@Override
  public GcsResourceId resolve(String other, ResolveOptions resolveOptions) {
    checkState(
        isDirectory(),
        String.format("Expected the gcsPath is a directory, but had [%s].", gcsPath));
    checkArgument(
        resolveOptions.equals(StandardResolveOptions.RESOLVE_FILE)
            || resolveOptions.equals(StandardResolveOptions.RESOLVE_DIRECTORY),
        String.format("ResolveOptions: [%s] is not supported.", resolveOptions));
    if (resolveOptions.equals(StandardResolveOptions.RESOLVE_FILE)) {
      checkArgument(
          !other.endsWith("/"), "The resolved file: [%s] should not end with '/'.", other);
      return fromGcsPath(gcsPath.resolve(other));
    } else {
      // StandardResolveOptions.RESOLVE_DIRECTORY
      if (other.endsWith("/")) {
        // other already contains the delimiter for gcs.
        // It is not recommended for callers to set the delimiter.
        // However, we consider it as a valid input.
        return fromGcsPath(gcsPath.resolve(other));
      } else {
        return fromGcsPath(gcsPath.resolve(other + "/"));
      }
    }
  }
@Test
  public void testResolveInvalidNotDirectory() {
    ResourceId tmpDir =
        toResourceIdentifier("gs://my_bucket/")
            .resolve("tmp dir", StandardResolveOptions.RESOLVE_FILE);

    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Expected the gcsPath is a directory, but had [gs://my_bucket/tmp dir].");
    tmpDir.resolve("aa", StandardResolveOptions.RESOLVE_FILE);
  }