SourceFileResolver { public static File resolveSourceFile( List<String> sourcePaths, String sourceFileName, String groupId, String artifactId ) { return resolveSourceFile( sourceFileName, PathUtil.filesList( sourcePaths ), groupId, artifactId ); }  static File resolveSourceFile( List<String> sourcePaths, String sourceFileName, String groupId,
                                          String artifactId ); static File resolveSourceFile( List<String> sourcePaths, String sourceFile ); static File resolveSourceFile( String sourceFileName, List<File> sourceRoots ); static File resolveSourceFile( String sourceFileName, List<File> sourceRoots, String groupId,
                                          String artifactId );  }
@Test public void resolveSimple() { File file = SourceFileResolver.resolveSourceFile( "thesimple.as", getDir( "simple" ), null, null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "thesimple.as" ) ); }
@Test public void resolvePackagedGroupPlusArtifact() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "packageartifact" ), "net.flexmojos.oss", "artifactid" ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "pack.mxml" ) ); }
@Test public void resolveMultipleRoots() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "nroots/root1", "nroots/root2", "nroots/root3" ), null, null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "root.as" ) ); }
@Test public void resolveAbsolute() throws IOException { File file = new File( root, "absolute/xummy.as" ).getCanonicalFile(); Assert.assertTrue( file.exists() ); File rfile = SourceFileResolver.resolveSourceFile( file.getAbsolutePath(), null, null, null ); Assert.assertTrue( rfile.exists() ); MatcherAssert.assertThat( rfile.getName(), CoreMatchers.equalTo( "xummy.as" ) ); MatcherAssert.assertThat( rfile, CoreMatchers.equalTo( file ) ); }
@Test( expectedExceptions = { IllegalArgumentException.class } ) public void notResolve() { File file = SourceFileResolver.resolveSourceFile( "NotResolve.mxml", getDir( "notresolve" ), null, null ); MatcherAssert.assertThat( file, CoreMatchers.nullValue() ); }
@Test( expectedExceptions = { IllegalArgumentException.class } ) public void notResolvePackage() { SourceFileResolver.resolveSourceFile( null, getDir( "notresolvepackage" ), "net.flexmojos.oss", "artifactid" ); }
@Test( expectedExceptions = { IllegalArgumentException.class } ) public void notResolvePackageArtifactid() { SourceFileResolver.resolveSourceFile( null, getDir( "notresolvepackageid" ), "net.flexmojos.oss.artifactid", "artifactid" ); }
@Test( expectedExceptions = { IllegalArgumentException.class } ) public void notResolveMultipleRoots() { SourceFileResolver.resolveSourceFile( null, getDir( "notresolvenroots/root1", "notresolvenroots/root2", "notresolvenroots/root3" ), null, null ); }
@Test( expectedExceptions = { IllegalArgumentException.class } ) public void notResolveNamedMultipleRoots() { File file = SourceFileResolver.resolveSourceFile( "NotResolve.mxml", getDir( "notresolvenroots2/root1", "notresolvenroots2/root2", "notresolvenroots2/root3" ), null, null ); MatcherAssert.assertThat( file, CoreMatchers.nullValue() ); }
@Test public void resolveIndexAs() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "indexas" ), null, null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "Index.as" ) ); }
@Test public void resolveIndexMxml() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "indexmxml" ), null, null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "Index.mxml" ) ); }
@Test public void resolveMainAs() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "mainas" ), null, null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "Main.as" ) ); }
@Test public void resolveMainMxml() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "mainmxml" ), null, null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "Main.mxml" ) ); }
@Test public void resolveUniqueAs() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "uniqueas" ), null, null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "dummy.as" ) ); }
@Test public void resolveUniqueMxml() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "uniquemxml" ), null, null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "dummy.mxml" ) ); }
@Test public void resolveArtifactIdAs() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "artifactidas" ), null, "artifact" ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "artifact.as" ) ); }
@Test public void resolveArtifactIdMxml() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "artifactidmxml" ), null, "artifact" ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "artifact.mxml" ) ); }
@Test public void resolvePackagedGroup() { File file = SourceFileResolver.resolveSourceFile( null, getDir( "packagegroup" ), "net.flexmojos.oss", null ); Assert.assertTrue( file.exists() ); MatcherAssert.assertThat( file.getName(), CoreMatchers.equalTo( "pack.as" ) ); }