Object Model

Applies to ReadyAPI 3.56, last modified on October 29, 2024

ModelItems

All project-related artifacts (projects, requests, test suites, and so on) are ModelItems .

You can find interface definitions in the following packages:

com.eviware.soapui.model.*

For example, for Interface/Operation/Request related classes), see the com.eviware.soapui.model.iface package.

For more information, see JavaDocs.

Structure

The project structure is hierarchical, and is similar to the one visible in the Navigator.

Common top level for all tools

Workspace
Project
(tool levels, see below)

Projects levels

|
Interface
Operation
(Action)
Request

ReadyAPI Test levels

|
TestSuites
TestCase
TestStep

ReadyAPI Test security tests levels

|
TestSuites
TestCase
SecurityTest

ReadyAPI Performance levels

|
TestSuites
TestCase
LoadTest

ReadyAPI Virtualization levels

|
MockServices (virtual services)
MockOperation (virtual operation)
MockResponse (virtual response)

Access

A modelItem name, description, icon, and so on, can be accessed through the corresponding getters.

Here are some getter examples:

log.info project.name

It would print the name of the project variable.

Obviously, different properties and methods for accessing children are available depending on the type of ModelItem.

The general model for accessing children of a certain type for ModelItem is as follows

(XX = the type of child):

int getXXCount()

getXXByName( String name )

getXXAt( int index )

List getXXList()

Map getXXs()

getYY for getting parents

For example, to get a certain virtual service in a project, you could use one of the following:

def mockService = project.getMockByName( "My Virtual Service" )

def mockService = project.getMockAt( 0 )

And so on.

For iterating through all load tests in a test case, you could use:

for( loadTest in testCase.loadTestList )

log.info loadTest.name

Parent objects are generally available through the name of their type, for example:

log.info( testCase.testSuite.name + " in project " + testCase.testSuite.project.name )

Navigates "upward" in the object model using the testSuite and project properties.

Properties

You will often want to manipulate properties within your scripts, either those that are built on or those that are custom properties, the later can be set on the following objects, projects, test suites, test cases, virtual services and the PropertiesTestStep (these all inherit from MutableTestPropertyHolder ).

Setting/getting properties is straightforward

// set property value
object.setPropertyValue( "name", "value" )
object.properties["name"].value = "value"
// get property value log.info object.getPropertValue( "name" ) log.info object.properties["name"].value log.info object.properties."name".value

Contexts

A context variable is always available inside different runs. This allows you to get and set context-specific variables.

Context Description Available in
SubmitContext Submit a request
TestRunContext Test case run
LoadTestRunContext load test Setup/Teardown scripts, in test case context via the LoadTestContext context variable
MockRunContext Virtaul service startup/shutdown scripts and Operation/VirtResponse dispatch scripts

All these contexts inherit from the PropertyExpansionContext interface.

This interface has methods for setting/getting properties and an expand method which can be used to expand arbitrary strings containing Property Expansions.

Logging

A standard log4j Logger is available. The variable log appends to the Log at the bottom of the window and can be used for diagnostic purposes.

Highlight search results