I am currently using Devtest Solutions v9.5.1, and due to heavy customizations I would like to know how to properly set the lisa.vse.response property without first going through the out of box VS Image Response Selection or the Live Invocation step.
As far as past experience goes, I was always able to first go through those two steps to ensure the property is set and exists, and then I was able to do change just the body text in the response using a java script with something like lisa_vse_response.get(0).setBody( testExec.getStateValue("SomeResponseBody") );
I have tried changing the property used in the Responder step, but clearly there is some kind of format that is different from lisa.vse.response and it will not work when I tried. If I don't use the two steps out of box steps listed above, the property is not set and an error is thrown at the Responder where the property doesn't exist.
Is there any way to setup lisa.vse.response properly on my own (assuming I can retrieve a response from elsewhere)f?
lisa.vse.response is in Transient form from "VS Image Response selection" step or from "LIVE Invocation" step and that is what "Responder" step uses it.
If you want to use your response and Responder step to send that then you need to convert your response to Transient form and then set it to lisa.vse.response.
Here is what I tried and worked for me.
Added a property customResponse2 in config file and changed the workflow in VSM to a JS step with below code. Set the next step of JS step to Http Responder.import com.itko.lisa.vse.stateful.model.TransientResponse; import com.itko.lisa.vse.stateful.model.Response;import com.itko.util.ParameterList;
Response response1 = new Response();response1.setBody(testExec.getStateObject("customResponse2").toString());ParameterList metadata = response1.getMetaData();metadata.setParameterValue("HTTP-Response-Code","200");TransientResponse transRsp = response1.createTransientCopy();testExec.setStateObject("lisa.vse.response", transRsp);return;
There may bean easier way to do this.
I added the following as a JSR-223 and let the Responder send lisa.vse.response.
import com.itko.lisa.vse.stateful.model.TransientResponse;import com.itko.lisa.vse.stateful.model.Response;import com.itko.util.ParameterList;
import java.util.List;import java.util.ArrayList;
// set up a response and add a bodyResponse rsp = new Response();rsp.setBody( "ABCDE" );
// add HTTP response meta data valuesParameterList metaData = new ParameterList();metaData.addParameters("HTTP-Response-Code=200&HTTP-Response-Code-Text=OK&Content-Type=application/xml");rsp.setMetaData( metaData );
// set a 100ms think timersp.setThinkTimeSpec( "100t" );
// add response to a response list and convert it to Transient Response list
// then place it in the lisa.vse.response list objectList lst = new ArrayList();lst.add( rsp );testExec.setStateValue("lisa.vse.response", TransientResponse.convert( lst ) );
// display output of access vse response list to return data set by routinereturn "response body is: " + testExec.getStateValue("lisa.vse.response").get(0).getBodyAsString() + "\r\nMetaData is: " + testExec.getStateValue("lisa.vse.response").get(0).getMetaData().toString() + "\r\nThinkTime is: " + testExec.getStateValue("lisa.vse.response").get(0).getThinkTimeSpec();
Raw REST Call Output:
See, there is more than one way to do this. :-)
I used the TransientResponse.convert( lst ) ); static method to convert each response in the response list to TransientResponses but probably should have used setStateObject. gadpr08 used createTransientCopy()... and set using setStateObject.
Sorry about the late response as I've been busy with other projects. But this is amazing to know. Thank you. I will keep a copy of this for future reference.