View Javadoc

1   /*
2    * Copyright 2010-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.testdoc.report.export.doc;
17  
18  import java.util.Comparator;
19  
20  import de.smartics.testdoc.core.doc.UnitTestDoc;
21  import de.smartics.testdoc.core.doc.UnitTestDocNaturalComparator;
22  import de.smartics.testdoc.report.junit.JUnitTestCaseManager;
23  
24  /**
25   * The configuration to control the generation of the report. This is simply a
26   * tool to pass the configuration information from the client (e.g. a Maven
27   * plugin) to the generator.
28   *
29   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
30   * @version $Revision:591 $
31   */
32  public final class ReportConfig
33  {
34    // ********************************* Fields *********************************
35  
36    // --- constants ------------------------------------------------------------
37  
38    // --- members --------------------------------------------------------------
39  
40    /**
41     * The category classes of test scenarios that should be included or not.
42     */
43    private final SelectionFilter selectionFilter;
44  
45    /**
46     * The configuration that tells which report information is to be displayed.
47     */
48    private final InformationFilter informationFilter;
49  
50    /**
51     * The manager to access JUnit report information. Is <code>null</code> if the
52     * information is not to be included.
53     */
54    private final JUnitTestCaseManager junitManager;
55  
56    /**
57     * The configuration of links to images used in reports.
58     */
59    private final ImageHelper imageHelper;
60  
61    /**
62     * The external reports to reference to.
63     */
64    private final ExternalReportReferences reports;
65  
66    /**
67     * The comparator to use to sort the rendering of unit test documentation.
68     */
69    private final Comparator<UnitTestDoc> unitTestDocComparator;
70  
71    // ****************************** Initializer *******************************
72  
73    // ****************************** Constructors ******************************
74  
75    /**
76     * Convenience constructor with default values for structures not needed for
77     * non visual reports.
78     */
79    public ReportConfig()
80    {
81      this(SelectionFilter.STANDARD, InformationFilter.SHOW_DEFAULTS, null,
82          new ImageHelper(null), ExternalReportReferences.EMPTY,
83          new UnitTestDocNaturalComparator());
84    }
85  
86    /**
87     * Default constructor.
88     *
89     * @param selectionFilter the category classes of test scenarios that should
90     *          be included or not.
91     * @param informationFilter the configuration that tells which report
92     *          information is to be displayed.
93     * @param junitManager the manager to access JUnit report information.
94     * @param imageHelper the configuration of links to images used in reports.
95     * @param reports the external reports to reference to.
96     * @param unitTestDocComparator the comparator to use to sort the rendering of
97     *          unit test documentation.
98     */
99    public ReportConfig(final SelectionFilter selectionFilter,
100       final InformationFilter informationFilter,
101       final JUnitTestCaseManager junitManager, final ImageHelper imageHelper,
102       final ExternalReportReferences reports,
103       final Comparator<UnitTestDoc> unitTestDocComparator)
104   {
105     this.selectionFilter = selectionFilter;
106     this.informationFilter = informationFilter;
107     this.junitManager = junitManager;
108     this.imageHelper = imageHelper;
109     this.reports = reports;
110     this.unitTestDocComparator = unitTestDocComparator;
111   }
112 
113   // ****************************** Inner Classes *****************************
114 
115   // ********************************* Methods ********************************
116 
117   // --- init -----------------------------------------------------------------
118 
119   // --- get&set --------------------------------------------------------------
120 
121   /**
122    * Returns the category classes of test scenarios that should be filtered.
123    *
124    * @return the category classes of test scenarios that should be filtered.
125    */
126   public SelectionFilter getSelectionFilter()
127   {
128     return selectionFilter;
129   }
130 
131   /**
132    * Returns the configuration that tells which report information is to be
133    * displayed.
134    *
135    * @return the configuration that tells which report information is to be
136    *         displayed.
137    */
138   public InformationFilter getInformationFilter()
139   {
140     return informationFilter;
141   }
142 
143   /**
144    * Returns the manager to access JUnit report information. Is
145    * <code>null</code> if the information is not to be included.
146    *
147    * @return the manager to access JUnit report information.
148    */
149   public JUnitTestCaseManager getJunitManager()
150   {
151     return junitManager;
152   }
153 
154   /**
155    * Returns the configuration of links to images used in reports.
156    *
157    * @return the configuration of links to images used in reports.
158    */
159   public ImageHelper getImageHelper()
160   {
161     return imageHelper;
162   }
163 
164   /**
165    * Returns the external reports to reference to.
166    *
167    * @return the external reports to reference to.
168    */
169   public ExternalReportReferences getReports()
170   {
171     return reports;
172   }
173 
174   /**
175    * Returns the comparator to use to sort the rendering of unit test
176    * documentation.
177    *
178    * @return the comparator to use to sort the rendering of unit test
179    *         documentation.
180    */
181   public Comparator<UnitTestDoc> getUnitTestDocComparator()
182   {
183     return unitTestDocComparator;
184   }
185 
186   // --- business -------------------------------------------------------------
187 
188   // --- object basics --------------------------------------------------------
189 
190 }