This topic describes the use of automation framework in a sample application, Task Manager. Task Manager is available as a Digital Service application and a smart library in BMC Helix Platform SDK. To understand the working of automation framework, installation, and deployment, see Testing-application-logic-with-the-automation-framework.
To access the Task Manager Java projects
Task Manager application and Task Manager library automation project examples are located in the automation project (they contain the same code). The source code for the automation project is located at /automation/src/test/ folder. You can access the project by using Eclipse.
- In Eclipse, navigate to File > Import.
- Select Maven > Existing Maven Projects and click Next.
- Click Browse, select the main project folder of Task Manager and import the project, and click OK.

Task Manager test cases
Task Manager consists of default dummy test cases which are located at com.example.automation and com.example.automation.steps, in the class Automationsuite.

The Automationsuite class has the following test case structure where given, when, and then are called steps:
given()
.user_login(userName, userPassword);
when()
.user_creates_company(userCompany);
then()
.user_has_created_company(userCompany);
Each step consists of a class, AutomationsuiteGivenState, AutomationSuiteThenState, and AutomationWhenState. For example, the given step user_login code is located in the class AutomationsuiteGivenState:
public AutomationSuiteGivenState user_login(@Hidden String userName, @Hidden String userPassword) throws Exception {
// Login operation can be here.
return self();
}
The Task Manager bundle consists of eight test cases that you can use to test the application process. There are four main test cases and four alternate versions of using the process methods to verify if a method has been reached or completed. The test cases are located in the package com.example.taskmanagement.taskmanager. For more information on Task Manager use case scenario, see Working-with-Task-Manager.
The Task Manager bundle consists of the following main test cases:
VerifyTaskManagerCanCreateTaskAndAssociateWithGroup
The following code snippet illustrates the VerifyTaskManagerCanCreateTaskAndAssociateWithGroup test case:
given()
.task_manager_login(taskManagerName, taskManagerPassword);
when()
.task_manager_creates_task_related_to_$_group(groupName);
then()
.task_has_been_created();
| |
---|
| The given step of the test case calls a login step. - To generate a login object, the automation framework uses the UserInfo method located in the class TaskManagerGivenState.
- To set the connection, the automation framework uses the connectToRESTServer method.
- To login to the Amazon instance, the automation framework uses the AutoConfig object and the properties.config file, where you set up information such as your Amazon instance URL.
- To access the automation framework, the serverREST is the object is used. For example, to create a record instance.
Sample code: UserInfo connectUser = new UserInfo(taskManagerName, taskManagerPassword); (...) serverREST = AutoConfig.connectToRESTServer(connectUser, AutoConfig.getTestServers().get(0)); (...) serverREST.login(); |
| In this step, the Task Manager creates a Task and associates the Task to a Customer Group using the task_manager_creates_task_related_to_$_group method. To create a Task record Instance and associates it to a Customer Group, the automation framework uses the following methods: - AssociateOperation—Declares an association object
- setAssociationDefinitionName—Sets the association
- setNodeSide
- setRecordInstanceIds—Adds a list of the instance IDs to associate (here the GUID from the Customer Group)
- add—Creates the association
Sample code: uniqueTaskDescription = java.util.UUID.randomUUID().toString(); String groupGUID = findGroupGUIDByName(groupName); AssociateOperation ao = new AssociateOperation(); ao.setAssociationDefinitionName("com.example.taskmanager-lib:Task To Task Group Customers"); ao.setNodeSide(NodeSide.nodeB); ArrayList<String> recordInstanceIds = new ArrayList<String>(); recordInstanceIds.add(groupGUID); ao.setRecordInstanceIds(recordInstanceIds); ArrayList<AssociateOperation> assoc = new ArrayList<AssociateOperation>(); assoc.add(ao); |
| - To create a record instance of the Task record definition, the automation framework uses the TaskRecordInstance class.
Sample code: TaskRecordInstance task = new TaskRecordInstance(); task.setRelation_Type(TaskRecordInstance.Relation_TypeOption.Parent); task.setTask_Manager(serverREST.getUserName()); task.setDescription(uniqueTaskDescription);
where,
- TaskRecordInstance—is the main class.
- setRelation_Type—sets the field TaskRecordInstance.Relation_Type to a value. This method calls BMC FieldInstance method to set a field to a value.
public static final int Relation_Type = 10029003; (...) FieldInstance fieldInstance = new FieldInstance(TaskRecordInstance.Relation_Type, "" + value.id);
- setTask_Manager and setDescription—sets the field value.
To create association between a task and a customer group, the automation framework uses the createRecordInstanceWithAssoc method Sample code: taskId = serverREST.createRecordInstanceWithAssoc(task, assoc);
|
VerifyTaskWillBeAutoAssigned
The following code snippet illustrates the VerifyTaskWillBeAutoAssigned test case:
given()
.task_manager_login(taskManagerName, taskManagerPassword)
.task_manager_knows_number_new_and_assigned_tasks();
when()
.task_manager_creates_task_related_to_$_group(groupName);
then()
.new_task_number_incremeted_by_1()
.and()
.waits_for_$_min(2)
.task_automatically_got_assigned()
.and()
.two_child_tasks_will_be_created()
.and()
.default_work_note_has_been_created()
.and()
.$_customers_were_related_to_task(2);
| |
---|
| This step calls a login step and checks the number of new tasks. - To generate a login object, the automation framework uses the UserInfo method located in the class TaskManagerGivenState.
- To set the connection, the automation framework uses the connectToRESTServer method.
- To login to the Amazon instance, the automation framework uses the AutoConfig object and the properties.config file, where you set up information such as your Amazon instance URL.
- To get the list of entries for a record definition, the automation framework uses the getRecordInstanceListJSON method.
Sample code: JSONArray searchResult = serverREST.getRecordInstanceListJSON(TaskRecordInstance.name, TaskRecordInstance.bundleName, "379", "'10029003' = 0 AND '7' = 0", "", 0, 200); |
| In this step, to create a Task and associate it to a Customer Group, the automation framework uses the task_manager_creates_task_related_to_$_group method. |
| In this step, the following actions are performed:
- The number of assigned tasks with new status is incremented by 1,
- wait for two minutes,
- check that the new task is at assigned status,
- check that there are two tasks associated with the created Task,
- check that a note is created,
- check that two users are associated to the Task.
The automation framework uses the following methods: - getrecordInstanceListJSON
getRecordInstance—Gets a record Instance using the record definition name and the record instance ID. serverREST.getRecordInstance(TaskRecordInstance.name, taskId);
TestHelper.waitMinuts—Wait function TestHelper.waitMinuts(min);
getRecordInstanceListByParentJSON—Gets the list of record instances associated with a parent record, the Tasks associated with the main Task (Request). JSONArray searchResult = serverREST.getRecordInstanceListByParentJSON("com.example.taskmanager-lib:Task To Task", TaskRecordInstance.bundleName, TaskRecordInstance.RECORD_ID_FIELD_ID + "," + TaskRecordInstance.Status + "," + TaskRecordInstance.Display_ID + "," + TaskRecordInstance.Description + "," + TaskRecordInstance.Task_Type + "," + TaskRecordInstance.RECORD_ID_FIELD_ID, taskId, NodeSide.nodeA, "", 0, 200);
|
VerifyChildTaskCanBeClosed
The following code snippet illustrates the VerifyChildTaskCanBeClosed test case:
given()
.task_manager_login(taskManagerName, taskManagerPassword)
.task_manager_knows_number_new_and_assigned_tasks();
when()
.task_manager_creates_task_related_to_$_group(groupName)
.and()
.task_manager_set_$_status(TaskRecordInstance.StatusOption.Assigned);
then()
.waits_for_$_min(2)
.task_manager_can_close_all_child_tasks();
VerifyTaskCanBeClosed
The following code snippet illustrates the VerifyTaskCanBeClosed test case:
given()
.task_manager_login(taskManagerName, taskManagerPassword)
.task_manager_knows_number_new_and_assigned_tasks();
when()
.task_manager_creates_task_related_to_$_group(groupName)
.and()
.task_manager_set_$_status(TaskRecordInstance.StatusOption.Assigned)
.waits_for_$_min(2)
.task_manager_can_close_all_child_tasks();
then()
.waits_for_$_min(2)
.task_manager_checks_tasks_are_closed();
The Task Manager bundle consists of the following alternate test cases:
VerifyTaskManagerCanCreateTaskAndAssociateWithGroupWatchActivity
This test case is an alternate version of the VerifyTaskManagerCanCreateTaskAndAssociateWithGroup test case. The following code snippet illustrates the VerifyTaskManagerCanCreateTaskAndAssociateWithGroupWatchActivity test case:
given()
.task_manager_login(taskManagerName, taskManagerPassword)
.task_manager_add_processes_from_bundle_$("com.example.taskmanager-lib")
.task_manager_add_processes_from_bundle_$("com.example.taskmanager");
when()
.task_manager_creates_task_related_to_$_group(groupName);
then()
.activity_$_reached("Waiting Request to be assigned")
.task_has_been_created();
The following table shows the comparison between VerifyTaskManagerCanCreateTaskAndAssociateWithGroup and VerifyTaskManagerCanCreateTaskAndAssociateWithGroupWatchActivity:
| |
---|
given() .task_manager_login(taskManagerName, taskManagerPassword); when() .task_manager_creates_task_related_to_$_group(groupName); then() .task_has_been_created();
| given() .task_manager_login(taskManagerName, taskManagerPassword) .task_manager_add_processes_from_bundle_$("com.example.taskmanager-lib") .task_manager_add_processes_from_bundle_$("com.example.taskmanager"); when() .task_manager_creates_task_related_to_$_group(groupName); then() .activity_$_reached("Waiting Request to be assigned") .task_has_been_created(); |
| |
---|
| The given step of the test case calls a login step. The automation framework is requested to load the processes from the bundles com.example.taskmanager-lib and com.example.taskmanager. given() (...) .task_manager_add_processes_from_bundle_$("com.example.taskmanager-lib") .task_manager_add_processes_from_bundle_$("com.example.taskmanager"); |
In the given class we can see we call the method refreshProcessList from the Automation framework. This method is tied to BaseTestGiven class from automation framework. The information is stored in the current class in a ProcessHelper object, processClass. The object processClass will be used later on in the When and Then classes of the test.
@ProvidedScenarioState(resolution = Resolution.NAME)
ProcessHelper processClass;
(...)
this.refreshProcessList(initBundleName, false);
processClass = this.processHelper;
In our process, we want to be sure we reached the Activity Waiting Request to be assigned:

We do the check in the then step. This method will return true if the activity has been reached within the 5 minutes timeout limit:
then()
.activity_$_reached("Waiting Request to be assigned")
In the function activity_$reached, the method waitForProcessPauseOnActivity is used from the ProcessHelper Object (processClass) that was initialized in the Given step. This method has several parameters:
public boolean waitForProcessPauseOnActivity(TestServer server,
String bundleName,
String contextKey,
String owner,
ProcessStatus processStatus,
String processName,
String activityName)
throws com.bmc.arsys.rx.services.internal.RxServicesException,
org.json.JSONException,
ParseException
This method will stop at the given Process Activity name until the Activity is reached or the checks are in timeout in 5 minutes. The poll is done every second.
Parameters:
- server - (TestServer) TestServer object used for the connection to your instance.
- bundleName - (String) Bundle name containing your process.
- contextKey - (String) Process context key (can be null).
- owner - (String) Process owner (can be null)
- processStatus - (ProcessStatus) ProcessStatus enum, it is strongly advised to define a value.
- processName - (String) Process Name where is the Activity (with the bundle name)
- activityName - (String) Activity label (name).
processClass.waitForProcessPauseOnActivity(serverREST, "com.example.taskmanager-lib", null, null, ProcessStatus.ACTIVE, "com.example.taskmanager-lib:Main Request Process", activityName);
BMC recommends to always define a processStatus. Here, the value is ACTIVE.
VerifyTaskWillBeAutoAssignedWithGroupWatchActivity
This is an alternate test case version of the VerifyTaskWillBeAutoAssigned test case. The following code snippet illustrates the VerifyTaskWillBeAutoAssignedWithGroupWatchActivity test case:
given()
.task_manager_login(taskManagerName, taskManagerPassword)
.task_manager_add_processes_from_bundle_$("com.example.taskmanager-lib")
.task_manager_add_processes_from_bundle_$("com.example.taskmanager")
.task_manager_knows_number_new_and_assigned_tasks();
when()
.task_manager_creates_task_related_to_$_group(groupName);
then()
.activity_$_reached("Waiting Request to be assigned")
.new_task_number_incremeted_by_1()
.activity_$_finished("Waiting Request to be assigned")
.task_automatically_got_assigned()
.and()
.two_child_tasks_will_be_created()
.and()
.default_work_note_has_been_created()
.and()
.$_customers_were_related_to_task(2)
.activity_$_has_been_executed("com.example.taskmanager-lib:Main Request Process", "Create Note")
.activity_$_reached("Waiting for Associated Tasks to be completed");
The following table shows the comparison between VerifyTaskManagerCanCreateTaskAndAssociateWithGroup and VerifyTaskManagerCanCreateTaskAndAssociateWithGroupWatchActivity:
| |
---|
given() .task_manager_login(taskManagerName, taskManagerPassword) .task_manager_knows_number_new_and_assigned_tasks(); when() .task_manager_creates_task_related_to_$_group(groupName); then() .new_task_number_incremeted_by_1() .and() .waits_for_$_min(2) .task_automatically_got_assigned() .and() .two_child_tasks_will_be_created() .and() .default_work_note_has_been_created() .and() .$_customers_were_related_to_task(2); | given() .task_manager_login(taskManagerName, taskManagerPassword) .task_manager_add_processes_from_bundle_$("com.example.taskmanager-lib") .task_manager_add_processes_from_bundle_$("com.example.taskmanager") .task_manager_knows_number_new_and_assigned_tasks(); when() .task_manager_creates_task_related_to_$_group(groupName); then() .activity_$_reached("Waiting Request to be assigned") .new_task_number_incremeted_by_1() .activity_$_finished("Waiting Request to be assigned") .task_automatically_got_assigned() .and() .two_child_tasks_will_be_created() .and() .default_work_note_has_been_created() .and() .$_customers_were_related_to_task(2) .activity_$_has_been_executed("com.example.taskmanager-lib:Main Request Process", "Create Note") .activity_$_reached("Waiting for Associated Tasks to be completed"); |
There is a mapping between the wait and waiting for an activity to be completed, as shown in the following table:
| |
---|
then() .new_task_number_incremeted_by_1() | then() .activity_$_reached("Waiting Request to be assigned") .new_task_number_incremeted_by_1() In this version, right activity is checked before performing the test: 
|
then() .waits_for_$_min(2) .task_automatically_got_assigned() .and() .two_child_tasks_will_be_created() .and() .default_work_note_has_been_created() .and() .$_customers_were_related_to_task(2); | then() .activity_$_finished("Waiting Request to be assigned") .task_automatically_got_assigned() .and() .two_child_tasks_will_be_created() .and() .default_work_note_has_been_created() .and() .$_customers_were_related_to_task(2) .activity_$_has_been_executed("com.example.taskmanager-lib:Main Request Process", "Create Note") .activity_$_reached("Waiting for Associated Tasks to be completed"); Here, it is checked that a note is created with the activity Create Note and that activity Waiting for Associated Tasks to be completed is reached. Reached is not used for the Create Note activity is because the process will never stop there. 
|
You can then verify if the activity is reached.
| |
---|
To see if an activity is executed, you can get the latest process execution by using the getLatestProcessInstanceId method for a specific bundle name and process name. | .activity_$_has_been_executed("com.example.taskmanager-lib:Main Request Process", "Create Note") (...) String processInstanceId = serverREST.getLatestProcessInstanceId(TaskRecordInstance.bundleName, null, null, ProcessStatus.ACTIVE, processName);
|
To get the executed activity list for the process, you can use the getListExecutedActivities method. | List<String> activityList = processClass.getListExecutedActivities(serverREST.getProcessInstance(TaskRecordInstance.bundleName, processName, processInstanceId)); |
To check if the activity is in the list, you can use the activityList. | if (!activityList.contains(activityName)) { Assert.fail("Activity " + activityName + " has not been executed in process " + processName); } |
To check if a process is completed, you can use the waitForProcessToCompleteActivity method.
| .activity_$_finished("Waiting Request to be assigned") (...) processClass.waitForProcessToCompleteActivity(serverREST, "com.example.taskmanager-lib", null, null, ProcessStatus.ACTIVE, "com.example.taskmanager-lib:Main Request Process", activityName);
|
VerifyChildTaskCanBeClosedWatchActivity
This is an alternate test case version of the VerifyChildTaskCanBeClosed test case.
given()
.task_manager_login(taskManagerName, taskManagerPassword)
.task_manager_add_processes_from_bundle_$("com.example.taskmanager-lib")
.task_manager_add_processes_from_bundle_$("com.example.taskmanager")
.task_manager_knows_number_new_and_assigned_tasks();
when()
.task_manager_creates_task_related_to_$_group(groupName)
.and()
.task_manager_set_$_status(TaskRecordInstance.StatusOption.Assigned);
then()
.activity_$_reached("Waiting for Associated Tasks to be completed")
.task_manager_can_close_all_child_tasks()
.activity_$_finished("Waiting for Associated Tasks to be completed");
VerifyTaskCanBeClosedWatchActivity
This is an alternate test case version of the VerifyTaskCanBeClosed test case.
given()
.task_manager_login(taskManagerName, taskManagerPassword)
.task_manager_add_processes_from_bundle_$("com.example.taskmanager-lib")
.task_manager_add_processes_from_bundle_$("com.example.taskmanager")
.task_manager_knows_number_new_and_assigned_tasks();
when()
.task_manager_creates_task_related_to_$_group(groupName)
.and()
.activity_$_reached("Waiting Request to be assigned")
.task_manager_set_$_status(TaskRecordInstance.StatusOption.Assigned)
.activity_$_finished("Waiting Request to be assigned")
.activity_$_reached("Waiting for Associated Tasks to be completed")
.task_manager_can_close_all_child_tasks();
then()
.activity_$_finished("Waiting for Associated Tasks to be completed")
.task_manager_checks_tasks_are_closed();
You must configure the Task Manager project so that you can run the test cases available for the Task Manager.
- Configure the properties.config file. See Testing-application-logic-with-the-automation-framework.
- Configure the Task Manager to have one customer group that consists of two customers and define one customer as the Task Manager.
- Configure the Java project.
In all the test cases in the class TaskManager (package com.example.taskmanagement.taskmanager), enter the credentials of the Task Manager user.
For example:
String taskManagerName = "agent01tm";
String taskManagerPassword = "password";
If required, enter the customer group name.
For example:
String groupName = "BMC Santa Clara";
To run a test case
- Open Windows command line and in the taskmanager project, navigate to the automation folder.
Run the following command:
mvn -Dit.test=className verify
For example:

To review the test results
When you run a test, a test report is created in the /automation/target/jgiven-reports/html/ folder.
The following image illustrates a sample test report:

Testing-application-logic-with-the-automation-framework