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

Last change on this file since 2218 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
RevLine 
[927]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
[922]15package de.ugoe.cs.autoquest.assertions;
[518]16
[922]17import de.ugoe.cs.autoquest.IReplayDecorator;
18import de.ugoe.cs.autoquest.eventcore.IReplayable;
[518]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
[559]31    /**
32     * <p>
33     * Reference value which is compared to the targets text.
34     * </p>
35     */
36    protected final String expectedValue;
[518]37
[559]38    /**
39     * <p>
40     * Target to which the text is compared.
41     * </p>
42     */
43    protected final String target;
[518]44
[559]45    /**
46     * <p>
47     * Id for object serialization.
48     * </p>
49     */
50    private static final long serialVersionUID = 1L;
[518]51
[559]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
[766]61     * @throws IllegalArgumentException
[559]62     *             thrown if target is null
63     */
64    public TextEqualsReplay(String expectedValue, String target) {
65        if (target == null) {
[766]66            throw new IllegalArgumentException("target must not be null");
[559]67        }
68        this.expectedValue = expectedValue;
69        this.target = target;
70    }
[518]71
[559]72    /*
73     * (non-Javadoc)
74     *
[922]75     * @see de.ugoe.cs.autoquest.eventcore.IReplayable#getReplay()
[559]76     */
77    @Override
78    public String getReplay() {
[518]79
[559]80        String expectedValueTmp = StringTools.xmlEntityReplacement(expectedValue);
[518]81
[559]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    }
[518]95
[559]96    /*
97     * (non-Javadoc)
98     *
[922]99     * @see de.ugoe.cs.autoquest.eventcore.IReplayable#getDecorator()
[560]100     */
101    @Override
102    public IReplayDecorator getDecorator() {
103        return null;
104    }
105
[518]106}
Note: See TracBrowser for help on using the repository browser.