mirror of https://github.com/apache/archiva.git
PR: MRM-51
Submitted by: John Tolentino Mock Objects and additional class files git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@351613 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7695127b05
commit
8ac619974c
|
@ -18,12 +18,26 @@ package org.apache.maven.repository.reporting;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
*/
|
*/
|
||||||
public class DefaultArtifactReporter
|
public class DefaultArtifactReporter
|
||||||
implements ArtifactReporter
|
implements ArtifactReporter
|
||||||
{
|
{
|
||||||
|
private List success;
|
||||||
|
private List warnings;
|
||||||
|
private List failures;
|
||||||
|
|
||||||
|
|
||||||
|
public DefaultArtifactReporter()
|
||||||
|
{
|
||||||
|
success = new ArrayList();
|
||||||
|
warnings = new ArrayList();
|
||||||
|
failures = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
public void addFailure( Artifact artifact, String reason )
|
public void addFailure( Artifact artifact, String reason )
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.maven.repository.reporting.reports;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public class Failure
|
||||||
|
extends ReportError
|
||||||
|
{
|
||||||
|
public Failure( Artifact artifact, String reason )
|
||||||
|
{
|
||||||
|
super( artifact, reason );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.apache.maven.repository.reporting.reports;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public class ReportError
|
||||||
|
extends ReportResult
|
||||||
|
{
|
||||||
|
String reason = "";
|
||||||
|
|
||||||
|
public ReportError( Artifact artifact, String reason )
|
||||||
|
{
|
||||||
|
super( artifact );
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason()
|
||||||
|
{
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason( String reason )
|
||||||
|
{
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.apache.maven.repository.reporting.reports;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public class ReportResult
|
||||||
|
{
|
||||||
|
private Artifact artifact;
|
||||||
|
|
||||||
|
public ReportResult( Artifact artifact )
|
||||||
|
{
|
||||||
|
this.artifact = artifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact getArtifact()
|
||||||
|
{
|
||||||
|
return artifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArtifact( Artifact artifact )
|
||||||
|
{
|
||||||
|
this.artifact = artifact;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package org.apache.maven.repository.reporting.reports;
|
||||||
|
|
||||||
|
import org.apache.maven.repository.reporting.reports.ReportResult;
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public class Success
|
||||||
|
extends ReportResult
|
||||||
|
{
|
||||||
|
public Success( Artifact artifact )
|
||||||
|
{
|
||||||
|
super( artifact );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package org.apache.maven.repository.reporting.reports;
|
||||||
|
|
||||||
|
import org.apache.maven.repository.reporting.reports.ReportError;
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public class Warning
|
||||||
|
extends ReportError
|
||||||
|
{
|
||||||
|
public Warning( Artifact artifact, String reason )
|
||||||
|
{
|
||||||
|
super( artifact, reason );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package org.apache.maven.repository.reporting;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public class MockArtifactReportProcessor
|
||||||
|
implements ArtifactReportProcessor
|
||||||
|
{
|
||||||
|
private List reportConditions;
|
||||||
|
private Iterator iterator;
|
||||||
|
|
||||||
|
public MockArtifactReportProcessor()
|
||||||
|
{
|
||||||
|
reportConditions = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter )
|
||||||
|
{
|
||||||
|
if ( iterator == null || !iterator.hasNext() ) // not initialized or reached end of the list. start again
|
||||||
|
{
|
||||||
|
iterator = reportConditions.iterator();
|
||||||
|
}
|
||||||
|
if ( ! reportConditions.isEmpty() )
|
||||||
|
{
|
||||||
|
ReportCondition reportCondition = (ReportCondition) iterator.next();
|
||||||
|
switch( reportCondition.getResult() )
|
||||||
|
{
|
||||||
|
case ReportCondition.SUCCESS :
|
||||||
|
{
|
||||||
|
reporter.addSuccess( reportCondition.getArtifact() );
|
||||||
|
}
|
||||||
|
case ReportCondition.WARNING :
|
||||||
|
{
|
||||||
|
reporter.addWarning( reportCondition.getArtifact(), reportCondition.getReason() );
|
||||||
|
}
|
||||||
|
case ReportCondition.FAILURE :
|
||||||
|
{
|
||||||
|
reporter.addFailure( reportCondition.getArtifact(), reportCondition.getReason() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addReturnValue( int result, Artifact artifact, String reason )
|
||||||
|
{
|
||||||
|
reportConditions.add( new ReportCondition( result, artifact, reason ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearList()
|
||||||
|
{
|
||||||
|
reportConditions.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
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 org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public class MockRepositoryQueryLayer
|
||||||
|
implements RepositoryQueryLayer
|
||||||
|
{
|
||||||
|
private List queryConditions;
|
||||||
|
private Iterator iterator;
|
||||||
|
|
||||||
|
public MockRepositoryQueryLayer()
|
||||||
|
{
|
||||||
|
queryConditions = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsArtifact( Artifact artifact )
|
||||||
|
{
|
||||||
|
if ( iterator == null || !iterator.hasNext() ) // not initialized or reached end of the list. start again
|
||||||
|
{
|
||||||
|
iterator = queryConditions.iterator();
|
||||||
|
}
|
||||||
|
if ( queryConditions.isEmpty() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ( (Boolean) iterator.next() ).booleanValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addReturnValue( boolean queryCondition )
|
||||||
|
{
|
||||||
|
queryConditions.add( new Boolean( queryCondition ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearList()
|
||||||
|
{
|
||||||
|
queryConditions.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
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 org.apache.maven.artifact.Artifact;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author <a href="mailto:jtolentino@mergere.com">John Tolentino</a>
|
||||||
|
*/
|
||||||
|
public class ReportCondition
|
||||||
|
{
|
||||||
|
public final static int SUCCESS = 0;
|
||||||
|
public final static int FAILURE = -1;
|
||||||
|
public final static int WARNING = 1;
|
||||||
|
|
||||||
|
private int result;
|
||||||
|
private Artifact artifact;
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
public ReportCondition( int result, Artifact artifact, String reason )
|
||||||
|
{
|
||||||
|
this.result = result;
|
||||||
|
this.artifact = artifact;
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getResult()
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult( int result )
|
||||||
|
{
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact getArtifact()
|
||||||
|
{
|
||||||
|
return artifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArtifact( Artifact artifact )
|
||||||
|
{
|
||||||
|
this.artifact = artifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason()
|
||||||
|
{
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason( String reason )
|
||||||
|
{
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue