1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.jameleon.result;
20
21 import net.sf.jameleon.bean.FunctionalPoint;
22
23 /***
24 * An implementation of @see TestResult that represents the result of a function point
25 */
26 public class FunctionResult extends JameleonTestResult {
27 private static final long serialVersionUID = 1L;
28
29 /***
30 * The name of the file where the results of the display were written to if any
31 */
32 protected String resultsFileName;
33 /***
34 * If the function is a precondition
35 */
36 protected boolean precondition;
37 /***
38 * If the function is a postcondition
39 */
40 protected boolean postcondition;
41
42 /***
43 * The default constructor
44 */
45 public FunctionResult(){
46 super();
47 }
48
49 /***
50 * @param tag - The functional point tied to the results
51 */
52 public FunctionResult(FunctionalPoint tag){
53 super(tag);
54 }
55
56 /***
57 * @param tag - The functional point tied to the results
58 * @param parentTestResult - The parent test results to update
59 */
60 public FunctionResult(FunctionalPoint tag, HasChildResults parentTestResult){
61 super(tag, parentTestResult);
62 }
63
64 protected String getErrorMsgPrefix(){
65 String prefix = "";
66 if (precondition) {
67 prefix = "PRECONDITION FAILURE: ";
68 } else if (postcondition) {
69 prefix = "POSTCONDITION FAILURE: ";
70 }
71 return prefix;
72 }
73
74 public String getErrorMsg(){
75 String errMsg = super.getErrorMsg();
76 if (errMsg != null) {
77 errMsg = getErrorMsgPrefix() + errMsg;
78 }
79 return errMsg;
80 }
81
82 public boolean isParent() {
83 return false;
84 }
85
86 public boolean isDataDriven() {
87 return false;
88 }
89
90 public boolean hasChildren() {
91 return false;
92 }
93
94 /***
95 * Tells whether the functional point is a precondition
96 * @return true if this is a precondition, otherwise false
97 */
98 public boolean isPrecondition(){
99 return precondition;
100 }
101
102 /***
103 * Sets the FunctionalPoint as a precondition
104 * @param precondition - set to true to make this a precondition
105 */
106 public void setPrecondition(boolean precondition){
107 this.precondition = precondition;
108 }
109
110 /***
111 * Tells whether the functional point is a postcondition
112 * @return true if this is a postcondition, otherwise false
113 */
114 public boolean isPostcondition(){
115 return postcondition;
116 }
117
118 /***
119 * Sets the FunctionalPoint as a postcondition
120 * @param postcondition - set to true to make this a postcondition
121 */
122 public void setPostcondition(boolean postcondition){
123 this.postcondition = postcondition;
124 }
125
126 /***
127 * @return a String representation of the function point results
128 */
129 public String toString(){
130 StringBuffer sb = new StringBuffer();
131 if (tag != null) {
132 sb.append(tag.toString());
133 }
134 sb.append(super.toString());
135 return sb.toString();
136 }
137
138 /***
139 * @return an XML representation of the function point results
140 */
141 public String toXML(){
142 StringBuffer str = new StringBuffer("\n");
143 str.append("\t<function-point>\n");
144 if (tag != null && tag.getFunctionId() != null) {
145 str.append("\t\t<functionId>").append(escapeXML(tag.getFunctionId())).append("</functionId>\n");
146 }
147 str.append(super.toXML());
148 if (tag != null) {
149 str.append(tag.toXML());
150 }
151 str.append("\t</function-point>\n");
152 return str.toString();
153 }
154 }