| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
package org.tap4j.model; |
| 25 | |
|
| 26 | |
import java.io.Serializable; |
| 27 | |
import java.util.LinkedList; |
| 28 | |
import java.util.List; |
| 29 | |
|
| 30 | |
import org.tap4j.util.StatusValues; |
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
public class TestSet implements Serializable { |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
private static final long serialVersionUID = 114777557084672201L; |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
private Header header; |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
private Plan plan; |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | 129 | private List<TapResult> tapLines = new LinkedList<TapResult>(); |
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | 129 | private List<TestResult> testResults = new LinkedList<TestResult>(); |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | 129 | private List<BailOut> bailOuts = new LinkedList<BailOut>(); |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | 129 | private List<Comment> comments = new LinkedList<Comment>(); |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
private Footer footer; |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
public TestSet() { |
| 84 | 129 | super(); |
| 85 | 129 | } |
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
public Header getHeader() { |
| 91 | 54 | return this.header; |
| 92 | |
} |
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
public void setHeader(Header header) { |
| 98 | 24 | this.header = header; |
| 99 | 24 | } |
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
public Plan getPlan() { |
| 105 | 138 | return this.plan; |
| 106 | |
} |
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
public void setPlan(Plan plan) { |
| 112 | 52 | this.plan = plan; |
| 113 | 52 | } |
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
public List<TapResult> getTapLines() { |
| 120 | 101 | return this.tapLines; |
| 121 | |
} |
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
public List<TestResult> getTestResults() { |
| 127 | 55 | return this.testResults; |
| 128 | |
} |
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
public int getNextTestNumber() { |
| 134 | 2 | return (this.testResults.size() + 1); |
| 135 | |
} |
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
public List<BailOut> getBailOuts() { |
| 141 | 36 | return this.bailOuts; |
| 142 | |
} |
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
public List<Comment> getComments() { |
| 148 | 3 | return this.comments; |
| 149 | |
} |
| 150 | |
|
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
public boolean addTapLine(TapResult tapLine) { |
| 158 | 62 | return this.tapLines.add(tapLine); |
| 159 | |
} |
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
|
| 169 | |
public boolean addTestResult(TestResult testResult) { |
| 170 | 203 | if (testResult.getTestNumber() == null || |
| 171 | |
testResult.getTestNumber() <= 0) { |
| 172 | 105 | testResult.setTestNumber(this.testResults.size() + 1); |
| 173 | |
} |
| 174 | 203 | this.testResults.add(testResult); |
| 175 | 203 | return this.tapLines.add(testResult); |
| 176 | |
} |
| 177 | |
|
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
public boolean addBailOut(BailOut bailOut) { |
| 183 | 9 | this.bailOuts.add(bailOut); |
| 184 | 9 | return this.tapLines.add(bailOut); |
| 185 | |
} |
| 186 | |
|
| 187 | |
|
| 188 | |
|
| 189 | |
|
| 190 | |
public boolean addComment(Comment comment) { |
| 191 | 20 | this.comments.add(comment); |
| 192 | 20 | return this.tapLines.add(comment); |
| 193 | |
} |
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | |
|
| 200 | |
|
| 201 | |
protected boolean removeTapLine(TapResult tapLine) { |
| 202 | 1 | return this.tapLines.remove(tapLine); |
| 203 | |
} |
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | |
|
| 211 | |
public boolean removeTestResult(TestResult testResult) { |
| 212 | 2 | boolean flag = false; |
| 213 | 2 | if (this.tapLines.remove(testResult)) { |
| 214 | 1 | this.testResults.remove(testResult); |
| 215 | 1 | flag = true; |
| 216 | |
} |
| 217 | 2 | return flag; |
| 218 | |
} |
| 219 | |
|
| 220 | |
|
| 221 | |
|
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
public boolean removeBailOut(BailOut bailOut) { |
| 227 | 2 | boolean flag = false; |
| 228 | 2 | if (this.tapLines.remove(bailOut)) { |
| 229 | 1 | this.bailOuts.remove(bailOut); |
| 230 | 1 | flag = true; |
| 231 | |
} |
| 232 | 2 | return flag; |
| 233 | |
} |
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | |
|
| 240 | |
|
| 241 | |
public boolean removeComment(Comment comment) { |
| 242 | 2 | boolean flag = false; |
| 243 | 2 | if (this.tapLines.remove(comment)) { |
| 244 | 1 | this.comments.remove(comment); |
| 245 | 1 | flag = true; |
| 246 | |
} |
| 247 | 2 | return flag; |
| 248 | |
} |
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
public int getNumberOfTapLines() { |
| 255 | 3 | return this.tapLines.size(); |
| 256 | |
} |
| 257 | |
|
| 258 | |
|
| 259 | |
|
| 260 | |
|
| 261 | |
public int getNumberOfTestResults() { |
| 262 | 112 | return this.testResults.size(); |
| 263 | |
} |
| 264 | |
|
| 265 | |
|
| 266 | |
|
| 267 | |
|
| 268 | |
public int getNumberOfBailOuts() { |
| 269 | 3 | return this.bailOuts.size(); |
| 270 | |
} |
| 271 | |
|
| 272 | |
|
| 273 | |
|
| 274 | |
|
| 275 | |
public int getNumberOfComments() { |
| 276 | 5 | return this.comments.size(); |
| 277 | |
} |
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | |
|
| 282 | |
public Footer getFooter() { |
| 283 | 26 | return this.footer; |
| 284 | |
} |
| 285 | |
|
| 286 | |
|
| 287 | |
|
| 288 | |
|
| 289 | |
public void setFooter(Footer footer) { |
| 290 | 13 | this.footer = footer; |
| 291 | 13 | } |
| 292 | |
|
| 293 | |
|
| 294 | |
|
| 295 | |
|
| 296 | |
public boolean hasBailOut() { |
| 297 | 2 | boolean isBailOut = false; |
| 298 | |
|
| 299 | 2 | for (TapResult tapLine : tapLines) { |
| 300 | 4 | if (tapLine instanceof BailOut) { |
| 301 | 1 | isBailOut = true; |
| 302 | 1 | break; |
| 303 | |
} |
| 304 | |
} |
| 305 | |
|
| 306 | 2 | return isBailOut; |
| 307 | |
} |
| 308 | |
|
| 309 | |
|
| 310 | |
|
| 311 | |
|
| 312 | |
|
| 313 | |
public Boolean containsOk() { |
| 314 | 7 | Boolean containsOk = false; |
| 315 | |
|
| 316 | 7 | for (TestResult testResult : this.testResults) { |
| 317 | 4 | if (testResult.getStatus().equals(StatusValues.OK)) { |
| 318 | 3 | containsOk = true; |
| 319 | 3 | break; |
| 320 | |
} |
| 321 | |
} |
| 322 | |
|
| 323 | 7 | return containsOk; |
| 324 | |
} |
| 325 | |
|
| 326 | |
|
| 327 | |
|
| 328 | |
|
| 329 | |
|
| 330 | |
public Boolean containsNotOk() { |
| 331 | 5 | Boolean containsNotOk = false; |
| 332 | |
|
| 333 | 5 | for (TestResult testResult : this.testResults) { |
| 334 | 5 | if (testResult.getStatus().equals(StatusValues.NOT_OK)) { |
| 335 | 3 | containsNotOk = true; |
| 336 | 3 | break; |
| 337 | |
} |
| 338 | |
} |
| 339 | |
|
| 340 | 5 | return containsNotOk; |
| 341 | |
} |
| 342 | |
|
| 343 | |
|
| 344 | |
|
| 345 | |
|
| 346 | |
|
| 347 | |
public Boolean containsBailOut() { |
| 348 | 4 | return this.bailOuts.size() > 0; |
| 349 | |
} |
| 350 | |
|
| 351 | |
|
| 352 | |
|
| 353 | |
|
| 354 | |
|
| 355 | |
public TestResult getTestResult(Integer testNumber) { |
| 356 | 25 | TestResult foundTestResult = null; |
| 357 | |
|
| 358 | 25 | for (TestResult testResult : this.testResults) { |
| 359 | 36 | if (testResult.getTestNumber() != null && |
| 360 | |
testResult.getTestNumber().equals(testNumber)) { |
| 361 | 25 | foundTestResult = testResult; |
| 362 | 25 | break; |
| 363 | |
} |
| 364 | |
} |
| 365 | |
|
| 366 | 25 | return foundTestResult; |
| 367 | |
} |
| 368 | |
|
| 369 | |
} |