1 package org.apache.archiva.metadata.repository.stats;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import junit.framework.TestCase;
23 import org.apache.archiva.metadata.model.ArtifactMetadata;
24 import org.apache.archiva.metadata.model.maven2.MavenArtifactFacet;
25 import org.apache.archiva.metadata.repository.MetadataRepository;
26 import org.apache.archiva.metadata.repository.RepositorySession;
27 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
28 import org.apache.archiva.metadata.repository.stats.model.DefaultRepositoryStatistics;
29 import org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics;
30 import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
31 import org.easymock.IMocksControl;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
36 import java.text.SimpleDateFormat;
37 import java.util.ArrayList;
38 import java.util.Arrays;
39 import java.util.Collections;
40 import java.util.Date;
41 import java.util.LinkedHashMap;
42 import java.util.List;
44 import java.util.TimeZone;
46 import static org.easymock.EasyMock.*;
48 @RunWith( ArchivaBlockJUnit4ClassRunner.class )
49 public class RepositoryStatisticsManagerTest
52 private DefaultRepositoryStatisticsManager repositoryStatisticsManager;
54 private static final String TEST_REPO_ID = "test-repo";
56 private IMocksControl metadataRepositoryControl;
58 private MetadataRepository metadataRepository;
60 private static final String FIRST_TEST_SCAN = "2009/12/01/123456.789";
62 private static final String SECOND_TEST_SCAN = "2009/12/02/012345.678";
64 private Map<String, RepositoryStatistics> statsCreated = new LinkedHashMap<String, RepositoryStatistics>();
66 private static final SimpleDateFormat TIMESTAMP_FORMAT = createTimestampFormat();
68 private RepositorySessionFactory repositorySessionFactory;
69 private IMocksControl factoryControl;
70 private IMocksControl sessionControl;
71 private RepositorySession session;
73 private static SimpleDateFormat createTimestampFormat()
75 SimpleDateFormat fmt = new SimpleDateFormat( DefaultRepositoryStatistics.SCAN_TIMESTAMP_FORMAT );
76 fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
87 repositoryStatisticsManager = new DefaultRepositoryStatisticsManager();
89 metadataRepositoryControl = createControl();
90 metadataRepository = metadataRepositoryControl.createMock( MetadataRepository.class );
92 factoryControl = createControl();
93 repositorySessionFactory = factoryControl.createMock(RepositorySessionFactory.class);
95 repositoryStatisticsManager.setRepositorySessionFactory( repositorySessionFactory );
97 sessionControl = createControl( );
98 session = sessionControl.createMock( RepositorySession.class );
103 public void testGetLatestStats()
106 Date startTime = TIMESTAMP_FORMAT.parse( SECOND_TEST_SCAN );
107 Date endTime = new Date( startTime.getTime() + 60000 );
109 DefaultRepositoryStatistics defStats = new DefaultRepositoryStatistics();
110 defStats.setScanStartTime( startTime );
111 defStats.setScanEndTime( endTime );
112 RepositoryStatistics stats = defStats;
113 stats.setTotalArtifactFileSize( 1314527915L );
114 stats.setNewFileCount( 123 );
115 stats.setTotalArtifactCount( 10386 );
116 stats.setTotalProjectCount( 2031 );
117 stats.setTotalGroupCount( 529 );
118 stats.setTotalFileCount( 56229 );
121 sessionControl.reset();
122 factoryControl.reset();
123 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
124 expect( session.getRepository() ).andStubReturn( metadataRepository );
126 expectLastCall( ).anyTimes( );
127 factoryControl.replay();
128 sessionControl.replay();
130 expect(metadataRepository.getMetadataFacets(session, TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID)).andReturn(
131 Arrays.asList(FIRST_TEST_SCAN, SECOND_TEST_SCAN));
133 expect(metadataRepository.getMetadataFacet(session, TEST_REPO_ID,
134 DefaultRepositoryStatistics.FACET_ID, SECOND_TEST_SCAN)).andReturn(stats);
135 metadataRepositoryControl.replay();
137 stats = repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID );
138 assertNotNull( stats );
139 assertEquals( 1314527915L, stats.getTotalArtifactFileSize() );
140 assertEquals( 123, stats.getNewFileCount() );
141 assertEquals( 10386, stats.getTotalArtifactCount() );
142 assertEquals( 2031, stats.getTotalProjectCount() );
143 assertEquals( 529, stats.getTotalGroupCount() );
144 assertEquals( 56229, stats.getTotalFileCount() );
145 assertEquals( SECOND_TEST_SCAN, TIMESTAMP_FORMAT.format( stats.getScanStartTime() ) );
146 assertEquals( SECOND_TEST_SCAN, stats.getName() );
147 assertEquals( endTime, stats.getScanEndTime() );
149 metadataRepositoryControl.verify();
153 public void testGetLatestStatsWhenEmpty()
157 sessionControl.reset();
158 factoryControl.reset();
159 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
160 expect( session.getRepository() ).andStubReturn( metadataRepository );
162 expectLastCall( ).anyTimes( );
163 factoryControl.replay();
164 sessionControl.replay();
166 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn(
167 Collections.<String>emptyList() );
168 metadataRepositoryControl.replay();
170 RepositoryStatistics stats = repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID );
173 metadataRepositoryControl.verify();
177 public void testAddNewStats()
180 Date current = new Date();
181 Date startTime = new Date( current.getTime() - 12345 );
183 RepositoryStatistics stats = createTestStats( startTime, current );
187 sessionControl.reset();
188 factoryControl.reset();
189 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
190 expect( session.getRepository() ).andStubReturn( metadataRepository );
192 expectLastCall( ).anyTimes( );
193 factoryControl.replay();
194 sessionControl.replay();
196 metadataRepository.addMetadataFacet(session , TEST_REPO_ID, stats );
198 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn(
199 Arrays.asList( stats.getName() ) );
201 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID,
202 DefaultRepositoryStatistics.FACET_ID, stats.getName() ) ).andReturn( stats );
204 metadataRepositoryControl.replay();
206 repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, startTime, current, 56345,
209 stats = repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID );
210 assertNotNull( stats );
211 assertEquals( 246900, stats.getTotalArtifactFileSize() );
212 assertEquals( 45, stats.getNewFileCount() );
213 assertEquals( 20, stats.getTotalArtifactCount() );
214 assertEquals( 5, stats.getTotalProjectCount() );
215 assertEquals( 4, stats.getTotalGroupCount() );
216 assertEquals( 56345, stats.getTotalFileCount() );
217 assertEquals( current.getTime() - 12345, stats.getScanStartTime().getTime() );
218 assertEquals( current, stats.getScanEndTime() );
220 metadataRepositoryControl.verify();
224 public void testDeleteStats()
229 Date current = new Date();
231 Date startTime1 = new Date( current.getTime() - 12345 );
232 DefaultRepositoryStatistics stats1 = createTestStats( startTime1, new Date( current.getTime() - 6000 ) );
234 sessionControl.reset();
235 factoryControl.reset();
236 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
237 expect( session.getRepository() ).andStubReturn( metadataRepository );
239 expectLastCall( ).anyTimes( );
240 factoryControl.replay();
241 sessionControl.replay();
243 metadataRepository.addMetadataFacet(session , TEST_REPO_ID, stats1 );
245 Date startTime2 = new Date( current.getTime() - 3000 );
246 DefaultRepositoryStatistics stats2 = createTestStats( startTime2, current );
247 metadataRepository.addMetadataFacet(session , TEST_REPO_ID, stats2 );
250 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn(
251 Arrays.asList( stats1.getName(), stats2.getName() ) );
253 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID,
254 DefaultRepositoryStatistics.FACET_ID, stats2.getName() ) ).andReturn( stats2 );
255 metadataRepository.removeMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID );
257 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn(
258 Collections.<String>emptyList() );
260 metadataRepositoryControl.replay();
262 repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, startTime1,
263 stats1.getScanEndTime(), 56345, 45 );
264 repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, startTime2,
265 stats2.getScanEndTime(), 56345, 45 );
267 assertNotNull( repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID ) );
269 repositoryStatisticsManager.deleteStatistics( TEST_REPO_ID );
271 assertNull( repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID ) );
273 metadataRepositoryControl.verify();
277 public void testDeleteStatsWhenEmpty()
280 sessionControl.reset();
281 factoryControl.reset();
282 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
283 expect( session.getRepository() ).andStubReturn( metadataRepository );
285 expectLastCall( ).anyTimes( );
286 factoryControl.replay();
287 sessionControl.replay();
289 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn(
290 Collections.<String>emptyList() ).times( 2 );
291 metadataRepository.removeMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID );
293 metadataRepositoryControl.replay();
295 assertNull( repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID ) );
297 repositoryStatisticsManager.deleteStatistics( TEST_REPO_ID );
299 assertNull( repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID ) );
301 metadataRepositoryControl.verify();
305 public void testGetStatsRangeInside()
310 Date current = new Date();
312 sessionControl.reset();
313 factoryControl.reset();
314 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
315 expect( session.getRepository() ).andStubReturn( metadataRepository );
317 expectLastCall( ).anyTimes( );
318 factoryControl.replay();
319 sessionControl.replay();
322 addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
323 addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
324 addStats( new Date( current.getTime() - 1000 ), current );
326 ArrayList<String> keys = new ArrayList<>( statsCreated.keySet() );
328 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys );
330 // only match the middle one
331 String key = keys.get( 1 );
333 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn(
334 statsCreated.get( key ) );
337 metadataRepositoryControl.replay();
339 for ( RepositoryStatistics stats : statsCreated.values() )
341 repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID,
342 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
346 List<RepositoryStatistics> list =
347 repositoryStatisticsManager.getStatisticsInRange( TEST_REPO_ID,
348 new Date( current.getTime() - 4000 ),
349 new Date( current.getTime() - 2000 ) );
351 assertEquals( 1, list.size() );
352 assertEquals( new Date( current.getTime() - 3000 ), list.get( 0 ).getScanStartTime() );
354 metadataRepositoryControl.verify();
358 public void testGetStatsRangeUpperOutside()
363 Date current = new Date();
365 sessionControl.reset();
366 factoryControl.reset();
367 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
368 expect( session.getRepository() ).andStubReturn( metadataRepository );
370 expectLastCall( ).anyTimes( );
371 factoryControl.replay();
372 sessionControl.replay();
374 addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
375 addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
376 addStats( new Date( current.getTime() - 1000 ), current );
378 List<String> keys = new ArrayList<>( statsCreated.keySet() );
380 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys );
382 String key = keys.get( 1 );
384 expect( metadataRepository.getMetadataFacet(session, TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn(
385 statsCreated.get( key ) );
390 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn(
391 statsCreated.get( key ) );
394 metadataRepositoryControl.replay();
396 for ( RepositoryStatistics stats : statsCreated.values() )
398 repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID,
399 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
403 List<RepositoryStatistics> list =
404 repositoryStatisticsManager.getStatisticsInRange( TEST_REPO_ID,
405 new Date( current.getTime() - 4000 ), current );
407 assertEquals( 2, list.size() );
408 assertEquals( new Date( current.getTime() - 3000 ), list.get( 1 ).getScanStartTime() );
409 assertEquals( new Date( current.getTime() - 1000 ), list.get( 0 ).getScanStartTime() );
411 metadataRepositoryControl.verify();
415 public void testGetStatsRangeLowerOutside()
420 Date current = new Date();
422 sessionControl.reset();
423 factoryControl.reset();
424 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
425 expect( session.getRepository() ).andStubReturn( metadataRepository );
427 expectLastCall( ).anyTimes( );
428 factoryControl.replay();
429 sessionControl.replay();
431 addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
432 addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
433 addStats( new Date( current.getTime() - 1000 ), current );
435 List<String> keys = new ArrayList<>( statsCreated.keySet() );
437 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys );
439 String key = keys.get( 0 );
441 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn(
442 statsCreated.get( key ) );
445 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn(
446 statsCreated.get( key ) );
448 metadataRepositoryControl.replay();
450 for ( RepositoryStatistics stats : statsCreated.values() )
452 repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID,
453 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
457 List<RepositoryStatistics> list =
458 repositoryStatisticsManager.getStatisticsInRange( TEST_REPO_ID,
459 new Date( current.getTime() - 20000 ),
460 new Date( current.getTime() - 2000 ) );
462 assertEquals( 2, list.size() );
463 assertEquals( new Date( current.getTime() - 12345 ), list.get( 1 ).getScanStartTime() );
464 assertEquals( new Date( current.getTime() - 3000 ), list.get( 0 ).getScanStartTime() );
466 metadataRepositoryControl.verify();
470 public void testGetStatsRangeLowerAndUpperOutside()
475 Date current = new Date();
477 sessionControl.reset();
478 factoryControl.reset();
479 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
480 expect( session.getRepository() ).andStubReturn( metadataRepository );
482 expectLastCall( ).anyTimes( );
483 factoryControl.replay();
484 sessionControl.replay();
486 addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
487 addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
488 addStats( new Date( current.getTime() - 1000 ), current );
490 ArrayList<String> keys = new ArrayList<>( statsCreated.keySet() );
492 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys );
494 String key = keys.get( 0 );
496 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn(
497 statsCreated.get( key ) );
500 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn(
501 statsCreated.get( key ) );
504 expect( metadataRepository.getMetadataFacet(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID, key ) ).andReturn(
505 statsCreated.get( key ) );
507 metadataRepositoryControl.replay();
509 for ( RepositoryStatistics stats : statsCreated.values() )
511 repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID,
512 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
516 List<RepositoryStatistics> list =
517 repositoryStatisticsManager.getStatisticsInRange( TEST_REPO_ID,
518 new Date( current.getTime() - 20000 ), current );
520 assertEquals( 3, list.size() );
521 assertEquals( new Date( current.getTime() - 12345 ), list.get( 2 ).getScanStartTime() );
522 assertEquals( new Date( current.getTime() - 3000 ), list.get( 1 ).getScanStartTime() );
523 assertEquals( new Date( current.getTime() - 1000 ), list.get( 0 ).getScanStartTime() );
525 metadataRepositoryControl.verify();
529 public void testGetStatsRangeNotInside()
534 Date current = new Date();
535 sessionControl.reset();
536 factoryControl.reset();
537 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
538 expect( session.getRepository() ).andStubReturn( metadataRepository );
540 expectLastCall( ).anyTimes( );
541 factoryControl.replay();
542 sessionControl.replay();
544 addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
545 addStats( new Date( current.getTime() - 3000 ), new Date( current.getTime() - 2000 ) );
546 addStats( new Date( current.getTime() - 1000 ), current );
548 ArrayList<String> keys = new ArrayList<>( statsCreated.keySet() );
550 expect( metadataRepository.getMetadataFacets(session , TEST_REPO_ID, DefaultRepositoryStatistics.FACET_ID ) ).andReturn( keys );
552 metadataRepositoryControl.replay();
554 for ( RepositoryStatistics stats : statsCreated.values() )
556 repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID,
557 stats.getScanStartTime(), stats.getScanEndTime(), 56345,
561 List<RepositoryStatistics> list =
562 repositoryStatisticsManager.getStatisticsInRange( TEST_REPO_ID,
563 new Date( current.getTime() - 20000 ),
564 new Date( current.getTime() - 16000 ) );
566 assertEquals( 0, list.size() );
568 metadataRepositoryControl.verify();
571 private void addStats( Date startTime, Date endTime )
574 RepositorySession session = repositorySessionFactory.createSession();
576 DefaultRepositoryStatistics stats = createTestStats( startTime, endTime );
577 metadataRepository.addMetadataFacet(session , TEST_REPO_ID, stats );
578 statsCreated.put( stats.getName(), stats );
581 private ArtifactMetadata createArtifact( String namespace, String projectId, String projectVersion, String type )
583 ArtifactMetadata metadata = new ArtifactMetadata();
584 metadata.setRepositoryId( TEST_REPO_ID );
585 metadata.setId( projectId + "-" + projectVersion + "." + type );
586 metadata.setProject( projectId );
587 metadata.setSize( 12345L );
588 metadata.setProjectVersion( projectVersion );
589 metadata.setVersion( projectVersion );
590 metadata.setNamespace( namespace );
592 MavenArtifactFacet facet = new MavenArtifactFacet();
593 facet.setType( type );
594 metadata.addFacet( facet );
599 private DefaultRepositoryStatistics createTestStats( Date startTime, Date endTime )
601 DefaultRepositoryStatistics stats = new DefaultRepositoryStatistics();
602 stats.setRepositoryId( TEST_REPO_ID );
603 stats.setScanStartTime( startTime );
604 stats.setScanEndTime( endTime );
605 stats.setTotalArtifactFileSize( 20 * 12345L );
606 stats.setNewFileCount( 45 );
607 stats.setTotalArtifactCount( 20 );
608 stats.setTotalProjectCount( 5 );
609 stats.setTotalGroupCount( 4 );
610 stats.setTotalFileCount( 56345 );
611 stats.setTotalCountForType( "jar", 10 );
612 stats.setTotalCountForType( "pom", 10 );
616 private void walkRepository( int count )
619 sessionControl.reset();
620 expect( repositorySessionFactory.createSession( ) ).andStubReturn( session );
621 factoryControl.replay();
623 for ( int i = 0; i < count; i++ )
627 expect( metadataRepository.getRootNamespaces(session , TEST_REPO_ID ) ).andReturn( Arrays.asList( "com", "org" ) );
629 expect( metadataRepository.getProjects(session , TEST_REPO_ID, "com" ) ).andReturn( Arrays.<String>asList() );
631 expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "com" ) ).andReturn( Arrays.asList( "example" ) );
633 expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "com.example" ) ).andReturn(
634 Arrays.<String>asList() );
636 expect( metadataRepository.getProjects(session , TEST_REPO_ID, "com.example" ) ).andReturn(
637 Arrays.asList( "example-project" ) );
639 expect( metadataRepository.getProjectVersions(session , TEST_REPO_ID, "com.example", "example-project" ) ).andReturn(
640 Arrays.asList( "1.0", "1.1" ) );
643 metadataRepository.getArtifacts(session , TEST_REPO_ID, "com.example", "example-project", "1.0" ) ).andReturn(
644 Arrays.asList( createArtifact( "com.example", "example-project", "1.0", "jar" ),
645 createArtifact( "com.example", "example-project", "1.0", "pom" ) ) );
648 metadataRepository.getArtifacts(session , TEST_REPO_ID, "com.example", "example-project", "1.1" ) ).andReturn(
649 Arrays.asList( createArtifact( "com.example", "example-project", "1.1", "jar" ),
650 createArtifact( "com.example", "example-project", "1.1", "pom" ) ) );
653 expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org" ) ).andReturn( Arrays.asList( "apache", "codehaus" ) );
655 expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.asList( "archiva", "maven" ) );
658 expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.apache" ) ).andReturn( Arrays.<String>asList() );
660 expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.<String>asList() );
662 expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.apache.archiva" ) ).andReturn( Arrays.asList( "metadata-repository-api", "metadata-model" ) );
664 expect( metadataRepository.getProjectVersions(session , TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api" ) )
665 .andReturn( Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
668 expect( metadataRepository.getArtifacts(session , TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT" ) )
669 .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
670 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT",
673 expect( metadataRepository.getArtifacts(session , TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3" ) )
674 .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ),
675 createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
677 expect( metadataRepository.getProjectVersions(session , TEST_REPO_ID, "org.apache.archiva", "metadata-model" ) )
678 .andReturn( Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
680 expect( metadataRepository.getArtifacts(session , TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT" ) )
681 .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ),
682 createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "pom" ) ) );
684 expect( metadataRepository.getArtifacts(session , TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3" ) )
685 .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3", "jar" ),
686 createArtifact( "org.apache.archiva", "metadata-model", "1.3", "pom" ) ) );
688 expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.apache.maven" ) ).andReturn( Arrays.<String>asList() );
690 expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.apache.maven" ) )
691 .andReturn( Arrays.asList( "maven-model" ) );
693 expect( metadataRepository.getProjectVersions(session , TEST_REPO_ID, "org.apache.maven", "maven-model" ) )
694 .andReturn( Arrays.asList( "2.2.1" ) );
696 expect( metadataRepository.getArtifacts(session , TEST_REPO_ID, "org.apache.maven", "maven-model", "2.2.1" ) )
697 .andReturn( Arrays.asList( createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "jar" ),
698 createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "pom" ) ) );
700 expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.codehaus" ) ).andReturn( Arrays.asList( "plexus" ) );
702 expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org" ) ).andReturn( Arrays.<String>asList( ) );
704 expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.codehaus" ) )
705 .andReturn( Arrays.<String>asList( ) );
707 expect( metadataRepository.getChildNamespaces(session , TEST_REPO_ID, "org.codehaus.plexus" ) )
708 .andReturn( Arrays.<String>asList( ) );
710 expect( metadataRepository.getProjects(session , TEST_REPO_ID, "org.codehaus.plexus" ) )
711 .andReturn( Arrays.asList( "plexus-spring" ) );
713 expect( metadataRepository.getProjectVersions(session, TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring" ) )
714 .andReturn( Arrays.asList( "1.0", "1.1", "1.2" ) );
717 expect( metadataRepository.getArtifacts(session , TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.0" ) )
718 .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "jar" ),
719 createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "pom" ) ) );
721 expect( metadataRepository.getArtifacts(session, TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.1" ) )
722 .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "jar" ),
723 createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "pom" ) ) );
725 expect( metadataRepository.getArtifacts(session , TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2" ) )
726 .andReturn( Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "jar" ),
727 createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "pom" ) ) );