]> source.dussan.org Git - archiva.git/blob
8c39e402be18ab744c275c5eaf0f37a66b1c9491
[archiva.git] /
1 package org.apache.archiva.metadata.repository.stats;
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 import junit.framework.TestCase;
23 import org.apache.archiva.metadata.model.ArtifactMetadata;
24 import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet;
25 import org.apache.archiva.metadata.repository.MetadataRepository;
26 import org.easymock.MockControl;
27
28 import java.text.SimpleDateFormat;
29 import java.util.ArrayList;
30 import java.util.Arrays;
31 import java.util.Collections;
32 import java.util.Date;
33 import java.util.LinkedHashMap;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.TimeZone;
37 import javax.jcr.Session;
38 import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
39 import org.junit.Before;
40 import org.junit.Test;
41 import org.junit.runner.RunWith;
42
43 @RunWith( ArchivaBlockJUnit4ClassRunner.class )
44 public class RepositoryStatisticsManagerTest
45     extends TestCase
46 {
47     private DefaultRepositoryStatisticsManager repositoryStatisticsManager;
48
49     private static final String TEST_REPO_ID = "test-repo";
50
51     private MockControl metadataRepositoryControl;
52
53     private MetadataRepository metadataRepository;
54
55     private static final String FIRST_TEST_SCAN = "2009/12/01/123456.789";
56
57     private static final String SECOND_TEST_SCAN = "2009/12/02/012345.678";
58
59     private Map<String, RepositoryStatistics> statsCreated = new LinkedHashMap<String, RepositoryStatistics>();
60
61     private static final SimpleDateFormat TIMESTAMP_FORMAT = createTimestampFormat();
62
63     private static SimpleDateFormat createTimestampFormat()
64     {
65         SimpleDateFormat fmt = new SimpleDateFormat( RepositoryStatistics.SCAN_TIMESTAMP_FORMAT );
66         fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
67         return fmt;
68     }
69
70     @Override
71     @Before
72     public void setUp()
73         throws Exception
74     {
75         super.setUp();
76
77         repositoryStatisticsManager = new DefaultRepositoryStatisticsManager();
78
79         metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
80         metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
81     }
82
83     @Test
84     public void testGetLatestStats()
85         throws Exception
86     {
87         Date startTime = TIMESTAMP_FORMAT.parse( SECOND_TEST_SCAN );
88         Date endTime = new Date( startTime.getTime() + 60000 );
89
90         RepositoryStatistics stats = new RepositoryStatistics();
91         stats.setScanStartTime( startTime );
92         stats.setScanEndTime( endTime );
93         stats.setTotalArtifactFileSize( 1314527915L );
94         stats.setNewFileCount( 123 );
95         stats.setTotalArtifactCount( 10386 );
96         stats.setTotalProjectCount( 2031 );
97         stats.setTotalGroupCount( 529 );
98         stats.setTotalFileCount( 56229 );
99
100         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
101                                                                                          RepositoryStatistics.FACET_ID ),
102                                                    Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) );
103         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
104                                                                                         RepositoryStatistics.FACET_ID,
105                                                                                         SECOND_TEST_SCAN ), stats );
106         metadataRepositoryControl.replay();
107
108         stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
109         assertNotNull( stats );
110         assertEquals( 1314527915L, stats.getTotalArtifactFileSize() );
111         assertEquals( 123, stats.getNewFileCount() );
112         assertEquals( 10386, stats.getTotalArtifactCount() );
113         assertEquals( 2031, stats.getTotalProjectCount() );
114         assertEquals( 529, stats.getTotalGroupCount() );
115         assertEquals( 56229, stats.getTotalFileCount() );
116         assertEquals( SECOND_TEST_SCAN, TIMESTAMP_FORMAT.format( stats.getScanStartTime() ) );
117         assertEquals( SECOND_TEST_SCAN, stats.getName() );
118         assertEquals( endTime, stats.getScanEndTime() );
119
120         metadataRepositoryControl.verify();
121     }
122
123     @Test
124     public void testGetLatestStatsWhenEmpty()
125         throws Exception
126     {
127         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
128                                                                                          RepositoryStatistics.FACET_ID ),
129                                                    Collections.emptyList() );
130         metadataRepositoryControl.replay();
131
132         RepositoryStatistics stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
133         assertNull( stats );
134
135         metadataRepositoryControl.verify();
136     }
137
138     @Test
139     public void testAddNewStats()
140         throws Exception
141     {
142         Date current = new Date();
143         Date startTime = new Date( current.getTime() - 12345 );
144
145         RepositoryStatistics stats = createTestStats( startTime, current );
146
147         walkRepository( 1 );
148
149         metadataRepository.addMetadataFacet( TEST_REPO_ID, stats );
150         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
151                                                                                          RepositoryStatistics.FACET_ID ),
152                                                    Arrays.asList( stats.getName() ) );
153         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
154                                                                                         RepositoryStatistics.FACET_ID,
155                                                                                         stats.getName() ), stats );
156         metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false );
157
158         metadataRepositoryControl.replay();
159
160         repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime, current, 56345,
161                                                             45 );
162
163         stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
164         assertNotNull( stats );
165         assertEquals( 246900, stats.getTotalArtifactFileSize() );
166         assertEquals( 45, stats.getNewFileCount() );
167         assertEquals( 20, stats.getTotalArtifactCount() );
168         assertEquals( 5, stats.getTotalProjectCount() );
169         assertEquals( 4, stats.getTotalGroupCount() );
170         assertEquals( 56345, stats.getTotalFileCount() );
171         assertEquals( current.getTime() - 12345, stats.getScanStartTime().getTime() );
172         assertEquals( current, stats.getScanEndTime() );
173
174         metadataRepositoryControl.verify();
175     }
176
177     @Test
178     public void testDeleteStats()
179         throws Exception
180     {
181         walkRepository( 2 );
182
183         Date current = new Date();
184
185         Date startTime1 = new Date( current.getTime() - 12345 );
186         RepositoryStatistics stats1 = createTestStats( startTime1, new Date( current.getTime() - 6000 ) );
187         metadataRepository.addMetadataFacet( TEST_REPO_ID, stats1 );
188
189         Date startTime2 = new Date( current.getTime() - 3000 );
190         RepositoryStatistics stats2 = createTestStats( startTime2, current );
191         metadataRepository.addMetadataFacet( TEST_REPO_ID, stats2 );
192
193         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
194                                                                                          RepositoryStatistics.FACET_ID ),
195                                                    Arrays.asList( stats1.getName(), stats2.getName() ) );
196         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
197                                                                                         RepositoryStatistics.FACET_ID,
198                                                                                         stats2.getName() ), stats2 );
199
200         metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID );
201
202         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
203                                                                                          RepositoryStatistics.FACET_ID ),
204                                                    Collections.emptyList() );
205         metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 2 );
206
207         metadataRepositoryControl.replay();
208
209         repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime1,
210                                                             stats1.getScanEndTime(), 56345, 45 );
211         repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime2,
212                                                             stats2.getScanEndTime(), 56345, 45 );
213
214         assertNotNull( repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ) );
215
216         repositoryStatisticsManager.deleteStatistics( metadataRepository, TEST_REPO_ID );
217
218         assertNull( repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ) );
219
220         metadataRepositoryControl.verify();
221     }
222
223     @Test
224     public void testDeleteStatsWhenEmpty()
225         throws Exception
226     {
227         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
228                                                                                          RepositoryStatistics.FACET_ID ),
229                                                    Collections.emptyList(), 2 );
230         metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID );
231
232         metadataRepositoryControl.replay();
233
234         assertNull( repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ) );
235
236         repositoryStatisticsManager.deleteStatistics( metadataRepository, TEST_REPO_ID );
237
238         assertNull( repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ) );
239
240         metadataRepositoryControl.verify();
241     }
242
243     @Test
244     public void testGetStatsRangeInside()
245         throws Exception
246     {
247         walkRepository( 3 );
248
249         Date current = new Date();
250
251         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
252         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
253         addStats( new Date( current.getTime() - 1000 ), current );
254
255         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
256         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
257                                                                                          RepositoryStatistics.FACET_ID ),
258                                                    keys );
259
260         // only match the middle one
261         String key = keys.get( 1 );
262         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
263                                                                                         RepositoryStatistics.FACET_ID,
264                                                                                         key ), statsCreated.get(
265             key ) );
266         metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
267
268         metadataRepositoryControl.replay();
269
270         for ( RepositoryStatistics stats : statsCreated.values() )
271         {
272             repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID,
273                                                                 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
274                                                                 45 );
275         }
276
277         List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
278                                                                                             TEST_REPO_ID, new Date(
279                 current.getTime() - 4000 ), new Date( current.getTime() - 2000 ) );
280
281         assertEquals( 1, list.size() );
282         assertEquals( new Date( current.getTime() - 3000 ), list.get( 0 ).getScanStartTime() );
283
284         metadataRepositoryControl.verify();
285     }
286
287     @Test
288     public void testGetStatsRangeUpperOutside()
289         throws Exception
290     {
291         walkRepository( 3 );
292
293         Date current = new Date();
294
295         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
296         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
297         addStats( new Date( current.getTime() - 1000 ), current );
298
299         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
300         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
301                                                                                          RepositoryStatistics.FACET_ID ),
302                                                    keys );
303
304         String key = keys.get( 1 );
305         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
306                                                                                         RepositoryStatistics.FACET_ID,
307                                                                                         key ), statsCreated.get(
308             key ) );
309         key = keys.get( 2 );
310         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
311                                                                                         RepositoryStatistics.FACET_ID,
312                                                                                         key ), statsCreated.get(
313             key ) );
314         metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
315
316         metadataRepositoryControl.replay();
317
318         for ( RepositoryStatistics stats : statsCreated.values() )
319         {
320             repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID,
321                                                                 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
322                                                                 45 );
323         }
324
325         List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
326                                                                                             TEST_REPO_ID, new Date(
327                 current.getTime() - 4000 ), current );
328
329         assertEquals( 2, list.size() );
330         assertEquals( new Date( current.getTime() - 3000 ), list.get( 1 ).getScanStartTime() );
331         assertEquals( new Date( current.getTime() - 1000 ), list.get( 0 ).getScanStartTime() );
332
333         metadataRepositoryControl.verify();
334     }
335
336     @Test
337     public void testGetStatsRangeLowerOutside()
338         throws Exception
339     {
340         walkRepository( 3 );
341
342         Date current = new Date();
343
344         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
345         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
346         addStats( new Date( current.getTime() - 1000 ), current );
347
348         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
349         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
350                                                                                          RepositoryStatistics.FACET_ID ),
351                                                    keys );
352
353         String key = keys.get( 0 );
354         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
355                                                                                         RepositoryStatistics.FACET_ID,
356                                                                                         key ), statsCreated.get(
357             key ) );
358         key = keys.get( 1 );
359         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
360                                                                                         RepositoryStatistics.FACET_ID,
361                                                                                         key ), statsCreated.get(
362             key ) );
363         metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
364
365         metadataRepositoryControl.replay();
366
367         for ( RepositoryStatistics stats : statsCreated.values() )
368         {
369             repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID,
370                                                                 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
371                                                                 45 );
372         }
373
374         List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
375                                                                                             TEST_REPO_ID, new Date(
376                 current.getTime() - 20000 ), new Date( current.getTime() - 2000 ) );
377
378         assertEquals( 2, list.size() );
379         assertEquals( new Date( current.getTime() - 12345 ), list.get( 1 ).getScanStartTime() );
380         assertEquals( new Date( current.getTime() - 3000 ), list.get( 0 ).getScanStartTime() );
381
382         metadataRepositoryControl.verify();
383     }
384
385     @Test
386     public void testGetStatsRangeLowerAndUpperOutside()
387         throws Exception
388     {
389         walkRepository( 3 );
390
391         Date current = new Date();
392
393         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
394         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
395         addStats( new Date( current.getTime() - 1000 ), current );
396
397         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
398         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
399                                                                                          RepositoryStatistics.FACET_ID ),
400                                                    keys );
401
402         String key = keys.get( 0 );
403         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
404                                                                                         RepositoryStatistics.FACET_ID,
405                                                                                         key ), statsCreated.get(
406             key ) );
407         key = keys.get( 1 );
408         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
409                                                                                         RepositoryStatistics.FACET_ID,
410                                                                                         key ), statsCreated.get(
411             key ) );
412         key = keys.get( 2 );
413         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
414                                                                                         RepositoryStatistics.FACET_ID,
415                                                                                         key ), statsCreated.get(
416             key ) );
417         metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
418
419         metadataRepositoryControl.replay();
420
421         for ( RepositoryStatistics stats : statsCreated.values() )
422         {
423             repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID,
424                                                                 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
425                                                                 45 );
426         }
427
428         List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
429                                                                                             TEST_REPO_ID, new Date(
430                 current.getTime() - 20000 ), current );
431
432         assertEquals( 3, list.size() );
433         assertEquals( new Date( current.getTime() - 12345 ), list.get( 2 ).getScanStartTime() );
434         assertEquals( new Date( current.getTime() - 3000 ), list.get( 1 ).getScanStartTime() );
435         assertEquals( new Date( current.getTime() - 1000 ), list.get( 0 ).getScanStartTime() );
436
437         metadataRepositoryControl.verify();
438     }
439
440     @Test
441     public void testGetStatsRangeNotInside()
442         throws Exception
443     {
444         walkRepository( 3 );
445
446         Date current = new Date();
447
448         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
449         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
450         addStats( new Date( current.getTime() - 1000 ), current );
451
452         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
453         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
454                                                                                          RepositoryStatistics.FACET_ID ),
455                                                    keys );
456         metadataRepositoryControl.expectAndReturn( metadataRepository.canObtainAccess( Session.class ), false, 3 );
457
458         metadataRepositoryControl.replay();
459
460         for ( RepositoryStatistics stats : statsCreated.values() )
461         {
462             repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID,
463                                                                 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
464                                                                 45 );
465         }
466
467         List<RepositoryStatistics> list = repositoryStatisticsManager.getStatisticsInRange( metadataRepository,
468                                                                                             TEST_REPO_ID, new Date(
469                 current.getTime() - 20000 ), new Date( current.getTime() - 16000 ) );
470
471         assertEquals( 0, list.size() );
472
473         metadataRepositoryControl.verify();
474     }
475
476     private void addStats( Date startTime, Date endTime )
477         throws Exception
478     {
479         RepositoryStatistics stats = createTestStats( startTime, endTime );
480         metadataRepository.addMetadataFacet( TEST_REPO_ID, stats );
481         statsCreated.put( stats.getName(), stats );
482     }
483
484     private ArtifactMetadata createArtifact( String namespace, String projectId, String projectVersion, String type )
485     {
486         ArtifactMetadata metadata = new ArtifactMetadata();
487         metadata.setRepositoryId( TEST_REPO_ID );
488         metadata.setId( projectId + "-" + projectVersion + "." + type );
489         metadata.setProject( projectId );
490         metadata.setSize( 12345L );
491         metadata.setProjectVersion( projectVersion );
492         metadata.setVersion( projectVersion );
493         metadata.setNamespace( namespace );
494
495         MavenArtifactFacet facet = new MavenArtifactFacet();
496         facet.setType( type );
497         metadata.addFacet( facet );
498
499         return metadata;
500     }
501
502     private RepositoryStatistics createTestStats( Date startTime, Date endTime )
503     {
504         RepositoryStatistics stats = new RepositoryStatistics();
505         stats.setRepositoryId( TEST_REPO_ID );
506         stats.setScanStartTime( startTime );
507         stats.setScanEndTime( endTime );
508         stats.setTotalArtifactFileSize( 20 * 12345L );
509         stats.setNewFileCount( 45 );
510         stats.setTotalArtifactCount( 20 );
511         stats.setTotalProjectCount( 5 );
512         stats.setTotalGroupCount( 4 );
513         stats.setTotalFileCount( 56345 );
514         stats.setTotalCountForType( "jar", 10 );
515         stats.setTotalCountForType( "pom", 10 );
516         return stats;
517     }
518
519     private void walkRepository( int count )
520         throws Exception
521     {
522         for ( int i = 0; i < count; i++ )
523         {
524             metadataRepositoryControl.expectAndReturn( metadataRepository.getRootNamespaces( TEST_REPO_ID ),
525                                                        Arrays.asList( "com", "org" ) );
526             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com" ),
527                                                        Arrays.asList() );
528             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ),
529                                                        Arrays.asList( "example" ) );
530             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ),
531                                                        Arrays.asList() );
532             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ),
533                                                        Arrays.asList( "example-project" ) );
534             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
535                                                                                               "com.example",
536                                                                                               "example-project" ),
537                                                        Arrays.asList( "1.0", "1.1" ) );
538             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example",
539                                                                                         "example-project", "1.0" ),
540                                                        Arrays.asList( createArtifact( "com.example", "example-project",
541                                                                                       "1.0", "jar" ), createArtifact(
542                                                            "com.example", "example-project", "1.0", "pom" ) ) );
543             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example",
544                                                                                         "example-project", "1.1" ),
545                                                        Arrays.asList( createArtifact( "com.example", "example-project",
546                                                                                       "1.1", "jar" ), createArtifact(
547                                                            "com.example", "example-project", "1.1", "pom" ) ) );
548             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ),
549                                                        Arrays.asList( "apache", "codehaus" ) );
550             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ),
551                                                        Arrays.asList( "archiva", "maven" ) );
552             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ),
553                                                        Arrays.asList() );
554             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
555                                                                                          "org.apache.archiva" ),
556                                                        Arrays.asList() );
557             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
558                                                                                        "org.apache.archiva" ),
559                                                        Arrays.asList( "metadata-repository-api", "metadata-model" ) );
560             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
561                                                                                               "org.apache.archiva",
562                                                                                               "metadata-repository-api" ),
563                                                        Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
564             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
565                                                                                         "org.apache.archiva",
566                                                                                         "metadata-repository-api",
567                                                                                         "1.3-SNAPSHOT" ), Arrays.asList(
568                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
569                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "pom" ) ) );
570             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
571                                                                                         "org.apache.archiva",
572                                                                                         "metadata-repository-api",
573                                                                                         "1.3" ), Arrays.asList(
574                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ), createArtifact(
575                 "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
576             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
577                                                                                               "org.apache.archiva",
578                                                                                               "metadata-model" ),
579                                                        Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
580             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
581                                                                                         "org.apache.archiva",
582                                                                                         "metadata-model",
583                                                                                         "1.3-SNAPSHOT" ), Arrays.asList(
584                 createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ), createArtifact(
585                 "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) );
586             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
587                                                                                         "org.apache.archiva",
588                                                                                         "metadata-model", "1.3" ),
589                                                        Arrays.asList( createArtifact( "org.apache.archiva",
590                                                                                       "metadata-model", "1.3", "jar" ),
591                                                                       createArtifact( "org.apache.archiva",
592                                                                                       "metadata-model", "1.3",
593                                                                                       "pom" ) ) );
594             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
595                                                                                          "org.apache.maven" ),
596                                                        Arrays.asList() );
597             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
598                                                                                        "org.apache.maven" ),
599                                                        Arrays.asList( "maven-model" ) );
600             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
601                                                                                               "org.apache.maven",
602                                                                                               "maven-model" ),
603                                                        Arrays.asList( "2.2.1" ) );
604             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
605                                                                                         "org.apache.maven",
606                                                                                         "maven-model", "2.2.1" ),
607                                                        Arrays.asList( createArtifact( "org.apache.archiva",
608                                                                                       "maven-model", "2.2.1", "jar" ),
609                                                                       createArtifact( "org.apache.archiva",
610                                                                                       "maven-model", "2.2.1",
611                                                                                       "pom" ) ) );
612             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ),
613                                                        Arrays.asList( "plexus" ) );
614             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ),
615                                                        Arrays.asList() );
616             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ),
617                                                        Arrays.asList() );
618             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
619                                                                                          "org.codehaus.plexus" ),
620                                                        Arrays.asList() );
621             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
622                                                                                        "org.codehaus.plexus" ),
623                                                        Arrays.asList( "plexus-spring" ) );
624             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
625                                                                                               "org.codehaus.plexus",
626                                                                                               "plexus-spring" ),
627                                                        Arrays.asList( "1.0", "1.1", "1.2" ) );
628             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
629                                                                                         "org.codehaus.plexus",
630                                                                                         "plexus-spring", "1.0" ),
631                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
632                                                                                       "plexus-spring", "1.0", "jar" ),
633                                                                       createArtifact( "org.codehaus.plexus",
634                                                                                       "plexus-spring", "1.0",
635                                                                                       "pom" ) ) );
636             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
637                                                                                         "org.codehaus.plexus",
638                                                                                         "plexus-spring", "1.1" ),
639                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
640                                                                                       "plexus-spring", "1.1", "jar" ),
641                                                                       createArtifact( "org.codehaus.plexus",
642                                                                                       "plexus-spring", "1.1",
643                                                                                       "pom" ) ) );
644             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
645                                                                                         "org.codehaus.plexus",
646                                                                                         "plexus-spring", "1.2" ),
647                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
648                                                                                       "plexus-spring", "1.2", "jar" ),
649                                                                       createArtifact( "org.codehaus.plexus",
650                                                                                       "plexus-spring", "1.2",
651                                                                                       "pom" ) ) );
652         }
653     }
654 }