]> source.dussan.org Git - archiva.git/blob
38ed0124dc76502e845c92258eba2c847f666b90
[archiva.git] /
1 package org.apache.maven.repository.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 artifactRepository )
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                 switch ( reportCondition.getResult() )
55                 {
56                     case ReportCondition.SUCCESS:
57                     {
58                         reporter.addSuccess( reportCondition.getArtifact() );
59                         break;
60                     }
61                     case ReportCondition.WARNING:
62                     {
63                         reporter.addWarning( reportCondition.getArtifact(), reportCondition.getReason() );
64                         break;
65                     }
66                     case ReportCondition.FAILURE:
67                     {
68                         reporter.addFailure( reportCondition.getArtifact(), reportCondition.getReason() );
69                         break;
70                     }
71                 }
72             }
73         }
74     }
75
76     public void addReturnValue( int result, Artifact artifact, String reason )
77     {
78         reportConditions.add( new ReportCondition( result, artifact, reason ) );
79     }
80
81     public void clearList()
82     {
83         reportConditions.clear();
84     }
85 }