Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Extension tool script failing

sabzwari
sabzwari Posts: 1

Newbie please bear with me.

I have a working groovy script

import groovy.json.*
def jsonFile = new File('C:\location\serviceresponse.json')
def jsonContent = new JsonSlurper().parseText(jsonFile.text)

jsonContent.someobject.each { tb ->
println "${targetObejct}

}

My goal was to do the same thing in SOATest.
In the case of json File I want to execute the get service store the response into json data bank store the root object with a new e.g.

import com.parasoft.api.*
import groovy.json.JsonSlurper
def jsonFile = new File('${databankStoredObject}') or get some other way of referencing databank extracted object.

and I stored the service response

I added groovy-3.025.jar to the classpath, script seems not getting executed. I commented out all other statements including the above one, just left the import command intact.

Answers

  • benken_parasoft
    benken_parasoft Posts: 1,366 ✭✭✭
    edited August 15

    See Extensibility Examples for SOAtest.

    or get some other way of referencing databank extracted object

    Notice that your script must define a method. One of the arguments to your method is a "context" object. This "context" object has various methods including those for accessing data source or data bank columns. In particular use context.getValue("Generated Data Source", "columnName") to retrieve the value of a custom data bank column named columnName. The first argument is the data source name but you use Generated Data Source to access custom data bank columns.

    I added groovy-3.025.jar to the classpath

    Do not do this. Groovy works out-of-box.

    script seems not getting executed

    Once your script defines a method you can select it from the "Method" box.