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