source: trunk/autoquest-core-assertions/src/main/java/de/ugoe/cs/autoquest/assertions/TextEqualsReplay.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:mime-type set to text/plain
File size: 3.2 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.assertions;
16
17import de.ugoe.cs.autoquest.IReplayDecorator;
18import de.ugoe.cs.autoquest.eventcore.IReplayable;
19import de.ugoe.cs.util.StringTools;
20
21/**
22 * <p>
23 * This class defines the replay for a textEquals assertion.
24 * </p>
25 *
26 * @author Jeffrey Hall, Steffen Herbold
27 * @version 2.0
28 */
29public class TextEqualsReplay implements IReplayable {
30
31    /**
32     * <p>
33     * Reference value which is compared to the targets text.
34     * </p>
35     */
36    protected final String expectedValue;
37
38    /**
39     * <p>
40     * Target to which the text is compared.
41     * </p>
42     */
43    protected final String target;
44
45    /**
46     * <p>
47     * Id for object serialization.
48     * </p>
49     */
50    private static final long serialVersionUID = 1L;
51
52    /**
53     * <p>
54     * Constructor. Creates a new TextEqualsReplay.
55     *
56     * @param expectedValue
57     *            expected string value
58     * @param target
59     *            string description of the target whose string value is compared to the expected
60     *            value
61     * @throws IllegalArgumentException
62     *             thrown if target is null
63     */
64    public TextEqualsReplay(String expectedValue, String target) {
65        if (target == null) {
66            throw new IllegalArgumentException("target must not be null");
67        }
68        this.expectedValue = expectedValue;
69        this.target = target;
70    }
71
72    /*
73     * (non-Javadoc)
74     *
75     * @see de.ugoe.cs.autoquest.eventcore.IReplayable#getReplay()
76     */
77    @Override
78    public String getReplay() {
79
80        String expectedValueTmp = StringTools.xmlEntityReplacement(expectedValue);
81
82        StringBuilder currentMsgStr = new StringBuilder(400);
83        currentMsgStr.append(" <textEquals expectedValue=\"" + expectedValueTmp + "\">");
84        currentMsgStr.append(StringTools.ENDLINE);
85        currentMsgStr.append("<target>");
86        currentMsgStr.append(StringTools.ENDLINE);
87        currentMsgStr.append(target);
88        currentMsgStr.append(StringTools.ENDLINE);
89        currentMsgStr.append("</target>");
90        currentMsgStr.append(StringTools.ENDLINE);
91        currentMsgStr.append("</textEquals>");
92        currentMsgStr.append(StringTools.ENDLINE);
93        return currentMsgStr.toString();
94    }
95
96    /*
97     * (non-Javadoc)
98     *
99     * @see de.ugoe.cs.autoquest.eventcore.IReplayable#getDecorator()
100     */
101    @Override
102    public IReplayDecorator getDecorator() {
103        return null;
104    }
105
106}
Note: See TracBrowser for help on using the repository browser.