@Test public void testNoParentProject() { File wwwZipBase = mock( File.class ); File wwwZipFile = mock( File.class ); when( project.getParent() ).thenReturn( null ); when( wwwZipBase.listFiles() ).thenReturn( new File[] { wwwZipFile } ); when( wwwZipFile.isDirectory() ).thenReturn( true ); when( wwwZipFile.getAbsolutePath() ).thenReturn( "d/e/f" ); LocalRepositoryCollector collector = new LocalRepositoryCollector( project, localRepository, new File[] { wwwZipBase } ); verify( project, times( 1 ) ).getArtifactId(); verify( project, times( 1 ) ).getParent(); String localRepositoryFound = collector.findLocalRepository( "a/b/c/d" ); assertEquals( localRepositoryBaseDir, localRepositoryFound ); localRepositoryFound = collector.findLocalRepository( "d/e/f/z" ); assertEquals( "d/e/f", localRepositoryFound ); localRepositoryFound = collector.findLocalRepository( "a/b/d/d" ); assertNull( localRepositoryFound ); }
public String findLocalRepository( String filePath ) { String localRepositoryPathFound = null; for ( String localRepositoryPath : localRepositoryPaths ) { if ( filePath.startsWith( localRepositoryPath ) ) { localRepositoryPathFound = localRepositoryPath; break; } } return localRepositoryPathFound; }
LocalRepositoryCollector { public String findLocalRepository( String filePath ) { String localRepositoryPathFound = null; for ( String localRepositoryPath : localRepositoryPaths ) { if ( filePath.startsWith( localRepositoryPath ) ) { localRepositoryPathFound = localRepositoryPath; break; } } return localRepositoryPathFound; } }
LocalRepositoryCollector { public String findLocalRepository( String filePath ) { String localRepositoryPathFound = null; for ( String localRepositoryPath : localRepositoryPaths ) { if ( filePath.startsWith( localRepositoryPath ) ) { localRepositoryPathFound = localRepositoryPath; break; } } return localRepositoryPathFound; } LocalRepositoryCollector( MavenProject project, //
                                     ArtifactRepository localRepository, File[] additionalFolderBases ); }
LocalRepositoryCollector { public String findLocalRepository( String filePath ) { String localRepositoryPathFound = null; for ( String localRepositoryPath : localRepositoryPaths ) { if ( filePath.startsWith( localRepositoryPath ) ) { localRepositoryPathFound = localRepositoryPath; break; } } return localRepositoryPathFound; } LocalRepositoryCollector( MavenProject project, //
                                     ArtifactRepository localRepository, File[] additionalFolderBases ); String findLocalRepository( String filePath ); void addLocalRepositoryPath( String path ); }
LocalRepositoryCollector { public String findLocalRepository( String filePath ) { String localRepositoryPathFound = null; for ( String localRepositoryPath : localRepositoryPaths ) { if ( filePath.startsWith( localRepositoryPath ) ) { localRepositoryPathFound = localRepositoryPath; break; } } return localRepositoryPathFound; } LocalRepositoryCollector( MavenProject project, //
                                     ArtifactRepository localRepository, File[] additionalFolderBases ); String findLocalRepository( String filePath ); void addLocalRepositoryPath( String path );  }