### Question:
MavenContentHelper { public String getArtifactVersion( StorageAsset artifactDir, ItemSelector selector) { if (selector.hasArtifactVersion()) { return selector.getArtifactVersion(); } else if (selector.hasVersion()) { if ( VersionUtil.isGenericSnapshot( selector.getVersion() ) ) { return getLatestArtifactSnapshotVersion( artifactDir, selector.getVersion( ) ); } else { return selector.getVersion( ); } } else { throw new IllegalArgumentException( "No version set on the selector " ); } } MavenContentHelper(); void setMetadataReader( MavenMetadataReader metadataReader ); static String getNamespaceFromNamespacePath( final StorageAsset namespacePath); String getArtifactVersion( StorageAsset artifactDir, ItemSelector selector); String getLatestArtifactSnapshotVersion( StorageAsset artifactDir, String snapshotVersion); static final Pattern UNIQUE_SNAPSHOT_NUMBER_PATTERN; static final String METADATA_FILENAME; static final String METADATA_REPOSITORY_FILENAME; }### Answer:
@Test void getArtifactVersion( ) throws IOException, URISyntaxException { MavenContentHelper mavenContentHelper = new MavenContentHelper( ); MavenMetadataReader reader = new MavenMetadataReader( ); mavenContentHelper.setMetadataReader( reader ); Path testRepoPath = Paths.get( Thread.currentThread( ).getContextClassLoader( ).getResource( "repositories/metadata-repository" ).toURI() ); FilesystemStorage storage = new FilesystemStorage( testRepoPath, new DefaultFileLockManager( ) ); assertArtifactVersion( mavenContentHelper, "1.0-alpha-11-SNAPSHOT", storage.getAsset( "org/apache/archiva/metadata/tests/snap_shots_1/1.0-alpha-11-SNAPSHOT" ) , "1.0-alpha-11-SNAPSHOT", "1.0-alpha-11-SNAPSHOT"); assertArtifactVersion( mavenContentHelper, "1.0-alpha-11-20070316.175232-11", storage.getAsset( "org/apache/archiva/metadata/tests/snap_shots_a/1.0-alpha-11-SNAPSHOT" ) , "", "1.0-alpha-11-SNAPSHOT"); assertArtifactVersion( mavenContentHelper, "2.2-20070316.153953-10", storage.getAsset( "org/apache/archiva/metadata/tests/snap_shots_b/2.2-SNAPSHOT" ) , "", "2.2-SNAPSHOT"); }