{"id":18995336,"url":"https://github.com/testpointcorp/vansah-api-binding-java","last_synced_at":"2025-04-22T13:12:29.969Z","repository":{"id":54252956,"uuid":"319811378","full_name":"testpointcorp/Vansah-API-Binding-Java","owner":"testpointcorp","description":"The Vansah API binding for Java can be used to access Vansah's API from Java based languages.","archived":false,"fork":false,"pushed_at":"2024-04-29T05:00:15.000Z","size":52965,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"prod","last_synced_at":"2024-04-29T06:23:31.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://vansah.com/connect-integrations/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/testpointcorp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-12-09T01:50:28.000Z","updated_at":"2024-04-29T05:00:19.000Z","dependencies_parsed_at":"2024-03-15T07:29:06.683Z","dependency_job_id":"5f7331cc-45d1-46f2-bd6c-65ae56b92906","html_url":"https://github.com/testpointcorp/Vansah-API-Binding-Java","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testpointcorp%2FVansah-API-Binding-Java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testpointcorp%2FVansah-API-Binding-Java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testpointcorp%2FVansah-API-Binding-Java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testpointcorp%2FVansah-API-Binding-Java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/testpointcorp","download_url":"https://codeload.github.com/testpointcorp/Vansah-API-Binding-Java/tar.gz/refs/heads/prod","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223725672,"owners_count":17192602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T17:30:01.754Z","updated_at":"2025-04-22T13:12:29.956Z","avatar_url":"https://github.com/testpointcorp.png","language":"Java","readme":"\u003cdiv align=\"center\"\u003e\n   \u003ca href=\"https://vansah.com\"\u003e\u003cimg src=\"https://vansah.com/app/logo/vansahjira-logo.svg\" /\u003e\u003c/a\u003e\u003cbr\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003eThe \"Vansah API binding for Java\" enables seamless integration with Maven, Selenium, Playwright, TestNG, Cucumber and more, while efficiently sending test results to Vansah Test Management for Jira\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://vansah.com/\"\u003e\u003cb\u003eWebsite\u003c/b\u003e\u003c/a\u003e •\n    \u003ca href=\"https://vansah.com/connect-integrations/\"\u003e\u003cb\u003eMore Connect Integrations\u003c/b\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n  - [Features](#features)\n  - [Prerequisite](#prerequisite)\n  - [Configuration](#configuration)\n  - [Dependencies](#dependencies)\n  - [Usage examples](#usage-examples)\n  - [Methods Overview](#methods-overview)\n\n## Features\n\n- Set custom API URL and tokens for authentication.\n- Easily connect your Java applications with `Vansah Test Management for Jira` to report test results, and update test runs without manual intervention.\n- Automatically send test results to `Vansah` as they are generated, ensuring that your test management system reflects the most current test outcomes.\n- Attach screenshots to test runs in `Vansah` for more detailed reporting and analysis.\n- Configure the library to suit your project's specific needs, including proxy settings.\n- Robust error handling and logging mechanisms to troubleshoot issues during integration and test result reporting.\n- Detailed documentation and usage examples to help you get started quickly and make the most out of the `Vansah Binding for Java`.\n\n\n## Prerequisite\n\n- Make sure that [`Vansah`](https://marketplace.atlassian.com/apps/1224250/vansah-test-management-for-jira?tab=overview\u0026hosting=cloud) is installed in your Jira workspace\n- You need to Generate Vansah [`connect`](https://docs.vansah.com/docs-base/generate-a-vansah-api-token-from-jira-cloud/) token to authenticate with Vansah APIs.\n- Your Automation Project requires Java JDK version 8 or newer.\n- You need to add Apache Commons Lang, and Unirest into your Maven project [pom.xml](#dependencies) .\n\n\n## Configuration\n\n- Download/Copy the latest Vansah Binding Java [VansahNode.java](/src/main/java/com/vansah/VansahNode.java) file and extract it into your maven project under test package.\n- Now You need to provide your Vansah [`connect`](https://docs.vansah.com/docs-base/generate-a-vansah-api-token-from-jira-cloud/) token into your VansahNode.java file.\n    - We have two options : \n\t    - Add Directly into VansahNode.file\n\t\t    ```Java\n\n\t\t\tpublic class VansahNode {\n\t\t\t\n\t\t\t/**\n\t\t\t * The authentication token required for making requests to the Vansah API. This token\n\t\t\t * authenticates the client to the Vansah system, ensuring secure access to API functions.\n\t\t\t * Replace \"Your Token Here\" with the actual token provided by Vansah. \n\t\t\t * Note that this token should be kept confidential to prevent unauthorized access to the API.\n\t\t\t */\n\t\t\t\tprivate static String VANSAH_TOKEN = \"Your Token Here\";\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t    ```\n\t    - Use Setter functions to add the token\n\t         ```Java\n\t         \n\t         \n\t           VansahNode app = new VansahNode(); //Instance of VansahNode app\n\t         \n\t         /**\n\t             * Sets the Vansah API authentication token to the specified value. This method allows for\n\t             * dynamically updating the token used for authenticating requests to the Vansah API. \n\t             * Changing the token can be necessary if the current token expires or if switching to \n\t             * a different Vansah environment.\n\t       */\n\n\t\t\tapp.setVansahToken(\"Add your Token here\");\n\t\t\t\n\t\t\t/**\n\t \t\t\t* Sets a custom URL for the Vansah APIs. \n\t \t\t*/\n\t\t\tapp.setVansahURL(\"Your Vansah API URL\") //Obtain your Vansah Connect URL from Vansah Settings \u003e Vansah API Tokens\n\t\t\t\n\t\t    ```\n\n## Dependencies\n\nTo Integrate Vansah Binding Java functions, you need to add the below dependencies into your pom.xml file.\n\n```java\n\n\t\u003cdependencies\u003e\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003eorg.apache.commons\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003ecommons-lang3\u003c/artifactId\u003e\n\t\t\t\u003cversion\u003e3.0\u003c/version\u003e\n\t\t\u003c/dependency\u003e\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003ecom.mashape.unirest\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003eunirest-java\u003c/artifactId\u003e\n\t\t\t\u003cversion\u003e1.4.9\u003c/version\u003e\n\t\t\u003c/dependency\u003e\n\t\u003c/dependencies\u003e\n\t\n```\n\n## Usage examples\n- Executing a Test Case with Steps against a Jira Issue \n\n```java\n    public class LoginTest {\n\n    private File screenshotFile;\n    \n    public WebDriver driver;\n\n    @Before\n    public void setUp() {\n       // Method implementation...\n    }\n\n    @Test\n    public void testLogin() {\n    \n        VansahNode apptest = new VansahNode();\n        \n        //Set Jira Issue or Test Folder Identifier\n        apptest.setJIRA_ISSUE_KEY(\"TEST-1\");\n        \n        //Set Environment\n        apptest.setENVIRONMENT_NAME(\"QA\");\n        \n        //Running Test Case for an Issue\n        apptest.addTestRunFromJIRAIssue(\"TEST-C1\");\n\n \t// Step 1: Navigate to the login page\n         try{\n        driver.get(\"https://example.com/login\");\n        \n        //Add logs for each step function without screenshot(ResultID, ActualResultComment , TestStepID);  \n        apptest.addTestLog(\"passed\", \"Website loaded successfully\",1);\n\n        }catch(Exception e){\n        \n        //Updates an existing test log with new information or failure screenshot when there is any Exception\n        apptest.updateTestLog(\"failed\",\"Failed to load the website URL\",screenshotFile);\n        }\n\n\n        // Step 2: Enter credentials and submit the form\n        WebElement usernameInput = driver.findElement(By.id(\"username\"));\n        WebElement passwordInput = driver.findElement(By.id(\"password\"));\n        WebElement loginButton = driver.findElement(By.id(\"loginButton\"));\n    \n        try{\n        usernameInput.sendKeys(\"your_username\");\n        passwordInput.sendKeys(\"your_password\");\n        loginButton.click();\n        \n        //Add logs for each step function with screenshot(ResultID, ActualResultComment , TestStepID, File Screenshot);  \n        apptest.addTestLog(\"passed\", \"As expected, User is able to enter the username and password\",2,screenshotFile);\n\n        }catch(Exception e){\n        \n        //Updates an existing test log with new information or failure screenshot when there is any Exception\n        apptest.updateTestLog(\"failed\",\"User is not able to click on Login Button\",screenshotFile);\n        }\n\n\n        // Step 3: Verify successful login\n        WebElement welcomeMessage = driver.findElement(By.id(\"welcomeMessage\"));\n        try{\n        assertTrue(\"Login was successful\", welcomeMessage.isDisplayed());\n        //Add logs for each step function with screenshot(ResultID, ActualResultComment , TestStepID, File Screenshot);  \n        apptest.addTestLog(\"passed\", \"As expected, Welcome Message is shown as \"+welcomeMessage.isDisplayed(),3,screenshotFile);\n        }catch(Exception e){\n        \n        //Updates an existing test log with new information when there is any Exception\n        apptest.updateTestLog(\"failed\",\"Welcome Message is not shown\");\n        }\n       \n    }\n\n    @After\n    public void tearDown() {\n        // Method implementation...\n    }\n}\n```\n\n- Adding Test Runs using Folder Path, Advanced Test Plan (ATP), and Standard Test Plan (STP)\n\n```java\n\n/**\n * Sample JUnit test class demonstrating how to send test execution results to Vansah.\n * \n * This class uses VansahNode to:\n * - Connect to Vansah with a project key and token\n * - Send test results using:\n *   1. Test Folder path\n *   2. Advanced Test Plan (ATP)\n *   3. Standard Test Plan (STP)\n */\nclass Tests {\n\n    // VansahNode instance for sending results\n    private final VansahNode sendResults = new VansahNode();\n\n    // Vansah server URL\n    private final String vansahURL = \"https://prodau.vansah.com\";\n\n    // Folder path in Vansah where the test cases are organized\n    private final String testfolderPath = \"vansah test automation/regression 2025/\";\n\n    // Test Case key from Jira\n    private final String testCaseKey = \"KAN-C17\";\n\n    // Jira Project key\n    private final String projectKey = \"KAN\";\n\n    // Advanced Test Plan key used for ATP-based test executions\n    private final String testPlanKeyforATP = \"KAN-P17\";\n\n    // Asset type for ATP (can be \"folder\" or \"issue\")\n    private final String testPlanAssetType = \"folder\";\n\n    // Standard Test Plan key used for STP-based test executions\n    private final String testPlanKeyforSTP = \"KAN-P18\";\n\n    /**\n     * Setup method that runs before each test.\n     * It initializes VansahNode with URL, API token, project key, folder path,\n     * and test plan keys for both ATP and STP.\n     */\n    @SuppressWarnings(\"static-access\")\n    @BeforeEach\n    void setup() {\n        sendResults.setVansahURL(vansahURL);\n        sendResults.setVansahToken(System.getenv(\"CONNECT_DEMO_TOKEN\")); // Token should be set as environment variable\n        sendResults.setProjectKey(projectKey);\n        sendResults.setFOLDERPATH(testfolderPath);\n        sendResults.setAdvancedTestPlanKey(testPlanKeyforATP);\n        sendResults.setStandardTestPlanKey(testPlanKeyforSTP);\n    }\n\n    /**\n     * Sends a test result to Vansah using the configured test folder path.\n     * This is useful when test cases are organized and executed based on folders.\n     */\n    @Test\n    void sendingResultstoVansah_usingTestFolderPath() throws Exception {\n        sendResults.addTestRunFromTestFolder(testCaseKey);\n        sendResults.addTestLog(\"passed\", \"Actual result for the Test Step\", 1);\n    }\n\n    /**\n     * Sends a test result to Vansah using an Advanced Test Plan (ATP).\n     * ATP helps manage test execution based on either folder or issue assets.\n     */\n    @Test\n    void sendingResultstoVansahforATP() throws Exception {\n        sendResults.addTestRunFromAdvancedTestPlan(testPlanAssetType, testCaseKey);\n        sendResults.addTestLog(\"passed\", \"Actual result for the Test Step\", 1);\n    }\n\n    /**\n     * Sends a test result to Vansah using a Standard Test Plan (STP).\n     * STPs are used to group test runs without needing folder or issue context.\n     */\n    @Test\n    void sendingResultstoVansahforSTP() throws Exception {\n        sendResults.addTestRunFromStandardTestPlan(testCaseKey);\n        sendResults.addTestLog(\"passed\", \"Actual result for the Test Step\", 1);\n    }\n}\n```\n\n\n## Methods Overview\nThe `VansahNode` class provides a comprehensive interface for interacting with Vansah Test Management for Jira directly from Java applications. Below is a description of its public methods, designed to facilitate various test management tasks such as creating test runs, logging test results, and managing test assets.\n### `addTestRunFromJIRAIssue(String testcase)`\n\nCreates a new test run linked to a specific JIRA issue. This method is ideal for tests associated directly with JIRA issues, allowing for automated test run creation within Vansah based on the issue key provided.\n\n- **Parameters**:\n  - `testcase`: The test case identifier linked to the JIRA issue.\n\n### `addTestRunFromTestFolder(String testcase)`\n\nInitiates a new test run within a specified test folder. Use this method to organize your test runs within Vansah's folder structure, facilitating structured test management.\n\n- **Parameters**:\n  - `testcase`: The identifier of the test case to be included in the test folder.\n\n### `addTestLog(String/Integer result, String comment, Integer testStepRow, File screenshotFile (optional))`\n\nLogs the result of a specific test step, optionally including a comment and a screenshot. This method provides detailed tracking of test execution outcomes.\n\n- **Parameters**:\n  - `result`: The outcome of the test step (e.g., PASSED, FAILED)|| (e.g  0 = N/A, 1 = FAIL, 2 = PASS, 3 = Not tested).\n  - `comment`: An optional comment describing the test step outcome.\n  - `testStepRow`: The index of the test step within the test case.\n  - `screenshotFile`: (Optional) The File Object of the screenshot taken to upload : Provide file object or Path of the screenshot.\n\n### `addQuickTestFromJiraIssue(String testcase, int result)` and `addQuickTestFromTestFolders(String testcase, int result)`\n\nQuickly logs the overall result of a test case associated with either a JIRA issue or a test folder. These methods are suited for tests that do not require detailed step-by-step logging.\n\n- **Parameters**:\n  - `testcase`: The test case identifier.\n  - `result`: The overall test result (e.g., PASS, FAIL).\n  \n### `addTestRunFromAdvancedTestPlan(String testPlanAssetType, String testCaseKey)`\n\nAdds a new test run in Vansah under an Advanced Test Plan (ATP). The method links the given test case to a specific asset type (either a folder or an issue) defined in the ATP, enabling organized execution tracking.\n\n- **Parameters**:\n  - `testPlanAssetType`: The type of asset linked to the ATP. Accepted values are:\n  \t- `folder` – If the ATP is structured by test folder.\n  \t- `issue` – If the ATP is linked to a specific Jira issue.\n  - `testCaseKey`: The key of the test case to be executed (e.g., \"KAN-C17\").\n  \n### `addTestRunFromStandardTestPlan(String testCaseKey)`\n\nAdds a new test run in Vansah under a Standard Test Plan (STP). This method links the specified test case to the configured Standard Test Plan, enabling execution tracking and reporting without the need for a specific folder or issue reference.\n\n- **Parameters**:\n  - `testCaseKey`: The key of the test case to be executed under the Standard Test Plan (e.g., \"KAN-C17\").\n\n### `removeTestRun()` and `removeTestLog()`\n\nDeletes a previously created test run or log. These methods are useful for cleaning up data in Vansah that is no longer relevant or was created in error.\n\n### `updateTestLog(String result, String comment, File screenshotFile (optional))`\n\nUpdates an existing test log with new information, such as a revised result or an additional comment, and optionally includes a new screenshot.\n\n- **Parameters**:\n  - Similar to `addTestLog`, with the same purpose of detailed logging but for updates.\n\n## Setter Methods of Vansah Binding\n\nThe `VansahNode` class provides a set of setter methods to configure your test management context before performing operations such as creating test runs, adding test logs, and more. Here's a detailed overview of each setter method:\n\n### `setTESTFOLDER_PATH(String TESTFOLDER_PATH)`\n\nConfigures the **Test Folder Path** for the VansahNode instance. This path is essential for associating your test runs and logs with the correct test folder structure in Vansah.\n\n- **Parameters**:\n  - `TESTFOLDER_PATH`: The folder path for the test folder in Vansah. The path must contain at least one `/` and must not start with `/`.\n\n\u003e **Note:** Invalid paths (e.g., those starting with `/` or lacking `/`) will print a warning and be ignored.\n\n### `setJIRA_ISSUE_KEY(String JIRA_ISSUE_KEY)`\n\nSets the JIRA issue key. Use this method to link your test runs or logs with a specific issue in Jira, facilitating better traceability and integration between testing and issue tracking.\n\n- **Parameters**:\n  - `JIRA_ISSUE_KEY`: The key of the Jira issue you want to associate with your test runs or logs.\n\n### `setSPRINT_NAME(String SPRINT_NAME)`\n\nDefines the sprint name related to the test activities. Setting the sprint name helps in organizing and filtering test results by specific development sprints.\n\n- **Parameters**:\n  - `SPRINT_NAME`: The name of the sprint to associate with your test runs or logs.\n\n### `setRELEASE_NAME(String RELEASE_NAME)`\n\nAssigns the release name to the VansahNode instance. This information is used to group test runs and logs under specific release cycles in Vansah, aiding in release management and reporting.\n\n- **Parameters**:\n  - `RELEASE_NAME`: The name of the release or version you're testing against.\n\n### `setENVIRONMENT_NAME(String ENVIRONMENT_NAME)`\n\nSets the testing environment's name. This helps in categorizing and understanding the context of test runs or logs, especially when managing tests across multiple environments (e.g., development, staging, production).\n\n- **Parameters**:\n  - `ENVIRONMENT_NAME`: The name of the environment where the tests are executed.\n  \n### `setAdvancedTestPlanKey(String testPlanKey);`\n\nSets the key for the Advanced Test Plan (ATP). This key is used to associate test runs with a specific Advanced Test Plan in Vansah. It is essential when executing test cases that belong to structured test planning under ATP.\n\n- **Parameters**:\n  - `testPlanKey`: The unique key of the Advanced Test Plan (e.g., \"KAN-P17\"), used to link test executions to a defined test plan in Vansah.\n  \n### `setStandardTestPlanKey(String testPlanKey);`\n\nSets the key for the Standard Test Plan (STP). This key is used to associate test runs with a specific Standard Test Plan in Vansah. It allows you to group and track test executions under a defined test plan without linking to a specific folder or issue.\n\n- **Parameters**:\n  - `testPlanKey`: The unique key of the Standard Test Plan (e.g., \"KAN-P17\"), used to organize and manage test executions in Vansah.\n  \n  \n### Usage\n\nTo use these setter methods in your application, create an instance of `VansahNode` and call the relevant setter methods with the appropriate values before proceeding with any test management operations. For example:\n\n```java\nVansahNode vansahNode = new VansahNode();\nvansahNode.setVansahToken(\"Add your Token here\");\nvansahNode.setTESTFOLDER_PATH(\"feature-tests/login\");\nvansahNode.setJIRA_ISSUE_KEY(\"your-jira-issue-key\");\nvansahNode.setSPRINT_NAME(\"your-sprint-name\");\nvansahNode.setRELEASE_NAME(\"your-release-name\");\nvansahNode.setENVIRONMENT_NAME(\"your-environment-name\");\nvansahNode.setAdvancedTestPlanKey(\"KAN-P18\");\nvansahNode.setStandardTestPlanKey(\"KAN-P17\");\n```\n## Developed By\n\n[Vansah](https://vansah.com/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestpointcorp%2Fvansah-api-binding-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftestpointcorp%2Fvansah-api-binding-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestpointcorp%2Fvansah-api-binding-java/lists"}