Creating/Updating Custom Libraries
Make sure to have Administrator privileges to manage custom libraries.
To create a custom library:
1. Login to Oracle Utilities Testing Accelerator as an Administrator.
2. Navigate to the Administration tab and click Libraries on the left pane.
3. Enter the name of the new custom library in the Library Name field. Click Create Library.
4. From the Library Type drop-down list, select the library type being created. Based on the library type selected, it can only be used for web services based components, REST based components, or all type of components.
5. Click Create.
Note: This step only creates a header definition of the library, the actual code supporting/implementing the definition is expected to have been already developed using an IDE like Eclipse or JavaScript consoles. See the example at the end of this section for more details.
6. Once a library is created, add the function definitions using “+Add”. The function definition should specify the function name (Function), number of input parameters of the function (Parameter Count), comma separated comments for each of the input parameters, which gets displayed against the parameter in the test data screen and description of the function.
7. On the Create/Update Library page, click “+” in the Library Functions section. Add functions exposed by the custom library and other details, such as parameters of the functions.
8. Add separate rows for each exposed function in the custom library.
Function: Function name in the custom library
Parameter Count: Total number of parameters for the function. A function can have a maximum of 6 parameters.
Parameter Comments: Description about parameters, helps to show more information about the parameters. If the function has more than one parameter, descriptions should be separated by a comma.
Description: Function description
9. Click Save.
10. Click Open Editor to develop or upload/code a Java Script library containing actual implementation of the functions included.
11. Specify the package name of the custom library.
12. Enter the code or paste it from an external source.
13. Click Save. This triggers the compilation of custom library Java Script code and displays errors if any. Rectify the code and click Save again to verify and save the changes.
Shows the JavaScript code editor in the application.
To create a function to generate a random social security number as test data to create a person, create a .groovy file with the function definition. The library name is “UTATEST” and the function name is “generateSSN”. It takes an input prefix and returns a random set of digits prefixed with the input value.
The script contents are as follows:
var ArrayList = Java.type('java.util.ArrayList');
var List = Java.type('java.util.List');
var Random = Java.type('java.util.Random');
var OUTSPCORELIB = Java.type('com.oracle.utilities.core.lib.OUTSPCORELIB');
 
function generateSSN(prefix){
var random = new Random();
var x = random.nextInt(900) + 100;
var y = random.nextInt(90) + 10;
var z = random.nextInt(9000) + 1000;
var zz = x+"-"+y+"-"+z;
print(prefix+zz);
return prefix+zz;
}
 
Below is the function definition in Oracle Utilities Testing Accelerator.
Click Open Editor to create the implementation of the groovy library. It can be plugged into any custom component or the pre-validations and post-validations section of flow test data definition.