private TestAccount createTestAccountAndFinishAuth() {
    Bundle parameters = new Bundle();
    parameters.putString("installed", "true");
    parameters.putString("permissions", getPermissionsString());
    parameters.putString("access_token", getAppAccessToken());

    // If we're in shared mode, we want to rename this user to encode its permissions, so we can
    // find it later
    // in another shared session. If we're in private mode, don't bother renaming it since we're
    // just going to
    // delete it at the end of the session.
    if (mode == Mode.SHARED) {
      parameters.putString(
          "name", String.format("Shared %s Testuser", getSharedTestAccountIdentifier()));
    }

    String graphPath = String.format("%s/accounts/test-users", testApplicationId);
    Request createUserRequest = new Request(null, graphPath, parameters, HttpMethod.POST);
    Response response = createUserRequest.executeAndWait();

    FacebookRequestError error = response.getError();
    TestAccount testAccount = response.getGraphObjectAs(TestAccount.class);
    if (error != null) {
      finishAuthOrReauth(null, error.getException());
      return null;
    } else {
      assert testAccount != null;

      // If we are in shared mode, store this new account in the dictionary so we can re-use it
      // later.
      if (mode == Mode.SHARED) {
        // Remember the new name we gave it, since we didn't get it back in the results of the
        // create request.
        testAccount.setName(parameters.getString("name"));
        storeTestAccount(testAccount);
      }

      finishAuthWithTestAccount(testAccount);

      return testAccount;
    }
  }
  private void deleteTestAccount(String testAccountId, String appAccessToken) {
    Bundle parameters = new Bundle();
    parameters.putString("access_token", appAccessToken);

    Request request = new Request(null, testAccountId, parameters, HttpMethod.DELETE);
    Response response = request.executeAndWait();

    FacebookRequestError error = response.getError();
    GraphObject graphObject = response.getGraphObject();
    if (error != null) {
      Log.w(
          LOG_TAG,
          String.format(
              "Could not delete test account %s: %s",
              testAccountId, error.getException().toString()));
    } else if (graphObject.getProperty(Response.NON_JSON_RESPONSE_PROPERTY) == (Boolean) false) {
      Log.w(
          LOG_TAG,
          String.format("Could not delete test account %s: unknown reason", testAccountId));
    }
  }