@Test
public void testStartAndCancel_WithChild() throws InterruptedException {
testTask.setStopOnError(false); // ensure there is no other reason for parent stopping child
taskManager.save(testTask);
Task childTask = new Task("taskRunManagerTestChildTask", "testGroup", "nullJob", true, true, "", "");
taskManager.save(childTask);
testTask.addChildTask(childTask);
taskManager.save(testTask);
JobExecutionContext context = createJobExecutionContext(testTask);
taskRunManager.jobToBeExecuted(context);
TaskRun taskRun = taskRunManager.getMostRecent(testTaskId);
assertTrue(taskRunManager.isRunning(taskRun.getTaskId()));
taskRunManager.stop(taskRun.getId());
taskRun = taskRunManager.get(taskRun.getId());
taskRunManager.jobWasExecuted(context, new JobExecutionException());
assertFalse(taskRunManager.isRunning(taskRun.getTaskId()));
Thread.sleep(1000); // give scheduler time to start child
// parent was cancelled, so no child should run
assertNull(taskRunManager.getMostRecent(childTask.getId()));
}