View Javadoc

1   package org.codehaus.mojo.dashboard.report.plugin.chart;
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.awt.Paint;
20  import java.util.ResourceBundle;
21  
22  import org.codehaus.mojo.dashboard.report.plugin.beans.IDashBoardReportBean;
23  import org.codehaus.mojo.dashboard.report.plugin.beans.SurefireReportBean;
24  import org.jfree.chart.ChartColor;
25  
26  /**
27   *
28   * @author <a href="dvicente72@gmail.com">David Vicente</a>
29   *
30   */
31  public class SurefirePieChartStrategy extends AbstractPieChartStrategy
32  {
33  
34      /**
35       * Default constructor
36       *
37       * @param bundle
38       * @param title
39       * @param dashboardReport
40       */
41      public SurefirePieChartStrategy( ResourceBundle bundle, String title, IDashBoardReportBean dashboardReport )
42      {
43          super( bundle, title, dashboardReport );
44      }
45  
46      /*
47       * (non-Javadoc)
48       *
49       * @see org.codehaus.mojo.dashboard.report.plugin.chart.IChartStrategy#fillDataset()
50       */
51      public void fillDataset()
52      {
53          if ( mDashboardReport != null )
54          {
55              SurefireReportBean fireReportBean = (SurefireReportBean) mDashboardReport;
56  
57              int total = fireReportBean.getNbTests();
58              int error = fireReportBean.getNbErrors();
59              int fail = fireReportBean.getNbFailures();
60              int skip = fireReportBean.getNbSkipped();
61              int success = total - error - fail - skip;
62              defaultdataset.setValue( this.bundle.getString( "report.surefire.label.success" )
63                              + " = " + ( success ), ( success ) );
64  
65              defaultdataset.setValue( this.bundle.getString( "report.surefire.label.errors" )
66                              + " = " + error, error );
67  
68              defaultdataset.setValue( this.bundle.getString( "report.surefire.label.failures" )
69                              + " = " + fail, fail );
70  
71              defaultdataset.setValue( this.bundle.getString( "report.surefire.label.skipped" )
72                              + " = " + skip, skip );
73          }
74      }
75  
76      /**
77       *
78       */
79      public Paint[] getPaintColor()
80      {
81          return new Paint[] { ChartColor.GREEN, ChartColor.RED, ChartColor.ORANGE, ChartColor.LIGHT_GRAY };
82      }
83  
84  }