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