public Optional<UfsStatus[]> listFromUfs(String path, boolean isRecursive)
      throws IOException {
    ListOptions ufsListOptions = ListOptions.defaults().setRecursive(isRecursive);
    UnderFileSystem ufs = getUfsInstance(path);
    try {
      UfsStatus[] listResults = ufs.listStatus(path, ufsListOptions);
      if (listResults != null) {
        return Optional.of(listResults);
      }
    } catch (IOException e) {
      if (!(e instanceof FileNotFoundException)) {
        throw e;
      }
    }
    // TODO(yimin) put the ufs status into the metastore
    // If list does not give a result,
    // the request path might either be a regular file/object or not exist.
    // Try getStatus() instead.
    try {
      UfsStatus status = ufs.getStatus(path);
      if (status == null) {
        return Optional.empty();
      }
      // Success. Create an array with only one element.
      status.setName(""); // listStatus() expects relative name to the @path.
      return Optional.of(new UfsStatus[] {status});
    } catch (FileNotFoundException e) {
      return Optional.empty();
    }
  }
@Test
  public void listFromUfsGetWhenGetSuccess() throws IOException {
    UnderFileSystem system = mock(UnderFileSystem.class);
    UfsStatus fakeStatus = mock(UfsStatus.class);
    when(system.listStatus(anyString())).thenReturn(null);
    when(system.getStatus(anyString())).thenReturn(fakeStatus);
    doReturn(system).when(mDoraUfsManager).getOrAdd(any(), any());

    Optional<UfsStatus[]> status = mManager.listFromUfs("/test", false);
    assertEquals(status.get()[0], fakeStatus);
  }