Search in sources :

Example 1 with DefaultPluginContainer

use of org.gradle.api.internal.plugins.DefaultPluginContainer in project jkube by eclipse.

the class TaskEnvironment method before.

@Override
protected void before() throws Throwable {
    super.before();
    project = mock(Project.class, RETURNS_DEEP_STUBS);
    logger = mock(Logger.class);
    when(project.getProjectDir()).thenReturn(getRoot());
    when(project.getBuildDir()).thenReturn(newFolder("build"));
    when(project.getPlugins()).thenReturn(new DefaultPluginContainer(null, null, null));
    final ConfigurationContainer cc = mock(ConfigurationContainer.class);
    when(project.getConfigurations()).thenReturn(cc);
    List<Configuration> projectConfigurations = new ArrayList<Configuration>();
    when(cc.stream()).thenAnswer(i -> projectConfigurations.stream());
    when(cc.toArray()).thenAnswer(i -> projectConfigurations.toArray());
    when(project.getBuildscript().getConfigurations().stream()).thenAnswer(i -> Stream.empty());
    when(project.getConvention().getPlugin(JavaPluginConvention.class)).thenReturn(mock(JavaPluginConvention.class));
    defaultTaskMockedConstruction = mockConstruction(DefaultTask.class, (mock, ctx) -> {
        when(mock.getProject()).thenReturn(project);
        when(mock.getLogger()).thenReturn(logger);
    });
}
Also used : Project(org.gradle.api.Project) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) DefaultPluginContainer(org.gradle.api.internal.plugins.DefaultPluginContainer) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) File(java.io.File) Logger(org.gradle.api.logging.Logger) ArrayList(java.util.ArrayList) Configuration(org.gradle.api.artifacts.Configuration) List(java.util.List) FileUtils(org.eclipse.jgit.util.FileUtils) Stream(java.util.stream.Stream) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) Mockito.mockConstruction(org.mockito.Mockito.mockConstruction) DefaultTask(org.gradle.api.DefaultTask) RETURNS_DEEP_STUBS(org.mockito.Mockito.RETURNS_DEEP_STUBS) TemporaryFolder(org.junit.rules.TemporaryFolder) MockedConstruction(org.mockito.MockedConstruction) Mockito.mock(org.mockito.Mockito.mock) Project(org.gradle.api.Project) Configuration(org.gradle.api.artifacts.Configuration) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) ArrayList(java.util.ArrayList) DefaultTask(org.gradle.api.DefaultTask) DefaultPluginContainer(org.gradle.api.internal.plugins.DefaultPluginContainer) Logger(org.gradle.api.logging.Logger)

Example 2 with DefaultPluginContainer

use of org.gradle.api.internal.plugins.DefaultPluginContainer in project jkube by eclipse.

the class GradleUtilTest method setUp.

@Before
public void setUp() throws IOException {
    project = mock(Project.class, RETURNS_DEEP_STUBS);
    javaPlugin = mock(JavaPluginConvention.class, RETURNS_DEEP_STUBS);
    when(javaPlugin.getSourceSets().stream()).thenReturn(Stream.empty());
    final ConfigurationContainer cc = mock(ConfigurationContainer.class);
    when(project.getConfigurations()).thenReturn(cc);
    projectConfigurations = new ArrayList<>();
    when(cc.stream()).thenAnswer(i -> projectConfigurations.stream());
    when(cc.toArray()).thenAnswer(i -> projectConfigurations.toArray());
    when(project.getBuildscript().getConfigurations().stream()).thenAnswer(i -> Stream.empty());
    when(project.getProperties()).thenReturn(Collections.emptyMap());
    when(project.getBuildDir()).thenReturn(folder.newFolder("build"));
    when(project.getPlugins()).thenReturn(new DefaultPluginContainer(null, null, null));
    when(project.getConvention().getPlugin(JavaPluginConvention.class)).thenReturn(javaPlugin);
}
Also used : GradleUtil.convertGradleProject(org.eclipse.jkube.gradle.plugin.GradleUtil.convertGradleProject) JavaProject(org.eclipse.jkube.kit.common.JavaProject) Project(org.gradle.api.Project) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) DefaultPluginContainer(org.gradle.api.internal.plugins.DefaultPluginContainer) Before(org.junit.Before)

Aggregations

Project (org.gradle.api.Project)2 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)2 DefaultPluginContainer (org.gradle.api.internal.plugins.DefaultPluginContainer)2 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 FileUtils (org.eclipse.jgit.util.FileUtils)1 GradleUtil.convertGradleProject (org.eclipse.jkube.gradle.plugin.GradleUtil.convertGradleProject)1 JavaProject (org.eclipse.jkube.kit.common.JavaProject)1 DefaultTask (org.gradle.api.DefaultTask)1 Configuration (org.gradle.api.artifacts.Configuration)1 Logger (org.gradle.api.logging.Logger)1 Before (org.junit.Before)1 TemporaryFolder (org.junit.rules.TemporaryFolder)1 MockedConstruction (org.mockito.MockedConstruction)1 RETURNS_DEEP_STUBS (org.mockito.Mockito.RETURNS_DEEP_STUBS)1 Mockito.mock (org.mockito.Mockito.mock)1