How to update VSE request and send it to LIVE system
book
Article ID: 127510
calendar_today
Updated On:
Products
CA Application TestCA Continuous Application Insight (PathFinder)
Issue/Introduction
There will be some scenarios where VSE request need to be modified before going to the LIVE system (LIVE Invocation step). This article will provide information on how to achieve it.
For example, below is the sample request hitting the VS.
When the request go to LIVE system the value "1313094687566198" need to be changed to "2567123476542345".
Environment
All supported DevTest environments.
Resolution
The property "lisa.vse.http.current.transaction" holds the current transaction information in VS and lisa.vse.http.current.transaction.body" holds the request payload.
To change the VSE request payload, need to capture it first and modify that with the desired value and then set the new payload in the current transaction.
In the VSM, this can be done in an "Execute Script" step or in a "Scripted Assertion" with the below Beanshell code before the LIVE Invocation step.
String OriginalRequestBody = testExec.getStateValue("lisa.vse.http.current.transaction.body"); // Original request payload hitting the VS String MofifiedRequestBody = OriginalRequestBody.replace("1313094687566198","2567123476542345"); // Original Text to be replaced- "1313094687566198" Replacement Text - "2567123476542345"
HTTPTransaction transaction = ((HTTPTransaction) testExec.getStateObject("lisa.vse.http.current.transaction")); // Get the current transaction transaction.setPayload(MofifiedRequestBody); // Setting the new payload return testExec.getStateValue("lisa.vse.http.current.transaction"); // Returning the current transaction with the updated payload ------
Additional Information
The functionality in this article is customization. The code provided in the instructions is very basic and it can be extended per the functionality.