@Test public void testRepositoryEventsUnsuccessfulRemote() throws IOException, ArtifactResolutionException { RecordingRepositoryConnector connector = new RecordingRepositoryConnector() { @Override public void get( Collection<? extends ArtifactDownload> artifactDownloads, Collection<? extends MetadataDownload> metadataDownloads ) { super.get( artifactDownloads, metadataDownloads ); ArtifactDownload download = artifactDownloads.iterator().next(); ArtifactTransferException exception = new ArtifactNotFoundException( download.getArtifact(), null, "not found" ); download.setException( exception ); } }; repositoryConnectorProvider.setConnector( connector ); RecordingRepositoryListener listener = new RecordingRepositoryListener(); session.setRepositoryListener( listener ); ArtifactRequest request = new ArtifactRequest( artifact, null, "" ); request.addRepository( new RemoteRepository.Builder( "id", "default", "file: try { resolver.resolveArtifact( session, request ); fail( "expected exception" ); } catch ( ArtifactResolutionException e ) { } List<RepositoryEvent> events = listener.getEvents(); assertEquals( events.toString(), 4, events.size() ); RepositoryEvent event = events.get( 0 ); assertEquals( artifact, event.getArtifact() ); assertEquals( EventType.ARTIFACT_RESOLVING, event.getType() ); event = events.get( 1 ); assertEquals( artifact, event.getArtifact() ); assertEquals( EventType.ARTIFACT_DOWNLOADING, event.getType() ); event = events.get( 2 ); assertEquals( artifact, event.getArtifact() ); assertEquals( EventType.ARTIFACT_DOWNLOADED, event.getType() ); assertNotNull( event.getException() ); assertEquals( 1, event.getExceptions().size() ); event = events.get( 3 ); assertEquals( artifact, event.getArtifact() ); assertEquals( EventType.ARTIFACT_RESOLVED, event.getType() ); assertNotNull( event.getException() ); assertEquals( 1, event.getExceptions().size() ); }
public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ) throws ArtifactResolutionException { return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 ); }
DefaultArtifactResolver implements ArtifactResolver, Service { public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ) throws ArtifactResolutionException { return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 ); } }
DefaultArtifactResolver implements ArtifactResolver, Service { public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ) throws ArtifactResolutionException { return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 ); } DefaultArtifactResolver(); @Inject  DefaultArtifactResolver( FileProcessor fileProcessor, RepositoryEventDispatcher repositoryEventDispatcher,
                             VersionResolver versionResolver, UpdateCheckManager updateCheckManager,
                             RepositoryConnectorProvider repositoryConnectorProvider,
                             RemoteRepositoryManager remoteRepositoryManager, SyncContextFactory syncContextFactory,
                             OfflineController offlineController, LoggerFactory loggerFactory ); }
DefaultArtifactResolver implements ArtifactResolver, Service { public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ) throws ArtifactResolutionException { return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 ); } DefaultArtifactResolver(); @Inject  DefaultArtifactResolver( FileProcessor fileProcessor, RepositoryEventDispatcher repositoryEventDispatcher,
                             VersionResolver versionResolver, UpdateCheckManager updateCheckManager,
                             RepositoryConnectorProvider repositoryConnectorProvider,
                             RemoteRepositoryManager remoteRepositoryManager, SyncContextFactory syncContextFactory,
                             OfflineController offlineController, LoggerFactory loggerFactory ); void initService( ServiceLocator locator ); DefaultArtifactResolver setLoggerFactory( LoggerFactory loggerFactory ); DefaultArtifactResolver setFileProcessor( FileProcessor fileProcessor ); DefaultArtifactResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ); DefaultArtifactResolver setVersionResolver( VersionResolver versionResolver ); DefaultArtifactResolver setUpdateCheckManager( UpdateCheckManager updateCheckManager ); DefaultArtifactResolver setRepositoryConnectorProvider( RepositoryConnectorProvider repositoryConnectorProvider ); DefaultArtifactResolver setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ); DefaultArtifactResolver setSyncContextFactory( SyncContextFactory syncContextFactory ); DefaultArtifactResolver setOfflineController( OfflineController offlineController ); ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ); List<ArtifactResult> resolveArtifacts( RepositorySystemSession session,
                                                  Collection<? extends ArtifactRequest> requests ); }
DefaultArtifactResolver implements ArtifactResolver, Service { public ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ) throws ArtifactResolutionException { return resolveArtifacts( session, Collections.singleton( request ) ).get( 0 ); } DefaultArtifactResolver(); @Inject  DefaultArtifactResolver( FileProcessor fileProcessor, RepositoryEventDispatcher repositoryEventDispatcher,
                             VersionResolver versionResolver, UpdateCheckManager updateCheckManager,
                             RepositoryConnectorProvider repositoryConnectorProvider,
                             RemoteRepositoryManager remoteRepositoryManager, SyncContextFactory syncContextFactory,
                             OfflineController offlineController, LoggerFactory loggerFactory ); void initService( ServiceLocator locator ); DefaultArtifactResolver setLoggerFactory( LoggerFactory loggerFactory ); DefaultArtifactResolver setFileProcessor( FileProcessor fileProcessor ); DefaultArtifactResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ); DefaultArtifactResolver setVersionResolver( VersionResolver versionResolver ); DefaultArtifactResolver setUpdateCheckManager( UpdateCheckManager updateCheckManager ); DefaultArtifactResolver setRepositoryConnectorProvider( RepositoryConnectorProvider repositoryConnectorProvider ); DefaultArtifactResolver setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ); DefaultArtifactResolver setSyncContextFactory( SyncContextFactory syncContextFactory ); DefaultArtifactResolver setOfflineController( OfflineController offlineController ); ArtifactResult resolveArtifact( RepositorySystemSession session, ArtifactRequest request ); List<ArtifactResult> resolveArtifacts( RepositorySystemSession session,
                                                  Collection<? extends ArtifactRequest> requests );  }