public static ListenableFuture<Void> createParentIfNeededAsync(
      AsyncBlobStore asyncBlobStore, String container, Blob blob) {
    checkNotNull(asyncBlobStore, "asyncBlobStore");
    checkNotNull(container, "container");

    String name = blobName.apply(blob);
    if (name.indexOf('/') > 0) {
      return asyncBlobStore.createDirectory(container, parseDirectoryFromPath(name));
    } else {
      return Futures.immediateFuture(null);
    }
  }
  public void testCreateParentIfNeededAsyncNestedPath() {
    AsyncBlobStore asyncBlobStore = createMock(AsyncBlobStore.class);
    String container = "container";
    Blob blob = createMock(Blob.class);
    MutableBlobMetadata md = createMock(MutableBlobMetadata.class);

    expect(blob.getMetadata()).andReturn(md).atLeastOnce();
    expect(md.getName()).andReturn("rootpath/subpath/hello").atLeastOnce();
    expect(asyncBlobStore.createDirectory("container", "rootpath/subpath")).andReturn(null);

    replay(asyncBlobStore);
    replay(blob);
    replay(md);

    createParentIfNeededAsync(asyncBlobStore, container, blob);

    verify(asyncBlobStore);
    verify(blob);
    verify(md);
  }