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

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