]> source.dussan.org Git - archiva.git/blob
54697973f02eabea1e5d53418871aadead418bdc
[archiva.git] /
1 package org.apache.maven.archiva.reporting;
2
3 /*
4  * Copyright 2005-2006 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 import org.apache.maven.artifact.Artifact;
20 import org.apache.maven.artifact.repository.ArtifactRepository;
21 import org.apache.maven.model.Model;
22
23 import java.util.ArrayList;
24 import java.util.Iterator;
25 import java.util.List;
26
27 /**
28  * 
29  */
30 public class MockArtifactReportProcessor
31     implements ArtifactReportProcessor
32 {
33     private List reportConditions;
34
35     private Iterator iterator;
36
37     public MockArtifactReportProcessor()
38     {
39         reportConditions = new ArrayList();
40     }
41
42     public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter,
43                                  ArtifactRepository repository )
44     {
45         if ( iterator == null || !iterator.hasNext() ) // not initialized or reached end of the list. start again
46         {
47             iterator = reportConditions.iterator();
48         }
49         if ( !reportConditions.isEmpty() )
50         {
51             while ( iterator.hasNext() )
52             {
53                 ReportCondition reportCondition = (ReportCondition) iterator.next();
54                 int i = reportCondition.getResult();
55                 if ( i == ReportCondition.SUCCESS )
56                 {
57                     reporter.addSuccess( reportCondition.getArtifact() );
58                 }
59                 else if ( i == ReportCondition.WARNING )
60                 {
61                     reporter.addWarning( reportCondition.getArtifact(), reportCondition.getReason() );
62                 }
63                 else if ( i == ReportCondition.FAILURE )
64                 {
65                     reporter.addFailure( reportCondition.getArtifact(), reportCondition.getReason() );
66                 }
67             }
68         }
69     }
70
71     public void addReturnValue( int result, Artifact artifact, String reason )
72     {
73         reportConditions.add( new ReportCondition( result, artifact, reason ) );
74     }
75
76     public void clearList()
77     {
78         reportConditions.clear();
79     }
80 }