@Test public void testWithParentProject() { MavenProject parentProject = mock( MavenProject.class ); when( project.getParent() ).thenReturn( parentProject ); List<String> modules = new ArrayList<String>( 1 ); modules.add( artifactId ); when( parentProject.getModules() ).thenReturn( modules ); when( parentProject.getArtifactId() ).thenReturn( "anotherArtifactId" ); String parentLocalRepositoryBaseDir = "x/y/z"; File parentLocalRepositoryBaseDirFile = mock( File.class ); when( parentLocalRepositoryBaseDirFile.getAbsolutePath() ).thenReturn( parentLocalRepositoryBaseDir ); when( parentProject.getBasedir() ).thenReturn( parentLocalRepositoryBaseDirFile ); when( parentProject.getParent() ).thenReturn( null ); LocalRepositoryCollector collector = new LocalRepositoryCollector( project, localRepository, new File[] {} ); verify( parentProject, times( 1 ) ).getModules(); verify( parentProject, times( 1 ) ).getArtifactId(); verify( parentProject, times( 1 ) ).getBasedir(); verify( parentProject, times( 1 ) ).getParent(); verify( parentLocalRepositoryBaseDirFile, times( 1 ) ).getAbsolutePath(); String localRepositoryFound = collector.findLocalRepository( "x/y/z/d" ); assertEquals( parentLocalRepositoryBaseDir, 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 );  }