More unit tests and some code formatting

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@354723 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Edwin L. Punzalan 2005-12-07 05:45:43 +00:00
parent 6f43288cd1
commit 7f3c7e3b75
10 changed files with 431 additions and 51 deletions

View File

@ -34,8 +34,15 @@ public interface ArtifactReporter
public static String NULL_MODEL = "Provided model was null";
public static String NULL_ARTIFACT = "Provided artifact was null";
public static String EMPTY_GROUP_ID = "Group id was empty or null";
public static String EMPTY_ARTIFACT_ID = "Artifact id was empty or null";
public static String EMPTY_VERSION = "Version was empty or null";
public static String EMPTY_DEPENDENCY_GROUP_ID = "Group id was empty or null";
public static String EMPTY_DEPENDENCY_ARTIFACT_ID = "Artifact id was empty or null";
public static String EMPTY_DEPENDENCY_VERSION = "Version was empty or null";
public static String NO_DEPENDENCIES = "Artifact has no dependencies";
public static String ARTIFACT_NOT_FOUND = "Artifact does not exist in the repository";
public static String DEPENDENCY_NOT_FOUND = "Artifact's dependency does not exist in the repository";
void addFailure( Artifact artifact, String reason );

View File

@ -31,18 +31,25 @@ import java.util.Iterator;
public class DefaultArtifactReportProcessor
implements ArtifactReportProcessor
{
private final static String EMPTY_STRING = "";
// plexus components
private ArtifactFactory artifactFactory;
private RepositoryQueryLayer repositoryQueryLayer;
public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter, ArtifactRepository repository )
public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter,
ArtifactRepository repository )
{
if ( artifact == null )
{
reporter.addFailure( artifact, ArtifactReporter.NULL_ARTIFACT );
}
else
{
processArtifact( artifact, reporter );
}
if ( model == null )
{
reporter.addFailure( artifact, ArtifactReporter.NULL_MODEL );
@ -50,38 +57,85 @@ public class DefaultArtifactReportProcessor
else
{
List dependencies = model.getDependencies();
if ( ( artifact != null ) && ( model != null ) && ( dependencies != null ) )
processDependencies( dependencies, reporter );
}
}
protected void processArtifact( Artifact artifact, ArtifactReporter reporter )
{
boolean hasFailed = false;
if ( EMPTY_STRING.equals( artifact.getGroupId() ) || artifact.getGroupId() == null )
{
reporter.addFailure( artifact, ArtifactReporter.EMPTY_GROUP_ID );
hasFailed = true;
}
if ( EMPTY_STRING.equals( artifact.getArtifactId() ) || artifact.getArtifactId() == null )
{
reporter.addFailure( artifact, ArtifactReporter.EMPTY_ARTIFACT_ID );
hasFailed = true;
}
if ( EMPTY_STRING.equals( artifact.getVersion() ) || artifact.getVersion() == null )
{
reporter.addFailure( artifact, ArtifactReporter.EMPTY_VERSION );
hasFailed = true;
}
if ( !hasFailed )
{
if ( repositoryQueryLayer.containsArtifact( artifact ) )
{
if ( repositoryQueryLayer.containsArtifact( artifact ) )
{
reporter.addSuccess( artifact );
}
else
{
reporter.addFailure( artifact, ArtifactReporter.ARTIFACT_NOT_FOUND );
}
if ( dependencies.size() > 0 )
{
Iterator iterator = dependencies.iterator();
while ( iterator.hasNext() )
{
Dependency dependency = (Dependency) iterator.next();
if ( repositoryQueryLayer.containsArtifact( createArtifact( dependency ) ) )
{
reporter.addSuccess( artifact );
}
else
{
reporter.addFailure( artifact, ArtifactReporter.ARTIFACT_NOT_FOUND );
}
}
}
reporter.addSuccess( artifact );
}
else
{
reporter.addFailure( artifact, ArtifactReporter.ARTIFACT_NOT_FOUND );
}
}
}
protected void processDependencies( List dependencies, ArtifactReporter reporter )
{
if ( dependencies.size() > 0 )
{
Iterator iterator = dependencies.iterator();
while ( iterator.hasNext() )
{
boolean hasFailed = false;
Dependency dependency = (Dependency) iterator.next();
Artifact artifact = createArtifact( dependency );
if ( EMPTY_STRING.equals( dependency.getGroupId() ) || dependency.getGroupId() == null )
{
reporter.addFailure( artifact, ArtifactReporter.EMPTY_DEPENDENCY_GROUP_ID );
hasFailed = true;
}
if ( EMPTY_STRING.equals( dependency.getArtifactId() ) || dependency.getArtifactId() == null )
{
reporter.addFailure( artifact, ArtifactReporter.EMPTY_DEPENDENCY_ARTIFACT_ID );
hasFailed = true;
}
if ( EMPTY_STRING.equals( dependency.getVersion() ) || dependency.getVersion() == null )
{
reporter.addFailure( artifact, ArtifactReporter.EMPTY_DEPENDENCY_VERSION );
hasFailed = true;
}
if ( !hasFailed )
{
if ( repositoryQueryLayer.containsArtifact( artifact ) )
{
reporter.addSuccess( artifact );
}
else
{
reporter.addFailure( artifact, ArtifactReporter.DEPENDENCY_NOT_FOUND );
}
}
}
}
}
/**
* Only used for passing a mock object when unit testing
*
* @param repositoryQueryLayer
*/
protected void setRepositoryQueryLayer( RepositoryQueryLayer repositoryQueryLayer )
@ -91,6 +145,7 @@ public class DefaultArtifactReportProcessor
/**
* Only used for passing a mock object when unit testing
*
* @param artifactFactory
*/
protected void setArtifactFactory( ArtifactFactory artifactFactory )

View File

@ -1,8 +1,22 @@
/*
* Copyright (c) 2005 Your Corporation. All Rights Reserved.
*/
package org.apache.maven.repository.reporting;
/*
* Copyright 2001-2005 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 java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;

View File

@ -20,12 +20,18 @@ import org.apache.maven.model.Model;
import org.apache.maven.model.Dependency;
import org.apache.maven.artifact.Artifact;
import java.util.Iterator;
/**
*
*/
public class ArtifactReportProcessorTest
extends AbstractRepositoryReportsTestCase
{
private final static String EMPTY_STRING = "";
private final static String VALID = "temp";
protected MockArtifactReporter reporter;
protected Artifact artifact;
@ -50,14 +56,24 @@ public class ArtifactReportProcessorTest
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.NULL_ARTIFACT.equals( result.getReason() ) );
}
public void testNoProjectDescriptor()
{
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, VALID, VALID, VALID );
processor.processArtifact( null, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getSuccesses() == 1 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.NULL_MODEL.equals( result.getReason() ) );
}
public void testArtifactFoundButNoDirectDependencies()
@ -65,6 +81,7 @@ public class ArtifactReportProcessorTest
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, VALID, VALID, VALID );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 1 );
assertTrue( reporter.getFailures() == 0 );
@ -76,10 +93,35 @@ public class ArtifactReportProcessorTest
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_NOT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, VALID, VALID, VALID );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.ARTIFACT_NOT_FOUND.equals( result.getReason() ) );
}
public void testValidArtifactWithNullDependency()
{
MockArtifactFactory artifactFactory = new MockArtifactFactory();
processor.setArtifactFactory( artifactFactory );
setRequiredElements( artifact, VALID, VALID, VALID );
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
Dependency dependency = new Dependency();
setRequiredElements( dependency, VALID, VALID, VALID );
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 2 );
assertTrue( reporter.getFailures() == 0 );
assertTrue( reporter.getWarnings() == 0 );
}
public void testValidArtifactWithValidSingleDependency()
@ -87,10 +129,12 @@ public class ArtifactReportProcessorTest
MockArtifactFactory artifactFactory = new MockArtifactFactory();
processor.setArtifactFactory( artifactFactory );
setRequiredElements( artifact, VALID, VALID, VALID );
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
Dependency dependency = new Dependency();
setRequiredElements( dependency, VALID, VALID, VALID );
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
@ -110,6 +154,7 @@ public class ArtifactReportProcessorTest
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
Dependency dependency = new Dependency();
setRequiredElements( dependency, VALID, VALID, VALID );
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
model.addDependency( dependency );
@ -121,6 +166,7 @@ public class ArtifactReportProcessorTest
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
setRequiredElements( artifact, VALID, VALID, VALID );
processor.setRepositoryQueryLayer( queryLayer );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 6 );
@ -137,6 +183,7 @@ public class ArtifactReportProcessorTest
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
Dependency dependency = new Dependency();
setRequiredElements( dependency, VALID, VALID, VALID );
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
model.addDependency( dependency );
@ -148,11 +195,243 @@ public class ArtifactReportProcessorTest
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
setRequiredElements( artifact, VALID, VALID, VALID );
processor.setRepositoryQueryLayer( queryLayer );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 5 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.DEPENDENCY_NOT_FOUND.equals( result.getReason() ) );
}
public void testEmptyGroupId()
{
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, EMPTY_STRING, VALID, VALID );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_GROUP_ID.equals( result.getReason() ) );
}
public void testEmptyArtifactId()
{
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, VALID, EMPTY_STRING, VALID );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_ARTIFACT_ID.equals( result.getReason() ) );
}
public void testEmptyVersion()
{
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, VALID, VALID, EMPTY_STRING );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_VERSION.equals( result.getReason() ) );
}
public void testNullGroupId()
{
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, null, VALID, VALID );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_GROUP_ID.equals( result.getReason() ) );
}
public void testNullArtifactId()
{
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, VALID, null, VALID );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_ARTIFACT_ID.equals( result.getReason() ) );
}
public void testNullVersion()
{
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, VALID, VALID, null );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_VERSION.equals( result.getReason() ) );
}
public void testMultipleFailures()
{
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
setRequiredElements( artifact, null, null, null );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 0 );
assertTrue( reporter.getFailures() == 3 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_GROUP_ID.equals( result.getReason() ) );
result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_ARTIFACT_ID.equals( result.getReason() ) );
result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_VERSION.equals( result.getReason() ) );
}
public void testValidArtifactWithInvalidDependencyGroupId()
{
MockArtifactFactory artifactFactory = new MockArtifactFactory();
processor.setArtifactFactory( artifactFactory );
setRequiredElements( artifact, VALID, VALID, VALID );
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
Dependency dependency = new Dependency();
setRequiredElements( dependency, null, VALID, VALID );
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 1 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_DEPENDENCY_GROUP_ID.equals( result.getReason() ) );
}
public void testValidArtifactWithInvalidDependencyArtifactId()
{
MockArtifactFactory artifactFactory = new MockArtifactFactory();
processor.setArtifactFactory( artifactFactory );
setRequiredElements( artifact, VALID, VALID, VALID );
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
Dependency dependency = new Dependency();
setRequiredElements( dependency, VALID, null, VALID );
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 1 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_DEPENDENCY_ARTIFACT_ID.equals( result.getReason() ) );
}
public void testValidArtifactWithInvalidDependencyVersion()
{
MockArtifactFactory artifactFactory = new MockArtifactFactory();
processor.setArtifactFactory( artifactFactory );
setRequiredElements( artifact, VALID, VALID, VALID );
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
Dependency dependency = new Dependency();
setRequiredElements( dependency, VALID, VALID, null );
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 1 );
assertTrue( reporter.getFailures() == 1 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_DEPENDENCY_VERSION.equals( result.getReason() ) );
}
public void testValidArtifactWithInvalidDependencyRequiredElements()
{
MockArtifactFactory artifactFactory = new MockArtifactFactory();
processor.setArtifactFactory( artifactFactory );
setRequiredElements( artifact, VALID, VALID, VALID );
MockRepositoryQueryLayer queryLayer = new MockRepositoryQueryLayer();
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
Dependency dependency = new Dependency();
setRequiredElements( dependency, null, null, null );
model.addDependency( dependency );
queryLayer.addReturnValue( RepositoryQueryLayer.ARTIFACT_FOUND );
processor.setRepositoryQueryLayer( queryLayer );
processor.processArtifact( model, artifact, reporter, null );
assertTrue( reporter.getSuccesses() == 1 );
assertTrue( reporter.getFailures() == 3 );
assertTrue( reporter.getWarnings() == 0 );
Iterator failures = reporter.getArtifactFailureIterator();
ArtifactResult result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_DEPENDENCY_GROUP_ID.equals( result.getReason() ) );
result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_DEPENDENCY_ARTIFACT_ID.equals( result.getReason() ) );
result = (ArtifactResult) failures.next();
assertTrue( ArtifactReporter.EMPTY_DEPENDENCY_VERSION.equals( result.getReason() ) );
}
protected void tearDown()
@ -163,4 +442,18 @@ public class ArtifactReportProcessorTest
reporter = null;
super.tearDown();
}
protected void setRequiredElements( Artifact artifact, String groupId, String artifactId, String version )
{
artifact.setGroupId( groupId );
artifact.setArtifactId( artifactId );
artifact.setVersion( version );
}
protected void setRequiredElements( Dependency dependency, String groupId, String artifactId, String version )
{
dependency.setGroupId( groupId );
dependency.setArtifactId( artifactId );
dependency.setVersion( version );
}
}

