stage3.stage(task32);
stage2.chain(stage3);
stage1.chain(stage2);
ClaimCheck check = manager.execute(stage1);
stopWatch.block(100);
manager.cancel(check.toString());
assertEquals(TaskStatus.WORKING,task11.getStatus());
assertEquals(TaskStatus.CANCELED,task12.getStatus());
assertEquals(TaskStatus.WORKING,stage1.getStatus());
stopWatch.block(300);
assertEquals(TaskStatus.CANCELED,stage2.getStatus());
assertEquals(TaskStatus.CANCELED,task21.getStatus());
assertEquals(TaskStatus.CANCELED,task22.getStatus());
assertEquals(TaskStatus.CANCELED,stage3.getStatus());
assertEquals(TaskStatus.CANCELED,task31.getStatus());
assertEquals(TaskStatus.CANCELED,task32.getStatus());
// Block until queued finished
stopWatch.block(550);
assertEquals(TaskStatus.SUCCESS,task11.getStatus());
assertEquals(TaskStatus.CANCELED,task12.getStatus());
assertEquals(TaskStatus.FAILED,stage1.getStatus());
assertEquals(TaskStatus.CANCELED,stage2.getStatus());
assertEquals(TaskStatus.CANCELED,task21.getStatus());
assertEquals(TaskStatus.CANCELED,task22.getStatus());
assertEquals(TaskStatus.CANCELED,stage3.getStatus());
assertEquals(TaskStatus.CANCELED,task31.getStatus());
assertEquals(TaskStatus.CANCELED,task32.getStatus());
// Cancel Stage 2 during Stage 2 using Stage 1 UUID
task11 = new TimerTask(300L);
task12 = new TimerTask(300L);
task21 = new TimerTask(300L);
task22 = new TimerTask(300L);
task31 = new TimerTask(300L);
task32 = new TimerTask(300L);
stage1 = new Stage();
stage2 = new Stage();
stage3 = new Stage();
stage1.stage(task11);
stage1.stage(task12);
stage2.stage(task21);
stage2.stage(task22);
stage3.stage(task31);
stage3.stage(task32);
stage2.chain(stage3);
stage1.chain(stage2);
check = manager.execute(stage1);
stopWatch.block(650);
assertEquals(TaskStatus.SUCCESS,task11.getStatus());
assertEquals(TaskStatus.SUCCESS,task12.getStatus());
assertEquals(TaskStatus.SUCCESS,stage1.getStatus());
assertEquals(TaskStatus.WORKING,stage2.getStatus());
assertEquals(TaskStatus.WORKING,task21.getStatus());
assertEquals(TaskStatus.QUEUED,task22.getStatus());
assertEquals(TaskStatus.DEQUEUED,stage3.getStatus());
assertEquals(TaskStatus.DEQUEUED,task31.getStatus());
assertEquals(TaskStatus.DEQUEUED,task32.getStatus());
manager.cancel(check.toString());
assertEquals(TaskStatus.SUCCESS,task11.getStatus());
assertEquals(TaskStatus.SUCCESS,task12.getStatus());
assertEquals(TaskStatus.SUCCESS,stage1.getStatus());