From f85defbfa5ee994ff735c3630de091e56e23b1ab Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 5 Sep 2006 04:45:59 +0000 Subject: [PATCH] [MRM-161] some reporting clean up git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@440257 13f79535-47bb-0310-9956-ffa450edef68 --- .../converter/RepositoryConverterTest.java | 30 ++--- .../archiva/reporting/ArtifactReporter.java | 6 +- .../reporting/BadMetadataReportProcessor.java | 6 +- .../reporting/DefaultArtifactReporter.java | 6 +- .../ArtifactReportProcessorTest.java | 120 ++++++++--------- .../reporting/ArtifactReporterTest.java | 34 ++--- .../BadMetadataReportProcessorTest.java | 28 +--- .../ChecksumArtifactReporterTest.java | 8 +- .../DefaultArtifactReporterTest.java | 42 +++--- ...licateArtifactFileReportProcessorTest.java | 42 +++--- ...InvalidPomArtifactReportProcessorTest.java | 8 +- .../LocationArtifactReportProcessorTest.java | 14 +- .../reporting/MockArtifactReporter.java | 121 ------------------ 13 files changed, 156 insertions(+), 309 deletions(-) delete mode 100755 archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/MockArtifactReporter.java diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java index a1fdd0f69..fd957e46a 100644 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java +++ b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java @@ -282,9 +282,9 @@ public class RepositoryConverterTest versionMetadataFile.delete(); repositoryConverter.convert( artifact, targetRepository, reporter ); - assertEquals( "check no errors", 0, reporter.getFailures() ); - assertEquals( "check number of warnings", 2, reporter.getWarnings() ); - assertEquals( "check success", 1, reporter.getSuccesses() ); + assertEquals( "check no errors", 0, reporter.getNumFailures() ); + assertEquals( "check number of warnings", 2, reporter.getNumWarnings() ); + assertEquals( "check success", 1, reporter.getNumSuccesses() ); File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); assertTrue( "Check artifact created", artifactFile.exists() ); @@ -453,9 +453,9 @@ public class RepositoryConverterTest Artifact artifact = createArtifact( "test", "noPomArtifact", "1.0.0" ); repositoryConverter.convert( artifact, targetRepository, reporter ); - assertEquals( "check no errors", 0, reporter.getFailures() ); - assertEquals( "check no warnings", 1, reporter.getWarnings() ); - assertEquals( "check success", 1, reporter.getSuccesses() ); + assertEquals( "check no errors", 0, reporter.getNumFailures() ); + assertEquals( "check no warnings", 1, reporter.getNumWarnings() ); + assertEquals( "check success", 1, reporter.getNumSuccesses() ); assertEquals( "check warning message", getI18nString( "warning.missing.pom" ), getWarning().getReason() ); File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); @@ -733,9 +733,9 @@ public class RepositoryConverterTest artifacts.add( createArtifact( "test", "artifact-two", "1.0.0" ) ); artifacts.add( createArtifact( "test", "artifact-three", "1.0.0" ) ); repositoryConverter.convert( artifacts, targetRepository, reporter ); - assertEquals( "check no errors", 0, reporter.getFailures() ); - assertEquals( "check no warnings", 0, reporter.getWarnings() ); - assertEquals( "check successes", 3, reporter.getSuccesses() ); + assertEquals( "check no errors", 0, reporter.getNumFailures() ); + assertEquals( "check no warnings", 0, reporter.getNumWarnings() ); + assertEquals( "check successes", 3, reporter.getNumSuccesses() ); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { @@ -906,16 +906,16 @@ public class RepositoryConverterTest private void checkSuccess() { - assertEquals( "check no errors", 0, reporter.getFailures() ); - assertEquals( "check no warnings", 0, reporter.getWarnings() ); - assertEquals( "check success", 1, reporter.getSuccesses() ); + assertEquals( "check no errors", 0, reporter.getNumFailures() ); + assertEquals( "check no warnings", 0, reporter.getNumWarnings() ); + assertEquals( "check success", 1, reporter.getNumSuccesses() ); } private void checkFailure() { - assertEquals( "check num errors", 1, reporter.getFailures() ); - assertEquals( "check no warnings", 0, reporter.getWarnings() ); - assertEquals( "check no success", 0, reporter.getSuccesses() ); + assertEquals( "check num errors", 1, reporter.getNumFailures() ); + assertEquals( "check no warnings", 0, reporter.getNumWarnings() ); + assertEquals( "check no success", 0, reporter.getNumSuccesses() ); } private String getI18nString( String key ) diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ArtifactReporter.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ArtifactReporter.java index af5b539d8..dab65753c 100644 --- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ArtifactReporter.java +++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ArtifactReporter.java @@ -80,9 +80,9 @@ public interface ArtifactReporter Iterator getRepositoryMetadataWarningIterator(); - int getFailures(); + int getNumFailures(); - int getSuccesses(); + int getNumSuccesses(); - int getWarnings(); + int getNumWarnings(); } diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java index 919940c80..bb3869ad2 100644 --- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java +++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java @@ -290,8 +290,8 @@ public class BadMetadataReportProcessor */ private Artifact createArtifact( RepositoryMetadata metadata ) { - return artifactFactory.createBuildArtifact( metadata.getGroupId(), metadata.getArtifactId(), - metadata.getBaseVersion(), "pom" ); + return artifactFactory.createProjectArtifact( metadata.getGroupId(), metadata.getArtifactId(), + metadata.getBaseVersion() ); } /** @@ -299,7 +299,7 @@ public class BadMetadataReportProcessor */ private Artifact createArtifact( RepositoryMetadata metadata, String version ) { - return artifactFactory.createBuildArtifact( metadata.getGroupId(), metadata.getArtifactId(), version, "pom" ); + return artifactFactory.createProjectArtifact( metadata.getGroupId(), metadata.getArtifactId(), version ); } /** diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultArtifactReporter.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultArtifactReporter.java index 9d944a86f..d70e77144 100644 --- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultArtifactReporter.java +++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultArtifactReporter.java @@ -101,17 +101,17 @@ public class DefaultArtifactReporter return metadataWarnings.iterator(); } - public int getFailures() + public int getNumFailures() { return artifactFailures.size() + metadataFailures.size(); } - public int getSuccesses() + public int getNumSuccesses() { return artifactSuccesses.size() + metadataSuccesses.size(); } - public int getWarnings() + public int getNumWarnings() { return artifactWarnings.size() + metadataWarnings.size(); } diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReportProcessorTest.java index 17b4723fd..f1e245368 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReportProcessorTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReportProcessorTest.java @@ -23,7 +23,7 @@ import org.apache.maven.model.Model; import java.util.Iterator; /** - * + * */ public class ArtifactReportProcessorTest extends AbstractRepositoryReportsTestCase @@ -32,7 +32,7 @@ public class ArtifactReportProcessorTest private static final String VALID = "temp"; - private MockArtifactReporter reporter; + private ArtifactReporter reporter; private Artifact artifact; @@ -48,7 +48,7 @@ public class ArtifactReportProcessorTest throws Exception { super.setUp(); - reporter = new MockArtifactReporter(); + reporter = new DefaultArtifactReporter(); artifact = new MockArtifact(); model = new Model(); processor = new DefaultArtifactReportProcessor(); @@ -57,9 +57,9 @@ public class ArtifactReportProcessorTest public void testNullArtifact() { processor.processArtifact( model, null, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); assertEquals( ArtifactReporter.NULL_ARTIFACT, result.getReason() ); @@ -72,9 +72,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); setRequiredElements( artifact, VALID, VALID, VALID ); processor.processArtifact( null, artifact, reporter, null ); - assertEquals( 1, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 1, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); assertEquals( ArtifactReporter.NULL_MODEL, result.getReason() ); @@ -87,9 +87,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); setRequiredElements( artifact, VALID, VALID, VALID ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 1, reporter.getSuccesses() ); - assertEquals( 0, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 1, reporter.getNumSuccesses() ); + assertEquals( 0, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); } public void testArtifactNotFound() @@ -99,9 +99,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); setRequiredElements( artifact, VALID, VALID, VALID ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); assertEquals( ArtifactReporter.ARTIFACT_NOT_FOUND, result.getReason() ); @@ -123,9 +123,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 2, reporter.getSuccesses() ); - assertEquals( 0, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 2, reporter.getNumSuccesses() ); + assertEquals( 0, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); } public void testValidArtifactWithValidSingleDependency() @@ -144,9 +144,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 2, reporter.getSuccesses() ); - assertEquals( 0, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 2, reporter.getNumSuccesses() ); + assertEquals( 0, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); } public void testValidArtifactWithValidMultipleDependencies() @@ -173,9 +173,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, VALID, VALID, VALID ); processor.setRepositoryQueryLayer( queryLayer ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 6, reporter.getSuccesses() ); - assertEquals( 0, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 6, reporter.getNumSuccesses() ); + assertEquals( 0, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); } public void testValidArtifactWithAnInvalidDependency() @@ -202,9 +202,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, VALID, VALID, VALID ); processor.setRepositoryQueryLayer( queryLayer ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 5, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 5, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -219,9 +219,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, EMPTY_STRING, VALID, VALID ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -236,9 +236,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, VALID, EMPTY_STRING, VALID ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -253,9 +253,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, VALID, VALID, EMPTY_STRING ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -270,9 +270,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, null, VALID, VALID ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -287,9 +287,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, VALID, null, VALID ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -304,9 +304,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, VALID, VALID, null ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -321,9 +321,9 @@ public class ArtifactReportProcessorTest setRequiredElements( artifact, null, null, null ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 3, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 3, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -350,9 +350,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 1, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 1, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -375,9 +375,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 1, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 1, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -400,9 +400,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 1, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 1, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); @@ -425,9 +425,9 @@ public class ArtifactReportProcessorTest processor.setRepositoryQueryLayer( queryLayer ); processor.processArtifact( model, artifact, reporter, null ); - assertEquals( 1, reporter.getSuccesses() ); - assertEquals( 3, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 1, reporter.getNumSuccesses() ); + assertEquals( 3, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); Iterator failures = reporter.getArtifactFailureIterator(); ArtifactResult result = (ArtifactResult) failures.next(); diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReporterTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReporterTest.java index e6a7e9ad5..80a09f72d 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReporterTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ArtifactReporterTest.java @@ -24,7 +24,7 @@ import org.apache.maven.model.Model; import java.util.Iterator; /** - * + * */ public class ArtifactReporterTest extends AbstractRepositoryReportsTestCase @@ -57,7 +57,7 @@ public class ArtifactReporterTest processor.processArtifact( model, artifact, reporter, null ); Iterator success = reporter.getArtifactSuccessIterator(); assertTrue( success.hasNext() ); - assertEquals( 1, reporter.getSuccesses() ); + assertEquals( 1, reporter.getNumSuccesses() ); Artifact result = ( (ArtifactResult) success.next() ).getArtifact(); assertEquals( "groupId", result.getGroupId() ); assertEquals( "artifactId", result.getArtifactId() ); @@ -81,9 +81,9 @@ public class ArtifactReporterTest success.next(); } assertEquals( 3, i ); - assertEquals( 3, reporter.getSuccesses() ); - assertEquals( 0, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 3, reporter.getNumSuccesses() ); + assertEquals( 0, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); } public void testArtifactReporterSingleFailure() @@ -94,9 +94,9 @@ public class ArtifactReporterTest assertTrue( failure.hasNext() ); failure.next(); assertFalse( failure.hasNext() ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 1, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 1, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); } public void testArtifactReporterMultipleFailure() @@ -113,9 +113,9 @@ public class ArtifactReporterTest failure.next(); } assertEquals( 3, i ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 3, reporter.getFailures() ); - assertEquals( 0, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 3, reporter.getNumFailures() ); + assertEquals( 0, reporter.getNumWarnings() ); } public void testFailureMessages() @@ -138,9 +138,9 @@ public class ArtifactReporterTest assertTrue( warning.hasNext() ); warning.next(); assertFalse( warning.hasNext() ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 0, reporter.getFailures() ); - assertEquals( 1, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 0, reporter.getNumFailures() ); + assertEquals( 1, reporter.getNumWarnings() ); } public void testArtifactReporterMultipleWarning() @@ -157,9 +157,9 @@ public class ArtifactReporterTest warning.next(); } assertEquals( 3, i ); - assertEquals( 0, reporter.getSuccesses() ); - assertEquals( 0, reporter.getFailures() ); - assertEquals( 3, reporter.getWarnings() ); + assertEquals( 0, reporter.getNumSuccesses() ); + assertEquals( 0, reporter.getNumFailures() ); + assertEquals( 3, reporter.getNumWarnings() ); } public void testWarningMessages() diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java index 808773b82..73f58393d 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java @@ -35,6 +35,8 @@ public class BadMetadataReportProcessorTest private MetadataReportProcessor badMetadataReportProcessor; + private ArtifactReporter reporter = new DefaultArtifactReporter(); + protected void setUp() throws Exception { @@ -48,8 +50,6 @@ public class BadMetadataReportProcessorTest public void testMetadataMissingLastUpdated() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" ); Versioning versioning = new Versioning(); @@ -71,8 +71,6 @@ public class BadMetadataReportProcessorTest public void testMetadataValidVersions() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" ); Versioning versioning = new Versioning(); @@ -91,8 +89,6 @@ public class BadMetadataReportProcessorTest public void testMetadataMissingADirectory() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" ); Versioning versioning = new Versioning(); @@ -117,8 +113,6 @@ public class BadMetadataReportProcessorTest public void testMetadataInvalidArtifactVersion() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" ); Versioning versioning = new Versioning(); @@ -145,8 +139,6 @@ public class BadMetadataReportProcessorTest public void testMoreThanOneMetadataVersionErrors() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" ); Versioning versioning = new Versioning(); @@ -178,8 +170,6 @@ public class BadMetadataReportProcessorTest public void testValidPluginMetadata() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" ); metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) ); metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default2" ) ); @@ -193,8 +183,6 @@ public class BadMetadataReportProcessorTest public void testMissingMetadataPlugin() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" ); metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) ); metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default2" ) ); @@ -214,8 +202,6 @@ public class BadMetadataReportProcessorTest public void testIncompletePluginMetadata() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" ); metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) ); @@ -234,8 +220,6 @@ public class BadMetadataReportProcessorTest public void testInvalidPluginArtifactId() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" ); metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) ); metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default2" ) ); @@ -259,8 +243,6 @@ public class BadMetadataReportProcessorTest public void testInvalidPluginPrefix() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" ); metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", null ) ); metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "" ) ); @@ -283,8 +265,6 @@ public class BadMetadataReportProcessorTest public void testDuplicatePluginPrefixes() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" ); metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) ); metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default" ) ); @@ -302,8 +282,6 @@ public class BadMetadataReportProcessorTest public void testValidSnapshotMetadata() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-SNAPSHOT", "type" ); @@ -322,8 +300,6 @@ public class BadMetadataReportProcessorTest public void testInvalidSnapshotMetadata() throws ReportProcessorException { - ArtifactReporter reporter = new MockArtifactReporter(); - Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-SNAPSHOT", "type" ); diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java index 7b28f6014..6132204db 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/ChecksumArtifactReporterTest.java @@ -40,7 +40,7 @@ public class ChecksumArtifactReporterTest { private ArtifactReportProcessor artifactReportProcessor; - private ArtifactReporter reporter = new MockArtifactReporter(); + private ArtifactReporter reporter = new DefaultArtifactReporter(); private MetadataReportProcessor metadataReportProcessor; @@ -67,7 +67,7 @@ public class ChecksumArtifactReporterTest new DefaultArtifact( "checksumTest", "validArtifact", version, "compile", "jar", "", handler ); artifactReportProcessor.processArtifact( null, artifact, reporter, repository ); - assertEquals( 2, reporter.getSuccesses() ); + assertEquals( 2, reporter.getNumSuccesses() ); } /** @@ -82,7 +82,7 @@ public class ChecksumArtifactReporterTest new DefaultArtifact( "checksumTest", "invalidArtifact", version, "compile", "jar", "", handler ); artifactReportProcessor.processArtifact( null, artifact, reporter, repository ); - assertEquals( 2, reporter.getFailures() ); + assertEquals( 2, reporter.getNumFailures() ); } /** @@ -151,7 +151,7 @@ public class ChecksumArtifactReporterTest new DefaultArtifact( "checksumTest", "validArtifact", version, "compile", "jar", "", handler ); artifactReportProcessor.processArtifact( null, artifact, reporter, repository ); - assertEquals( 2, reporter.getFailures() ); + assertEquals( 2, reporter.getNumFailures() ); RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact ); metadataReportProcessor.processMetadata( metadata, repository, reporter ); diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DefaultArtifactReporterTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DefaultArtifactReporterTest.java index fb4bb274f..7cd3b94bf 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DefaultArtifactReporterTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DefaultArtifactReporterTest.java @@ -38,9 +38,9 @@ public class DefaultArtifactReporterTest public void testEmptyArtifactReporter() { - assertEquals( "No failures", 0, reporter.getFailures() ); - assertEquals( "No warnings", 0, reporter.getWarnings() ); - assertEquals( "No successes", 0, reporter.getSuccesses() ); + assertEquals( "No failures", 0, reporter.getNumFailures() ); + assertEquals( "No warnings", 0, reporter.getNumWarnings() ); + assertEquals( "No successes", 0, reporter.getNumSuccesses() ); assertFalse( "No artifact failures", reporter.getArtifactFailureIterator().hasNext() ); assertFalse( "No artifact warnings", reporter.getArtifactWarningIterator().hasNext() ); assertFalse( "No artifact successes", reporter.getArtifactSuccessIterator().hasNext() ); @@ -52,9 +52,9 @@ public class DefaultArtifactReporterTest public void testMetadataSingleFailure() { reporter.addFailure( metadata, "Single Failure Reason" ); - assertEquals( "failures count", 1, reporter.getFailures() ); - assertEquals( "warnings count", 0, reporter.getWarnings() ); - assertEquals( "successes count", 0, reporter.getSuccesses() ); + assertEquals( "failures count", 1, reporter.getNumFailures() ); + assertEquals( "warnings count", 0, reporter.getNumWarnings() ); + assertEquals( "successes count", 0, reporter.getNumSuccesses() ); Iterator results = reporter.getRepositoryMetadataFailureIterator(); assertTrue( "must have failures", results.hasNext() ); @@ -68,9 +68,9 @@ public class DefaultArtifactReporterTest { reporter.addFailure( metadata, "First Failure Reason" ); reporter.addFailure( metadata, "Second Failure Reason" ); - assertEquals( "failures count", 2, reporter.getFailures() ); - assertEquals( "warnings count", 0, reporter.getWarnings() ); - assertEquals( "successes count", 0, reporter.getSuccesses() ); + assertEquals( "failures count", 2, reporter.getNumFailures() ); + assertEquals( "warnings count", 0, reporter.getNumWarnings() ); + assertEquals( "successes count", 0, reporter.getNumSuccesses() ); Iterator results = reporter.getRepositoryMetadataFailureIterator(); assertTrue( "must have failures", results.hasNext() ); @@ -87,9 +87,9 @@ public class DefaultArtifactReporterTest public void testMetadataSingleWarning() { reporter.addWarning( metadata, "Single Warning Message" ); - assertEquals( "failures count", 0, reporter.getFailures() ); - assertEquals( "warnings count", 1, reporter.getWarnings() ); - assertEquals( "successes count", 0, reporter.getSuccesses() ); + assertEquals( "failures count", 0, reporter.getNumFailures() ); + assertEquals( "warnings count", 1, reporter.getNumWarnings() ); + assertEquals( "successes count", 0, reporter.getNumSuccesses() ); Iterator results = reporter.getRepositoryMetadataWarningIterator(); assertTrue( "must have failures", results.hasNext() ); @@ -103,9 +103,9 @@ public class DefaultArtifactReporterTest { reporter.addWarning( metadata, "First Warning" ); reporter.addWarning( metadata, "Second Warning" ); - assertEquals( "failures count", 0, reporter.getFailures() ); - assertEquals( "warnings count", 2, reporter.getWarnings() ); - assertEquals( "successes count", 0, reporter.getSuccesses() ); + assertEquals( "failures count", 0, reporter.getNumFailures() ); + assertEquals( "warnings count", 2, reporter.getNumWarnings() ); + assertEquals( "successes count", 0, reporter.getNumSuccesses() ); Iterator results = reporter.getRepositoryMetadataWarningIterator(); assertTrue( "must have warnings", results.hasNext() ); @@ -122,9 +122,9 @@ public class DefaultArtifactReporterTest public void testMetadataSingleSuccess() { reporter.addSuccess( metadata ); - assertEquals( "failures count", 0, reporter.getFailures() ); - assertEquals( "warnings count", 0, reporter.getWarnings() ); - assertEquals( "successes count", 1, reporter.getSuccesses() ); + assertEquals( "failures count", 0, reporter.getNumFailures() ); + assertEquals( "warnings count", 0, reporter.getNumWarnings() ); + assertEquals( "successes count", 1, reporter.getNumSuccesses() ); Iterator results = reporter.getRepositoryMetadataSuccessIterator(); assertTrue( "must have successes", results.hasNext() ); @@ -143,9 +143,9 @@ public class DefaultArtifactReporterTest reporter.addSuccess( metadata ); reporter.addSuccess( metadata2 ); - assertEquals( "failures count", 0, reporter.getFailures() ); - assertEquals( "warnings count", 0, reporter.getWarnings() ); - assertEquals( "successes count", 2, reporter.getSuccesses() ); + assertEquals( "failures count", 0, reporter.getNumFailures() ); + assertEquals( "warnings count", 0, reporter.getNumWarnings() ); + assertEquals( "successes count", 2, reporter.getNumSuccesses() ); Iterator results = reporter.getRepositoryMetadataSuccessIterator(); assertTrue( "must have successes", results.hasNext() ); diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DuplicateArtifactFileReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DuplicateArtifactFileReportProcessorTest.java index c1223137b..8e55976d9 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DuplicateArtifactFileReportProcessorTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DuplicateArtifactFileReportProcessorTest.java @@ -43,6 +43,8 @@ public class DuplicateArtifactFileReportProcessorTest File indexDirectory; + private DefaultArtifactReporter reporter = new DefaultArtifactReporter(); + protected void setUp() throws Exception { @@ -73,38 +75,32 @@ public class DuplicateArtifactFileReportProcessorTest { artifact.setFile( null ); - MockArtifactReporter reporter = new MockArtifactReporter(); - processor.processArtifact( model, artifact, reporter, repository ); - assertEquals( "Check no successes", 0, reporter.getSuccesses() ); - assertEquals( "Check warnings", 1, reporter.getWarnings() ); - assertEquals( "Check no failures", 0, reporter.getFailures() ); + assertEquals( "Check no successes", 0, reporter.getNumSuccesses() ); + assertEquals( "Check warnings", 1, reporter.getNumWarnings() ); + assertEquals( "Check no failures", 0, reporter.getNumFailures() ); } public void testSuccessOnAlreadyIndexedArtifact() throws Exception { - MockArtifactReporter reporter = new MockArtifactReporter(); - processor.processArtifact( model, artifact, reporter, repository ); - assertEquals( "Check no successes", 1, reporter.getSuccesses() ); - assertEquals( "Check warnings", 0, reporter.getWarnings() ); - assertEquals( "Check no failures", 0, reporter.getFailures() ); + assertEquals( "Check no successes", 1, reporter.getNumSuccesses() ); + assertEquals( "Check warnings", 0, reporter.getNumWarnings() ); + assertEquals( "Check no failures", 0, reporter.getNumFailures() ); } public void testSuccessOnDifferentGroupId() throws Exception { - MockArtifactReporter reporter = new MockArtifactReporter(); - artifact.setGroupId( "different.groupId" ); processor.processArtifact( model, artifact, reporter, repository ); - assertEquals( "Check no successes", 1, reporter.getSuccesses() ); - assertEquals( "Check warnings", 0, reporter.getWarnings() ); - assertEquals( "Check no failures", 0, reporter.getFailures() ); + assertEquals( "Check no successes", 1, reporter.getNumSuccesses() ); + assertEquals( "Check warnings", 0, reporter.getNumWarnings() ); + assertEquals( "Check no failures", 0, reporter.getNumFailures() ); } public void testSuccessOnNewArtifact() @@ -112,13 +108,11 @@ public class DuplicateArtifactFileReportProcessorTest { Artifact newArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "1.0-alpha-1", "pom" ); - MockArtifactReporter reporter = new MockArtifactReporter(); - processor.processArtifact( model, newArtifact, reporter, repository ); - assertEquals( "Check no successes", 1, reporter.getSuccesses() ); - assertEquals( "Check warnings", 0, reporter.getWarnings() ); - assertEquals( "Check no failures", 0, reporter.getFailures() ); + assertEquals( "Check no successes", 1, reporter.getNumSuccesses() ); + assertEquals( "Check warnings", 0, reporter.getNumWarnings() ); + assertEquals( "Check no failures", 0, reporter.getNumFailures() ); } public void testFailure() @@ -128,13 +122,11 @@ public class DuplicateArtifactFileReportProcessorTest artifact.getVersion(), artifact.getType() ); duplicate.setFile( artifact.getFile() ); - MockArtifactReporter reporter = new MockArtifactReporter(); - processor.processArtifact( model, duplicate, reporter, repository ); - assertEquals( "Check no successes", 0, reporter.getSuccesses() ); - assertEquals( "Check warnings", 0, reporter.getWarnings() ); - assertEquals( "Check no failures", 1, reporter.getFailures() ); + assertEquals( "Check no successes", 0, reporter.getNumSuccesses() ); + assertEquals( "Check warnings", 0, reporter.getNumWarnings() ); + assertEquals( "Check no failures", 1, reporter.getNumFailures() ); } private Artifact createArtifact( String groupId, String artifactId, String baseVersion, String version, diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/InvalidPomArtifactReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/InvalidPomArtifactReportProcessorTest.java index 40fc565b3..511601d96 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/InvalidPomArtifactReportProcessorTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/InvalidPomArtifactReportProcessorTest.java @@ -30,7 +30,7 @@ public class InvalidPomArtifactReportProcessorTest { private ArtifactReportProcessor artifactReportProcessor; - private ArtifactReporter reporter = new MockArtifactReporter(); + private ArtifactReporter reporter = new DefaultArtifactReporter(); public void setUp() throws Exception @@ -51,7 +51,7 @@ public class InvalidPomArtifactReportProcessorTest new DefaultArtifact( "org.apache.maven", "artifactId", version, "compile", "pom", "", handler ); artifactReportProcessor.processArtifact( null, artifact, reporter, repository ); - assertEquals( 1, reporter.getFailures() ); + assertEquals( 1, reporter.getNumFailures() ); } @@ -66,7 +66,7 @@ public class InvalidPomArtifactReportProcessorTest Artifact artifact = new DefaultArtifact( "groupId", "artifactId", version, "compile", "pom", "", handler ); artifactReportProcessor.processArtifact( null, artifact, reporter, repository ); - assertEquals( 1, reporter.getSuccesses() ); + assertEquals( 1, reporter.getNumSuccesses() ); } @@ -81,6 +81,6 @@ public class InvalidPomArtifactReportProcessorTest Artifact artifact = new DefaultArtifact( "groupId", "artifactId", version, "compile", "jar", "", handler ); artifactReportProcessor.processArtifact( null, artifact, reporter, repository ); - assertEquals( 1, reporter.getWarnings() ); + assertEquals( 1, reporter.getNumWarnings() ); } } diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java index f1acef97e..38d1ef064 100644 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java +++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java @@ -38,7 +38,7 @@ public class LocationArtifactReportProcessorTest { private ArtifactReportProcessor artifactReportProcessor; - private ArtifactReporter reporter = new MockArtifactReporter(); + private ArtifactReporter reporter = new DefaultArtifactReporter(); private MavenXpp3Reader pomReader; @@ -74,7 +74,7 @@ public class LocationArtifactReportProcessorTest Model model = readPom( path ); artifactReportProcessor.processArtifact( model, artifact, reporter, repository ); - assertEquals( 1, reporter.getSuccesses() ); + assertEquals( 1, reporter.getNumSuccesses() ); } /** @@ -92,7 +92,7 @@ public class LocationArtifactReportProcessorTest Model model = readPom( path ); artifactReportProcessor.processArtifact( model, artifact, reporter, repository ); - assertEquals( 1, reporter.getSuccesses() ); + assertEquals( 1, reporter.getNumSuccesses() ); } /** @@ -110,7 +110,7 @@ public class LocationArtifactReportProcessorTest Model model = readPom( path ); artifactReportProcessor.processArtifact( model, artifact, reporter, repository ); - assertEquals( 1, reporter.getFailures() ); + assertEquals( 1, reporter.getNumFailures() ); } /** @@ -129,7 +129,7 @@ public class LocationArtifactReportProcessorTest Model model = readPom( path ); artifactReportProcessor.processArtifact( model, artifact, reporter, repository ); - assertEquals( 1, reporter.getFailures() ); + assertEquals( 1, reporter.getNumFailures() ); } private Model readPom( String path ) @@ -165,7 +165,7 @@ public class LocationArtifactReportProcessorTest Model model = readPom( path ); artifactReportProcessor.processArtifact( model, artifact, reporter, repository ); - assertEquals( 1, reporter.getFailures() ); + assertEquals( 1, reporter.getNumFailures() ); } /** @@ -184,6 +184,6 @@ public class LocationArtifactReportProcessorTest Model model = readPom( path ); artifactReportProcessor.processArtifact( model, artifact, reporter, repository ); - assertEquals( 1, reporter.getFailures() ); + assertEquals( 1, reporter.getNumFailures() ); } } diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/MockArtifactReporter.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/MockArtifactReporter.java deleted file mode 100755 index 0666b95c6..000000000 --- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/MockArtifactReporter.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.apache.maven.archiva.reporting; - -/* - * Copyright 2005-2006 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Mock implementation of the artifact reporter. - * - * @author Brett Porter - * @version $Id$ - */ -public class MockArtifactReporter - implements ArtifactReporter -{ - private List artifactFailures = new ArrayList(); - - private List artifactSuccesses = new ArrayList(); - - private List artifactWarnings = new ArrayList(); - - private List metadataFailures = new ArrayList(); - - private List metadataSuccesses = new ArrayList(); - - private List metadataWarnings = new ArrayList(); - - public void addFailure( Artifact artifact, String reason ) - { - artifactFailures.add( new ArtifactResult( artifact, reason ) ); - } - - public void addSuccess( Artifact artifact ) - { - artifactSuccesses.add( new ArtifactResult( artifact ) ); - } - - public void addWarning( Artifact artifact, String message ) - { - artifactWarnings.add( new ArtifactResult( artifact, message ) ); - } - - public void addFailure( RepositoryMetadata metadata, String reason ) - { - metadataFailures.add( new RepositoryMetadataResult( metadata, reason ) ); - } - - public void addSuccess( RepositoryMetadata metadata ) - { - metadataSuccesses.add( new RepositoryMetadataResult( metadata ) ); - } - - public void addWarning( RepositoryMetadata metadata, String message ) - { - metadataWarnings.add( new RepositoryMetadataResult( metadata, message ) ); - } - - public Iterator getArtifactFailureIterator() - { - return artifactFailures.iterator(); - } - - public Iterator getArtifactSuccessIterator() - { - return artifactSuccesses.iterator(); - } - - public Iterator getArtifactWarningIterator() - { - return artifactWarnings.iterator(); - } - - public Iterator getRepositoryMetadataFailureIterator() - { - return metadataFailures.iterator(); - } - - public Iterator getRepositoryMetadataSuccessIterator() - { - return metadataSuccesses.iterator(); - } - - public Iterator getRepositoryMetadataWarningIterator() - { - return metadataWarnings.iterator(); - } - - public int getFailures() - { - return artifactFailures.size(); - } - - public int getSuccesses() - { - return artifactSuccesses.size(); - } - - public int getWarnings() - { - return artifactWarnings.size(); - } -} -- 2.39.5