1   /*
2    * The MIT License
3    *
4    * Copyright (c) <2010> <tap4j>
5    * 
6    * Permission is hereby granted, free of charge, to any person obtaining a copy
7    * of this software and associated documentation files (the "Software"), to deal
8    * in the Software without restriction, including without limitation the rights
9    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10   * copies of the Software, and to permit persons to whom the Software is
11   * furnished to do so, subject to the following conditions:
12   * 
13   * The above copyright notice and this permission notice shall be included in
14   * all copies or substantial portions of the Software.
15   * 
16   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22   * THE SOFTWARE.
23   */
24  package org.tap4j.model;
25  
26  import java.util.LinkedList;
27  import java.util.List;
28  
29  import org.tap4j.util.StatusValues;
30  
31  /**
32   * A simple test result. Valid values are <em>OK</em> and <em>NOT OK</em>.
33   * 
34   * @since 1.0
35   */
36  public class TestResult extends TapResult {
37  
38      /*
39       * Serial Version UID.
40       */
41      private static final long serialVersionUID = -2735372334488828166L;
42  
43      /**
44       * Test Status (OK, NOT OK).
45       */
46      private StatusValues status;
47  
48      /**
49       * Test Number.
50       */
51      private Integer testNumber;
52  
53      /**
54       * Description of the test.
55       */
56      private String description;
57  
58      /**
59       * Directive of the test (TO DO, SKIP).
60       */
61      private Directive directive;
62  
63      /**
64       * Child subtest.
65       */
66      private TestSet subtest;
67  
68      /**
69       * Comment.
70       */
71      private List<Comment> comments;
72  
73      public TestResult() {
74          super();
75          this.status = StatusValues.NOT_OK;
76          this.testNumber = -1;
77          this.subtest = null;
78          this.comments = new LinkedList<Comment>();
79      }
80  
81      /**
82       * Constructor with parameter.
83       * 
84       * @param testStatus Status of the test.
85       * @param testNumber Number of the test.
86       */
87      public TestResult(StatusValues testStatus, Integer testNumber) {
88          super();
89          this.status = testStatus;
90          this.testNumber = testNumber;
91          this.comments = new LinkedList<Comment>();
92      }
93  
94      /**
95       * @return Status of the test.
96       */
97      public StatusValues getStatus() {
98          return this.status;
99      }
100 
101     /**
102      * @param status Status of the test.
103      */
104     public void setStatus(StatusValues status) {
105         this.status = status;
106     }
107 
108     /**
109      * @return Test Number.
110      */
111     public Integer getTestNumber() {
112         return this.testNumber;
113     }
114 
115     /**
116      * @param testNumber Test Number.
117      */
118     public void setTestNumber(Integer testNumber) {
119         this.testNumber = testNumber;
120     }
121 
122     /**
123      * @return Test description.
124      */
125     public String getDescription() {
126         return this.description;
127     }
128 
129     /**
130      * @param description Test description.
131      */
132     public void setDescription(String description) {
133         this.description = description;
134     }
135 
136     /**
137      * @return Optional Directive.
138      */
139     public Directive getDirective() {
140         return this.directive;
141     }
142 
143     /**
144      * @param directive Optional Directive.
145      */
146     public void setDirective(Directive directive) {
147         this.directive = directive;
148     }
149 
150     /**
151      * @return the subtest
152      */
153     public TestSet getSubtest() {
154         return subtest;
155     }
156 
157     /**
158      * @param subtest the subtest to set
159      */
160     public void setSubtest(TestSet subtest) {
161         this.subtest = subtest;
162     }
163 
164     /**
165      * @return The comments for this Test Result.
166      */
167     public List<Comment> getComments() {
168         return this.comments;
169     }
170 
171     /**
172      * @param comments list of comments for this Test Result.
173      */
174     public void setComments(List<Comment> comments) {
175         this.comments = comments;
176     }
177 
178     /**
179      * Adds a new comment to this Test Result.
180      * 
181      * @param comment comment for this Test Result.
182      */
183     public void addComment(Comment comment) {
184         this.comments.add(comment);
185     }
186 
187 }