@Test public void testLoadIncludesWithEmptyChanges() throws MojoExecutionException { final List<String> changedFiles = Collections.emptyList(); JacocoReportChangesMojo mojo = new JacocoReportChangesMojo() { @Override public List<String> loadChangedFiles(String branchName) throws MojoExecutionException { return changedFiles; } }; MavenProject project = mock(MavenProject.class); when(project.getCompileSourceRoots()).thenReturn(Arrays.asList("src/main/java")); when(project.getBasedir()).thenReturn(new File(System.getProperty("user.dir"))); mojo.setProject(project); List<String> result = mojo.loadIncludes(); assertEquals(1, result.size()); assertEquals("", result.get(0)); }
@Test public void testLoadIncludes() throws MojoExecutionException { final List<String> changedFiles = Arrays.asList("src/main/java/a/A.java", "src/test/java/a/B.java", "src/main/java/a/C.txt"); JacocoReportChangesMojo mojo = new JacocoReportChangesMojo() { @Override public List<String> loadChangedFiles(String branchName) throws MojoExecutionException { return changedFiles; } }; MavenProject project = mock(MavenProject.class); when(project.getCompileSourceRoots()).thenReturn(Arrays.asList("src/main/java")); when(project.getBasedir()).thenReturn(new File(System.getProperty("user.dir"))); mojo.setProject(project); assertEquals( Arrays.asList("a" + System.getProperty("file.separator") + "A" + CLASS_SUFFIX), mojo.loadIncludes()); }