I am trying to build the dynamic response at runtime from request with below java code.
You can execute the execute the Java code using Dynamic Java Execution Step. However, I haven't tried this yet.
I generally use the Execute Script (JSR -223) Step for any scripting using Beanshell scripting.
Its very much similar to java where you need not create any objects / classes / require main to execute. Import statements should be provided.
In your case , for setting the Value of Str to property - you need to use testExec.setStateValue("propertyname", "value")
Lastly, if you were doing this for your following question
then, you can try the suggestion I have provided in the answer.
If you are just attempting to get the response to respond with "true" or "false" depending on what's in the input, these values can be automatically correlated without any scripting. By default, DevTest ignores those values, because it is too easy to get false matches with such widely-used terms, but that behaviour can be changed by editing the file DEVTEST_HOME/lisa.properties (or copying these lines into DEVTEST_HOME/local.properties) and removing the "true, True, TRUE, false, False, FALSE," pieces:
# This allows you to exclude certain strings from being eligible# for magic stringing.lisa.magic.string.exclusion=Yes, YES, yes, No, NO, no, true, True, TRUE, false, False, FALSE, __NULL
# This allows you to exclude certain strings from being eligible# for magic stringing.
lisa.magic.string.exclusion=Yes, YES, yes, No, NO, no, true, True, TRUE, false, False, FALSE, __NULL
Retrieving data ...