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

Last change on this file since 922 was 922, checked in by sherbold, 12 years ago
  • renaming of packages from de.ugoe.cs.quest to de.ugoe.cs.autoquest
  • Property svn:mime-type set to text/plain
File size: 2.5 KB
RevLine 
[922]1package de.ugoe.cs.autoquest.assertions;
[518]2
[922]3import de.ugoe.cs.autoquest.IReplayDecorator;
4import de.ugoe.cs.autoquest.eventcore.IReplayable;
[518]5import de.ugoe.cs.util.StringTools;
6
7/**
8 * <p>
9 * This class defines the replay for a textEquals assertion.
10 * </p>
11 *
12 * @author Jeffrey Hall, Steffen Herbold
13 * @version 2.0
14 */
15public class TextEqualsReplay implements IReplayable {
16
[559]17    /**
18     * <p>
19     * Reference value which is compared to the targets text.
20     * </p>
21     */
22    protected final String expectedValue;
[518]23
[559]24    /**
25     * <p>
26     * Target to which the text is compared.
27     * </p>
28     */
29    protected final String target;
[518]30
[559]31    /**
32     * <p>
33     * Id for object serialization.
34     * </p>
35     */
36    private static final long serialVersionUID = 1L;
[518]37
[559]38    /**
39     * <p>
40     * Constructor. Creates a new TextEqualsReplay.
41     *
42     * @param expectedValue
43     *            expected string value
44     * @param target
45     *            string description of the target whose string value is compared to the expected
46     *            value
[766]47     * @throws IllegalArgumentException
[559]48     *             thrown if target is null
49     */
50    public TextEqualsReplay(String expectedValue, String target) {
51        if (target == null) {
[766]52            throw new IllegalArgumentException("target must not be null");
[559]53        }
54        this.expectedValue = expectedValue;
55        this.target = target;
56    }
[518]57
[559]58    /*
59     * (non-Javadoc)
60     *
[922]61     * @see de.ugoe.cs.autoquest.eventcore.IReplayable#getReplay()
[559]62     */
63    @Override
64    public String getReplay() {
[518]65
[559]66        String expectedValueTmp = StringTools.xmlEntityReplacement(expectedValue);
[518]67
[559]68        StringBuilder currentMsgStr = new StringBuilder(400);
69        currentMsgStr.append(" <textEquals expectedValue=\"" + expectedValueTmp + "\">");
70        currentMsgStr.append(StringTools.ENDLINE);
71        currentMsgStr.append("<target>");
72        currentMsgStr.append(StringTools.ENDLINE);
73        currentMsgStr.append(target);
74        currentMsgStr.append(StringTools.ENDLINE);
75        currentMsgStr.append("</target>");
76        currentMsgStr.append(StringTools.ENDLINE);
77        currentMsgStr.append("</textEquals>");
78        currentMsgStr.append(StringTools.ENDLINE);
79        return currentMsgStr.toString();
80    }
[518]81
[559]82    /*
83     * (non-Javadoc)
84     *
[922]85     * @see de.ugoe.cs.autoquest.eventcore.IReplayable#getDecorator()
[560]86     */
87    @Override
88    public IReplayDecorator getDecorator() {
89        return null;
90    }
91
[518]92}
Note: See TracBrowser for help on using the repository browser.