예제 #1
0
  /**
   * Fetch the raw body of an ApexLog with the specified log ID.
   *
   * @param forceProject
   * @param logId
   * @return Raw log. Null if something is wrong.
   */
  public String getApexLogBody(ForceProject forceProject, String logId) {
    String rawLog = null;

    try {
      initializeConnection(forceProject);

      PromiseableJob<String> job =
          new ApexLogCommand(
              new HTTPAdapter<>(
                  String.class,
                  new ApexLogTransport(toolingRESTConnection, logId),
                  HTTPMethod.GET));
      job.schedule();

      try {
        job.join();
        rawLog = job.getAnswer();
      } catch (InterruptedException e) {
        logger.error("Failed to get Apex Log", e);
      }
    } catch (ForceConnectionException | ForceRemoteException e) {
      logger.error("Failed to connect to Tooling API", e);
    }

    return rawLog;
  }
예제 #2
0
  /**
   * Enqueue a tests array to Tooling's runTestsAsynchronous.
   *
   * @param testsInJson
   * @return The test run ID if valid. Null otherwise.
   */
  public String enqueueTests(String testsInJson) {
    String response = null;

    if (Utils.isEmpty(forceProject)) {
      return response;
    }

    try {
      initializeConnection(forceProject);

      PromiseableJob<String> job =
          new RunTestsCommand(
              new HTTPAdapter<>(
                  String.class, new RunTestsTransport(toolingRESTConnection), HTTPMethod.POST),
              testsInJson);
      job.schedule();

      try {
        job.join();
        response = job.getAnswer();
      } catch (InterruptedException e) {
        logger.error("Failed to enqueue test run", e);
      }

    } catch (ForceConnectionException | ForceRemoteException e) {
      logger.error("Failed to connect to Tooling API", e);
    }

    return response;
  }