}
@Test(timeout = DEFAULT_TEST_TIMEOUT)
public void testRunNow_Success_WithChildDisabled() throws InterruptedException {
String group = "diamondTest";
Task task1 = new Task("task1", group, BEAN_WAIT_JOB, true, true, "3000", "");
taskManager.save(task1);
Task task2 = new Task("task2", group, BEAN_WAIT_JOB, true, true, "100", "");
taskManager.save(task2);
Task task3 = new Task("task3", group, BEAN_WAIT_JOB, true, true, "6000", "");
taskManager.save(task3);
Task task4 = new Task("task4", group, BEAN_WAIT_JOB, true, true, "1000", "");
taskManager.save(task4);
// now create our task "diamond"
task1.addChildTask(task2);
task1.addChildTask(task3);
taskManager.save(task1);
task2.addChildTask(task4);
taskManager.save(task2);
task3.addChildTask(task4);
taskManager.save(task3);
schedulerManager.runTaskNow(task1);
Thread.sleep(1000); // wait enough that task1 should have started but not yet finished
assertEquals(1, taskRunManager.findByTaskId(task1.getId()).size());
assertEquals(0, taskRunManager.findByTaskId(task3.getId()).size());
assertEquals(0, taskRunManager.findByTaskId(task2.getId()).size());
waitForTask(task1);
// now tasks 2 and 3 should get kicked off
Thread.sleep(1000); // wait a bit for this to happen
assertEquals(1, taskRunManager.findByTaskId(task2.getId()).size());
assertEquals(1, taskRunManager.findByTaskId(task3.getId()).size());
assertEquals(0, taskRunManager.findByTaskId(task4.getId()).size()); // should not be triggered yet
waitForTask(task4); // once 2 and 3 are finished, 4 should get triggered
assertEquals(1, taskRunManager.findByTaskId(task1.getId()).size());
assertEquals(1, taskRunManager.findByTaskId(task2.getId()).size());
assertEquals(1, taskRunManager.findByTaskId(task3.getId()).size());
assertEquals(1, taskRunManager.findByTaskId(task4.getId()).size());
}