1 | /* |
2 | * JTiger Unit Testing Framework for J2SE 1.5 |
3 | * Copyright (C) 2005 Tony Morris |
4 | * |
5 | * This software is licenced under the |
6 | * Common Public Licence version 1.0 |
7 | * http://www.opensource.org/licenses/cpl1.0.php |
8 | * |
9 | * You received a copy of this licence with this software. |
10 | */ |
11 | package org.jtiger.report.html; |
12 | |
13 | /** |
14 | * A bean that is used by {@link org.jtiger.report.html.HtmlFixtureResultsHandler the HTML result handler} to produce a report. |
15 | * |
16 | * @author %javadoc.author.tag% |
17 | * @version %version%<br/> |
18 | * <i>Build Number %build.number%</i><br/> |
19 | * <i>Build Time %build.time% CET (GMT + 1)</i> |
20 | */ |
21 | public final class TestResultBeanImpl |
22 | implements TestResultBean |
23 | { |
24 | private static final long serialVersionUID = 2L; |
25 | |
26 | private String name; |
27 | private String exception; |
28 | private String elapsedTime; |
29 | private String message; |
30 | private String methodName; |
31 | private String description; |
32 | private String result; |
33 | |
34 | /** |
35 | * Create a default <tt>TestResultBeanImpl</tt>. |
36 | */ |
37 | public TestResultBeanImpl() |
38 | { |
39 | |
40 | } |
41 | |
42 | TestResultBeanImpl(final String name, final String exception, final String elapsedTime, |
43 | final String message, final String methodName, final String description, final String result) |
44 | { |
45 | this.name = name; |
46 | this.exception = exception; |
47 | this.elapsedTime = elapsedTime; |
48 | this.message = message; |
49 | this.methodName = methodName; |
50 | this.description = description; |
51 | this.result = result; |
52 | } |
53 | |
54 | /** |
55 | * Returns the name property of the bean. |
56 | * |
57 | * @return The name property of the bean. |
58 | */ |
59 | public String getName() |
60 | { |
61 | return name; |
62 | } |
63 | |
64 | /** |
65 | * Sets the name property of the bean. |
66 | * |
67 | * @param name The name property of the bean. |
68 | */ |
69 | public void setName(final String name) |
70 | { |
71 | this.name = name; |
72 | } |
73 | |
74 | /** |
75 | * Returns the exception property of the bean. |
76 | * |
77 | * @return The exception property of the bean. |
78 | */ |
79 | public String getException() |
80 | { |
81 | return exception; |
82 | } |
83 | |
84 | /** |
85 | * Sets the exception property of the bean. |
86 | * |
87 | * @param exception The exception property of the bean. |
88 | */ |
89 | public void setException(final String exception) |
90 | { |
91 | this.exception = exception; |
92 | } |
93 | |
94 | /** |
95 | * Returns the elapsedTime property of the bean. |
96 | * |
97 | * @return The elapsedTime property of the bean. |
98 | */ |
99 | public String getElapsedTime() |
100 | { |
101 | return elapsedTime; |
102 | } |
103 | |
104 | /** |
105 | * Sets the elapsedTime property of the bean. |
106 | * |
107 | * @param elapsedTime The elapsedTime property of the bean. |
108 | */ |
109 | public void setElapsedTime(final String elapsedTime) |
110 | { |
111 | this.elapsedTime = elapsedTime; |
112 | } |
113 | |
114 | /** |
115 | * Returns the message property of the bean. |
116 | * |
117 | * @return The message property of the bean. |
118 | */ |
119 | public String getMessage() |
120 | { |
121 | return message; |
122 | } |
123 | |
124 | /** |
125 | * Sets the message property of the bean. |
126 | * |
127 | * @param message The message property of the bean. |
128 | */ |
129 | public void setMessage(final String message) |
130 | { |
131 | this.message = message; |
132 | } |
133 | |
134 | /** |
135 | * Returns the methodName property of the bean. |
136 | * |
137 | * @return The methodName property of the bean. |
138 | */ |
139 | public String getMethodName() |
140 | { |
141 | return methodName; |
142 | } |
143 | |
144 | /** |
145 | * Sets the methodName property of the bean. |
146 | * |
147 | * @param methodName The methodName property of the bean. |
148 | */ |
149 | public void setMethodName(final String methodName) |
150 | { |
151 | this.methodName = methodName; |
152 | } |
153 | |
154 | /** |
155 | * Returns the description property of the bean. |
156 | * |
157 | * @return The description property of the bean. |
158 | */ |
159 | public String getDescription() |
160 | { |
161 | return description; |
162 | } |
163 | |
164 | /** |
165 | * Sets the description property of the bean. |
166 | * |
167 | * @param description The description property of the bean. |
168 | */ |
169 | public void setDescription(final String description) |
170 | { |
171 | this.description = description; |
172 | } |
173 | |
174 | /** |
175 | * Returns the result property of the bean. |
176 | * |
177 | * @return The result property of the bean. |
178 | */ |
179 | public String getResult() |
180 | { |
181 | return result; |
182 | } |
183 | |
184 | /** |
185 | * Sets the result property of the bean. |
186 | * |
187 | * @param result The result property of the bean. |
188 | */ |
189 | public void setResult(final String result) |
190 | { |
191 | this.result = result; |
192 | } |
193 | |
194 | /** |
195 | * Returns a <a href="%j2se.api.spec%/java/lang/String.html">java.lang.String</a> representation of the bean, which |
196 | * consists of the name property, the exception property, the elapsedTime property, the message property, the |
197 | * methodName property, the description property, and the result property. |
198 | * |
199 | * @return A <a href="%j2se.api.spec%/java/lang/String.html">java.lang.String</a> representation of the bean, which |
200 | * consists of the name property, the exception property, the elapsedTime property, the message property, the |
201 | * methodName property, the description property, and the result property. |
202 | */ |
203 | @Override |
204 | public String toString() |
205 | { |
206 | final StringBuilder sb = new StringBuilder(); |
207 | |
208 | sb.append('['); |
209 | sb.append(name); |
210 | sb.append("]["); |
211 | sb.append(exception); |
212 | sb.append("]["); |
213 | sb.append(elapsedTime); |
214 | sb.append("]["); |
215 | sb.append(message); |
216 | sb.append("]["); |
217 | sb.append(methodName); |
218 | sb.append("]["); |
219 | sb.append(description); |
220 | sb.append("]["); |
221 | sb.append(result); |
222 | sb.append(']'); |
223 | |
224 | return sb.toString(); |
225 | } |
226 | |
227 | /** |
228 | * Compares two instance of <tt>TestResultBeanImpl</tt> returning <code>true</code> iff the name, exception, |
229 | * elapsedTime, message, methodName, description, and result properties are equal, <code>false</code> otherwise. |
230 | * |
231 | * @param o An instance of <tt>TestResultBeanImpl</tt> to compare for equality. |
232 | * @return <code>true</code> iff the name, exception, elapsedTime, message, methodName, description, and result |
233 | * properties are equal, <code>false</code> otherwise. |
234 | */ |
235 | @Override |
236 | public boolean equals(final Object o) |
237 | { |
238 | if(this == o) |
239 | { |
240 | return true; |
241 | } |
242 | |
243 | if(o == null || o.getClass() != TestResultBeanImpl.class) |
244 | { |
245 | return false; |
246 | } |
247 | |
248 | final TestResultBeanImpl f = (TestResultBeanImpl)o; |
249 | |
250 | return (name == null ? f.name == null : name.equals(f.name)) && |
251 | (exception == null ? f.exception == null : exception.equals(f.exception)) && |
252 | (elapsedTime == null ? f.elapsedTime == null : elapsedTime.equals(f.elapsedTime)) && |
253 | (message == null ? f.message == null : message.equals(f.message)) && |
254 | (methodName == null ? f.methodName == null : methodName.equals(f.methodName)) && |
255 | (description == null ? f.description == null : description.equals(f.description)) && |
256 | (result == null ? f.result == null : result.equals(f.result)); |
257 | } |
258 | |
259 | /** |
260 | * Returns a hash code for this <tt>TestResultBeanImpl</tt> based on the name, exception, elapsedTime, message, |
261 | * methodName, description, and result properties. |
262 | * |
263 | * @return A hash code for this <tt>TestResultBeanImpl</tt> based on the name, exception, elapsedTime, message, |
264 | * methodName, description, and result properties. |
265 | */ |
266 | @Override |
267 | public int hashCode() |
268 | { |
269 | final int oddPrime = 461; |
270 | int result = 73; |
271 | |
272 | if(name != null) |
273 | { |
274 | result = result * oddPrime + name.hashCode(); |
275 | } |
276 | |
277 | if(exception != null) |
278 | { |
279 | result = result * oddPrime + exception.hashCode(); |
280 | } |
281 | |
282 | if(elapsedTime != null) |
283 | { |
284 | result = result * oddPrime + elapsedTime.hashCode(); |
285 | } |
286 | |
287 | if(message != null) |
288 | { |
289 | result = result * oddPrime + message.hashCode(); |
290 | } |
291 | |
292 | if(methodName != null) |
293 | { |
294 | result = result * oddPrime + methodName.hashCode(); |
295 | } |
296 | |
297 | if(description != null) |
298 | { |
299 | result = result * oddPrime + description.hashCode(); |
300 | } |
301 | |
302 | if(this.result != null) |
303 | { |
304 | result = result * oddPrime + this.result.hashCode(); |
305 | } |
306 | |
307 | return result; |
308 | } |
309 | } |