1 package org.apache.maven.artifact;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Map;
25
26 import org.apache.maven.artifact.versioning.VersionRange;
27
28 import junit.framework.TestCase;
29
30
31
32
33
34
35
36 public class ArtifactUtilsTest
37 extends TestCase
38 {
39
40
41
42
43 public void testArtifactMapByArtifactIdOrdering()
44 throws Exception
45 {
46 List list = new ArrayList();
47 list.add( newArtifact( "b" ) );
48 list.add( newArtifact( "a" ) );
49 list.add( newArtifact( "c" ) );
50 list.add( newArtifact( "e" ) );
51 list.add( newArtifact( "d" ) );
52
53 Map map = ArtifactUtils.artifactMapByArtifactId( list );
54 assertNotNull( map );
55 assertEquals( list, new ArrayList( map.values() ) );
56 }
57
58
59
60
61 public void testArtifactMapByVersionlessIdOrdering()
62 throws Exception
63 {
64 List list = new ArrayList();
65 list.add( newArtifact( "b" ) );
66 list.add( newArtifact( "a" ) );
67 list.add( newArtifact( "c" ) );
68 list.add( newArtifact( "e" ) );
69 list.add( newArtifact( "d" ) );
70
71 Map map = ArtifactUtils.artifactMapByVersionlessId( list );
72 assertNotNull( map );
73 assertEquals( list, new ArrayList( map.values() ) );
74 }
75
76 private Artifact newArtifact( String aid )
77 {
78 return new DefaultArtifact( "org.apache.maven.ut", aid, VersionRange.createFromVersion( "1.0" ), "test", "jar",
79 "tests", null );
80 }
81
82 }