1 package org.apache.maven.archiva.web.action.reports;
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 com.opensymphony.xwork2.Action;
23 import org.apache.archiva.metadata.model.MetadataFacet;
24 import org.apache.archiva.metadata.repository.MetadataRepository;
25 import org.apache.archiva.metadata.repository.RepositorySession;
26 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
27 import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
28 import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
29 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
30 import org.apache.archiva.reports.RepositoryProblemFacet;
31 import org.apache.commons.io.IOUtils;
32 import org.apache.maven.archiva.web.action.AbstractActionTestCase;
33 import org.easymock.MockControl;
35 import java.io.IOException;
36 import java.util.ArrayList;
37 import java.util.Arrays;
38 import java.util.Collections;
39 import java.util.Date;
40 import java.util.List;
42 import static org.mockito.Mockito.mock;
43 import static org.mockito.Mockito.when;
46 * Test the GenerationReportAction. Note that we are testing for <i>current</i> behaviour, however there are several
47 * instances below where other behaviour may actually be more appropriate (eg the error handling, download stats should
48 * never forward to HTML page, etc). This is also missing tests for various combinations of paging at this point.
50 public class GenerateReportActionTest
51 extends AbstractActionTestCase
53 private GenerateReportAction action;
55 private static final String SNAPSHOTS = "snapshots";
57 private static final String INTERNAL = "internal";
59 private static final String GROUP_ID = "groupId";
61 private RepositoryStatisticsManager repositoryStatisticsManager;
63 private MockControl repositoryStatisticsManagerControl;
65 private MockControl metadataRepositoryControl;
67 private MetadataRepository metadataRepository;
69 private static final String PROBLEM = "problem";
72 protected void setUp()
79 action = (GenerateReportAction) lookup( Action.class, "generateReport" );
83 // clean up cache - TODO: move handling to plexus-spring
84 applicationContext.close();
88 repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
89 repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
90 action.setRepositoryStatisticsManager( repositoryStatisticsManager );
92 metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
93 metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
95 RepositorySession repositorySession = mock( RepositorySession.class );
96 when( repositorySession.getRepository() ).thenReturn( metadataRepository );
98 TestRepositorySessionFactory factory = (TestRepositorySessionFactory) lookup( RepositorySessionFactory.class );
99 factory.setRepositorySession( repositorySession );
102 private void prepareAction( List<String> selectedRepositories, List<String> availableRepositories )
104 action.setSelectedRepositories( selectedRepositories );
107 assertEquals( Arrays.asList( GenerateReportAction.ALL_REPOSITORIES, INTERNAL, SNAPSHOTS ),
108 action.getRepositoryIds() );
109 assertEquals( availableRepositories, action.getAvailableRepositories() );
112 public void testGenerateStatisticsInvalidRowCount()
114 repositoryStatisticsManagerControl.replay();
115 prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
117 action.setRowCount( 0 );
118 String result = action.generateStatistics();
119 assertEquals( Action.INPUT, result );
120 assertTrue( action.hasFieldErrors() );
121 repositoryStatisticsManagerControl.verify();
124 public void testGenerateStatisticsInvalidEndDate()
126 repositoryStatisticsManagerControl.replay();
127 prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
129 action.setStartDate( "2009/12/12" );
130 action.setEndDate( "2008/11/11" );
131 String result = action.generateStatistics();
132 assertEquals( Action.INPUT, result );
133 assertTrue( action.hasFieldErrors() );
134 repositoryStatisticsManagerControl.verify();
137 public void testGenerateStatisticsMalformedEndDate()
139 repositoryStatisticsManagerControl.replay();
140 prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
142 action.setEndDate( "This is not a date" );
143 String result = action.generateStatistics();
145 // TODO: should be an input error
146 assertEquals( Action.ERROR, result );
147 assertTrue( action.hasActionErrors() );
148 repositoryStatisticsManagerControl.verify();
151 public void testGenerateStatisticsInvalidEndDateMultiRepo()
153 repositoryStatisticsManagerControl.replay();
154 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
156 action.setStartDate( "2009/12/12" );
157 action.setEndDate( "2008/11/11" );
158 String result = action.generateStatistics();
159 assertEquals( Action.INPUT, result );
160 assertTrue( action.hasFieldErrors() );
161 repositoryStatisticsManagerControl.verify();
164 public void testGenerateStatisticsMalformedEndDateMultiRepo()
166 repositoryStatisticsManagerControl.replay();
167 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
169 action.setEndDate( "This is not a date" );
170 String result = action.generateStatistics();
172 // TODO: should be an input error
173 assertEquals( Action.ERROR, result );
174 assertTrue( action.hasActionErrors() );
175 repositoryStatisticsManagerControl.verify();
178 public void testGenerateStatisticsNoRepos()
180 repositoryStatisticsManagerControl.replay();
181 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
183 String result = action.generateStatistics();
184 assertEquals( Action.INPUT, result );
185 assertTrue( action.hasFieldErrors() );
186 repositoryStatisticsManagerControl.verify();
189 public void testGenerateStatisticsSingleRepo()
192 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
193 metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) );
195 repositoryStatisticsManagerControl.replay();
196 prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
198 String result = action.generateStatistics();
199 assertSuccessResult( result );
200 repositoryStatisticsManagerControl.verify();
203 public void testGenerateStatisticsSingleRepoNoStats()
207 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
208 metadataRepository, INTERNAL, null, null ), Collections.<Object>emptyList() );
209 repositoryStatisticsManagerControl.replay();
210 prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
212 String result = action.generateStatistics();
213 assertEquals( Action.ERROR, result );
214 assertTrue( action.hasActionErrors() );
216 repositoryStatisticsManagerControl.verify();
219 public void testGenerateStatisticsOvershotPages()
223 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
224 metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) );
225 repositoryStatisticsManagerControl.replay();
227 prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
229 String result = action.generateStatistics();
230 assertEquals( Action.ERROR, result );
231 assertTrue( action.hasActionErrors() );
232 repositoryStatisticsManagerControl.verify();
235 public void testGenerateStatisticsMultipleRepoNoResults()
239 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
240 metadataRepository, SNAPSHOTS, null, null ), Collections.<Object>emptyList() );
241 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
242 metadataRepository, INTERNAL, null, null ), Collections.<Object>emptyList() );
243 repositoryStatisticsManagerControl.replay();
244 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
246 String result = action.generateStatistics();
247 assertEquals( GenerateReportAction.BLANK, result );
248 assertFalse( action.hasActionErrors() );
249 assertFalse( action.hasActionMessages() );
250 assertFalse( action.hasFieldErrors() );
252 repositoryStatisticsManagerControl.verify();
255 public void testGenerateStatisticsMultipleRepo()
259 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
260 metadataRepository, SNAPSHOTS, null, null ), Collections.singletonList( createDefaultStats() ) );
261 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
262 metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) );
264 repositoryStatisticsManagerControl.replay();
265 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
267 String result = action.generateStatistics();
268 assertSuccessResult( result );
269 repositoryStatisticsManagerControl.verify();
272 public void testDownloadStatisticsSingleRepo()
275 Date date = new Date();
276 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
277 metadataRepository, SNAPSHOTS, null, null ), Collections.singletonList( createStats( date ) ) );
278 repositoryStatisticsManagerControl.replay();
280 prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
282 String result = action.downloadStatisticsReport();
283 assertEquals( GenerateReportAction.SEND_FILE, result );
284 assertFalse( action.hasActionErrors() );
285 assertFalse( action.hasFieldErrors() );
288 "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n" +
289 date + ",0,0,0,0,0,0,0,0,0\n", IOUtils.toString( action.getInputStream() ) );
290 repositoryStatisticsManagerControl.verify();
293 public void testDownloadStatisticsMultipleRepos()
296 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
297 metadataRepository, SNAPSHOTS, null, null ), Collections.singletonList( createDefaultStats() ) );
298 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
299 metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) );
300 repositoryStatisticsManagerControl.replay();
301 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
303 String result = action.downloadStatisticsReport();
304 assertEquals( GenerateReportAction.SEND_FILE, result );
305 assertFalse( action.hasActionErrors() );
306 assertFalse( action.hasFieldErrors() );
308 assertMultiRepoCsvResult();
309 repositoryStatisticsManagerControl.verify();
312 public void testDownloadStatisticsMalformedEndDateMultiRepo()
314 repositoryStatisticsManagerControl.replay();
315 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
317 action.setEndDate( "This is not a date" );
318 String result = action.downloadStatisticsReport();
320 // TODO: should be an input error
321 assertEquals( Action.ERROR, result );
322 assertTrue( action.hasActionErrors() );
323 repositoryStatisticsManagerControl.verify();
326 public void testDownloadStatisticsMalformedEndDateSingleRepo()
328 repositoryStatisticsManagerControl.replay();
329 prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
331 action.setEndDate( "This is not a date" );
332 String result = action.downloadStatisticsReport();
334 // TODO: should be an input error
335 assertEquals( Action.ERROR, result );
336 assertTrue( action.hasActionErrors() );
337 repositoryStatisticsManagerControl.verify();
340 public void testDownloadStatisticsInvalidEndDateMultiRepo()
342 repositoryStatisticsManagerControl.replay();
343 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
345 action.setStartDate( "2009/12/12" );
346 action.setEndDate( "2008/11/11" );
347 String result = action.downloadStatisticsReport();
348 assertEquals( Action.INPUT, result );
349 assertTrue( action.hasFieldErrors() );
350 repositoryStatisticsManagerControl.verify();
353 public void testDownloadStatisticsInvalidEndDateSingleRepo()
355 repositoryStatisticsManagerControl.replay();
356 prepareAction( Arrays.asList( SNAPSHOTS ), Arrays.asList( INTERNAL ) );
358 action.setStartDate( "2009/12/12" );
359 action.setEndDate( "2008/11/11" );
360 String result = action.downloadStatisticsReport();
361 assertEquals( Action.INPUT, result );
362 assertTrue( action.hasFieldErrors() );
363 repositoryStatisticsManagerControl.verify();
366 public void testDownloadStatisticsSingleRepoNoStats()
370 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
371 metadataRepository, INTERNAL, null, null ), Collections.<Object>emptyList() );
372 repositoryStatisticsManagerControl.replay();
373 prepareAction( Collections.singletonList( INTERNAL ), Collections.singletonList( SNAPSHOTS ) );
375 String result = action.downloadStatisticsReport();
376 assertEquals( Action.ERROR, result );
377 assertTrue( action.hasActionErrors() );
378 repositoryStatisticsManagerControl.verify();
381 public void testDownloadStatisticsNoRepos()
383 repositoryStatisticsManagerControl.replay();
384 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
386 String result = action.downloadStatisticsReport();
387 assertEquals( Action.INPUT, result );
388 assertTrue( action.hasFieldErrors() );
389 repositoryStatisticsManagerControl.verify();
392 public void testDownloadStatisticsMultipleRepoNoResults()
396 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
397 metadataRepository, SNAPSHOTS, null, null ), Collections.<Object>emptyList() );
398 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
399 metadataRepository, INTERNAL, null, null ), Collections.<Object>emptyList() );
400 repositoryStatisticsManagerControl.replay();
401 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
403 String result = action.downloadStatisticsReport();
404 assertEquals( GenerateReportAction.BLANK, result );
405 assertFalse( action.hasActionErrors() );
406 assertFalse( action.hasActionMessages() );
407 assertFalse( action.hasFieldErrors() );
408 repositoryStatisticsManagerControl.verify();
411 public void testDownloadStatisticsMultipleRepoInStrutsFormat()
414 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
415 metadataRepository, SNAPSHOTS, null, null ), Collections.singletonList( createDefaultStats() ) );
416 repositoryStatisticsManagerControl.expectAndReturn( repositoryStatisticsManager.getStatisticsInRange(
417 metadataRepository, INTERNAL, null, null ), Collections.singletonList( createDefaultStats() ) );
418 repositoryStatisticsManagerControl.replay();
419 prepareAction( Arrays.asList( SNAPSHOTS, INTERNAL ), Collections.<String>emptyList() );
421 action.setSelectedRepositories( Collections.singletonList( "[" + SNAPSHOTS + "],[" + INTERNAL + "]" ) );
422 String result = action.downloadStatisticsReport();
423 assertEquals( GenerateReportAction.SEND_FILE, result );
424 assertFalse( action.hasActionErrors() );
425 assertFalse( action.hasFieldErrors() );
427 assertMultiRepoCsvResult();
428 repositoryStatisticsManagerControl.verify();
431 public void testHealthReportSingleRepo()
434 RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
435 RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", INTERNAL );
437 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL,
438 RepositoryProblemFacet.FACET_ID ),
439 Arrays.asList( problem1.getName(), problem2.getName() ) );
440 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL,
441 RepositoryProblemFacet.FACET_ID,
442 problem1.getName() ),
444 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL,
445 RepositoryProblemFacet.FACET_ID,
446 problem2.getName() ),
448 metadataRepositoryControl.replay();
450 action.setRepositoryId( INTERNAL );
452 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
454 String result = action.execute();
455 assertSuccessResult( result );
457 assertEquals( Collections.singleton( INTERNAL ), action.getRepositoriesMap().keySet() );
458 assertEquals( Arrays.asList( problem1, problem2 ), action.getRepositoriesMap().get( INTERNAL ) );
460 metadataRepositoryControl.verify();
463 public void testHealthReportInvalidRowCount()
466 metadataRepositoryControl.replay();
468 action.setRowCount( 0 );
469 action.setRepositoryId( INTERNAL );
471 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
473 String result = action.execute();
474 assertEquals( Action.INPUT, result );
475 assertFalse( action.hasActionErrors() );
476 assertTrue( action.hasFieldErrors() );
478 metadataRepositoryControl.verify();
481 public void testHealthReportAllRepos()
484 RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
485 RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", SNAPSHOTS );
486 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL,
487 RepositoryProblemFacet.FACET_ID ),
488 Arrays.asList( problem1.getName() ) );
489 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( SNAPSHOTS,
490 RepositoryProblemFacet.FACET_ID ),
491 Arrays.asList( problem2.getName() ) );
492 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL,
493 RepositoryProblemFacet.FACET_ID,
494 problem1.getName() ),
496 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( SNAPSHOTS,
497 RepositoryProblemFacet.FACET_ID,
498 problem2.getName() ),
500 metadataRepositoryControl.replay();
502 action.setRepositoryId( GenerateReportAction.ALL_REPOSITORIES );
504 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
506 String result = action.execute();
507 assertSuccessResult( result );
509 assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ), new ArrayList<String>(
510 action.getRepositoriesMap().keySet() ) );
511 assertEquals( Arrays.asList( problem1 ), action.getRepositoriesMap().get( INTERNAL ) );
512 assertEquals( Arrays.asList( problem2 ), action.getRepositoriesMap().get( SNAPSHOTS ) );
514 metadataRepositoryControl.verify();
517 public void testHealthReportSingleRepoByCorrectGroupId()
520 RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
521 RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", INTERNAL );
522 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL,
523 RepositoryProblemFacet.FACET_ID ),
524 Arrays.asList( problem1.getName(), problem2.getName() ) );
525 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL,
526 RepositoryProblemFacet.FACET_ID,
527 problem1.getName() ),
529 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL,
530 RepositoryProblemFacet.FACET_ID,
531 problem2.getName() ),
533 metadataRepositoryControl.replay();
535 action.setGroupId( GROUP_ID );
536 action.setRepositoryId( INTERNAL );
538 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
540 String result = action.execute();
541 assertSuccessResult( result );
543 assertEquals( Collections.singleton( INTERNAL ), action.getRepositoriesMap().keySet() );
544 assertEquals( Arrays.asList( problem1, problem2 ), action.getRepositoriesMap().get( INTERNAL ) );
546 metadataRepositoryControl.verify();
549 public void testHealthReportSingleRepoByCorrectGroupIdAllRepositories()
552 RepositoryProblemFacet problem1 = createProblem( GROUP_ID, "artifactId", INTERNAL );
553 RepositoryProblemFacet problem2 = createProblem( GROUP_ID, "artifactId-2", SNAPSHOTS );
554 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL,
555 RepositoryProblemFacet.FACET_ID ),
556 Arrays.asList( problem1.getName() ) );
557 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( SNAPSHOTS,
558 RepositoryProblemFacet.FACET_ID ),
559 Arrays.asList( problem2.getName() ) );
560 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( INTERNAL,
561 RepositoryProblemFacet.FACET_ID,
562 problem1.getName() ),
564 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacet( SNAPSHOTS,
565 RepositoryProblemFacet.FACET_ID,
566 problem2.getName() ),
568 metadataRepositoryControl.replay();
570 action.setGroupId( GROUP_ID );
571 action.setRepositoryId( GenerateReportAction.ALL_REPOSITORIES );
573 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
575 String result = action.execute();
576 assertSuccessResult( result );
578 assertEquals( Arrays.asList( INTERNAL, SNAPSHOTS ), new ArrayList<String>(
579 action.getRepositoriesMap().keySet() ) );
580 assertEquals( Arrays.asList( problem1 ), action.getRepositoriesMap().get( INTERNAL ) );
581 assertEquals( Arrays.asList( problem2 ), action.getRepositoriesMap().get( SNAPSHOTS ) );
583 metadataRepositoryControl.verify();
586 public void testHealthReportSingleRepoByIncorrectGroupId()
589 metadataRepositoryControl.expectAndReturn( metadataRepository.getMetadataFacets( INTERNAL,
590 RepositoryProblemFacet.FACET_ID ),
591 Collections.<MetadataFacet>emptyList() );
592 metadataRepositoryControl.replay();
594 action.setGroupId( "not.it" );
595 action.setRepositoryId( INTERNAL );
597 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
599 String result = action.execute();
600 assertEquals( GenerateReportAction.BLANK, result );
601 assertFalse( action.hasActionErrors() );
602 assertFalse( action.hasFieldErrors() );
604 metadataRepositoryControl.verify();
607 private void assertMultiRepoCsvResult()
611 "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count,Plugins,Archetypes,Jars,Wars\n" +
612 "snapshots,0,0,0,0,0,0,0,0,0\n" + "internal,0,0,0,0,0,0,0,0,0\n", IOUtils.toString(
613 action.getInputStream() ) );
616 private RepositoryProblemFacet createProblem( String groupId, String artifactId, String repoId )
618 RepositoryProblemFacet problem = new RepositoryProblemFacet();
619 problem.setRepositoryId( repoId );
620 problem.setNamespace( groupId );
621 problem.setProject( artifactId );
622 problem.setProblem( PROBLEM );
626 public void testHealthReportNoRepositoryId()
629 prepareAction( Collections.<String>emptyList(), Arrays.asList( SNAPSHOTS, INTERNAL ) );
631 String result = action.execute();
632 assertEquals( Action.INPUT, result );
633 assertTrue( action.hasFieldErrors() );
636 private void assertSuccessResult( String result )
638 assertEquals( Action.SUCCESS, result );
639 assertFalse( action.hasActionErrors() );
640 assertFalse( action.hasFieldErrors() );
643 private RepositoryStatistics createDefaultStats()
645 return createStats( new Date() );
648 private RepositoryStatistics createStats( Date date )
650 RepositoryStatistics stats = new RepositoryStatistics();
651 stats.setScanStartTime( date );