@Test public void testResolveArtifact() throws InvalidVersionSpecificationException { final Artifact provider = createArtifact( "surefire-junit-platform" ); RepositorySystem repositorySystem = mock( RepositorySystem.class ); final ArtifactResolutionResult expectedResult = mock( ArtifactResolutionResult.class ); when( repositorySystem.resolve( any( ArtifactResolutionRequest.class ) ) ) .then( new Answer<ArtifactResolutionResult>() { @Override public ArtifactResolutionResult answer( InvocationOnMock invocation ) { Object[] args = invocation.getArguments(); assertThat( args ) .hasSize( 1 ); ArtifactResolutionRequest request = (ArtifactResolutionRequest) args[0]; assertThat( request.getArtifact() ) .isSameAs( provider ); assertThat( request.isResolveTransitively() ) .isTrue(); assertThat( request.getArtifactDependencies() ) .isNull(); assertThat( request.getRemoteRepositories() ) .isNull(); assertThat( request.getLocalRepository() ) .isNull(); assertThat( request.getCache() ) .isNull(); assertThat( request.getCollectionFilter() ) .isNotNull(); assertThat( request.getCollectionFilter() ) .isInstanceOf( RuntimeArtifactFilter.class ); assertThat( request.getManagedVersionMap() ) .isNull(); assertThat( request.getMirrors() ) .isEmpty(); assertThat( request.getProxies() ) .isEmpty(); assertThat( request.getResolutionFilter() ) .isNull(); assertThat( request.getServers() ) .isEmpty(); return expectedResult; } } ); SurefireDependencyResolver surefireDependencyResolver = new SurefireDependencyResolver( repositorySystem, null, null, null, null, null, null, false ); ArtifactResolutionResult actualResult = surefireDependencyResolver.resolvePluginArtifact( provider ); assertThat( actualResult ) .isSameAs( expectedResult ); }
private ArtifactResolutionResult resolveArtifact( Artifact artifact, List<ArtifactRepository> repositories, ArtifactFilter filter ) { ArtifactResolutionRequest request = new ArtifactResolutionRequest() .setOffline( offline ) .setArtifact( artifact ) .setLocalRepository( localRepository ) .setResolveTransitively( true ) .setCollectionFilter( filter ) .setRemoteRepositories( repositories ); return repositorySystem.resolve( request ); }
SurefireDependencyResolver { private ArtifactResolutionResult resolveArtifact( Artifact artifact, List<ArtifactRepository> repositories, ArtifactFilter filter ) { ArtifactResolutionRequest request = new ArtifactResolutionRequest() .setOffline( offline ) .setArtifact( artifact ) .setLocalRepository( localRepository ) .setResolveTransitively( true ) .setCollectionFilter( filter ) .setRemoteRepositories( repositories ); return repositorySystem.resolve( request ); } }
SurefireDependencyResolver { private ArtifactResolutionResult resolveArtifact( Artifact artifact, List<ArtifactRepository> repositories, ArtifactFilter filter ) { ArtifactResolutionRequest request = new ArtifactResolutionRequest() .setOffline( offline ) .setArtifact( artifact ) .setLocalRepository( localRepository ) .setResolveTransitively( true ) .setCollectionFilter( filter ) .setRemoteRepositories( repositories ); return repositorySystem.resolve( request ); } SurefireDependencyResolver( RepositorySystem repositorySystem, ConsoleLogger log,
                                ArtifactRepository localRepository,
                                List<ArtifactRepository> pluginRemoteRepositories,
                                List<ArtifactRepository> projectRemoteRepositories, String pluginName,
                                DependencyResolver dependencyResolver, boolean offline ); }
SurefireDependencyResolver { private ArtifactResolutionResult resolveArtifact( Artifact artifact, List<ArtifactRepository> repositories, ArtifactFilter filter ) { ArtifactResolutionRequest request = new ArtifactResolutionRequest() .setOffline( offline ) .setArtifact( artifact ) .setLocalRepository( localRepository ) .setResolveTransitively( true ) .setCollectionFilter( filter ) .setRemoteRepositories( repositories ); return repositorySystem.resolve( request ); } SurefireDependencyResolver( RepositorySystem repositorySystem, ConsoleLogger log,
                                ArtifactRepository localRepository,
                                List<ArtifactRepository> pluginRemoteRepositories,
                                List<ArtifactRepository> projectRemoteRepositories, String pluginName,
                                DependencyResolver dependencyResolver, boolean offline );  }
SurefireDependencyResolver { private ArtifactResolutionResult resolveArtifact( Artifact artifact, List<ArtifactRepository> repositories, ArtifactFilter filter ) { ArtifactResolutionRequest request = new ArtifactResolutionRequest() .setOffline( offline ) .setArtifact( artifact ) .setLocalRepository( localRepository ) .setResolveTransitively( true ) .setCollectionFilter( filter ) .setRemoteRepositories( repositories ); return repositorySystem.resolve( request ); } SurefireDependencyResolver( RepositorySystem repositorySystem, ConsoleLogger log,
                                ArtifactRepository localRepository,
                                List<ArtifactRepository> pluginRemoteRepositories,
                                List<ArtifactRepository> projectRemoteRepositories, String pluginName,
                                DependencyResolver dependencyResolver, boolean offline );   }