String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [users['bobba' ], users['darth'] ], }),";
str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })";
BlockingAddTaskResponseHandler addTaskResponseHandler = new BlockingAddTaskResponseHandler();
Task task = ( Task ) eval( new StringReader( str ), vars );
client.addTask( task, null, addTaskResponseHandler );
long taskId = addTaskResponseHandler.getTaskId();
// Go straight from Ready to Inprogress
BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();
client.start( taskId, users.get( "darth" ).getId(), responseHandler );
responseHandler.waitTillDone(DEFAULT_WAIT_TIME);
BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
Task task1 = getTaskResponseHandler.getTask();
assertEquals( Status.InProgress, task1.getTaskData().getStatus() );
assertEquals( users.get( "darth" ), task1.getTaskData().getActualOwner() );
// Should not stop
responseHandler = new BlockingTaskOperationResponseHandler();
client.stop( taskId, users.get( "bobba" ).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.InProgress, task2.getTaskData().getStatus() );
assertEquals( users.get( "darth" ), task2.getTaskData().getActualOwner() );
}