client.addTask( task, null, addTaskResponseHandler );
long taskId = addTaskResponseHandler.getTaskId();
// A Task with multiple potential owners moves to "Ready" state until someone claims it.
BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
Task task1 = getTaskResponseHandler.getTask();
assertEquals( Status.Ready , task1.getTaskData().getStatus() );
// State should not change as user isn't potential owner
BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();
client.start( taskId, users.get( "tony" ).getId(), responseHandler );
PermissionDeniedException denied = null;
try {
responseHandler.waitTillDone( DEFAULT_WAIT_TIME );
} catch(PermissionDeniedException e) {
denied = e;
}
assertNotNull("Should get permissed denied exception", denied);
getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
Task task2 = getTaskResponseHandler.getTask();
assertEquals( Status.Ready, task2.getTaskData().getStatus() );
assertNull( task2.getTaskData().getActualOwner() );
}