Search in sources :

Example 1 with DefaultProjectTaskLister

use of org.gradle.api.internal.project.DefaultProjectTaskLister in project gradle by gradle.

the class TestUtility method createMockProject.

/**
     * Creates a mock project with the specified properties.
     *
     * Note: depth is 0 for a root project. 1 for a root project's subproject, etc.
     */
public static Project createMockProject(JUnit4Mockery context, final String name, final String buildFilePath, final int depth, Project[] subProjectArray, Task[] tasks, String[] defaultTasks) {
    final ProjectInternal project = context.mock(ProjectInternal.class, "[project]_" + name + '_' + uniqueNameCounter++);
    final ServiceRegistry services = ServiceRegistryBuilder.builder().provider(new Object() {

        ProjectTaskLister createTaskLister() {
            return new DefaultProjectTaskLister();
        }
    }).build();
    context.checking(new Expectations() {

        {
            allowing(project).getName();
            will(returnValue(name));
            allowing(project).getDescription();
            will(returnValue(null));
            allowing(project).getBuildFile();
            will(returnValue(new File(buildFilePath)));
            allowing(project).getDepth();
            will(returnValue(depth));
            allowing(project).getServices();
            will(returnValue(services));
        }
    });
    attachSubProjects(context, project, subProjectArray);
    attachTasks(context, project, tasks);
    assignDefaultTasks(context, project, defaultTasks);
    return project;
}
Also used : Expectations(org.jmock.Expectations) DefaultProjectTaskLister(org.gradle.api.internal.project.DefaultProjectTaskLister) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) File(java.io.File)

Aggregations

File (java.io.File)1 DefaultProjectTaskLister (org.gradle.api.internal.project.DefaultProjectTaskLister)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)1 Expectations (org.jmock.Expectations)1