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