]> source.dussan.org Git - archiva.git/blob
7c224cf995bcd2c905201484c8af0156efc70a10
[archiva.git] /
1 package org.apache.archiva.web.xmlrpc.services;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21
22
23 import org.apache.archiva.indexer.search.RepositorySearch;
24 import org.apache.archiva.indexer.search.SearchResultHit;
25 import org.apache.archiva.indexer.search.SearchResultLimits;
26 import org.apache.archiva.indexer.search.SearchResults;
27 import org.apache.archiva.indexer.util.SearchUtil;
28 import org.apache.archiva.metadata.model.ArtifactMetadata;
29 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
30 import org.apache.archiva.metadata.model.ProjectVersionReference;
31 import org.apache.archiva.metadata.repository.MetadataRepository;
32 import org.apache.archiva.metadata.repository.MetadataResolver;
33 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
34 import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
35 import org.apache.archiva.web.xmlrpc.api.SearchService;
36 import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
37 import org.apache.archiva.web.xmlrpc.api.beans.Dependency;
38 import org.apache.archiva.web.xmlrpc.security.XmlRpcUserRepositories;
39 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
40 import org.easymock.MockControl;
41 import org.easymock.classextension.MockClassControl;
42
43 import java.util.ArrayList;
44 import java.util.Arrays;
45 import java.util.Collections;
46 import java.util.Date;
47 import java.util.List;
48
49 /**
50  * SearchServiceImplTest
51  *
52  * @version $Id: SearchServiceImplTest.java
53  */
54 public class SearchServiceImplTest
55     extends PlexusInSpringTestCase
56 {
57     private SearchService searchService;
58
59     private MockControl userReposControl;
60
61     private XmlRpcUserRepositories userRepos;
62
63     private MockControl searchControl;
64
65     private RepositorySearch search;
66
67     private static final String ARCHIVA_TEST_ARTIFACT_ID = "archiva-xmlrpc-test";
68
69     private static final String ARCHIVA_TEST_GROUP_ID = "org.apache.archiva";
70
71     private MockControl metadataResolverControl;
72
73     private MetadataResolver metadataResolver;
74
75     private MockControl metadataRepositoryControl;
76
77     private MetadataRepository metadataRepository;
78
79     private static final String CHECKSUM = "a1b2c3aksjhdasfkdasasd";
80
81     private static final String TEST_REPO = "test-repo";
82
83     @Override
84     public void setUp()
85         throws Exception
86     {
87         userReposControl = MockClassControl.createControl( XmlRpcUserRepositories.class );
88         userRepos = (XmlRpcUserRepositories) userReposControl.getMock();
89
90         searchControl = MockControl.createControl( RepositorySearch.class );
91         searchControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
92         search = (RepositorySearch) searchControl.getMock();
93
94         metadataResolverControl = MockControl.createControl( MetadataResolver.class );
95         metadataResolver = (MetadataResolver) metadataResolverControl.getMock();
96
97         metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
98         metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
99
100         searchService = new SearchServiceImpl( userRepos, metadataResolver, metadataRepository, search );
101     }
102
103     // MRM-1230
104
105     public void testQuickSearchModelPackagingIsUsed()
106         throws Exception
107     {
108         List<String> observableRepoIds = new ArrayList<String>();
109         observableRepoIds.add( "repo1.mirror" );
110         observableRepoIds.add( "public.releases" );
111
112         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
113
114         SearchResults results = new SearchResults();
115         List<String> versions = new ArrayList<String>();
116         versions.add( "1.0" );
117
118         SearchResultHit resultHit = new SearchResultHit();
119         resultHit.setGroupId( ARCHIVA_TEST_GROUP_ID );
120         resultHit.setArtifactId( "archiva-webapp" );
121         resultHit.setVersions( versions );
122         resultHit.setRepositoryId( null );
123
124         results.addHit( SearchUtil.getHitId( ARCHIVA_TEST_GROUP_ID, "archiva-webapp" ), resultHit );
125
126         SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
127
128         searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
129                                               results );
130
131         ProjectVersionMetadata model = new ProjectVersionMetadata();
132         model.setId( "1.0" );
133         MavenProjectFacet facet = new MavenProjectFacet();
134         facet.setPackaging( "war" );
135         model.addFacet( facet );
136
137         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror",
138                                                                                          ARCHIVA_TEST_GROUP_ID,
139                                                                                          "archiva-webapp", "1.0" ),
140                                                  model );
141
142         userReposControl.replay();
143         searchControl.replay();
144         metadataResolverControl.replay();
145         metadataRepositoryControl.replay();
146
147         List<Artifact> artifacts = searchService.quickSearch( "archiva" );
148
149         userReposControl.verify();
150         searchControl.verify();
151         metadataResolverControl.verify();
152         metadataRepositoryControl.verify();
153
154         assertNotNull( artifacts );
155         assertEquals( 1, artifacts.size() );
156
157         Artifact artifact = artifacts.get( 0 );
158         assertEquals( ARCHIVA_TEST_GROUP_ID, artifact.getGroupId() );
159         assertEquals( "archiva-webapp", artifact.getArtifactId() );
160         assertEquals( "1.0", artifact.getVersion() );
161         assertEquals( "war", artifact.getType() );
162         assertNotNull( "Repository should not be null!", artifact.getRepositoryId() );
163         assertEquals( "repo1.mirror", artifact.getRepositoryId() );
164     }
165
166     public void testQuickSearchDefaultPackagingIsUsed()
167         throws Exception
168     {
169         List<String> observableRepoIds = new ArrayList<String>();
170         observableRepoIds.add( "repo1.mirror" );
171         observableRepoIds.add( "public.releases" );
172
173         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
174
175         SearchResults results = new SearchResults();
176         List<String> versions = new ArrayList<String>();
177         versions.add( "1.0" );
178
179         SearchResultHit resultHit = new SearchResultHit();
180         resultHit.setRepositoryId( null );
181         resultHit.setGroupId( ARCHIVA_TEST_GROUP_ID );
182         resultHit.setArtifactId( ARCHIVA_TEST_ARTIFACT_ID );
183         resultHit.setVersions( versions );
184
185         results.addHit( SearchUtil.getHitId( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID ), resultHit );
186
187         SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
188
189         searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
190                                               results );
191
192         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror",
193                                                                                          ARCHIVA_TEST_GROUP_ID,
194                                                                                          ARCHIVA_TEST_ARTIFACT_ID,
195                                                                                          "1.0" ), null );
196
197         ProjectVersionMetadata model = new ProjectVersionMetadata();
198         model.setId( "1.0" );
199         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "public.releases",
200                                                                                          ARCHIVA_TEST_GROUP_ID,
201                                                                                          ARCHIVA_TEST_ARTIFACT_ID,
202                                                                                          "1.0" ), model );
203
204         userReposControl.replay();
205         searchControl.replay();
206         metadataResolverControl.replay();
207         metadataRepositoryControl.replay();
208
209         List<Artifact> artifacts = searchService.quickSearch( "archiva" );
210
211         userReposControl.verify();
212         searchControl.verify();
213         metadataResolverControl.verify();
214         metadataRepositoryControl.verify();
215
216         assertNotNull( artifacts );
217         assertEquals( 1, artifacts.size() );
218
219         Artifact artifact = artifacts.get( 0 );
220         assertEquals( ARCHIVA_TEST_GROUP_ID, artifact.getGroupId() );
221         assertEquals( ARCHIVA_TEST_ARTIFACT_ID, artifact.getArtifactId() );
222         assertEquals( "1.0", artifact.getVersion() );
223         assertEquals( "jar", artifact.getType() );
224         assertEquals( "public.releases", artifact.getRepositoryId() );
225     }
226
227     public void testQuickSearchArtifactRegularSearch()
228         throws Exception
229     {
230         List<String> observableRepoIds = new ArrayList<String>();
231         observableRepoIds.add( "repo1.mirror" );
232         observableRepoIds.add( "public.releases" );
233
234         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
235
236         SearchResults results = new SearchResults();
237         List<String> versions = new ArrayList<String>();
238         versions.add( "1.0" );
239
240         SearchResultHit resultHit = new SearchResultHit();
241         resultHit.setGroupId( ARCHIVA_TEST_GROUP_ID );
242         resultHit.setArtifactId( ARCHIVA_TEST_ARTIFACT_ID );
243         resultHit.setVersions( versions );
244         resultHit.setRepositoryId( null );
245
246         results.addHit( SearchUtil.getHitId( resultHit.getGroupId(), resultHit.getArtifactId() ), resultHit );
247
248         SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
249
250         searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
251                                               results );
252
253         ProjectVersionMetadata model = new ProjectVersionMetadata();
254         model.setId( "1.0" );
255         MavenProjectFacet facet = new MavenProjectFacet();
256         facet.setPackaging( "jar" );
257         model.addFacet( facet );
258
259         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror",
260                                                                                          ARCHIVA_TEST_GROUP_ID,
261                                                                                          ARCHIVA_TEST_ARTIFACT_ID,
262                                                                                          "1.0" ), model );
263
264         userReposControl.replay();
265         searchControl.replay();
266         metadataRepositoryControl.replay();
267         metadataResolverControl.replay();
268
269         List<Artifact> artifacts = searchService.quickSearch( "archiva" );
270
271         userReposControl.verify();
272         searchControl.verify();
273         metadataRepositoryControl.verify();
274         metadataResolverControl.verify();
275
276         assertNotNull( artifacts );
277         assertEquals( 1, artifacts.size() );
278
279         Artifact artifact = artifacts.get( 0 );
280         assertEquals( ARCHIVA_TEST_GROUP_ID, artifact.getGroupId() );
281         assertEquals( ARCHIVA_TEST_ARTIFACT_ID, artifact.getArtifactId() );
282         assertEquals( "1.0", artifact.getVersion() );
283         assertEquals( "jar", artifact.getType() );
284         assertNotNull( "Repository should not be null!", artifact.getRepositoryId() );
285         assertEquals( "repo1.mirror", artifact.getRepositoryId() );
286     }
287
288     public void testQuickSearchNoResults()
289         throws Exception
290     {
291         List<String> observableRepoIds = new ArrayList<String>();
292         observableRepoIds.add( "repo1.mirror" );
293         observableRepoIds.add( "public.releases" );
294
295         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
296
297         SearchResults results = new SearchResults();
298         SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
299
300         searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "non-existent", limits, null ),
301                                               results );
302         userReposControl.replay();
303         searchControl.replay();
304
305         List<Artifact> artifacts = searchService.quickSearch( "test" );
306
307         userReposControl.verify();
308         searchControl.verify();
309
310         assertNotNull( artifacts );
311         assertEquals( 0, artifacts.size() );
312     }
313
314     public void testGetArtifactByChecksum()
315         throws Exception
316     {
317         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList(
318             TEST_REPO ) );
319
320         Date whenGathered = new Date();
321
322         ArtifactMetadata artifact = createArtifact( whenGathered );
323         metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifactsByChecksum( TEST_REPO, CHECKSUM ),
324                                                    Collections.singletonList( artifact ) );
325
326         metadataRepositoryControl.replay();
327         userReposControl.replay();
328
329         List<Artifact> results = searchService.getArtifactByChecksum( CHECKSUM );
330
331         metadataRepositoryControl.verify();
332         userReposControl.verify();
333
334         assertNotNull( results );
335         assertEquals( 1, results.size() );
336         Artifact result = results.get( 0 );
337         assertEquals( ARCHIVA_TEST_GROUP_ID, result.getGroupId() );
338         assertEquals( ARCHIVA_TEST_ARTIFACT_ID, result.getArtifactId() );
339         assertEquals( "1.0", result.getVersion() );
340         assertEquals( "jar", result.getType() );
341         assertEquals( TEST_REPO, result.getRepositoryId() );
342     }
343
344     public void testGetArtifactVersionsArtifactExists()
345         throws Exception
346     {
347         List<String> observableRepoIds = new ArrayList<String>();
348         observableRepoIds.add( "repo1.mirror" );
349         observableRepoIds.add( "public.releases" );
350
351         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
352         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersions( "repo1.mirror",
353                                                                                           ARCHIVA_TEST_GROUP_ID,
354                                                                                           ARCHIVA_TEST_ARTIFACT_ID ),
355                                                  Arrays.asList( "1.0", "1.1-beta-2", "1.2" ) );
356         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersions( "public.releases",
357                                                                                           ARCHIVA_TEST_GROUP_ID,
358                                                                                           ARCHIVA_TEST_ARTIFACT_ID ),
359                                                  Arrays.asList( "1.1-beta-1", "1.1", "1.2.1-SNAPSHOT" ) );
360
361         userReposControl.replay();
362         metadataResolverControl.replay();
363
364         List<Artifact> artifacts = searchService.getArtifactVersions( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID );
365
366         userReposControl.verify();
367         metadataResolverControl.verify();
368
369         assertNotNull( artifacts );
370         assertEquals( 6, artifacts.size() );
371         assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0", "pom" ),
372                       artifacts.get( 0 ) );
373         assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-1",
374                                     "pom" ), artifacts.get( 3 ) );
375         assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-2",
376                                     "pom" ), artifacts.get( 1 ) );
377         assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1", "pom" ),
378                       artifacts.get( 4 ) );
379         assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.2", "pom" ),
380                       artifacts.get( 2 ) );
381         assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID,
382                                     "1.2.1-SNAPSHOT", "pom" ), artifacts.get( 5 ) );
383     }
384
385     public void testGetArtifactVersionsByDateArtifactExists()
386         throws Exception
387     {
388         // TODO
389     }
390
391     public void testGetArtifactVersionsByDateArtifactDoesNotExist()
392         throws Exception
393     {
394         // TODO
395     }
396
397     public void testGetDependenciesArtifactExists()
398         throws Exception
399     {
400         String repoId = "repo1.mirror";
401
402         ProjectVersionMetadata model = new ProjectVersionMetadata();
403         model.setId( "1.0" );
404
405         org.apache.archiva.metadata.model.Dependency dependency = new org.apache.archiva.metadata.model.Dependency();
406         dependency.setGroupId( "org.apache.commons" );
407         dependency.setArtifactId( "commons-logging" );
408         dependency.setVersion( "2.0" );
409
410         model.addDependency( dependency );
411
412         dependency = new org.apache.archiva.metadata.model.Dependency();
413         dependency.setGroupId( "junit" );
414         dependency.setArtifactId( "junit" );
415         dependency.setVersion( "2.4" );
416         dependency.setScope( "test" );
417
418         model.addDependency( dependency );
419
420         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( repoId ) );
421         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID,
422                                                                                          ARCHIVA_TEST_ARTIFACT_ID,
423                                                                                          "1.0" ), model );
424
425         metadataResolverControl.replay();
426         userReposControl.replay();
427
428         List<Dependency> dependencies = searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID,
429                                                                        "1.0" );
430
431         metadataResolverControl.verify();
432         userReposControl.verify();
433
434         assertNotNull( dependencies );
435         assertEquals( 2, dependencies.size() );
436         assertEquals( new Dependency( "org.apache.commons", "commons-logging", "2.0", null, null, null ),
437                       dependencies.get( 0 ) );
438         assertEquals( new Dependency( "junit", "junit", "2.4", null, null, "test" ), dependencies.get( 1 ) );
439     }
440
441     public void testGetDependenciesArtifactDoesNotExist()
442         throws Exception
443     {
444         String repoId = "repo1.mirror";
445
446         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( repoId ) );
447         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID,
448                                                                                          ARCHIVA_TEST_ARTIFACT_ID,
449                                                                                          "1.0" ), null );
450
451         userReposControl.replay();
452         metadataResolverControl.replay();
453
454         try
455         {
456             searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" );
457             fail( "An exception should have been thrown." );
458         }
459         catch ( Exception e )
460         {
461             assertEquals( "Artifact does not exist.", e.getMessage() );
462         }
463
464         userReposControl.verify();
465         metadataResolverControl.verify();
466     }
467
468     public void testGetDependencyTreeArtifactExists()
469         throws Exception
470     {
471         // TODO
472     }
473
474     public void testGetDependencyTreeArtifactDoesNotExist()
475         throws Exception
476     {
477         // TODO
478     }
479
480     public void testGetDependees()
481         throws Exception
482     {
483         List<String> observableRepoIds = new ArrayList<String>();
484         String repoId = "repo1.mirror";
485         observableRepoIds.add( repoId );
486
487         List<ProjectVersionReference> dependeeModels = new ArrayList<ProjectVersionReference>();
488         ProjectVersionReference dependeeModel = new ProjectVersionReference();
489         dependeeModel.setNamespace( ARCHIVA_TEST_GROUP_ID );
490         dependeeModel.setProjectId( "archiva-dependee-one" );
491         dependeeModel.setProjectVersion( "1.0" );
492         dependeeModels.add( dependeeModel );
493
494         dependeeModel = new ProjectVersionReference();
495         dependeeModel.setNamespace( ARCHIVA_TEST_GROUP_ID );
496         dependeeModel.setProjectId( "archiva-dependee-two" );
497         dependeeModel.setProjectVersion( "1.0" );
498         dependeeModels.add( dependeeModel );
499
500         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
501         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( repoId,
502                                                                                             ARCHIVA_TEST_GROUP_ID,
503                                                                                             ARCHIVA_TEST_ARTIFACT_ID,
504                                                                                             "1.0" ), dependeeModels );
505
506         metadataResolverControl.replay();
507         userReposControl.replay();
508
509         List<Artifact> dependees = searchService.getDependees( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" );
510
511         metadataResolverControl.verify();
512         userReposControl.verify();
513
514         assertNotNull( dependees );
515         assertEquals( 2, dependees.size() );
516         assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-one", "1.0", "" ), dependees.get(
517             0 ) );
518         assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-two", "1.0", "" ), dependees.get(
519             1 ) );
520     }
521
522     public void testGetDependeesArtifactDoesNotExist()
523         throws Exception
524     {
525         List<String> observableRepoIds = new ArrayList<String>();
526         observableRepoIds.add( "repo1.mirror" );
527         observableRepoIds.add( "public.releases" );
528
529         // no longer differentiating between a project not being present and a project that is present but with
530         // no references. If it is later determined to be needed, we will need to modify the metadata content repository
531         userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
532         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( "repo1.mirror",
533                                                                                             ARCHIVA_TEST_GROUP_ID,
534                                                                                             ARCHIVA_TEST_ARTIFACT_ID,
535                                                                                             "1.0" ),
536                                                  Collections.<ProjectVersionReference>emptyList() );
537         metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( "public.releases",
538                                                                                             ARCHIVA_TEST_GROUP_ID,
539                                                                                             ARCHIVA_TEST_ARTIFACT_ID,
540                                                                                             "1.0" ),
541                                                  Collections.<ProjectVersionReference>emptyList() );
542
543         userReposControl.replay();
544         metadataResolverControl.replay();
545
546         assertTrue( searchService.getDependees( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ).isEmpty() );
547     }
548
549     private ArtifactMetadata createArtifact( Date whenGathered )
550     {
551         String version = "1.0";
552         ArtifactMetadata artifactMetadata = new ArtifactMetadata();
553         artifactMetadata.setVersion( version );
554         artifactMetadata.setProjectVersion( version );
555         artifactMetadata.setId( ARCHIVA_TEST_ARTIFACT_ID + "-" + version + ".jar" );
556         artifactMetadata.setProject( ARCHIVA_TEST_ARTIFACT_ID );
557         artifactMetadata.setNamespace( ARCHIVA_TEST_GROUP_ID );
558         artifactMetadata.setMd5( CHECKSUM );
559         artifactMetadata.setWhenGathered( whenGathered );
560         artifactMetadata.setRepositoryId( TEST_REPO );
561
562         MavenArtifactFacet facet = new MavenArtifactFacet();
563         facet.setType( "jar" );
564         artifactMetadata.addFacet( facet );
565
566         return artifactMetadata;
567     }
568 }