public static <T> Response call(RestUtils.RestCallable<T> callable,
      AlluxioConfiguration alluxioConf, @Nullable Map<String, Object> headers) {
    try {
      // TODO(cc): reconsider how to enable authentication
      if (SecurityUtils.isSecurityEnabled(alluxioConf)
          && AuthenticatedClientUser.get(alluxioConf) == null) {
        AuthenticatedClientUser.set(ServerUserState.global().getUser().getName());
      }
    } catch (IOException e) {
      LOG.warn("Failed to set AuthenticatedClientUser in REST service handler: {}", e.toString());
      return createErrorResponse(e, alluxioConf);
    }

    try {
      return createResponse(callable.call(), alluxioConf, headers);
    } catch (Exception e) {
      LOG.warn("Unexpected error invoking rest endpoint: {}", e.toString());
      return createErrorResponse(e, alluxioConf);
    }
  }
@Test
  public void objectOkResponse() throws Exception {
    class Obj {
      private final int mStatus;
      private final String mMessage;

      Obj(int status, String message) {
        mStatus = status;
        mMessage = message;
      }

      public int getStatus() {
        return mStatus;
      }

      public String getMessage() {
        return mMessage;
      }
    }

    int status = 200;
    String message = "OK";
    final Obj object = new Obj(status, message);
    Response response = RestUtils.call(new RestUtils.RestCallable<Obj>() {
      @Override
      public Obj call() throws Exception {
        return object;
      }
    }, Configuration.global());
    Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    Obj obj = (Obj) response.getEntity();
    Assert.assertEquals(status, obj.getStatus());
    Assert.assertEquals(message, obj.getMessage());
  }