Applying functions
You can apply functions on the item types of a schema to define the component rules.
Before you begin
You must have a defined schema in a schema designer. See Schema design overview.
About this task
You can also apply functions on the types of the imported JSON or XSD schemas.
Procedure
- Select your project in HCL OneTest™ Server and go to the Data Fabrication page.
- Click Schemas, and then select the schema for which you want to generate the test data.
- Select the group type, and then open the structural view of the schema.
- Select the item type on which you want to apply the function, in the Structure dialog box.
-
Click the menu on the right side of the Structure dialog
box.
A blank field is displayed next to the item type.
-
Click the blank field.
The Rule Editor pane is displayed on the page.
- Enter the equal sign (=) in the Rule Editor pane.
-
Provide the function in the Rule Editor pane.
You can enter the function by performing any one of the following methods:
- Enter the function manually.
- Select from the list of functions by using the following steps:
- Click the Insert mapping functions icon .
- Select the function that you want to apply as a component rule, and then click Insert from the menu of the selected function.
For example, if you want the generated value of an item type in uppercase, then you must enter or select the
UPPERCASE()
function.=UPPERCASE(RANDDATA())
- Optional:
Enter a parameter for the selected function.
You can provide the parameter value either as a constant value or as a reference of the item type.
You must use the following syntax to provide the parameter in any function:
<item type name>:Out1
where:
- item type name - Represents the name of the item type.
:Out1
- Represents a standard output argument.
For example, consider that you have a group type as Flowers with Colors and Pattern as two item types. If you want to generate the value of Colors item type in uppercase, then you can select the item type Pattern in the Structure dialog box. You must open the Rule Editor pane, and then select the
UPPERCASE()
function with reference of Colors item type as the parameter.= Uppercase (Colors:Out1)
-
Press Enter.
The selected function is displayed in the item type field of the Structure dialog box.
- Save the changes.
Results
You have successfully applied the function on an item type of the schema.