Rule Functions

The data model is made up of rules that define the behavior of the virtual service.


The rules in the data model are made up of rows, in which each row represents a response/request pair. Rule functions are used to define the behavior of the responses, in order to directly impact the simulation. Functions are set on a per column, per operation basis.

Each rule contains the following:

Condition functions Mainly used to evaluate data in request columns, to determine the appropriate response.
Action functions Used to manipulate data in response columns. Action functions cannot be used in request columns.

When the simulation is in progress, the simulator engine walks through each rule according to rule priorities, looking for a single row in each rule that most precisely conforms to the condition functions used. When a single data row is selected, all the action functions are applied to that row.


Suppose your scenario is to retrieve credit card data according to customer name.

  • The name data is your request, and you would define it with the Is condition function.

  • The credit card data is your response, and you would define it with the Set action function.

So, if the customer name is Jane Doe and her credit card number is 1234-5678-1234-5678, one row in your rule would be as follows:

The request data is Jane Doe, where the function used = Is.

The response data uses the function Set, which sets the response to 1234-5678-1234-5678.

Back to top

There are several categories of functions in Service Virtualization, listed below.

Basic default functions

Default condition functions:

Is If the incoming message data matches the value of this field, Service Virtualization performs the response action defined in this row.
Ignore If the incoming message data matches the value of this field, Service Virtualization ignores the data. It does not impact the simulation.

Default action functions:

Set The simulation returns the response that is listed in this field.
Copy from The simulation takes the value of another field and returns it as the response.


  • For the Learned Data rule, request columns are defined as Is, and response columns are defined as Set.
  • In a new, custom rule, the default function for all columns is Ignore. The data in the column does not influence the simulation in any way.
  • If you type a value in a cell, the function is automatically set to Is or Set.

Back to top

Array functions

The following functions are available for use when the message includes an array data structure:

Condition functions:

Compare ordered This condition is met when items in an array match and are in the same order.This is the default condition function for arrays.
Compare unordered This condition is met when items in an array match, but may be in a different order.

Action functions:

Replace array Sets the response to the relevant array values. Generates array items for the response data according to the number of array items in the rule's matching row.
Set array items count Enables you to define a set number of array items for the action to create in the response.
Copy array items count Generates the same number of array items as are in an array that you select. (You select the source array the same way you select a source element for the Copy From function.)
Array template Does not generate any array items in the response, but fills existing array items with values from array items in the rule's matching row. If the rule's matching row does not contain enough array items to fill values in all existing array items in the response, this action uses the value of the last array item as a template for all the remaining array items in the response.


You can create a rule with the highest priority in the data model, and use the Set Array Items Count to create a specified number of empty array items. Assign an Ignore action to the array items so that they remain empty and another rule can overwrite their values.

Then create a lower priority rule, using the Array Template action, with a Set action on the array items to fill in the values in the response. You can also use one of the dynamic data functions, such as the random number generator function, to fill the values of the array items with meaningful response data.


Back to top

Dynamic data functions

You can generate dynamic data in certain elements of the responses using the Service Virtualization data generator functions.

There are several types of dynamic data functions:

Sequential number generator Generates a series of increasing/decreasing numbers in a specified format. The number increases/decreases by a predefined value with each received request.
Set relative date/time Generates a date and/or time that is relative to the time of the request arrival. For example: time of request arrival plus 2 hours and 5 minutes.
Set date/time relative to Generates a date and/or time that is relative to a date/time that is stored in any element of the request. For example: time stored in a certain element minus 3 days and 5 hours.
Random number generator Generates a random sequence of integers.
Substring The simulation takes a substring of a value in another field that you select, and returns it as the response.

Back to top

Custom functions

You can define custom functions to manage more complex conditions. These are to be used by an advanced user aware of the complete system structure. Complex conditions can be set with structured query language.

There are two classes of variables:

Input ($input_*) Input variables are those present in a processing row during simulation. A more simplified explanation of Input variables is that they are data from requests.
Data ($data_*) Data variables represent data written in the cell.

Back to top

See also: