Parameters of the Function generator

After you add the Function generator in a field of a Data definition, you can customize the existing configurations of the field.

When you click the Function generator of a specific field in the Data definition in the edit branch, the unique parameters of the Function generator that contains the existing configuration details for that field are displayed in the Function dialog.

The following table provides the list of UI elements of the Function dialog with their default parameters, and the actions that you can perform in the dialog to customize the parameters for the selected field:

UI element Description Default feature Action
The Generator field Displays the name of the selected generator, that is, Function. The name is not editable. NA
The Distribution field Determines if the values are randomly generated or not in the function column of the test data. Contains the Random option. The Random option is selected.
  • Do not perform any action if you want the values, when generated in the function column, to follow a random distribution.

  • Clear the Random option if you want the function values to follow a fixed distribution and to be non-random.

    When you clear the option, the Percentage fields of all the existing configurations become editable. You can thereby set a fixed distribution for the Function values using the Percentage field.

    For example, if you set the percentage distribution of 30% to a configuration that contains the names in uppercase and 70% to another configuration that contains the names in lowercase, then the Function column of the generated data displays the values accordingly.

The Duplicates field Determines if duplicate or unique function values are present in the generated data. Contains the Allowed option. The Allowed option is selected.
  • Do not perform any action if you want the generated function values to include duplicate entries.
  • Clear the Allowed option if you want to ensure unique function values with no duplicates. This will prevent any duplicate values from appearing in the function column.
The Blank percentage field Determines the frequency of blank function values in the generated data. Displays 0 and is editable. Enter a number from 0 to 100. For example, if you enter 10, approximately 10% of the function values in the generated data will be blank.
The Name field Displays the custom name of the selected configuration. Displays Default and is editable. Enter an identifiable name to the selected configuration, if required.
The Percentage field Determines the proportion of the generated function values when you do not select the Random option. Editable when Random is not selected. If you did not select the Random option for distribution, enter a number from 0 to 100 in the Percentage field to set the percentage of function values to be generated. For example, if you enter 50, the generated data will display the function column with a 50% occurrence rate.
The Function section Determines the additional details about the function for the selected configuration. NA Provide information about the function for the selected configuration. For more details about the section, see The Function section.
The Add new configuration tab You can add additional function configurations with specific components and settings, if required.
  • The Name field displays Configuration-1 and is editable.
  • The Percentage field is editable when the Random option is not selected.
  • The Function field displays the same values that were provided in the previous configuration.

Click the tab and then add the required components for the additional configuration.

For example, you can have one configuration for uppercase names with 30% distribution and another configuration for lowercase names with 70% distribution. You can similarly customize the values, distribution, and percentage as required.

Note: You can click the delete icon Delete icon to delete any additional configuration that you do not need.
The Save to catalog option After the customization of the Function generator is complete, you can use the Function generator as the base generator to create a new custom generator. NA

Click the Save to catalog icon .

You can thereby reuse the same configuration at a later time in different scenarios without having to set it up again from the scratch. See Creating custom generators and categories from Data definitions.

The close icon NA NA Click the icon to exit the Function generator dialog.
Note: The total percentage displayed in the Percentage fields of all the configurations in the Function generator should be equal to 100.

The Function section

You can add additional details about the function for a selected configuration in the Function section of the Function dialog. The following table provides the list of UI elements of the section with their description, default features, and actions that you can perform in the section to customize the configuration:

UI element Description Default feature Action
The Function field Editable field where you can combine the built-in methods and the Data definition fields to create custom functions. Empty

You can either enter a function or select values from the Fields and Methods scroll areas to create a function.

The Items for function field Search field that can help you find matching results in both the Methods and Fields scroll areas based on the entered text. NA You can type a few letters in the Items for function field, and matching results from both the Methods and Fields scroll areas will be displayed.
The Methods scroll area Displays predefined Java methods that you can use to perform specific operations on entity fields within the function. NA

When you double-click on an available method, the corresponding parameter is added to the Function field.

When you hover over a method in the scroll area, the corresponding function, description, and example are displayed.

The Data fabrication feature of HCL OneTest Server supports a variety of in-built methods. See The supported built-in methods.

The Fields scroll area Displays the names of all the fields used in the Data definition. You can double-click a field to add it to the Function field and incorporate it into the custom function. NA When you double-click an item in the Fields scroll area, the corresponding parameter is added to the Function field.

The supported built-in methods

The Data fabrication feature of HCL OneTest Server supports a variety of built-in methods. The following table provides the list of built-in methods, their description, and relavant examples that you can use as functions:

Method Description Example
replace(oldString, newString) Replaces all occurrences of the old string with the new string F$address.replace('road', 'street')
format(formatString, args) Returns a formatted string using format string and arguments String.format('Hello %s', F$name)
split(matchString) Splits the string around the given matching string

F$name.split(" ")[0].concat('@gmail.com'). In this example, the name is split where a white space is present and only the first part of the split is considered. Also, the first part of the split is appended with @gmail.com. If the input name is Amy Smith, then the result of the function is Amy@gmail.com.

join(delimiter, stringElements) Joins string elements by a delimiter. String.join(',', F$id, F$name)
length() Returns the length of the string F$name.length
isBlank() Returns True only if the string has zero length or contains only white spaces F$address.isBlank
trim() Removes leading and trailing spaces of the string F$phone.trim
toUpperCase() Converts all characters into upper case F$name.toUpperCase
toLowerCase() Converts all characters into lower case F$name.toLowerCase
concat Concatenates the specified string to the end of the selected string 'Hello '.concat(F$name)