GradleTaskTree { public static List<GradleTaskTree> createTaskTree(Collection<GradleTaskID> tasks) { return createTaskTree(DEFAULT_TASK_LIMIT, tasks); } GradleTaskTree(GradleTaskID taskID);  GradleTaskTree(String caption, List<GradleTaskTree> children); private  GradleTaskTree(
            String caption,
            GradleTaskID taskID,
            List<GradleTaskTree> children); String getCaption(); @Nullable GradleTaskID getTaskID(); List<GradleTaskTree> getChildren(); static List<GradleTaskTree> createTaskTree(Collection<GradleTaskID> tasks); static List<GradleTaskTree> createTaskTree(
            int taskLimit,
            Collection<GradleTaskID> taskIDs);  }
@Test(timeout = 10000) public void testNoInfiniteLoop1() { List<GradleTaskID> taskIDs = toTaskIDs("A"); List<GradleTaskTree> nodes = GradleTaskTree.createTaskTree(0, taskIDs); assertEquals("Node count", 1, nodes.size()); assertLeaf(nodes.get(0), "A"); }
@Test(timeout = 10000) public void testNoInfiniteLoop2() { List<GradleTaskID> taskIDs = toTaskIDs("A", "B"); List<GradleTaskTree> nodes = GradleTaskTree.createTaskTree(0, taskIDs); assertEquals("Node count", 2, nodes.size()); assertLeaf(nodes.get(0), "A"); assertLeaf(nodes.get(1), "B"); }
@Test public void testSingleTask() { List<GradleTaskID> taskIDs = toTaskIDs("TASK"); List<GradleTaskTree> nodes = GradleTaskTree.createTaskTree(5, taskIDs); assertEquals("Node count", 1, nodes.size()); assertLeaf(nodes.get(0), "TASK"); }
@Test public void testUnderscoreSeparated() { List<GradleTaskID> taskIDs = toTaskIDs( "TASK_A", "TASK_B", "TASK_C", "TASK_D", "TASK_E", "OTHER_A", "OTHER_B", "OTHER_C"); List<GradleTaskTree> nodes = GradleTaskTree.createTaskTree(5, taskIDs); assertEquals("Node count", 2, nodes.size()); assertTasks(nodes.get(0), "TASK", "TASK_A", "TASK_B", "TASK_C", "TASK_D", "TASK_E"); assertTasks(nodes.get(1), "OTHER", "OTHER_A", "OTHER_B", "OTHER_C"); }
@Test public void testBasicSingleLevelSplit() { List<GradleTaskID> taskIDs = toTaskIDs( "", "compileGroovy", "compileJava", "compileTestJava", "compileTestGroovy", "build", "buildSubA", "buildSubB"); List<GradleTaskTree> nodes = GradleTaskTree.createTaskTree(7, taskIDs); assertEquals("Node count", 3, nodes.size()); assertLeaf(nodes.get(0), ""); assertTasks(nodes.get(1), "compile", "compileGroovy", "compileJava", "compileTestJava", "compileTestGroovy"); assertTasks(nodes.get(2), "build", "build", "buildSubA", "buildSubB"); }
@Test public void testSingleLevelNoUnnecessaryIndirection() { List<GradleTaskID> taskIDs = toTaskIDs( "buildApp1", "buildApp2", "buildLib1", "buildLib2", "buildLib3"); List<GradleTaskTree> nodes = GradleTaskTree.createTaskTree(4, taskIDs); assertEquals("Node count", 2, nodes.size()); assertTasks(nodes.get(0), "buildApp", "buildApp1", "buildApp2"); assertTasks(nodes.get(1), "buildLib", "buildLib1", "buildLib2", "buildLib3"); }