Newer
Older
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
/**
*
*/
package fr.emse.gitlab.saref.entities;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
/**
* @author Omar Qawasmeh
*
*
*/
@XmlRootElement(name = "testcase")
@XmlType(propOrder = { "name", "status", "error", "failure", "systemErr", "systemOut" })
public class TestCase {
@XmlAttribute
private String name = "";
@XmlTransient
private String status = "success";
@XmlElement
private Error error;
@XmlElement
private Error failure;
@XmlTransient
private String systemErr;
@XmlTransient
private String systemOut;
public TestCase() {
}
public TestCase(final String name) {
this.name = name;
}
public String getName() {
return name;
}
@XmlAttribute
public String getStatus() {
return status;
}
@XmlElement(name = "system-err")
public String getSystemErr() {
return systemErr;
}
public void setSystemErr(String systemErr) {
this.systemErr = systemErr;
}
@XmlElement(name = "system-out")
public String getSystemOut() {
return systemOut;
}
public void setSystemOut(String systemOut) {
this.systemOut = systemOut;
}
public void setStatus(Status status) {
this.status = status.getName();
}
public void setError(String type, String message) {
this.error = new Error(type, message);
this.status = "error";
}
public boolean isError() {
return status.equals(Status.ERROR.getName());
}
public void setFailure(String type, String message) {
this.failure = new Error(type, message);
this.status = "failure";
}
public boolean isFailure() {
return status.equals(Status.FAILURE.getName());
}
public String getErrorType() {
if (error != null) {
return error.getType();
}
return null;
}
public String getErrorMessage() {
if (error != null) {
return error.getMessage();
}
return null;
}
public String getFailureType() {
if (failure != null) {
return failure.getType();
}
return null;
}
public String getFailureMessage() {
if (failure != null) {
return failure.getMessage();
}
return null;
}
@XmlRootElement(name = "error")
private static class Error implements Serializable {
@XmlAttribute
private String type;
@XmlAttribute
private String message;
public Error() {
}
private Error(String type, String message) {
this.type = type;
this.message = message;
}
public String getType() {
return type;
}
public String getMessage() {
return message;
}
}
public static enum Status {
SUCCESS, FAILURE, ERROR, WARNING;
public String getName() {
return toString().toLowerCase();
}
}
}