FileUtils { public static Map< String, IFlexFile > computeFilesList( final File source, final List< File > sourceList, final String packageToExclude, final List< String > excludePatterns ) throws PMDException { final Map< String, IFlexFile > files = new LinkedHashMap< String, IFlexFile >(); final FlexFilter flexFilter = new FlexFilter(); final Collection< File > foundFiles = getFlexFiles( source, sourceList, flexFilter ); for ( final File sourceFile : foundFiles ) { final AbstractFlexFile file = create( sourceFile, source ); if ( ( "".equals( packageToExclude ) || !file.getFullyQualifiedName().startsWith( packageToExclude ) ) && !currentPackageIncludedInExcludePatterns( file.getFullyQualifiedName(), excludePatterns ) ) { files.put( file.getFullyQualifiedName(), file ); } } return files; } private  FileUtils(); static Map< String, IFlexFile > computeFilesList( final File source,
                                                            final List< File > sourceList,
                                                            final String packageToExclude,
                                                            final List< String > excludePatterns ); static AbstractFlexFile create( final File sourceFile,
                                          final File sourceDirectory ); static String[] readLines( final File file );  }
@Test public void testComputeFilesList() throws PMDException { Map< String, IFlexFile > files; files = FileUtils.computeFilesList( getTestDirectory(), null, "", null ); Assert.assertEquals( 110, files.size() ); final List< String > excludePatterns = new ArrayList< String >(); excludePatterns.add( "bug" ); files = FileUtils.computeFilesList( getTestDirectory(), null, "", excludePatterns ); Assert.assertEquals( 93, files.size() ); }
@Test public void testComputeFilesListWithEmptySourceFolder() throws PMDException { final Map< String, IFlexFile > files = FileUtils.computeFilesList( new File( getTestDirectory().getAbsolutePath() + "/" + "empty/emptyFolder" ), null, "", null ); Assert.assertEquals( 1, files.size() ); }
@Test public void testComputeFilesListWithoutSource() { try { FileUtils.computeFilesList( null, null, "", null ); Assert.fail(); } catch ( final PMDException e ) { Assert.assertEquals( "sourceDirectory is not specified", e.getMessage() ); } }
@Test public void testComputeFilesListWithSourceFile() throws PMDException { final Map< String, IFlexFile > files = FileUtils.computeFilesList( new File( getTestFiles().get( "AbstractRowData.as" ) .getFilePath() ), null, "", null ); Assert.assertEquals( 1, files.size() ); }
@Test public void testComputeFilesListWithSourceList() throws PMDException { final List< File > sourceList = new ArrayList< File >(); sourceList.add( getTestDirectory() ); final Map< String, IFlexFile > files = FileUtils.computeFilesList( null, sourceList, "", null ); Assert.assertEquals( 110, files.size() ); }