this is java program created to extract testcases from alm using api key but not sure how to configure API key in HP ALM can someone explain me setting up api key is java program created to extract testcases from alm using api key but not sure how to configure API key in HP ALM can someone explain me setting up api keyis java program created to extract testcases from alm using api key but not sure how to configure API key in HP ALM can someone explain me setting up api keyis java program created to extract testcases from alm using api key but not sure how to configure API key in HP ALM can someone explain me setting up api keyis java program created to extract testcases from alm using api key but not sure how to configure API key in HP ALM can someone explain me setting up api key
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpHeaders;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class ALMTestCaseExtractor {
public static void main(String[] args) {
String almURL = "http://your_alm_server:port/qcbin";
String almDomain = "your_domain";
String almProject = "your_project";
String almAPIKey = "your_api_key";
String almFolderPath = "your_folder_path"; // Example: "Subject\Folder1\Folder2"
String excelFilePath = "path/to/excel/file.xlsx";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// Set ALM API key
String authorizationHeader = "Bearer " + almAPIKey;
// Retrieve test cases from ALM
String testCasesUrl = almURL + "/rest/domains/" + almDomain + "/projects/" + almProject
+ "/test-instances?query=" + almFolderPath;
HttpGet httpGet = new HttpGet(testCasesUrl);
httpGet.setHeader(HttpHeaders.AUTHORIZATION, authorizationHeader);
httpGet.setHeader(HttpHeaders.ACCEPT, "application/json");
String responseString = EntityUtils.toString(httpClient.execute(httpGet).getEntity());
List<Map<String, Object>> testCases = extractTestCasesFromResponse(responseString);
// Create Excel workbook
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Test Cases");
// Create headers
Row headerRow = sheet.createRow(0);
headerRow.createCell(0).setCellValue("Test Case Name");
headerRow.createCell(1).setCellValue("Description");
headerRow.createCell(2).setCellValue("Steps");
headerRow.createCell(3).setCellValue("Expected Results");
// Populate test case data
int rowIndex = 1;
for (Map<String, Object> testCase : testCases) {
Row row = sheet.createRow(rowIndex++);
row.createCell(0).setCellValue((String) testCase.get("name"));
row.createCell(1).setCellValue((String) testCase.get("description"));
row.createCell(2).setCellValue((String) testCase.get("steps"));
row.createCell(3).setCellValue((String) testCase.get("expected-results"));
}
// Save Excel file
try (OutputStream outputStream = new FileOutputStream(excelFilePath)) {
workbook.write(outputStream);
System.out.println("Test cases exported to Excel successfully.");
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static List<Map<String, Object>> extractTestCasesFromResponse(String responseString) {
// Parse the JSON response and extract the relevant test case information
// You can use your preferred JSON parsing library for this task
// Here, we're assuming the response is in a specific JSON structure
// Modify the code accordingly if your ALM API response structure is different
// This is just a sample implementation
// You may need to adjust it to fit your requirements
// ...
// Your JSON parsing logic goes here
// ...
return null; // Modify the return statement to return the actual test case data
}
}
this is java program created to extract testcases from alm using api key
but not sure how to configure API key in HP ALM
can someone explain me setting up api key
is java program created to extract testcases from alm using api key
but not sure how to configure API key in HP ALM
can someone explain me setting up api keyis java program created to extract testcases from alm using api key
but not sure how to configure API key in HP ALM
can someone explain me setting up api keyis java program created to extract testcases from alm using api key
but not sure how to configure API key in HP ALM
can someone explain me setting up api keyis java program created to extract testcases from alm using api key
but not sure how to configure API key in HP ALM
can someone explain me setting up api key