]> source.dussan.org Git - archiva.git/blob
31903a6caaddc9bebb5aa584bfdbba3a047eda58
[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.repository.MetadataRepository;
25 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
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.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.setScanStartTime( startTime );
506         stats.setScanEndTime( endTime );
507         stats.setTotalArtifactFileSize( 20 * 12345L );
508         stats.setNewFileCount( 45 );
509         stats.setTotalArtifactCount( 20 );
510         stats.setTotalProjectCount( 5 );
511         stats.setTotalGroupCount( 4 );
512         stats.setTotalFileCount( 56345 );
513         stats.setTotalCountForType( "jar", 10 );
514         stats.setTotalCountForType( "pom", 10 );
515         return stats;
516     }
517
518     private void walkRepository( int count )
519         throws Exception
520     {
521         for ( int i = 0; i < count; i++ )
522         {
523             metadataRepositoryControl.expectAndReturn( metadataRepository.getRootNamespaces( TEST_REPO_ID ),
524                                                        Arrays.asList( "com", "org" ) );
525             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com" ),
526                                                        Arrays.asList() );
527             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ),
528                                                        Arrays.asList( "example" ) );
529             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ),
530                                                        Arrays.asList() );
531             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ),
532                                                        Arrays.asList( "example-project" ) );
533             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
534                                                                                               "com.example",
535                                                                                               "example-project" ),
536                                                        Arrays.asList( "1.0", "1.1" ) );
537             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example",
538                                                                                         "example-project", "1.0" ),
539                                                        Arrays.asList( createArtifact( "com.example", "example-project",
540                                                                                       "1.0", "jar" ), createArtifact(
541                                                            "com.example", "example-project", "1.0", "pom" ) ) );
542             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example",
543                                                                                         "example-project", "1.1" ),
544                                                        Arrays.asList( createArtifact( "com.example", "example-project",
545                                                                                       "1.1", "jar" ), createArtifact(
546                                                            "com.example", "example-project", "1.1", "pom" ) ) );
547             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ),
548                                                        Arrays.asList( "apache", "codehaus" ) );
549             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ),
550                                                        Arrays.asList( "archiva", "maven" ) );
551             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ),
552                                                        Arrays.asList() );
553             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
554                                                                                          "org.apache.archiva" ),
555                                                        Arrays.asList() );
556             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
557                                                                                        "org.apache.archiva" ),
558                                                        Arrays.asList( "metadata-repository-api", "metadata-model" ) );
559             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
560                                                                                               "org.apache.archiva",
561                                                                                               "metadata-repository-api" ),
562                                                        Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
563             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
564                                                                                         "org.apache.archiva",
565                                                                                         "metadata-repository-api",
566                                                                                         "1.3-SNAPSHOT" ), Arrays.asList(
567                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
568                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "pom" ) ) );
569             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
570                                                                                         "org.apache.archiva",
571                                                                                         "metadata-repository-api",
572                                                                                         "1.3" ), Arrays.asList(
573                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ), createArtifact(
574                 "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
575             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
576                                                                                               "org.apache.archiva",
577                                                                                               "metadata-model" ),
578                                                        Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
579             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
580                                                                                         "org.apache.archiva",
581                                                                                         "metadata-model",
582                                                                                         "1.3-SNAPSHOT" ), Arrays.asList(
583                 createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ), createArtifact(
584                 "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) );
585             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
586                                                                                         "org.apache.archiva",
587                                                                                         "metadata-model", "1.3" ),
588                                                        Arrays.asList( createArtifact( "org.apache.archiva",
589                                                                                       "metadata-model", "1.3", "jar" ),
590                                                                       createArtifact( "org.apache.archiva",
591                                                                                       "metadata-model", "1.3",
592                                                                                       "pom" ) ) );
593             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
594                                                                                          "org.apache.maven" ),
595                                                        Arrays.asList() );
596             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
597                                                                                        "org.apache.maven" ),
598                                                        Arrays.asList( "maven-model" ) );
599             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
600                                                                                               "org.apache.maven",
601                                                                                               "maven-model" ),
602                                                        Arrays.asList( "2.2.1" ) );
603             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
604                                                                                         "org.apache.maven",
605                                                                                         "maven-model", "2.2.1" ),
606                                                        Arrays.asList( createArtifact( "org.apache.archiva",
607                                                                                       "maven-model", "2.2.1", "jar" ),
608                                                                       createArtifact( "org.apache.archiva",
609                                                                                       "maven-model", "2.2.1",
610                                                                                       "pom" ) ) );
611             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ),
612                                                        Arrays.asList( "plexus" ) );
613             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ),
614                                                        Arrays.asList() );
615             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ),
616                                                        Arrays.asList() );
617             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
618                                                                                          "org.codehaus.plexus" ),
619                                                        Arrays.asList() );
620             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
621                                                                                        "org.codehaus.plexus" ),
622                                                        Arrays.asList( "plexus-spring" ) );
623             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
624                                                                                               "org.codehaus.plexus",
625                                                                                               "plexus-spring" ),
626                                                        Arrays.asList( "1.0", "1.1", "1.2" ) );
627             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
628                                                                                         "org.codehaus.plexus",
629                                                                                         "plexus-spring", "1.0" ),
630                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
631                                                                                       "plexus-spring", "1.0", "jar" ),
632                                                                       createArtifact( "org.codehaus.plexus",
633                                                                                       "plexus-spring", "1.0",
634                                                                                       "pom" ) ) );
635             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
636                                                                                         "org.codehaus.plexus",
637                                                                                         "plexus-spring", "1.1" ),
638                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
639                                                                                       "plexus-spring", "1.1", "jar" ),
640                                                                       createArtifact( "org.codehaus.plexus",
641                                                                                       "plexus-spring", "1.1",
642                                                                                       "pom" ) ) );
643             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
644                                                                                         "org.codehaus.plexus",
645                                                                                         "plexus-spring", "1.2" ),
646                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
647                                                                                       "plexus-spring", "1.2", "jar" ),
648                                                                       createArtifact( "org.codehaus.plexus",
649                                                                                       "plexus-spring", "1.2",
650                                                                                       "pom" ) ) );
651         }
652     }
653 }