java.lang.Object
Services.CorrelationsView.ScriptGeneration.Converter

public class Converter extends Object
Handles the conversion of HAR files into JMeter JMX scripts using the BlazeMeter Converter public API.

The conversion workflow is:

  1. Upload a HAR files
  2. Trigger the conversion process
  3. Poll conversion status until finished
  4. Download the generated JMX file
  5. Save it locally

This class acts as an HTTP client wrapper and orchestrator for the full conversion lifecycle.

  • Constructor Details

    • Converter

      public Converter()
  • Method Details

    • runMain

      public static void runMain(String filename, String filehar, String path) throws IOException, org.json.simple.parser.ParseException, InterruptedException, ParserConfigurationException, TransformerException, SAXException
      Main orchestration method that converts a HAR file into a JMX script.

      The method:

      • Uploads the HAR file
      • Starts the conversion process
      • Polls the status endpoint until conversion is finished
      • Downloads the resulting JMX file
      • Saves it to the configured scripts directory
      Parameters:
      filename - name of the HAR file
      filehar - HAR file identifier
      path - directory where the HAR file is located
      Throws:
      IOException
      org.json.simple.parser.ParseException
      InterruptedException
      ParserConfigurationException
      TransformerException
      SAXException
    • saveJMXFile

      public static void saveJMXFile(String jmx, String filename) throws ParserConfigurationException, TransformerException, IOException, SAXException
      Saves the converted JMX content to disk.
      Parameters:
      jmx - JMX file content returned by the converter
      filename - original HAR filename (used to derive output name)
      Throws:
      ParserConfigurationException
      TransformerException
      IOException
      SAXException
    • UploadRequest

      public static okhttp3.Response UploadRequest(String filename, String path) throws IOException
      Uploads a HAR file to the BlazeMeter converter service.
      Parameters:
      filename - HAR file name
      path - directory containing the HAR file
      Returns:
      HTTP response containing a public token
      Throws:
      IOException
    • convertRequest

      public static okhttp3.Response convertRequest(String res) throws org.json.simple.parser.ParseException, IOException
      Triggers the conversion process for a previously uploaded HAR file.
      Parameters:
      res - upload response JSON containing the public token
      Returns:
      HTTP response for the conversion request
      Throws:
      org.json.simple.parser.ParseException
      IOException
    • downloadRequest

      public static String downloadRequest(String url) throws org.json.simple.parser.ParseException, IOException
      Downloads the generated JMX file from the given URL.
      Parameters:
      url - download URL returned by the converter
      Returns:
      JMX file content as a string
      Throws:
      org.json.simple.parser.ParseException
      IOException
    • statusRequest

      public static okhttp3.Response statusRequest(String res) throws org.json.simple.parser.ParseException, IOException
      Retrieves the conversion status from the API.
      Parameters:
      res - response JSON containing the public token
      Returns:
      HTTP response with status information
      Throws:
      org.json.simple.parser.ParseException
      IOException
    • getToken

      public static String getToken(String response) throws org.json.simple.parser.ParseException
      Extracts the public token from a JSON response.
      Parameters:
      response - JSON response returned by the API
      Returns:
      public token used to track conversion
      Throws:
      org.json.simple.parser.ParseException
    • getNamefileHar

      public static String getNamefileHar(String filename)
      Returns the base filename without extension.
      Parameters:
      filename - input file name
      Returns:
      filename without extension
    • getStatus

      public static String getStatus(String response) throws org.json.simple.parser.ParseException
      Extracts the conversion status from a JSON response.
      Parameters:
      response - status response JSON
      Returns:
      conversion status (e.g. FINISHED)
      Throws:
      org.json.simple.parser.ParseException
    • getoUrl

      public static String getoUrl(String response) throws org.json.simple.parser.ParseException
      Extracts the output download URL from the API response.
      Parameters:
      response - JSON response containing conversion result data
      Returns:
      URL used to download the generated JMX file
      Throws:
      org.json.simple.parser.ParseException