CentralRepositoryService implements RepositoryService { @SuppressWarnings( "unchecked" ) public List<String> getAvailableVersions( String groupId, String artifactId ) throws RepositoryException { Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, "1.0" ); List<ArtifactVersion> versions = null; try { versions = metadataSource.retrieveAvailableVersions( artifact, localRepository, Collections.singletonList( repository ) ); } catch ( ArtifactMetadataRetrievalException e ) { throw new RepositoryException( e.getMessage(), e ); } Collections.sort( versions ); List<String> availableVersions = new ArrayList<String>( versions.size() ); for ( ArtifactVersion version : versions ) { availableVersions.add( version.toString() ); } return availableVersions; } @Inject private  CentralRepositoryService( RepositoryParams params ); @SuppressWarnings( "unchecked" ) List<String> getAvailableVersions( String groupId, String artifactId ); Project retrieveProject( String groupId, String artifactId, String version );  }
@Test public void getAvailableVersions() throws RepositoryException { List<String> versions = repositoryService.getAvailableVersions( "com.effectivemaven.test", "artifact" ); assert Arrays.asList( "1.0", "1.2" ).equals( versions ); }
@Test public void getAvailableVersionsNoMetadata() throws RepositoryException { List<String> versions = repositoryService.getAvailableVersions( "com.effectivemaven.test", "parent" ); assert Collections.emptyList().equals( versions ); }