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() );
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 ) );
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(); )
{
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 )
Iterator getRepositoryMetadataWarningIterator();
- int getFailures();
+ int getNumFailures();
- int getSuccesses();
+ int getNumSuccesses();
- int getWarnings();
+ int getNumWarnings();
}
*/
private Artifact createArtifact( RepositoryMetadata metadata )
{
- return artifactFactory.createBuildArtifact( metadata.getGroupId(), metadata.getArtifactId(),
- metadata.getBaseVersion(), "pom" );
+ return artifactFactory.createProjectArtifact( metadata.getGroupId(), metadata.getArtifactId(),
+ metadata.getBaseVersion() );
}
/**
*/
private Artifact createArtifact( RepositoryMetadata metadata, String version )
{
- return artifactFactory.createBuildArtifact( metadata.getGroupId(), metadata.getArtifactId(), version, "pom" );
+ return artifactFactory.createProjectArtifact( metadata.getGroupId(), metadata.getArtifactId(), version );
}
/**
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();
}
import java.util.Iterator;
/**
- *
+ *
*/
public class ArtifactReportProcessorTest
extends AbstractRepositoryReportsTestCase
private static final String VALID = "temp";
- private MockArtifactReporter reporter;
+ private ArtifactReporter reporter;
private Artifact artifact;
throws Exception
{
super.setUp();
- reporter = new MockArtifactReporter();
+ reporter = new DefaultArtifactReporter();
artifact = new MockArtifact();
model = new Model();
processor = new DefaultArtifactReportProcessor();
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() );
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() );
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()
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() );
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()
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()
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()
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
import java.util.Iterator;
/**
- *
+ *
*/
public class ArtifactReporterTest
extends AbstractRepositoryReportsTestCase
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() );
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()
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()
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()
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()
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()
private MetadataReportProcessor badMetadataReportProcessor;
+ private ArtifactReporter reporter = new DefaultArtifactReporter();
+
protected void setUp()
throws Exception
{
public void testMetadataMissingLastUpdated()
throws ReportProcessorException
{
- ArtifactReporter reporter = new MockArtifactReporter();
-
Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
Versioning versioning = new Versioning();
public void testMetadataValidVersions()
throws ReportProcessorException
{
- ArtifactReporter reporter = new MockArtifactReporter();
-
Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
Versioning versioning = new Versioning();
public void testMetadataMissingADirectory()
throws ReportProcessorException
{
- ArtifactReporter reporter = new MockArtifactReporter();
-
Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
Versioning versioning = new Versioning();
public void testMetadataInvalidArtifactVersion()
throws ReportProcessorException
{
- ArtifactReporter reporter = new MockArtifactReporter();
-
Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
Versioning versioning = new Versioning();
public void testMoreThanOneMetadataVersionErrors()
throws ReportProcessorException
{
- ArtifactReporter reporter = new MockArtifactReporter();
-
Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
Versioning versioning = new Versioning();
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" ) );
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" ) );
public void testIncompletePluginMetadata()
throws ReportProcessorException
{
- ArtifactReporter reporter = new MockArtifactReporter();
-
RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" );
metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) );
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" ) );
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", "" ) );
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" ) );
public void testValidSnapshotMetadata()
throws ReportProcessorException
{
- ArtifactReporter reporter = new MockArtifactReporter();
-
Artifact artifact =
artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-SNAPSHOT", "type" );
public void testInvalidSnapshotMetadata()
throws ReportProcessorException
{
- ArtifactReporter reporter = new MockArtifactReporter();
-
Artifact artifact =
artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-SNAPSHOT", "type" );
{
private ArtifactReportProcessor artifactReportProcessor;
- private ArtifactReporter reporter = new MockArtifactReporter();
+ private ArtifactReporter reporter = new DefaultArtifactReporter();
private MetadataReportProcessor metadataReportProcessor;
new DefaultArtifact( "checksumTest", "validArtifact", version, "compile", "jar", "", handler );
artifactReportProcessor.processArtifact( null, artifact, reporter, repository );
- assertEquals( 2, reporter.getSuccesses() );
+ assertEquals( 2, reporter.getNumSuccesses() );
}
/**
new DefaultArtifact( "checksumTest", "invalidArtifact", version, "compile", "jar", "", handler );
artifactReportProcessor.processArtifact( null, artifact, reporter, repository );
- assertEquals( 2, reporter.getFailures() );
+ assertEquals( 2, reporter.getNumFailures() );
}
/**
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 );
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() );
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() );
{
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() );
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() );
{
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() );
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() );
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() );
File indexDirectory;
+ private DefaultArtifactReporter reporter = new DefaultArtifactReporter();
+
protected void setUp()
throws Exception
{
{
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()
{
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()
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,
{
private ArtifactReportProcessor artifactReportProcessor;
- private ArtifactReporter reporter = new MockArtifactReporter();
+ private ArtifactReporter reporter = new DefaultArtifactReporter();
public void setUp()
throws Exception
new DefaultArtifact( "org.apache.maven", "artifactId", version, "compile", "pom", "", handler );
artifactReportProcessor.processArtifact( null, artifact, reporter, repository );
- assertEquals( 1, reporter.getFailures() );
+ assertEquals( 1, reporter.getNumFailures() );
}
Artifact artifact = new DefaultArtifact( "groupId", "artifactId", version, "compile", "pom", "", handler );
artifactReportProcessor.processArtifact( null, artifact, reporter, repository );
- assertEquals( 1, reporter.getSuccesses() );
+ assertEquals( 1, reporter.getNumSuccesses() );
}
Artifact artifact = new DefaultArtifact( "groupId", "artifactId", version, "compile", "jar", "", handler );
artifactReportProcessor.processArtifact( null, artifact, reporter, repository );
- assertEquals( 1, reporter.getWarnings() );
+ assertEquals( 1, reporter.getNumWarnings() );
}
}
{
private ArtifactReportProcessor artifactReportProcessor;
- private ArtifactReporter reporter = new MockArtifactReporter();
+ private ArtifactReporter reporter = new DefaultArtifactReporter();
private MavenXpp3Reader pomReader;
Model model = readPom( path );
artifactReportProcessor.processArtifact( model, artifact, reporter, repository );
- assertEquals( 1, reporter.getSuccesses() );
+ assertEquals( 1, reporter.getNumSuccesses() );
}
/**
Model model = readPom( path );
artifactReportProcessor.processArtifact( model, artifact, reporter, repository );
- assertEquals( 1, reporter.getSuccesses() );
+ assertEquals( 1, reporter.getNumSuccesses() );
}
/**
Model model = readPom( path );
artifactReportProcessor.processArtifact( model, artifact, reporter, repository );
- assertEquals( 1, reporter.getFailures() );
+ assertEquals( 1, reporter.getNumFailures() );
}
/**
Model model = readPom( path );
artifactReportProcessor.processArtifact( model, artifact, reporter, repository );
- assertEquals( 1, reporter.getFailures() );
+ assertEquals( 1, reporter.getNumFailures() );
}
private Model readPom( String path )
Model model = readPom( path );
artifactReportProcessor.processArtifact( model, artifact, reporter, repository );
- assertEquals( 1, reporter.getFailures() );
+ assertEquals( 1, reporter.getNumFailures() );
}
/**
Model model = readPom( path );
artifactReportProcessor.processArtifact( model, artifact, reporter, repository );
- assertEquals( 1, reporter.getFailures() );
+ assertEquals( 1, reporter.getNumFailures() );
}
}
+++ /dev/null
-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 <a href="mailto:brett@apache.org">Brett Porter</a>
- * @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();
- }
-}