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());
responseHandler = new BlockingTaskOperationResponseHandler();
client.complete( taskId, users.get( "bobba" ).getId(), null, responseHandler );
taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler();
client.getTasksAssignedAsPotentialOwner(users.get( "bobba" ).getId(), "en-UK", taskSummaryResponseHandler);
tasks = taskSummaryResponseHandler.getResults();
assertEquals(0, tasks.size());
Payload payload = handler.getPayload();
TaskCompletedEvent event = ( TaskCompletedEvent ) payload.get();
assertNotNull( event );