View Javadoc

1   package org.codehaus.mojo.dashboard.report.plugin.beans;
2   
3   /*
4    * Copyright 2006 David Vicente
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 java.util.Date;
20  
21  /**
22   * 
23   * @author <a href="dvicente72@gmail.com">David Vicente</a>
24   * 
25   */
26  public class SurefireReportBean extends AbstractReportBean
27  {
28      /**
29       * 
30       */
31      private int nbTests;
32      /**
33       * 
34       */
35      private int nbErrors;
36      /**
37       * 
38       */
39      private int nbFailures;
40      /**
41       * 
42       */
43      private int nbSkipped;
44      /**
45       * 
46       */
47      private double sucessRate;
48      /**
49       * 
50       */
51      private double elapsedTime;
52      /**
53       * 
54       */
55      private static final int PCENT = 100;
56      /**
57       * 
58       *
59       */
60      public SurefireReportBean()
61      {
62      }
63      /**
64       * 
65       * @param projectName
66       */
67      public SurefireReportBean( Date dateGeneration )
68      {
69          super( dateGeneration );
70      }
71      /**
72       * 
73       * @return
74       */
75      public double getElapsedTime()
76      {
77          return elapsedTime;
78      }
79      /**
80       * 
81       * @param elapsedTime
82       */
83      public void setElapsedTime( double elapsedTime )
84      {
85          this.elapsedTime = elapsedTime;
86      }
87      /**
88       * 
89       * @return
90       */
91      public int getNbErrors()
92      {
93          return nbErrors;
94      }
95      /**
96       * 
97       * @param nbErrors
98       */
99      public void setNbErrors( int nbErrors )
100     {
101         this.nbErrors = nbErrors;
102     }
103     /**
104      * 
105      * @return
106      */
107     public int getNbFailures()
108     {
109         return nbFailures;
110     }
111     /**
112      * 
113      * @param nbFailures
114      */
115     public void setNbFailures( int nbFailures )
116     {
117         this.nbFailures = nbFailures;
118     }
119     /**
120      * 
121      * @return
122      */
123     public int getNbSkipped()
124     {
125         return nbSkipped;
126     }
127     /**
128      * 
129      * @param nbSkipped
130      */
131     public void setNbSkipped( int nbSkipped )
132     {
133         this.nbSkipped = nbSkipped;
134     }
135     /**
136      * 
137      * @return
138      */
139     public int getNbTests()
140     {
141         return nbTests;
142     }
143     /**
144      * 
145      * @param nbTests
146      */
147     public void setNbTests( int nbTests )
148     {
149         this.nbTests = nbTests;
150     }
151     /**
152      * 
153      * @return
154      */
155     public double getSucessRate()
156     {
157         return sucessRate;
158     }
159     /**
160      * 
161      * @param sucessRate
162      */
163     public void setSucessRate( double sucessRate )
164     {
165         this.sucessRate = sucessRate;
166     }
167     /**
168      * 
169      * @param dashboardReport
170      */
171     public void merge( IDashBoardReportBean dashboardReport )
172     {
173         if ( dashboardReport != null && dashboardReport instanceof SurefireReportBean )
174         {
175             this.nbTests = this.nbTests + ( (SurefireReportBean) dashboardReport ).getNbTests();
176 
177             this.nbErrors = this.nbErrors + ( (SurefireReportBean) dashboardReport ).getNbErrors();
178 
179             this.nbFailures = this.nbFailures + ( (SurefireReportBean) dashboardReport ).getNbFailures();
180 
181             this.nbSkipped = this.nbSkipped + ( (SurefireReportBean) dashboardReport ).getNbSkipped();
182 
183             this.elapsedTime = this.elapsedTime + ( (SurefireReportBean) dashboardReport ).getElapsedTime();
184 
185             if ( this.nbTests == 0 )
186             {
187                 this.sucessRate = 0D;
188             }
189             else
190             {
191                 double success = (double) ( this.nbTests - this.nbErrors - this.nbFailures - this.nbSkipped );
192                 this.sucessRate = ( success / (double) this.nbTests ) * PCENT;
193             }
194         }
195     }
196 }