forked from anujgandharv/easytest
/
TestResultBean.java
191 lines (154 loc) · 4.02 KB
/
TestResultBean.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package org.easetech.easytest.reports.data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* This class is a single result of a test run for one test method.
*
* @author gpcmol
*
*/
public class TestResultBean implements Serializable {
private static final long serialVersionUID = -2336621400716756554L;
/**
* Method name
*/
private String method;
/**
* Input values. key=parameter name, value=value
*/
private Map<String, Object> input;
/**
* Return object of method
*/
private Object output;
/**
* True if passed
*/
private Boolean passed;
/**
* Assertion message
*/
private String result;
/**
* True if exception
*/
private Boolean exception;
/**
* Exception message when execution of method throws exception
*/
private String exceptionResult;
/**
* Test item duration beans (contains items that in the method run are
* called, e.g. service method calls. These method calls need to be
* annotated with @Intercept)
*/
private List<DurationBean> testItemDurations;
/**
* Date of run
*/
private Date date;
public TestResultBean() {
this.input = new LinkedHashMap<String, Object>();
this.testItemDurations = new ArrayList<DurationBean>();
}
public TestResultBean(String method, Map<String, Object> input,
Object output, Boolean passed, String result, Boolean exception,
String exceptionResult, Date date) {
this.method = method;
this.input = input;
this.output = output;
this.passed = passed;
this.result = result;
this.exception = exception;
this.exceptionResult = exceptionResult;
this.date = date;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public Map<String, Object> getInput() {
return input;
}
public void setInput(Map<String, Object> input) {
this.input = input;
}
public void addInput(String key, String value) {
this.input.put(key, value);
}
public Object getOutput() {
return output;
}
public void setOutput(Object output) {
this.output = output;
}
public Boolean getPassed() {
return passed;
}
public void setPassed(Boolean passed) {
this.passed = passed;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public Boolean getException() {
return exception;
}
public void setException(Boolean exception) {
this.exception = exception;
}
public String getExceptionResult() {
return exceptionResult;
}
public void setExceptionResult(String exceptionResult) {
this.exceptionResult = exceptionResult;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
/**
* Returns either the result of an assertion or an exception trace
*
* @return string
*/
public String getResultString() {
if (result != null) {
return result;
} else if (exceptionResult != null) {
return exceptionResult;
}
return null;
}
public List<DurationBean> getTestItemDurations() {
return testItemDurations;
}
public void setTestItemDurations(List<DurationBean> testItemDurations) {
this.testItemDurations = testItemDurations;
}
public void addTestItemDurationBean(DurationBean testItemDurationBean) {
this.testItemDurations.add(testItemDurationBean);
}
@Override
public String toString() {
return "TestResultBean [getMethod()=" + getMethod() + ", getInput()="
+ getInput() + ", getOutput()=" + getOutput()
+ ", getPassed()=" + getPassed() + ", getResult()="
+ getResult() + ", getException()=" + getException()
+ ", getExceptionResult()=" + getExceptionResult()
+ ", getDate()=" + getDate() + ", getResultString()="
+ getResultString() + ", getTestItemDurations()="
+ getTestItemDurations() + "]";
}
}