### Question:
CDocReportMojo extends AbstractMavenReport { List<File> getFiles() throws MavenReportException { try { final String excludePattern = excludes == null ? "" : StringUtils.join(excludes, ','); final List<File> sourceFiles = new ArrayList<File>(); if (sourceDirectory.exists()) { sourceFiles.addAll(FileUtils.getFiles(sourceDirectory, "*.prg,*.inc,*.sub", excludePattern)); } if (resourcesDirectory.exists()) { sourceFiles.addAll(FileUtils.getFiles(resourcesDirectory, "*.prg,*.inc,*.sub", excludePattern)); } return sourceFiles; } catch (final IOException e) { throw new MavenReportException("Failed to locate source files.", e); } } CDocReportMojo();  CDocReportMojo(final TextParser textParser, final ScriptExecutionDetailsParser detailsParser); @Override boolean canGenerateReport(); @Override String getDescription(final Locale locale); @Override String getName(final Locale locale); @Override String getOutputName(); @Override boolean isExternalReport();  }### Answer:
@Test public void testGetFiles() throws Exception { final File sourceFile = mock(File.class); final File sourceDirectory = mock(File.class); when(sourceDirectory.exists()).thenReturn(Boolean.TRUE); final File resourceFile = mock(File.class); final File resourcesDirectory = mock(File.class); when(resourcesDirectory.exists()).thenReturn(Boolean.TRUE); mockStatic(FileUtils.class); when(FileUtils.getFiles(sourceDirectory, "*.prg,*.inc,*.sub", "")) .thenReturn(Collections.singletonList(sourceFile)); when(FileUtils.getFiles(resourcesDirectory, "*.prg,*.inc,*.sub", "")) .thenReturn(Collections.singletonList(resourceFile)); mojo.sourceDirectory = sourceDirectory; mojo.resourcesDirectory = resourcesDirectory; assertThat(mojo.getFiles()).containsOnly(sourceFile, resourceFile); }
@Test public void testGetFilesNoResourcesDirectory() throws Exception { final File sourceFile = mock(File.class); final File sourceDirectory = mock(File.class); when(sourceDirectory.exists()).thenReturn(Boolean.TRUE); final File resourceFile = mock(File.class); final File resourcesDirectory = mock(File.class); when(resourcesDirectory.exists()).thenReturn(Boolean.FALSE); mockStatic(FileUtils.class); when(FileUtils.getFiles(sourceDirectory, "*.prg,*.inc,*.sub", "")) .thenReturn(Collections.singletonList(sourceFile)); when(FileUtils.getFiles(resourcesDirectory, "*.prg,*.inc,*.sub", "")) .thenReturn(Collections.singletonList(resourceFile)); mojo.sourceDirectory = sourceDirectory; mojo.resourcesDirectory = resourcesDirectory; assertThat(mojo.getFiles()).containsOnly(sourceFile); }
@Test public void testGetFilesNoSourcesDirectory() throws Exception { final File sourceFile = mock(File.class); final File sourceDirectory = mock(File.class); when(sourceDirectory.exists()).thenReturn(Boolean.FALSE); final File resourceFile = mock(File.class); final File resourcesDirectory = mock(File.class); when(resourcesDirectory.exists()).thenReturn(Boolean.TRUE); mockStatic(FileUtils.class); when(FileUtils.getFiles(sourceDirectory, "*.prg,*.inc,*.sub", "")) .thenReturn(Collections.singletonList(sourceFile)); when(FileUtils.getFiles(resourcesDirectory, "*.prg,*.inc,*.sub", "")) .thenReturn(Collections.singletonList(resourceFile)); mojo.sourceDirectory = sourceDirectory; mojo.resourcesDirectory = resourcesDirectory; assertThat(mojo.getFiles()).containsOnly(resourceFile); }