View File

@ -61,7 +61,11 @@ public class ArtifactReporterTest
processor.processArtifact( model, artifact, reporter, null );
Iterator success = reporter.getArtifactSuccessIterator();
assertTrue( success.hasNext() );
success.next();
assertTrue( reporter.getSuccesses() == 1 );
Artifact result = ( (ArtifactResult) success.next() ).getArtifact();
assertTrue( "groupId".equals( result.getGroupId() ) );
assertTrue( "artifactId".equals( result.getArtifactId() ) );
assertTrue( "1.0-alpha-1".equals( result.getVersion() ) );
assertFalse( success.hasNext() );
}
@ -125,9 +129,9 @@ public class ArtifactReporterTest
processor.addReturnValue( ReportCondition.FAILURE, artifact, "failed thrice" );
processor.processArtifact( model, artifact, reporter, null );
Iterator failure = reporter.getArtifactFailureIterator();
assertTrue( "failed once".equals( ((ArtifactResult) failure.next()).getReason() ) );
assertTrue( "failed twice".equals( ((ArtifactResult) failure.next()).getReason() ) );
assertTrue( "failed thrice".equals( ((ArtifactResult) failure.next()).getReason() ) );
assertTrue( "failed once".equals( ( (ArtifactResult) failure.next() ).getReason() ) );
assertTrue( "failed twice".equals( ( (ArtifactResult) failure.next() ).getReason() ) );
assertTrue( "failed thrice".equals( ( (ArtifactResult) failure.next() ).getReason() ) );
}
public void testArtifactReporterSingleWarning()
@ -169,9 +173,9 @@ public class ArtifactReporterTest
processor.addReturnValue( ReportCondition.WARNING, artifact, "all right... that does it!" );
processor.processArtifact( model, artifact, reporter, null );
Iterator warning = reporter.getArtifactWarningIterator();
assertTrue( "i'm warning you".equals( ((ArtifactResult) warning.next()).getReason() ) );
assertTrue( "you have to stop now".equals( ((ArtifactResult) warning.next()).getReason() ) );
assertTrue( "all right... that does it!".equals( ((ArtifactResult) warning.next()).getReason() ) );
assertTrue( "i'm warning you".equals( ( (ArtifactResult) warning.next() ).getReason() ) );
assertTrue( "you have to stop now".equals( ( (ArtifactResult) warning.next() ).getReason() ) );
assertTrue( "all right... that does it!".equals( ( (ArtifactResult) warning.next() ).getReason() ) );
}
protected void tearDown()

