package com.bisnode.versioncheck;

import org.gradle.api.Project;
import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency;
import org.gradle.testfixtures.ProjectBuilder;
import org.junit.Test;

import com.bisnode.versioncheck.rules.DuplicateRule;
import com.bisnode.versioncheck.rules.SameVersionGroupRule;

public class VersionCheckPluginTest {

    @Test
    public void pluginSetupFunctional() {
        Project project = ProjectBuilder.builder().build();

        project.getPluginManager().apply("java");
        project.getPluginManager().apply("com.bisnode.version-check");
        project.getRepositories().mavenCentral();

        project.getDependencies().add("compile", new DefaultExternalModuleDependency("org.springframework.boot", "spring-boot-starter", "1.5.1.RELEASE"));
        project.getDependencies().add("testCompile", new DefaultExternalModuleDependency("org.springframework.boot", "spring-boot-starter-test", "1.4.1.RELEASE"));

        VersionCheckExtension extension = project.getExtensions().findByType(VersionCheckExtension.class);
        extension.setDependencies("transitive");

        extension.configurations("testCompile");

        extension.getVersionRules().add(new DuplicateRule());
        extension.getVersionRules().add(new SameVersionGroupRule("org.springframework.boot"));

        ValidationTask validateTask = (ValidationTask) project.getTasksByName("versionCheck", false).iterator().next();

        validateTask.execute();
    }
}

@@ -39,30 +39,115 @@
 ort 
-org.gradle.api.Project
+static org.mockito.Mockito.*;%0A%0Aimport org.gradle.api.Project;%0Aimport org.gradle.api.artifacts.Configuration
 ;%0Aim
@@ -300,16 +300,44 @@
 it.Test;
+%0Aimport org.mockito.Mockito;
 %0A%0Aimport
@@ -1586,31 +1586,691 @@
     
-validateTask.execute();
+ValidationReportRenderer mockRenderer = mock(ValidationReportRenderer.class);%0A        validateTask.setRenderer(mockRenderer);%0A%0A        validateTask.execute();%0A%0A        verify(mockRenderer).startProject(project);%0A        verify(mockRenderer).completeProject(project);%0A%0A        Configuration configuration = project.getConfigurations().findByName(%22testCompile%22);%0A%0A        verify(mockRenderer).startConfiguration(configuration);%0A        verify(mockRenderer).completeConfiguration(configuration);%0A%0A        verify(mockRenderer).startViolationGroup(any());%0A        verify(mockRenderer).completeViolationGroup();%0A%0A        verify(mockRenderer, times(4)).reportViolation(any(), anyVararg());%0A
 %0A   

Implement proper unit test