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() );
FaultData data = new FaultData();
data.setAccessType(AccessType.Inline);
data.setType("type");
data.setFaultName("faultName");
data.setContent("content".getBytes());
responseHandler = new BlockingTaskOperationResponseHandler();
client.fail( taskId, users.get( "darth" ).getId(), data, responseHandler );
responseHandler.waitTillDone(DEFAULT_WAIT_TIME);
getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask( taskId, getTaskResponseHandler );
Task task2 = getTaskResponseHandler.getTask();
assertEquals( Status.Failed, task2.getTaskData().getStatus() );
assertEquals( AccessType.Inline, task2.getTaskData().getFaultAccessType() );
assertEquals( "type", task2.getTaskData().getFaultType() );
assertEquals( "faultName", task2.getTaskData().getFaultName() );
long contentId = task2.getTaskData().getFaultContentId();
assertTrue( contentId != -1 );
BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler();
client.getContent(contentId, getContentResponseHandler);
Content content = getContentResponseHandler.getContent();