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();
// Check is Reserved
BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();
client.claim( 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.Reserved, task1.getTaskData().getStatus() );
assertEquals( users.get( "darth" ), task1.getTaskData().getActualOwner() );
// Check is suspended
responseHandler = new BlockingTaskOperationResponseHandler();
client.suspend( taskId, users.get( "darth" ).getId(), responseHandler );
responseHandler.waitTillDone(DEFAULT_WAIT_TIME);
getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
Task task2 = getTaskResponseHandler.getTask();
assertEquals( Status.Reserved, task2.getTaskData().getPreviousStatus() );
assertEquals( Status.Suspended, task2.getTaskData().getStatus() );
assertEquals( users.get( "darth" ), task2.getTaskData().getActualOwner() );
// Check is Resumed
responseHandler = new BlockingTaskOperationResponseHandler();
client.resume( taskId, users.get( "darth" ).getId(), responseHandler );
responseHandler.waitTillDone(DEFAULT_WAIT_TIME);
getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
Task task3 = getTaskResponseHandler.getTask();
assertEquals( Status.Reserved, task3.getTaskData().getStatus() );
assertEquals( Status.Suspended, task3.getTaskData().getPreviousStatus() );
assertEquals( users.get( "darth" ), task3.getTaskData().getActualOwner() );
}