]> source.dussan.org Git - archiva.git/blob
70ef1703b2a7a6a3bb0bb329fa13461deaa5603c
[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     }
75
76     public void testGetLatestStats()
77         throws Exception
78     {
79         Date startTime = TIMESTAMP_FORMAT.parse( SECOND_TEST_SCAN );
80         Date endTime = new Date( startTime.getTime() + 60000 );
81
82         RepositoryStatistics stats = new RepositoryStatistics();
83         stats.setScanStartTime( startTime );
84         stats.setScanEndTime( endTime );
85         stats.setTotalArtifactFileSize( 1314527915L );
86         stats.setNewFileCount( 123 );
87         stats.setTotalArtifactCount( 10386 );
88         stats.setTotalProjectCount( 2031 );
89         stats.setTotalGroupCount( 529 );
90         stats.setTotalFileCount( 56229 );
91
92         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
93                                                                                          RepositoryStatistics.FACET_ID ),
94                                                    Arrays.asList( FIRST_TEST_SCAN, SECOND_TEST_SCAN ) );
95         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
96                                                                                         RepositoryStatistics.FACET_ID,
97                                                                                         SECOND_TEST_SCAN ), stats );
98         metadataRepositoryControl.replay();
99
100         stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
101         assertNotNull( stats );
102         assertEquals( 1314527915L, stats.getTotalArtifactFileSize() );
103         assertEquals( 123, stats.getNewFileCount() );
104         assertEquals( 10386, stats.getTotalArtifactCount() );
105         assertEquals( 2031, stats.getTotalProjectCount() );
106         assertEquals( 529, stats.getTotalGroupCount() );
107         assertEquals( 56229, stats.getTotalFileCount() );
108         assertEquals( SECOND_TEST_SCAN, TIMESTAMP_FORMAT.format( stats.getScanStartTime() ) );
109         assertEquals( SECOND_TEST_SCAN, stats.getName() );
110         assertEquals( endTime, stats.getScanEndTime() );
111
112         metadataRepositoryControl.verify();
113     }
114
115     public void testGetLatestStatsWhenEmpty()
116         throws Exception
117     {
118         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
119                                                                                          RepositoryStatistics.FACET_ID ),
120                                                    Collections.emptyList() );
121         metadataRepositoryControl.replay();
122
123         RepositoryStatistics stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
124         assertNull( stats );
125
126         metadataRepositoryControl.verify();
127     }
128
129     public void testAddNewStats()
130         throws Exception
131
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
148         metadataRepositoryControl.replay();
149
150         repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime, current, 56345,
151                                                             45 );
152
153         stats = repositoryStatisticsManager.getLastStatistics( metadataRepository, 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( metadataRepository, TEST_REPO_ID, startTime1,
199                                                             stats1.getScanEndTime(), 56345, 45 );
200         repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO_ID, startTime2,
201                                                             stats2.getScanEndTime(), 56345, 45 );
202
203         assertNotNull( repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID ) );
204
205         repositoryStatisticsManager.deleteStatistics( metadataRepository, TEST_REPO_ID );
206
207         assertNull( repositoryStatisticsManager.getLastStatistics( metadataRepository, 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( 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     {
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( 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     {
279         walkRepository( 3 );
280
281         Date current = new Date();
282
283         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
284         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
285         addStats( new Date( current.getTime() - 1000 ), current );
286
287         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
288         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
289                                                                                          RepositoryStatistics.FACET_ID ),
290                                                    keys );
291
292         String key = keys.get( 1 );
293         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
294                                                                                         RepositoryStatistics.FACET_ID,
295                                                                                         key ), statsCreated.get(
296             key ) );
297         key = keys.get( 2 );
298         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
299                                                                                         RepositoryStatistics.FACET_ID,
300                                                                                         key ), statsCreated.get(
301             key ) );
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     {
327         walkRepository( 3 );
328
329         Date current = new Date();
330
331         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
332         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
333         addStats( new Date( current.getTime() - 1000 ), current );
334
335         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
336         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
337                                                                                          RepositoryStatistics.FACET_ID ),
338                                                    keys );
339
340         String key = keys.get( 0 );
341         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
342                                                                                         RepositoryStatistics.FACET_ID,
343                                                                                         key ), statsCreated.get(
344             key ) );
345         key = keys.get( 1 );
346         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
347                                                                                         RepositoryStatistics.FACET_ID,
348                                                                                         key ), statsCreated.get(
349             key ) );
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     {
375         walkRepository( 3 );
376
377         Date current = new Date();
378
379         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
380         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
381         addStats( new Date( current.getTime() - 1000 ), current );
382
383         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
384         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
385                                                                                          RepositoryStatistics.FACET_ID ),
386                                                    keys );
387
388         String key = keys.get( 0 );
389         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
390                                                                                         RepositoryStatistics.FACET_ID,
391                                                                                         key ), statsCreated.get(
392             key ) );
393         key = keys.get( 1 );
394         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
395                                                                                         RepositoryStatistics.FACET_ID,
396                                                                                         key ), statsCreated.get(
397             key ) );
398         key = keys.get( 2 );
399         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( TEST_REPO_ID,
400                                                                                         RepositoryStatistics.FACET_ID,
401                                                                                         key ), statsCreated.get(
402             key ) );
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     {
429         walkRepository( 3 );
430
431         Date current = new Date();
432
433         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
434         addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
435         addStats( new Date( current.getTime() - 1000 ), current );
436
437         ArrayList<String> keys = new ArrayList<String>( statsCreated.keySet() );
438         metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( TEST_REPO_ID,
439                                                                                          RepositoryStatistics.FACET_ID ),
440                                                    keys );
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     {
464         RepositoryStatistics stats = createTestStats( startTime, endTime );
465         metadataRepository.addMetadataFacet( TEST_REPO_ID, stats );
466         statsCreated.put( stats.getName(), stats );
467     }
468
469     private ArtifactMetadata createArtifact( String namespace, String projectId, String projectVersion, String type )
470     {
471         ArtifactMetadata metadata = new ArtifactMetadata();
472         metadata.setRepositoryId( TEST_REPO_ID );
473         metadata.setId( projectId + "-" + projectVersion + "." + type );
474         metadata.setProject( projectId );
475         metadata.setSize( 12345L );
476         metadata.setProjectVersion( projectVersion );
477         metadata.setVersion( projectVersion );
478         metadata.setNamespace( namespace );
479
480         MavenArtifactFacet facet = new MavenArtifactFacet();
481         facet.setType( type );
482         metadata.addFacet( facet );
483
484         return metadata;
485     }
486
487     private RepositoryStatistics createTestStats( Date startTime, Date endTime )
488     {
489         RepositoryStatistics stats = new RepositoryStatistics();
490         stats.setScanStartTime( startTime );
491         stats.setScanEndTime( endTime );
492         stats.setTotalArtifactFileSize( 20 * 12345L );
493         stats.setNewFileCount( 45 );
494         stats.setTotalArtifactCount( 20 );
495         stats.setTotalProjectCount( 5 );
496         stats.setTotalGroupCount( 4 );
497         stats.setTotalFileCount( 56345 );
498         stats.setTotalCountForType( "jar", 10 );
499         stats.setTotalCountForType( "pom", 10 );
500         return stats;
501     }
502
503     private void walkRepository( int count )
504         throws Exception
505     {
506         for ( int i = 0; i < count; i++ )
507         {
508             metadataRepositoryControl.expectAndReturn( metadataRepository.getRootNamespaces( TEST_REPO_ID ),
509                                                        Arrays.asList( "com", "org" ) );
510             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com" ),
511                                                        Arrays.asList() );
512             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ),
513                                                        Arrays.asList( "example" ) );
514             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ),
515                                                        Arrays.asList() );
516             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ),
517                                                        Arrays.asList( "example-project" ) );
518             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
519                                                                                               "com.example",
520                                                                                               "example-project" ),
521                                                        Arrays.asList( "1.0", "1.1" ) );
522             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example",
523                                                                                         "example-project", "1.0" ),
524                                                        Arrays.asList( createArtifact( "com.example", "example-project",
525                                                                                       "1.0", "jar" ), createArtifact(
526                                                            "com.example", "example-project", "1.0", "pom" ) ) );
527             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID, "com.example",
528                                                                                         "example-project", "1.1" ),
529                                                        Arrays.asList( createArtifact( "com.example", "example-project",
530                                                                                       "1.1", "jar" ), createArtifact(
531                                                            "com.example", "example-project", "1.1", "pom" ) ) );
532             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ),
533                                                        Arrays.asList( "apache", "codehaus" ) );
534             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ),
535                                                        Arrays.asList( "archiva", "maven" ) );
536             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ),
537                                                        Arrays.asList() );
538             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
539                                                                                          "org.apache.archiva" ),
540                                                        Arrays.asList() );
541             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
542                                                                                        "org.apache.archiva" ),
543                                                        Arrays.asList( "metadata-repository-api", "metadata-model" ) );
544             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
545                                                                                               "org.apache.archiva",
546                                                                                               "metadata-repository-api" ),
547                                                        Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
548             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
549                                                                                         "org.apache.archiva",
550                                                                                         "metadata-repository-api",
551                                                                                         "1.3-SNAPSHOT" ), Arrays.asList(
552                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
553                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "pom" ) ) );
554             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
555                                                                                         "org.apache.archiva",
556                                                                                         "metadata-repository-api",
557                                                                                         "1.3" ), Arrays.asList(
558                 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ), createArtifact(
559                 "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
560             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
561                                                                                               "org.apache.archiva",
562                                                                                               "metadata-model" ),
563                                                        Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
564             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
565                                                                                         "org.apache.archiva",
566                                                                                         "metadata-model",
567                                                                                         "1.3-SNAPSHOT" ), Arrays.asList(
568                 createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ), createArtifact(
569                 "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) );
570             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
571                                                                                         "org.apache.archiva",
572                                                                                         "metadata-model", "1.3" ),
573                                                        Arrays.asList( createArtifact( "org.apache.archiva",
574                                                                                       "metadata-model", "1.3", "jar" ),
575                                                                       createArtifact( "org.apache.archiva",
576                                                                                       "metadata-model", "1.3",
577                                                                                       "pom" ) ) );
578             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
579                                                                                          "org.apache.maven" ),
580                                                        Arrays.asList() );
581             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
582                                                                                        "org.apache.maven" ),
583                                                        Arrays.asList( "maven-model" ) );
584             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
585                                                                                               "org.apache.maven",
586                                                                                               "maven-model" ),
587                                                        Arrays.asList( "2.2.1" ) );
588             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
589                                                                                         "org.apache.maven",
590                                                                                         "maven-model", "2.2.1" ),
591                                                        Arrays.asList( createArtifact( "org.apache.archiva",
592                                                                                       "maven-model", "2.2.1", "jar" ),
593                                                                       createArtifact( "org.apache.archiva",
594                                                                                       "maven-model", "2.2.1",
595                                                                                       "pom" ) ) );
596             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ),
597                                                        Arrays.asList( "plexus" ) );
598             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ),
599                                                        Arrays.asList() );
600             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ),
601                                                        Arrays.asList() );
602             metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID,
603                                                                                          "org.codehaus.plexus" ),
604                                                        Arrays.asList() );
605             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID,
606                                                                                        "org.codehaus.plexus" ),
607                                                        Arrays.asList( "plexus-spring" ) );
608             metadataRepositoryControl.expectAndReturn( metadataRepository.getProjectVersions( TEST_REPO_ID,
609                                                                                               "org.codehaus.plexus",
610                                                                                               "plexus-spring" ),
611                                                        Arrays.asList( "1.0", "1.1", "1.2" ) );
612             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
613                                                                                         "org.codehaus.plexus",
614                                                                                         "plexus-spring", "1.0" ),
615                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
616                                                                                       "plexus-spring", "1.0", "jar" ),
617                                                                       createArtifact( "org.codehaus.plexus",
618                                                                                       "plexus-spring", "1.0",
619                                                                                       "pom" ) ) );
620             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
621                                                                                         "org.codehaus.plexus",
622                                                                                         "plexus-spring", "1.1" ),
623                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
624                                                                                       "plexus-spring", "1.1", "jar" ),
625                                                                       createArtifact( "org.codehaus.plexus",
626                                                                                       "plexus-spring", "1.1",
627                                                                                       "pom" ) ) );
628             metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( TEST_REPO_ID,
629                                                                                         "org.codehaus.plexus",
630                                                                                         "plexus-spring", "1.2" ),
631                                                        Arrays.asList( createArtifact( "org.codehaus.plexus",
632                                                                                       "plexus-spring", "1.2", "jar" ),
633                                                                       createArtifact( "org.codehaus.plexus",
634                                                                                       "plexus-spring", "1.2",
635                                                                                       "pom" ) ) );
636         }
637     }
638 }