View File

@ -17,7 +17,6 @@ package org.apache.maven.repository.reporting;
* limitations under the License.
*/
import java.util.Iterator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
@ -27,6 +26,8 @@ import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.artifact.versioning.VersionRange;
import java.util.Iterator;
public class ChecksumArtifactReporterTest
extends AbstractChecksumArtifactReporterTest
{

View File

@ -16,13 +16,14 @@ package org.apache.maven.repository.reporting;
* limitations under the License.
*/
import java.util.Iterator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import java.util.Iterator;
/**
*
*/

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.maven.artifact.Artifact;
/**
*

View File

@ -35,24 +35,28 @@ import java.util.List;
public class MockArtifact
implements Artifact
{
private String groupId;
private String artifactId;
private String version;
public String getGroupId()
{
return null;
return groupId;
}
public String getArtifactId()
{
return null;
return artifactId;
}
public String getVersion()
{
return null;
return version;
}
public void setVersion( String s )
{
version = s;
}
public String getScope()
@ -176,10 +180,12 @@ public class MockArtifact
public void setGroupId( String s )
{
groupId = s;
}
public void setArtifactId( String s )
{
artifactId = s;
}
public boolean isSnapshot()

View File

@ -1,13 +1,5 @@
package org.apache.maven.repository.reporting;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
@ -24,6 +16,14 @@ import java.util.ArrayList;
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
/**
*
*/