Class Converter
java.lang.Object
Services.CorrelationsView.ScriptGeneration.Converter
Handles the conversion of HAR files into JMeter JMX scripts using
the BlazeMeter Converter public API.
The conversion workflow is:
- Upload a HAR files
- Trigger the conversion process
- Poll conversion status until finished
- Download the generated JMX file
- Save it locally
This class acts as an HTTP client wrapper and orchestrator for the full conversion lifecycle.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic okhttp3.ResponseconvertRequest(String res) Triggers the conversion process for a previously uploaded HAR file.static StringdownloadRequest(String url) Downloads the generated JMX file from the given URL.static StringgetNamefileHar(String filename) Returns the base filename without extension.static StringExtracts the output download URL from the API response.static StringExtracts the conversion status from a JSON response.static StringExtracts the public token from a JSON response.static voidMain orchestration method that converts a HAR file into a JMX script.static voidsaveJMXFile(String jmx, String filename) Saves the converted JMX content to disk.static okhttp3.ResponsestatusRequest(String res) Retrieves the conversion status from the API.static okhttp3.ResponseUploadRequest(String filename, String path) Uploads a HAR file to the BlazeMeter converter service.
-
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 filefilehar- HAR file identifierpath- directory where the HAR file is located- Throws:
IOExceptionorg.json.simple.parser.ParseExceptionInterruptedExceptionParserConfigurationExceptionTransformerExceptionSAXException
-
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 converterfilename- original HAR filename (used to derive output name)- Throws:
ParserConfigurationExceptionTransformerExceptionIOExceptionSAXException
-
UploadRequest
Uploads a HAR file to the BlazeMeter converter service.- Parameters:
filename- HAR file namepath- 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.ParseExceptionIOException
-
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.ParseExceptionIOException
-
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.ParseExceptionIOException
-
getToken
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
Returns the base filename without extension.- Parameters:
filename- input file name- Returns:
- filename without extension
-
getStatus
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
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
-