diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java index 74240b244..ba706210f 100644 --- a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DefaultArtifactReporter.java @@ -18,12 +18,26 @@ package org.apache.maven.repository.reporting; import org.apache.maven.artifact.Artifact; +import java.util.List; +import java.util.ArrayList; + /** * @author John Tolentino */ public class DefaultArtifactReporter 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 ) { diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java new file mode 100644 index 000000000..8f3505de7 --- /dev/null +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Failure.java @@ -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 John Tolentino + */ +public class Failure + extends ReportError +{ + public Failure( Artifact artifact, String reason ) + { + super( artifact, reason ); + } +} diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java new file mode 100644 index 000000000..7d7a99320 --- /dev/null +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportError.java @@ -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 John Tolentino + */ +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; + } +} diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java new file mode 100644 index 000000000..773ac4165 --- /dev/null +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/ReportResult.java @@ -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 John Tolentino + */ +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; + } +} diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java new file mode 100644 index 000000000..22927d914 --- /dev/null +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Success.java @@ -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 John Tolentino + */ +public class Success + extends ReportResult +{ + public Success( Artifact artifact ) + { + super( artifact ); + } +} diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java new file mode 100644 index 000000000..15a6391e6 --- /dev/null +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/reports/Warning.java @@ -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 John Tolentino + */ +public class Warning + extends ReportError +{ + public Warning( Artifact artifact, String reason ) + { + super( artifact, reason ); + } +} diff --git a/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java new file mode 100644 index 000000000..a081aed20 --- /dev/null +++ b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockArtifactReportProcessor.java @@ -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 John Tolentino + */ +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(); + } +} diff --git a/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java new file mode 100644 index 000000000..df3232182 --- /dev/null +++ b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/MockRepositoryQueryLayer.java @@ -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 John Tolentino + */ +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(); + } +} diff --git a/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java new file mode 100644 index 000000000..5df02c333 --- /dev/null +++ b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/ReportCondition.java @@ -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 John Tolentino + */ +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; + } +}