Bulk actions are a common extension point within Enterprise Tester, exposed as features of the grid (normally a button, or selection field and button combination).

Bulk actions can be invoked asynchronously by issuing a POST request to the backgroundtasks collection resource, with the configuration information including the command being invoked passed in the Parameters collection, as show in the example below:

{
  "Type": "bulkaction",
  "Parameters": {
    "commandName": "BulkCopy",
    "scenarioName": "BulkCopyScriptsScenario",
    "targetId": "ab1bd3c3-f30b-43b2-82e2-a07e0133511c",
    "targetType": "TestScriptPackage",
    "targetPackageId": "ab1bd3c3-f30b-43b2-82e2-a07e0133511c",
    "sourcePackageId": "4016f35b-817f-459e-8533-9fc8015335c8",
    "projectId": "c651ed19-5375-475a-a539-9f6401467130",
    "selections":[
        {"Id":"0a02cb6d-4afa-463c-a6df-9fe400b7d8fc","Type":"TestScript"},
        {"Id":"0a675d09-78cd-463e-a600-9fc80153481b","Type":"TestScript"}
    ],
    "retainStructure":true
  }
}

If we pull apart the above request we can see that we are:

  • Invoking the command "BulkCopy".
  • Invoking the command scenario "BulkCopyScriptsScenario" - many commands have more then one associated scenario, and you must use the scenario applicable to your source and target package type, and the type of items you have selected.
  • For move and copy operations there needs to be a target and source package (targetPackageId and sourcePackageId) - the source package is used as the "Root" of the bulk copy/move operation so that retain structure can calculate what folders are required.
  • In the above example, our targetType and targetId is the same as the targetPackage.
  • The selected items to copy "selections" - each selection features an Id and a Type (any type which is supported in TQL as a valid EntityType alias will work here i.e. Script and TestScript will both be treated as a TestScript entity type).
  • "retainStructure" - which is a parameter specific to bulk/copy move to retain the packages related to the sourcePackage when copying to the targetPackage.

Available commands

CSV Export command

The CSV Export command is an example of an action which has a payload (an exported file) which you can download after completing the action - first, here is an example of a CSV export task being created:

{
  "Type": "bulkaction",
  "Parameters": {
    "scenarioName": "CSV",
    "encoding": "UTF8",
    "delimiter": "comma",
    "onlyVisibleColumns": false,
    "includeHeader": true,
    "includeSteps": true,
    "includeStepsResults": true,
    "query": "Name ~ export",
    "exportAll": true,
    "commandName": "Export"
  }
}

As a result of creating this task, the response will indicate where the task updates can be fetched from via GET using the "Self" URL:

{   
  "Complete": false,
  "TotalElements": 0,
  "ProcessedElements": 0,
  "StartedAt": "2012-07-03T12:16:30Z",
  "ProgressInPercent": 0.0,
  "Id": "bulkaction_Export_CSV_56065c63-cdf7-4285-ab10-321646317be8",
  "Message": null,
  "Self": "http://localhost:29840/api/backgroundtask/bulkaction_Export_CSV_56065c63-cdf7-4285-ab10-321646317be8"
}

When the task has completed, fetching the task will include in it's response details of the where you can then download the exported file from (indicated in the "exportedfile" link).

{
  "Complete": true,
  "StartedAt": "2012-07-03T12:16:30Z",
  "FinishedAt": "2012-07-03T12:16:30Z",
  "ProgressInPercent": 1.0,
  "Id": "bulkaction_Export_CSV_56065c63-cdf7-4285-ab10-321646317be8",
  "Message": "Completed",
  "TotalTimeToExecute": "0s",
  "FileName": "export-Entities-2012-07-04-121630am.csv",
  "ContentType": "text/csv",
  "Encoding": "UTF8",
  "Self": "http://localhost:29840/api/backgroundtask/bulkaction_Export_CSV_56065c63-cdf7-4285-ab10-321646317be8",
  "Links": [
    {
      "Href": "http://localhost:29840/api/exportfile/export-Entities-2012-07-04-121630am.csv",
      "Rel": "exportedfile"
    }
  ]
}
  • No labels