com.atlassian.jira.task
Class MockTaskDescriptor<V>

java.lang.Object
  extended by com.atlassian.jira.task.MockTaskDescriptor<V>
All Implemented Interfaces:
TaskDescriptor<V>

public class MockTaskDescriptor<V>
extends Object
implements TaskDescriptor<V>

Since:
v5.1

Constructor Summary
MockTaskDescriptor()
           
 
Method Summary
 void cancel()
          Requests that this task be cancelled.
 void clear()
           
 String getDescription()
          Return the description of the task passed when it was created.
 long getElapsedRunTime()
          This returns number of milliseconds the task has been running for.
 Date getFinishedTimestamp()
          Return the date when the task was finished.
 String getProgressURL()
          Returns the URL that displays progress on this task.
 V getResult()
          This returns the result of the long running task.
 Date getStartedTimestamp()
          Return the date when the task was started.
 Date getSubmittedTimestamp()
          Return the date when the task was submitted.
 TaskContext getTaskContext()
          Return he context of task.
 Long getTaskId()
          Reuturn the identifier for this task.
 TaskProgressIndicator getTaskProgressIndicator()
          Return the TaskProgressIndicator associated with the task.
 com.atlassian.crowd.embedded.api.User getUser()
          Return the user that started to task.
 boolean isCancellable()
          Returns whether this supports requests to cancel it.
 boolean isCancelled()
          Returns whether cancellation of task has been requested.
 boolean isFinished()
          Tells if caller if the task has finished running or not.
 boolean isStarted()
          True if the task has been started.
 void setDescription(String description)
           
 void setElapsedRunTime(long elapsedRunTime)
           
 void setFinishedTime(Date finishedTime)
           
 void setResult(V result)
           
 void setStartedTime(Date startedTime)
           
 void setSubmittedTime(Date submittedTime)
           
 void setTaskContext(TaskContext taskContext)
           
 void setTaskId(Long taskId)
           
 void setTaskProgressIndicator(TaskProgressIndicator taskProgressIndicator)
           
 void setUser(com.atlassian.crowd.embedded.api.User user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockTaskDescriptor

public MockTaskDescriptor()
Method Detail

clear

public void clear()

getResult

public V getResult()
            throws ExecutionException,
                   InterruptedException
Description copied from interface: TaskDescriptor
This returns the result of the long running task. WARNING: This will BLOCK if the task has not finished and will not return until it has finished executing.

Specified by:
getResult in interface TaskDescriptor<V>
Returns:
the result of the long running task or null if it has not return value.
Throws:
ExecutionException - if an uncaught exception is thrown from the task's callable.
InterruptedException - if the calling thread is interrupted while waiting for the result.

isStarted

public boolean isStarted()
Description copied from interface: TaskDescriptor
True if the task has been started.

Specified by:
isStarted in interface TaskDescriptor<V>
Returns:
true if the task has been started.

isFinished

public boolean isFinished()
Description copied from interface: TaskDescriptor
Tells if caller if the task has finished running or not.

Specified by:
isFinished in interface TaskDescriptor<V>
Returns:
true if the task has finished running.

getTaskId

public Long getTaskId()
Description copied from interface: TaskDescriptor
Reuturn the identifier for this task. This is only unique in the current execution of the JVM.

Specified by:
getTaskId in interface TaskDescriptor<V>
Returns:
The unique id of the task

getStartedTimestamp

public Date getStartedTimestamp()
Description copied from interface: TaskDescriptor
Return the date when the task was started.

Specified by:
getStartedTimestamp in interface TaskDescriptor<V>
Returns:
the time that task was started. null will be returned if the task has not started executing.

getFinishedTimestamp

public Date getFinishedTimestamp()
Description copied from interface: TaskDescriptor
Return the date when the task was finished.

Specified by:
getFinishedTimestamp in interface TaskDescriptor<V>
Returns:
the time that task finished executing. null will be returned if the task has not finished executing.

getSubmittedTimestamp

public Date getSubmittedTimestamp()
Description copied from interface: TaskDescriptor
Return the date when the task was submitted.

Specified by:
getSubmittedTimestamp in interface TaskDescriptor<V>
Returns:
the time that task was submited to the TaskManager. A null value will never be returned as the task will always have a submission time.

getElapsedRunTime

public long getElapsedRunTime()
Description copied from interface: TaskDescriptor
This returns number of milliseconds the task has been running for. Will return zero if the task has not started. When the task has started but not finished, it will return the the difference between the current time and the time was started (i.e. it will change). When the task has finished, it will return the difference between the start time and the end time (i.e. it will not change).

Specified by:
getElapsedRunTime in interface TaskDescriptor<V>
Returns:
the elapsed run time in milliseconds.

getUser

public com.atlassian.crowd.embedded.api.User getUser()
Description copied from interface: TaskDescriptor
Return the user that started to task.

Specified by:
getUser in interface TaskDescriptor<V>
Returns:
the user that caused the task to be submitted. This may be null.

getDescription

public String getDescription()
Description copied from interface: TaskDescriptor
Return the description of the task passed when it was created.

Specified by:
getDescription in interface TaskDescriptor<V>
Returns:
a meaningful description of the task

getTaskContext

public TaskContext getTaskContext()
Description copied from interface: TaskDescriptor
Return he context of task. Code that starts long running tasks can implement their own variants of this.

Specified by:
getTaskContext in interface TaskDescriptor<V>
Returns:
the context of the task. This method will never return null as a task must always have a context.

getProgressURL

public String getProgressURL()
Description copied from interface: TaskDescriptor
Returns the URL that displays progress on this task. It is built using the TaskContext.

Specified by:
getProgressURL in interface TaskDescriptor<V>
Returns:
the URL that displays progress for this task. null cannot be returned.

getTaskProgressIndicator

public TaskProgressIndicator getTaskProgressIndicator()
Description copied from interface: TaskDescriptor
Return the TaskProgressIndicator associated with the task. A task will only have an indictator if its callable implements the ProvidesTaskProgress interface.

Specified by:
getTaskProgressIndicator in interface TaskDescriptor<V>
Returns:
the TaskProgressIndicator associated with the task or null if there isn't one.

setResult

public void setResult(V result)

setSubmittedTime

public void setSubmittedTime(Date submittedTime)

setStartedTime

public void setStartedTime(Date startedTime)

setFinishedTime

public void setFinishedTime(Date finishedTime)

setTaskProgressIndicator

public void setTaskProgressIndicator(TaskProgressIndicator taskProgressIndicator)

setDescription

public void setDescription(String description)

setTaskId

public void setTaskId(Long taskId)

setElapsedRunTime

public void setElapsedRunTime(long elapsedRunTime)

setTaskContext

public void setTaskContext(TaskContext taskContext)

setUser

public void setUser(com.atlassian.crowd.embedded.api.User user)

isCancelled

public boolean isCancelled()
Description copied from interface: TaskDescriptor
Returns whether cancellation of task has been requested. Long-running operations should poll to see if task has been requested.

Specified by:
isCancelled in interface TaskDescriptor<V>
Returns:
true if cancellation has been requested, and false otherwise
See Also:
TaskDescriptor.cancel()

cancel

public void cancel()
Description copied from interface: TaskDescriptor
Requests that this task be cancelled.

Specified by:
cancel in interface TaskDescriptor<V>
See Also:
TaskDescriptor.isCancelled()

isCancellable

public boolean isCancellable()
Description copied from interface: TaskDescriptor
Returns whether this supports requests to cancel it.

Specified by:
isCancellable in interface TaskDescriptor<V>
Returns:
true if cancellation is supported, and false otherwise
See Also:
TaskDescriptor.cancel()


Copyright © 2002-2014 Atlassian. All Rights Reserved.