For Example:
REST Request
I want to read these REST matrix request using Java or groovy.
What could be the possible solution?
You need to check where they are the properties.
You review the attachment.
Show properties
You follow this steps:
Create a testSuite with the testcase.
Add the activity Groovy script and you add this code.
//Print all properties
log.info testRunner.testCase.getTestStepByName('NAME_TESTSTEP').getPropertyList().name;
log.info testRunner.testCase.getTestStepByName('NAME_TESTSTEP').getPropertyList().value;
//Get value propertie
def value_property = testRunner.testCase.getTestStepByName('NAME_TESTSTEP').getPropertyValue('NAME_PROPERTY');
//Print Get value propertie
log.info value_property
//Set value Property
testRunner.testCase.getTestStepByName('NAME_TESTSTEP').setPropertyValue('NAME_PROPERTY','VALUE');
You need to update the values (NAME_TESTSTEP ,NAME_PROPERTY ,VALUE)
Run the grrovy script.
Related
I am sending a request using SOAPUI and need to add a tab/space at the end of the text/XML message so it is accepted by the server and I get the proper response. I need a Groovy script that will simply add a tab to the end of the text/XML request. Thanks
The way to go as it's said in the comments is to fix your WS to work correctly without the extra tab/space at the end of your request.
Another simple option if you can't fix de WS because it's a third party service, it's simply to add manually a tab in the testStep as part of your request.
Anywise since some times is necessary or util to modify the request for some other reason I will show you an example of how to get the SOAP Request with a Groovy script to manipulate it. You can do it adding a Groovy testStep with the following code:
// get the testStep by name
def testStep = testRunner.testCase.getTestStepByName('Your request name')
// get request content
def originalRequestContent = testStep.getPropertyValue('request')
// perform your modifications...
// in your case simply add a new tab
def newRequestContent = "${originalRequestContent}\t"
// as tab is not showed in the Raw tab of your testStep,
// to show that this code work as expected I add
// and unnecessary extra text
newRequestContent += 'it works'
// set the new modified request
testStep.setPropertyValue('request',newRequestContent)
// and finally you can send the request
testStep.run(testRunner,context)
// if you want to keep the step as orignal uncomment
// the follow line
// testStep.setPropertyValue('request',originalRequestContent)
Hope it helps,
I am trying to get the test instance names from the test set. I am able to get the test id by using the following URL:
"rest/domains/"+domain+"/projects/"+project+"/test-instances?query={cycle-id["+testSetId+"]}" ;
Is there any way I can get the test names also?
I guess you're talking about the ALM Rest API.
If you do, you can try to add in final of your URL the following:
&fields=test-config.name
Then your URL will look like this:
rest/domains/{domain}/projects/{project}/test-instances?query={cycle-id[{testSetId}]}&fields=test-config.name
The name of your Test Instance will be shown into the RelatedEntities tag from your XML.
For more information about ALM REST API you can click here.
I'm trying to develop a step plugin using Pentaho,
I used textVar() Input for listing the variables.
the problem is that the custom variables that created from the previous step aren't listed, so i tried to used environmentSubstitute(${var}) inside my code for fetching the variable's value, and no thing effected !.
so please guide me to the right way for listing the custom variables that created using the previous steps , for listing it inside textVar() input inside my custom step plugin.
After many days of testing , I succeeded of listing previous field names using the follwoing :
Combo wField = new Combo();
String[] inputFields = transMeta.getPrevStepFields(stepname).getFieldNames();
Arrays.sort(inputFields);
for (String fName : inputFields) {
wField.add(fName);
}
That's all :)
Hey there,
I've got a small problem. I am creating a plugin for Bukkit. I tried to code a in-game config editor - that means that one can change configuration options with a command from inside the game. I already got it to work, but as of the build I'm using (#2879), the method YamlConfiguration.set(String, Object) doesn't seem to work. Here is the essential part of my code for setting and saving the YamlConfiguration I've got.
plugin.debug("option = "+option); // the configuration option
plugin.debug("newvalue = "+value); // the new value
config.set(option, value); // this should set the value of 'option' to 'value'
plugin.debug("savedvalue = "+config.get(option)); // the value saved in the config
As I tested my plugin, I've got the following output.
option = debug
newvalue = false
savedvalue = true
If you need the full and detailed code, look into it on GitHub: GeneralCommands.java, function config(CommandSender, String, String) (line 1074).
Kind regards.
My bad, it was a problem with another method I used (plugin.getConfig()).
I have a bunch of SOAP request messages in XML format. Is there a way to import them to a SoapUI project?
I want to import them and add as "Test Request" Test Step to an existing Test Case.
An easy and more automatic way to do so is using a groovy script to automatically create the testStep request from a directory where you have you xml request files:
Create a TestCase manually.
Add an empty TestStep request which we will use as a template to create the other requests.
Add a groovy testStep which imports all files using the code below, and execute it in order to create the testSteps.
Your SOAPUI before groovy code execution looks like:
And the necessary groovy code:
import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory
import groovy.io.FileType
// get the current testCase to add testSteps later
def tc = testRunner.testCase
// get the testStep as template to create the other requests
def tsTemplate = tc.getTestStepByName("TestRequest template")
// create the factory to create testSteps
def testStepFactory = new WsdlTestRequestStepFactory()
def requestDir = new File("/your_xml_request_directory/")
// for each xml file in the directory
requestDir.eachFileRecurse (FileType.FILES) { file ->
def newTestStepName = file.getName()
// create the config
def testStepConfig = testStepFactory.createConfig( tsTemplate.getOperation(), newTestStepName )
// add the new testStep to current testCase
def newTestStep = tc.insertTestStep( testStepConfig, -1 )
// set the request which just create with the file content
newTestStep.getTestRequest().setRequestContent(file.getText())
}
Hope this helps,
Copy/paste each into a new request, then right click on each request and add them to your test case.
Or select "Load from..." when opening the context menu in the request view.
Another option is:
Create a soapui project with one request
Open the soapui-project XML file
Search for con:call part
Duplicate it and replace the con:request with your own XML request
Save and reload the project in soapui