I want to do the following in soapUI using Groovy:
- Select random value and correspondating data from database
- Get the response from webservice
- Compare my database data with the response from the webservice
To achieve this I have the following steps definied:
- Created property object for the test suite
- Groovy Script to get the random and correspondating values from database
- Transformation to put the random value into the request
- Webservice call to get response
- Groovy Script to compare the values from my database with the response of the webservice
I did the same steps for other tests already by putting the values from database into the property object in step 2 and reading them from there in step 5. But up to now the values were always normal String or int. In the response I get in my current test case I get a list back. So I create an array and filled it with bean objects my wanted data in step 2. In step 5 I parse my XML-String and convert the data into an Object-Array too. So I can compare all attributes of them.
I wrote the whole test case in a singular script and tested it on groovy console first. When I started to transform it to soapUI and working with the property to "transport" the data from step 2 to step 5 my problem occurs as it looks like I can't put an Arraylist to the properties (see error message below).
Now I'm confused that this is not possible as I can easily put SQL-Instances in the properties:
def contextSqlInstanz = Sql.newInstance(urlH2, userH2, passwordH2, driverH2)
context.setProperty( "contextSqlInstanz", contextSqlInstanz )
sql = context.getProperty("contextSqlInstanz");
So how I can transport my Array, filled the Objects, from step 2 to step 5 to compare it with my webservice response. I DON'T want to convert both to strings and compare if the strings are equal but I want to compare each attributes of my bean-class by hand.
Bean Class:
class myBean {
String value1;
String value2;
...
}
Reading my local database, generating the beans and put them into a list
function getdata() {
def liste = []
// sql-statements
sql.eachRow(...) {
def myBean = new myBean();
myBean.value1 = it.value1.toString();
myBean.value2 = it.value2.toString();
...
liste.add(Schluesselwert)
}
return liste
}
Trying to put the list into properties
sollListeH2 = getdata()
def props = testRunner.testCase.getTestStepByName("P_testcase")
props.setPropertyValue( "sollListe", sollListeH2)
results in:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep.setPropertyValue() is applicable for argument types: (java.lang.String, java.util.ArrayList) values: [sollListe, [value1@15d4334, value2@1e739c8, ...]] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String) error at line: 91