Class TaskController
java.lang.Object
com.appiancorp.suiteapi.process.test.Controller
com.appiancorp.suiteapi.process.test.ProcessController
com.appiancorp.suiteapi.process.test.TaskController
TaskController enables testing processes with attended tasks via program automation.
TaskController provides simplified access to find a task within a recursive process tree, and it provides simplified execution of such task once found.
Example:
TaskController session = TaskController.initialize(currentServiceContext, processId); TaskDetails taskDetails = session.expect("MyNode*"); if (taskDetails != null) { session.execute(new ActivityClassParameter[] {new ActivityClassParameter( "myparam", AppianTypeLong.STRING, "Hello")}); } session.expect("Order Number *"); if (taskDetails != null) { session.execute(new ActivityClassParameter[] {new ActivityClassParameter( "otherparam", AppianTypeLong.STRING, "Goodbye")}); }
Call session.getLog() to get log of actions taken; use session.setLogLevel() to tune
the amount of information.
Call session.getPerformanceSummary() for a textual description of performance timings.
As this extends ProcessController and Controller, all ProcessController and Controller capabilities are available.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.appiancorp.suiteapi.process.test.Controller
Controller.ControllerException, Controller.LogElement, Controller.LogLevel
-
Field Summary
Fields inherited from class com.appiancorp.suiteapi.process.test.ProcessController
targetProcessId
Fields inherited from class com.appiancorp.suiteapi.process.test.Controller
defaultDuration, defaultTimeUnit, log, LOG, logLevel, logToLogger, performance, sc
-
Method Summary
Modifier and TypeMethodDescriptionexecute
(TaskProperties taskProperties, long duration, TimeUnit timeUnit, ActivityClassParameter... inputs) Executes a given taskexecute
(TaskProperties taskProperties, ActivityClassParameter... inputs) Executes a given taskExamine tasks to find a task name that matches taskNameRegEx.Examine tasks to find a task name that matches taskNameRegEx.Examine tasks to find a task name that matches taskNameRegEx.static TaskController
initialize
(ServiceContext sc, Long targetProcessId) Generate a TaskController from the given targetProcessId and its recursive children.static TaskController
initialize
(ServiceContext sc, Long targetProcessId, Long[] excludeProcessIds, boolean recursive) Generate a TaskController from the given targetProcessId, and its recursive children if requested, excluding the excludeProcessId if set.Methods inherited from class com.appiancorp.suiteapi.process.test.ProcessController
concludeProcess, concludeProcess, startProcess
Methods inherited from class com.appiancorp.suiteapi.process.test.Controller
clearLog, enableLogToLogger, enablePerformanceLogging, getLog, getPerformanceSummary, log, setLogLevel, setTimeout, yieldWithLog
-
Method Details
-
initialize
public static TaskController initialize(ServiceContext sc, Long targetProcessId) throws InvalidProcessException, PrivilegeException Generate a TaskController from the given targetProcessId and its recursive children.- Parameters:
sc
- ServiceContext under which this will executetargetProcessId
- in which to find the task- Returns:
- TaskController
- Throws:
InvalidProcessException
- if targetProcessId is invalidPrivilegeException
- if access to targetProcessId is not allowed
-
initialize
public static TaskController initialize(ServiceContext sc, Long targetProcessId, Long[] excludeProcessIds, boolean recursive) throws InvalidProcessException, PrivilegeException Generate a TaskController from the given targetProcessId, and its recursive children if requested, excluding the excludeProcessId if set.- Parameters:
sc
- ServiceContext under which this will executetargetProcessId
- in which to find the taskexcludeProcessIds
- will not find the task in the given excluded process ids, useful for recursive to exclude self or other specific process idsrecursive
- if true will search subprocesses recursively for matching task- Returns:
- TaskController
- Throws:
InvalidProcessException
- if targetProcessId is invalidPrivilegeException
- if access to targetProcessId is not allowed
-
expect
public TaskSummary[] expect(String taskNameRegEx) throws InvalidProcessException, PrivilegeException, TimeoutException Examine tasks to find a task name that matches taskNameRegEx. The TaskController session object is updated with TaskSummary if found.- Parameters:
taskNameRegEx
- regex to match. Use Pattern.quote(taskNameRegEx) for an exact match, Pattern.quote(taskNameRegEx)+"*" for startsWith.- Returns:
- TaskSummary matching taskNameRegEx or null if not found; activityId needed for execute is set if and only if TaskSummary is returned.
- Throws:
InvalidProcessException
PrivilegeException
TimeoutException
- if timeout occurs
-
expect
public TaskSummary[] expect(String taskNameRegEx, Integer... requiredStatus) throws InvalidProcessException, PrivilegeException, TimeoutException Examine tasks to find a task name that matches taskNameRegEx. The TaskController session object is updated with TaskSummary if found.- Parameters:
taskNameRegEx
- regex to match. Use Pattern.quote(taskNameRegEx) for an exact match, Pattern.quote(taskNameRegEx)+"*" for startsWith.requiredStatus
- will only return TaskSummary for tasks that have one of these requiredStatus; null allows any status including null; empty allows TASK_STATUS_ASSIGNED or TASK_STATUS_ACCEPTED, the two states under which an attended task may be executed.- Returns:
- TaskSummary matching taskNameRegEx or null if not found; activityId needed for execute is set if and only if TaskSummary is returned.
- Throws:
InvalidProcessException
PrivilegeException
TimeoutException
- if timeout occurs
-
expect
public TaskSummary[] expect(String taskNameRegEx, long duration, TimeUnit timeUnit, Integer... requiredStatus) throws InvalidProcessException, PrivilegeException, TimeoutException Examine tasks to find a task name that matches taskNameRegEx. The TaskSummary session object is returned if found.- Parameters:
taskNameRegEx
- regex to match. Use Pattern.quote(taskNameRegEx) for an exact match, Pattern.quote(taskNameRegEx)+"*" for startsWith.duration
- 0 is no timeout, >0 is time in timeUnit it will fail with Timeout for no task matches.timeUnit
- unit for durationrequiredStatus
- will only return TaskSummary for tasks that have one of these requiredStatus; null allows any status including null; empty allows TASK_STATUS_ASSIGNED or TASK_STATUS_ACCEPTED, the two states under which an attended task may be executed.- Returns:
- TaskSummary matching taskNameRegEx or null if not found; activityId needed for execute is set if and only if TaskSummary is returned.
- Throws:
InvalidProcessException
PrivilegeException
TimeoutException
- if timeout occurs
-
execute
public TaskDetails execute(TaskProperties taskProperties, ActivityClassParameter... inputs) throws InvalidActivityException, PrivilegeException, InvalidUserException, InvalidStateException, InvalidOperationException, InvalidProcessException, ArchivedProcessException, InvalidActivityClassParameterException, InvalidProcessModelException, InvalidPriorityException, StorageLimitException, InvalidExpressionException, TaskNavigationException, Controller.ControllerException, IllegalArgumentException, TimeoutException Executes a given task- Accepts the current task.
- If the current user could not accept the task because the current user is not an assignee, but the current user could complete if reassigned, then the task will be reassigned then accepted.
- If the task is not successfully accepted, then an IllegalArgumentException is thrown.
- If the task is a subprocess task, then the subprocess's input map is set to the given inputs. If the task is not a subprocess task, then the inputs are mapped by name to the task's expected inputs.
- Saves the mapped activity parameters.
- Advances to the next attended task.
The default Controller duration and timeUnit will be used; it will fail with TimeoutException if it cannot accept and execute the task in the given time.
- Parameters:
TaskProperties
- (note, TaskSummary as returned by expect extends TaskProperties and will typically be the TaskProperties passed here)inputs
- If the task matches a subprocess task, these are the subprocess parameters. If the task matches any other task, then the names are mapped to the names in task's parameters.- Returns:
- TaskDetails of subsequent attended request if available, null otherwise.
- Throws:
PrivilegeException
InvalidActivityException
InvalidOperationException
InvalidStateException
InvalidUserException
InvalidActivityClassParameterException
IllegalArgumentException
TaskNavigationException
InvalidExpressionException
StorageLimitException
InvalidPriorityException
InvalidProcessModelException
ArchivedProcessException
InvalidProcessException
TimeoutException
Controller.ControllerException
IllegalStateException
- if activityId was not set by expect
-
execute
public TaskDetails execute(TaskProperties taskProperties, long duration, TimeUnit timeUnit, ActivityClassParameter... inputs) throws InvalidActivityException, PrivilegeException, InvalidUserException, InvalidStateException, InvalidOperationException, InvalidProcessException, ArchivedProcessException, Controller.ControllerException, TimeoutException, InvalidActivityClassParameterException, InvalidProcessModelException, InvalidPriorityException, StorageLimitException, InvalidExpressionException, TaskNavigationException, IllegalArgumentException Executes a given task- Accepts the current task.
- If the current user could not accept the task because the current user is not an assignee, but the current user could complete if reassigned, then the task will be reassigned then accepted.
- If the task is not successfully accepted, then an IllegalArgumentException is thrown.
- If the task is a subprocess task, then the subprocess's input map is set to the given inputs. If the task is not a subprocess task, then the inputs are mapped by name to the task's expected inputs.
- Saves the mapped activity parameters.
- Advances to the next attended task.
- Parameters:
TaskProperties
- (note, TaskSummary as returned by expect extends TaskProperties and will typically be the TaskProperties passed here)inputs
- If the task matches a subprocess task, these are the subprocess parameters. If the task matches any other task, then the names are mapped to the names in task's parameters.duration
- 0 is no timeout, >0 is time in timeUnit; it will fail with TimeoutException if it cannot accept and execute the task in the given time.timeUnit
- unit for duration- Returns:
- TaskDetails of subsequent attended request if available, null otherwise.
- Throws:
PrivilegeException
InvalidActivityException
InvalidOperationException
InvalidStateException
InvalidUserException
InvalidActivityClassParameterException
IllegalArgumentException
TaskNavigationException
InvalidExpressionException
StorageLimitException
InvalidPriorityException
InvalidProcessModelException
ArchivedProcessException
InvalidProcessException
TimeoutException
Controller.ControllerException
IllegalStateException
- if activityId was not set by expect
-