cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get property transfer step information via Groovy?

Occasional Contributor

How do I get property transfer step information via Groovy?

Hi - I'm looking for examples using PropertyTransfer and I don't see any that are working for me. I want to grab information on the Property Transfer test step I have via Groovy. Below is just a very scaled down script as an example. I have a Property Transfer test step with just one transfer within it. When I run the script below, everything is null. I assume it's because there can be more than one transfer within a Property Transfer test step. However, I don't see a way to pass in the index into any of the methods. I also don't see anything that would allow me to iterate through the various transfers within the Property Transfer test step (i.e. something like: for (def prop in propTxfr()) or any methods that bring back a 'list' of transfers. Does anyone know how to do this?

import com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfer

def tCase = testRunner.testCase.testSuite.testCases[testRunner.testCase.name]
def tStep = tCase.testSteps["PropertyTransfer"]
def propTxfr = new PropertyTransfer(tStep)

log.info "GetName: " + propTxfr.getName()
log.info "GetSourcePath: " + propTxfr.getSourcePath()
log.info "GetSourcePropertyName: " + propTxfr.getSourcePropertyName()
log.info "GetSourceStepName: " + propTxfr.getSourceStepName()
log.info "GetTargetPath: " + propTxfr.getTargetPath()
log.info "GetTargetPropertyName: " + propTxfr.getTargetPropertyName()
log.info "GetTargetStepName: " + propTxfr.getTargetStepName()
7 REPLIES 7
Regular Contributor

Re: How do I get property transfer step information via Groo

Good morning.

It would appear that you are attampting to handle an object as if the class is PropertyTransfer when you likely need to be using PropertyTransferTestStep. The PropertyTransferTestStep class has a function called getTransferByName that I believe would achieve your desired result.
Remember:Questions are more important than answers.
The answer is 42 I'm a ninja!
Occasional Contributor

Re: How do I get property transfer step information via Groo

Paul - Thank you so much for the tip! I sincerely appreciate it!

By any chance do you have further knowledge on that class? I wrote the following basic steps. I can tell that my test case is grabbing properly. When I log the tStepConfig it also has all of the configuration for the test step, including my property transfer that is on the step. However,something is not right with the PropertyTransfersTestStep because I get a null pointer exception when I try to get the count of the transfers.

import com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfer
import com.eviware.soapui.impl.wsdl.teststeps.PropertyTransfersTestStep

def tCase = testRunner.testCase.testSuite.testCases[testRunner.testCase.name]
def tStep = tCase.testSteps["PropertyTransfer"]
def tStepConfig = tStep.getConfig()
def propTxfrTestStep = new PropertyTransfersTestStep(tCase,tStepConfig,false)
log.info tCase.name
log.info tStepConfig
log.info propTxfrTestStep.getTransferCount()
Regular Contributor

Re: How do I get property transfer step information via Groo

I have a feeling it is because you are just creating a PropertyTransferTestStep and not the actual PropertyTransfer. Is there a reason you are initializing a new PropertyTransferTestStep and not just using the one that already exists (tStep)? If you change your code to the following, it works.

import com.eviware.soapui.impl.wsdl.teststeps.*

def tCase = testRunner.testCase.testSuite.testCases[testRunner.testCase.name]
def tStep = tCase.testSteps["Property Transfer"]
log.info tCase.name
log.info tStep.getTransferCount()


Edit:

Based on your first question I think I have put the pieces together.

Here is some updated code that should work.

import com.eviware.soapui.impl.wsdl.teststeps.*

def tCase = testRunner.testCase.testSuite.testCases[testRunner.testCase.name]
def tStep = tCase.testSteps["Property Transfer"]
log.info tCase.name
for (int i =0; i < tStep.getTransferCount(); i++) {
def propTxfr = tStep.getTransferAt(i);
log.info "GetName: " + propTxfr.getName()
log.info "GetSourcePath: " + propTxfr.getSourcePath()
log.info "GetSourcePropertyName: " + propTxfr.getSourcePropertyName()
log.info "GetSourceStepName: " + propTxfr.getSourceStepName()
log.info "GetTargetPath: " + propTxfr.getTargetPath()
log.info "GetTargetPropertyName: " + propTxfr.getTargetPropertyName()
log.info "GetTargetStepName: " + propTxfr.getTargetStepName()
}
Remember:Questions are more important than answers.
The answer is 42 I'm a ninja!
Occasional Contributor

Re: How do I get property transfer step information via Groo

Oh! Yes, I see. You are right. I don't need to use PropertyTransferTestStep at all. I didn't notice those property inherited methods for teststep on the documentation. So this works just fine, which I will shortly change to be a loop.

def propTxfr = tStep.getTransferAt(0)
log.info "GetName: " + propTxfr.getName()
log.info "GetSourcePath: " + propTxfr.getSourcePath()
log.info "GetSourcePropertyName: " + propTxfr.getSourcePropertyName()
log.info "GetSourceStepName: " + propTxfr.getSourceStepName()
log.info "GetTargetPath: " + propTxfr.getTargetPath()
log.info "GetTargetPropertyName: " + propTxfr.getTargetPropertyName()
log.info "GetTargetStepName: " + propTxfr.getTargetStepName()

Many, many thanks!
Occasional Contributor

Re: How do I get property transfer step information via Groo

Our posts crossed paths. I see you've already done the loop! Thanks again!!!!
Regular Contributor

Re: How do I get property transfer step information via Groo

MPleas wrote:
Oh! Yes, I see. You are right. I don't need to use PropertyTransferTestStep at all. I didn't notice those property inherited methods for teststep on the documentation. So this works just fine, which I will shortly change to be a loop.

def propTxfr = tStep.getTransferAt(0)
log.info "GetName: " + propTxfr.getName()
log.info "GetSourcePath: " + propTxfr.getSourcePath()
log.info "GetSourcePropertyName: " + propTxfr.getSourcePropertyName()
log.info "GetSourceStepName: " + propTxfr.getSourceStepName()
log.info "GetTargetPath: " + propTxfr.getTargetPath()
log.info "GetTargetPropertyName: " + propTxfr.getTargetPropertyName()
log.info "GetTargetStepName: " + propTxfr.getTargetStepName()

Many, many thanks!



Not using "PropertyTransferTestStep" is a stretch. The tStep variable is a PropertyTransferTestStep object. You just didn't need to create a new one.
Remember:Questions are more important than answers.
The answer is 42 I'm a ninja!
Occasional Contributor

Re: How do I get property transfer step information via Groo

Thank you for the clarification!
New Here?
Join us and watch the welcome video:
Final Interview in the Series
API_testing_mistake#7