@Test
public void schedule4() throws Exception {

    final Executor executor = Executors.newCachedThreadPool();
    LaunchTask task0 = TaskFactory.create("task0", 1000, Collections.singletonList("task2"), executor, new TestTaskCallback() {
        @Override
        public void taskStart() {
        }
        @Override
        public void taskEnd() {
        }
    });
    LaunchTask task1 = TaskFactory.create("task1", 1000, Collections.singletonList("task0"), executor, new TestTaskCallback() {
        @Override
        public void taskStart() {
        }
        @Override
        public void taskEnd() {
        }
    });
    LaunchTask task2 = TaskFactory.create("task2", 1000, Collections.singletonList("task1"), executor, new TestTaskCallback() {
        @Override
        public void taskStart() {
        }
        @Override
        public void taskEnd() {
        }
    });
    try {
        new TaskScheduer(Arrays.asList(task2, task1, task0)).schedule(null, 0, null);
    } catch (Throwable throwable) {
        Assert.assertTrue(throwable instanceof IllegalStateException);
        Assert.assertTrue(throwable.getLocalizedMessage().equals("Exists a cycle in the graph"));
        return;
    }
    Assert.assertTrue(false);
}