### Question:
MetadataResolver { public ArtifactMetadata resolveArtifactMetadata( Artifact artifact ) { initArtifactMap(); return artifactMap.get( artifact ); } MetadataResolver( List<String> metadataLocations ); ArtifactMetadata resolveArtifactMetadata( Artifact artifact ); synchronized void invalidateMappings();  }### Answer:
@Test public void testCompatExactVersion() throws Exception { List<String> pathList = Collections.singletonList( "src/test/resources/metadata1.xml" ); MetadataResolver resolver = new MetadataResolver( pathList ); Artifact artifact = new DefaultArtifact( "gid", "aid", "ext", "cla", "1.2-beta3" ); ArtifactMetadata am = resolver.resolveArtifactMetadata( artifact ); assertNotNull( am ); assertEquals( "/foo/bar", am.getPath() ); }
@Test public void testCompatNonExactVersion() throws Exception { List<String> pathList = Collections.singletonList( "src/test/resources/metadata1.xml" ); MetadataResolver resolver = new MetadataResolver( pathList ); Artifact artifact = new DefaultArtifact( "gid", "aid", "ext", "cla", "1.1" ); ArtifactMetadata am = resolver.resolveArtifactMetadata( artifact ); assertNull( am ); }
@Test public void testNonCompatExactVersion() throws Exception { List<String> pathList = Collections.singletonList( "src/test/resources/metadata1-non-compat.xml" ); MetadataResolver resolver = new MetadataResolver( pathList ); Artifact artifact = new DefaultArtifact( "gid", "aid", "ext", "cla", Artifact.DEFAULT_VERSION ); ArtifactMetadata am = resolver.resolveArtifactMetadata( artifact ); assertNotNull( am ); assertEquals( "/foo/bar", am.getPath() ); }
@Test public void testNonCompatNonExactVersion() throws Exception { List<String> pathList = Collections.singletonList( "src/test/resources/metadata1-non-compat.xml" ); MetadataResolver resolver = new MetadataResolver( pathList ); Artifact artifact = new DefaultArtifact( "gid", "aid", "ext", "cla", "1.1" ); ArtifactMetadata am = resolver.resolveArtifactMetadata( artifact ); assertNull( am ); }