public <T extends AbstractTask> T createTask(Class<T> type, Project project, String name) { Task task = TASK_FACTORY.createTask( (ProjectInternal) project, GUtil.map(Task.TASK_TYPE, type, Task.TASK_NAME, name)); assertTrue(type.isAssignableFrom(task.getClass())); return type.cast(task); }
@Test public void testDependsOn() { Task dependsOnTask = createTask(project, "somename"); Task task = createTask(project, TEST_TASK_NAME); project.getTasks().add("path1"); project.getTasks().add("path2"); task.dependsOn(Project.PATH_SEPARATOR + "path1"); assertThat(task, dependsOn("path1")); task.dependsOn("path2", dependsOnTask); assertThat(task, dependsOn("path1", "path2", "somename")); }
@Test public void testPath() { DefaultProject rootProject = HelperUtil.createRootProject(); DefaultProject childProject = HelperUtil.createChildProject(rootProject, "child"); childProject.getProjectDir().mkdirs(); DefaultProject childchildProject = HelperUtil.createChildProject(childProject, "childchild"); childchildProject.getProjectDir().mkdirs(); Task task = createTask(rootProject, TEST_TASK_NAME); assertEquals(Project.PATH_SEPARATOR + TEST_TASK_NAME, task.getPath()); task = createTask(childProject, TEST_TASK_NAME); assertEquals( Project.PATH_SEPARATOR + "child" + Project.PATH_SEPARATOR + TEST_TASK_NAME, task.getPath()); task = createTask(childchildProject, TEST_TASK_NAME); assertEquals( Project.PATH_SEPARATOR + "child" + Project.PATH_SEPARATOR + "childchild" + Project.PATH_SEPARATOR + TEST_TASK_NAME, task.getPath()); }