Thread.sleep(500);
//Start the parent task
System.out.println("Starting task " + task.getId());
BlockingTaskOperationResponseHandler operationResponseHandler = new BlockingTaskOperationResponseHandler();
client.start(task.getId(), "Darth Vader", operationResponseHandler);
operationResponseHandler.waitTillDone(DEFAULT_WAIT_TIME);
System.out.println("Started task " + task.getId());
//Check if the parent task is InProgress
BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask(task.getId(), getTaskResponseHandler);
Task parentTask = getTaskResponseHandler.getTask();
assertEquals(Status.InProgress, parentTask.getTaskData().getStatus());
assertEquals(users.get("darth"), parentTask.getTaskData().getActualOwner());
//Get all the subtask created for the parent task based on the potential owner
responseHandler = new BlockingTaskSummaryResponseHandler();
client.getSubTasksAssignedAsPotentialOwner(parentTask.getId(), "Darth Vader", "en-UK", responseHandler);
List<TaskSummary> subTasks = responseHandler.getResults();
assertEquals(2, subTasks.size());
TaskSummary subTaskSummary1 = subTasks.get(0);
TaskSummary subTaskSummary2 = subTasks.get(1);
assertNotNull(subTaskSummary1);
assertNotNull(subTaskSummary2);
//Starting the sub task 1
System.out.println("Starting sub task " + subTaskSummary1.getId());
operationResponseHandler = new BlockingTaskOperationResponseHandler();
client.start(subTaskSummary1.getId(), "Darth Vader", operationResponseHandler);
operationResponseHandler.waitTillDone(DEFAULT_WAIT_TIME);
System.out.println("Started sub task " + subTaskSummary1.getId());
//Starting the sub task 2
System.out.println("Starting sub task " + subTaskSummary2.getId());
operationResponseHandler = new BlockingTaskOperationResponseHandler();
client.start(subTaskSummary2.getId(), "Darth Vader", operationResponseHandler);
operationResponseHandler.waitTillDone(DEFAULT_WAIT_TIME);
System.out.println("Started sub task " + subTaskSummary2.getId());
//Check if the child task 1 is InProgress
getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask(subTaskSummary1.getId(), getTaskResponseHandler);
Task subTask1 = getTaskResponseHandler.getTask();
assertEquals(Status.InProgress, subTask1.getTaskData().getStatus());
assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
//Check if the child task 2 is InProgress
getTaskResponseHandler = new BlockingGetTaskResponseHandler();
client.getTask(subTaskSummary2.getId(), getTaskResponseHandler);
Task subTask2 = getTaskResponseHandler.getTask();
assertEquals(Status.InProgress, subTask2.getTaskData().getStatus());
assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
// Complete the child task 1
System.out.println("Completing sub task " + subTask1.getId());
operationResponseHandler = new BlockingTaskOperationResponseHandler();
client.complete(subTask1.getId(), "Darth Vader", null, operationResponseHandler);
operationResponseHandler.waitTillDone(DEFAULT_WAIT_TIME);
System.out.println("Completed sub task " + subTask1.getId());
// Complete the child task 2
System.out.println("Completing sub task " + subTask2.getId());
operationResponseHandler = new BlockingTaskOperationResponseHandler();
client.complete(subTask2.getId(), "Darth Vader", null, operationResponseHandler);
operationResponseHandler.waitTillDone(DEFAULT_WAIT_TIME);
System.out.println("Completed sub task " + subTask2.getId());
//Check if the child task 1 is Completed
getTaskResponseHandler = new BlockingGetTaskResponseHandler();