View Javadoc
1   package org.apache.maven.plugins.surefire.report;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import static org.apache.maven.shared.utils.StringUtils.isNotBlank;
23  
24  /**
25   *
26   */
27  public final class ReportTestCase
28  {
29      private String fullClassName;
30  
31      private String className;
32  
33      private String fullName;
34  
35      private String name;
36  
37      private float time;
38  
39      private String failureMessage;
40  
41      private String failureType;
42  
43      private String failureErrorLine;
44  
45      private String failureDetail;
46  
47      private boolean hasFailure;
48  
49      private boolean hasError;
50  
51      private boolean hasSkipped;
52  
53      public String getName()
54      {
55          return name;
56      }
57  
58      public ReportTestCase setName( String name )
59      {
60          this.name = name;
61          return this;
62      }
63  
64      public String getFullClassName()
65      {
66          return fullClassName;
67      }
68  
69      public ReportTestCase setFullClassName( String name )
70      {
71          fullClassName = name;
72          return this;
73      }
74  
75      public String getClassName()
76      {
77          return className;
78      }
79  
80      public ReportTestCase setClassName( String name )
81      {
82          className = name;
83          return this;
84      }
85  
86      public float getTime()
87      {
88          return time;
89      }
90  
91      public ReportTestCase setTime( float time )
92      {
93          this.time = time;
94          return this;
95      }
96  
97      public String getFullName()
98      {
99          return fullName;
100     }
101 
102     public ReportTestCase setFullName( String fullName )
103     {
104         this.fullName = fullName;
105         return this;
106     }
107 
108     public String getFailureMessage()
109     {
110         return failureMessage;
111     }
112 
113     private ReportTestCase setFailureMessage( String failureMessage )
114     {
115         this.failureMessage = failureMessage;
116         return this;
117     }
118 
119     public String getFailureType()
120     {
121         return failureType;
122     }
123 
124     public String getFailureErrorLine()
125     {
126         return failureErrorLine;
127     }
128 
129     public ReportTestCase setFailureErrorLine( String failureErrorLine )
130     {
131         this.failureErrorLine = failureErrorLine;
132         return this;
133     }
134 
135     public String getFailureDetail()
136     {
137         return failureDetail;
138     }
139 
140     public ReportTestCase setFailureDetail( String failureDetail )
141     {
142         this.failureDetail = failureDetail;
143         return this;
144     }
145 
146     public ReportTestCase setFailure( String message, String type )
147     {
148         hasFailure = isNotBlank( type );
149         hasError = false;
150         hasSkipped = false;
151         return setFailureMessage( message ).setFailureType( type );
152     }
153 
154     public ReportTestCase setError( String message, String type )
155     {
156         hasFailure = false;
157         hasError = isNotBlank( type );
158         hasSkipped = false;
159         return setFailureMessage( message ).setFailureType( type );
160     }
161 
162     public ReportTestCase setSkipped( String message )
163     {
164         hasFailure = false;
165         hasError = false;
166         hasSkipped = isNotBlank( message );
167         return setFailureMessage( message ).setFailureType( "skipped" );
168     }
169 
170     public boolean isSuccessful()
171     {
172         return !hasFailure() && !hasError() && !hasSkipped();
173     }
174 
175     public boolean hasFailure()
176     {
177         return hasFailure;
178     }
179 
180     public boolean hasError()
181     {
182         return hasError;
183     }
184 
185     public boolean hasSkipped()
186     {
187         return hasSkipped;
188     }
189 
190     /**
191      * {@inheritDoc}
192      */
193     @Override
194     public String toString()
195     {
196         return fullName;
197     }
198 
199     private ReportTestCase setFailureType( String failureType )
200     {
201         this.failureType = failureType;
202         return this;
203     }
204 }