]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc/src/main/java/org/argeo/slc/core/test/SimpleResultPart.java
Improve error logging and reporting
[gpl/argeo-slc.git] / org.argeo.slc / src / main / java / org / argeo / slc / core / test / SimpleResultPart.java
1 package org.argeo.slc.core.test;
2
3 /**
4 * <p>
5 * Basic implementation of a result part, implementing the standard three status
6 * approach for test results.
7 * </p>
8 *
9 * @see TestStatus
10 */
11 public class SimpleResultPart implements TestResultPart, TestStatus {
12
13 /** For ORM */
14 private Long tid;
15
16 private Integer status;
17 private String message;
18 private Throwable exception;
19
20 public SimpleResultPart() {
21 }
22
23 public SimpleResultPart(Integer status, String message) {
24 this(status, message, null);
25 }
26
27 public SimpleResultPart(Integer status, String message, Throwable exception) {
28 this.status = status;
29 this.message = message;
30 this.exception = exception;
31 }
32
33 public String getMessage() {
34 return message;
35 }
36
37 public void setMessage(String message) {
38 this.message = message;
39 }
40
41 public void setStatus(Integer status) {
42 this.status = status;
43 }
44
45 public Integer getStatus() {
46 return status;
47 }
48
49 public Throwable getException() {
50 return exception;
51 }
52
53 public void setException(Throwable exception) {
54 this.exception = exception;
55 }
56
57 @Override
58 public String toString() {
59 StringBuffer buf = new StringBuffer("");
60 if (status == PASSED) {
61 buf.append("PASSED ");
62 } else if (status == FAILED) {
63 buf.append("FAILED ");
64 } else if (status == ERROR) {
65 buf.append("ERROR ");
66 }
67 buf.append(message);
68 if (exception != null) {
69 buf.append("(").append(exception.getMessage()).append(")");
70 }
71 return buf.toString();
72 }
73
74 Long getTid() {
75 return tid;
76 }
77
78 void setTid(Long tid) {
79 this.tid = tid;
80 }
81
82 }