Task task = ( Task ) eval( new StringReader( str ), vars );
client.addTask( task, null, addTaskResponseHandler );
long taskId = addTaskResponseHandler.getTaskId();
EventKey key = new TaskEventKey(TaskCompletedEvent.class, taskId );
BlockingEventResponseHandler handler = new BlockingEventResponseHandler();
client.registerForEvent( key, true, handler );
BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();
client.getTasksAssignedAsPotentialOwner(users.get( "bobba" ).getId(), "en-UK", taskSummaryResponseHandler);
List<TaskSummary> tasks = taskSummaryResponseHandler.getResults();
assertEquals(1, tasks.size());
assertEquals(Status.Reserved, tasks.get(0).getStatus());
BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();
client.start( taskId, users.get( "bobba" ).getId(), responseHandler );
taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();
client.getTasksAssignedAsPotentialOwner(users.get( "bobba" ).getId(), "en-UK", taskSummaryResponseHandler);
tasks = taskSummaryResponseHandler.getResults();
assertEquals(1, tasks.size());
assertEquals(Status.InProgress, tasks.get(0).getStatus());
BlockingAddTaskResponseHandler addTaskResponseHandler2 = new BlockingAddTaskResponseHandler();
Task task2 = ( Task ) eval( new StringReader( str ), vars );
client.addTask( task2, null, addTaskResponseHandler2 );
long taskId2 = addTaskResponseHandler.getTaskId();
EventKey key2 = new TaskEventKey(TaskCompletedEvent.class, taskId2 );
BlockingEventResponseHandler handler2 = new BlockingEventResponseHandler();
client.registerForEvent( key2, true, handler2 );
taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();
client.getTasksAssignedAsPotentialOwner(users.get( "bobba" ).getId(), "en-UK", taskSummaryResponseHandler);
tasks = taskSummaryResponseHandler.getResults();