ScanManyArtifactsMojo extends AbstractITestWithPlanMojo { final List<File> listScanFiles() throws MojoFailureException { List<File> resolvedArtifacts = new ArrayList<>(); if (scanArtifacts != null && !scanArtifacts.isEmpty()) { resolvedArtifacts.addAll(resolveDependencies(scanArtifacts, false)); } if (scanFiles != null && !scanFiles.isEmpty()) { resolvedArtifacts.addAll(scanFiles); } return resolvedArtifacts; }    }
@Test public void testListScanFiles() throws Exception { final File testOutDir = new File(testOutBaseDir, "testListScanFiles"); FileUtils.deleteDirectory(testOutDir); testOutDir.mkdirs(); ScanManyArtifactsMojo mojo = newMojo(); assertTrue("empty by default", mojo.listScanFiles().isEmpty()); final File artifactFile = new File(testOutDir, "scan-artifact-file.zip"); FileUtils.touch(artifactFile); final File fileFile = new File(testOutDir, "scan-file-file.zip"); FileUtils.touch(fileFile); final Dependency dependency = new DependencyFilter() .withGroupId("com.example") .withArtifactId("scan-artifact-file") .withVersion("1.0-SNAPSHOT") .withType("zip") .toDependency(); mojo.scanArtifacts = Collections.singletonList(dependency); mojo.scanFiles = Collections.singletonList(fileFile); final MavenSession session = mock(MavenSession.class); mojo.session = session; final MavenExecutionRequest executionRequest = mock(MavenExecutionRequest.class); when(session.getRequest()).thenReturn(executionRequest); final RepositorySystem repositorySystem = mock(RepositorySystem.class); mojo.repositorySystem = repositorySystem; final Artifact scanArtifact = mock(Artifact.class); when(scanArtifact.getFile()).thenReturn(artifactFile); when(repositorySystem.createDependencyArtifact(dependency)).thenReturn(scanArtifact); final List<File> scanFiles = mojo.listScanFiles(); assertEquals("expect files", Arrays.asList(artifactFile, fileFile), scanFiles); }